#include<stdio.h>
#include<conio.h>
#include<windows.h>
#include<string.h>
#include"Init.h"
extern int GetString(char p[],int max);
extern int InsertData(struct STU data);
extern int IsInvalid(char *s,int c);
extern int snocallback;
extern int GetLinkLen();
extern int counts;
extern int sno,sign;
extern struct LINK *head;
extern char* Make_Sno(char *p);
extern void GoToXY(int x, int y);
extern void Title_Windows(char a[]);
extern void GoToXY(int x, int y);
extern void ClearMidMessage();
extern void Clear_Message();
extern void Creat_Window();
extern void Get_Time();
extern void Fill_Message(char str1[],char str2[]);
extern void PrintStu(struct LINK *p,int count);
extern void main();
int sno=0;
int delsno[100];
void Add_Info()
{
int i=0,j=0,k=0,n=0,flag;
struct LINK stu;
char key,s[20];
char str1[]="error! Data is full! you can't add again";
char str2[]="please enter any key to back ";
char str3[]="error!you input a lawless character ";
char str4[]="error! Data is out of length ";
char str5[]="please input a 10<=age<=20 ";
char str6[]="error! Input NULL ";
char str7[]="please input again ";
char str8[]="please input a name";
char str9[]="please input a 0<=score<=100 ";
char str0[]="Do you want to go on adding[y/n]";
char str10[]="the radix point exceed one";
char str11[]="the radix point place error";
char str12[]="please input a name";
char a[8][40]={
{" Input student's sno:"},
{" Input student's name:"},
{" Input student's age:"},
{" Input student's chinese score:"},
{" Input student's english score:"},
{" Input student's math score:"},
{" Input student's physics score:"},
{" Input student's chemistry score:"}
};
do{
ClearMidMessage();
Get_Time();
Title_Windows("Add Info");
GoToXY(30,7);
for( i=6;i<14;++i)
{
GoToXY(27,i-1);
printf("%s\n",a[i-6]);//循环输出这五个选项
}
if(counts>=100)//判断记录数是否大等与100
{
Fill_Message(str1,str2);
getch();
main();
}
if(snocallback>0)
{
GoToXY(51,5);
printf("%03d",delsno[snocallback-1]);
sprintf(stu.data.sno,"%03d",delsno[snocallback-1]);
snocallback--;
}
else
{
GoToXY(51,5);
printf("%s",Make_Sno(s));
strcpy(stu.data.sno,s);
}
//================================输入姓名========================================//
Clear_Message();
do{
GoToXY(52,6);
GetString(s,25);
flag=IsInvalid(s,0);
if(flag==0)
{
GoToXY(52,6);
for(i=0;i<=25;++i)
{
printf(" ");
}
GoToXY(52,6);
printf("%s",s);
break;
}
else if(flag==1)
{
Clear_Message();
Fill_Message(str6,NULL);
}else if(flag==2)
{
Clear_Message();
Fill_Message(str4,NULL);
}
GoToXY(52,6);
for(i=0;i<=25;++i)
{
printf(" ");
}
GoToXY(52,6);
}while(1);
strcpy(stu.data.name,s);
//===============================判断年龄=======================================//
Clear_Message();
do
{
GoToXY(51,7);
GetString(s,10);
flag=IsInvalid(s,1);
if(flag==0)
{
GoToXY(51,7);
for(i=0;i<=25;++i)
{
printf(" ");
}
GoToXY(51,7);
printf("%s",s);
break;
}
else if(flag==1)
{
Clear_Message();
Fill_Message(str6,NULL);
}else if(flag==2)
{
Clear_Message();
Fill_Message(str4,NULL);
}else if(flag==4)
{
Clear_Message();
Fill_Message(str3,NULL);
}else if(flag==3)
{
Clear_Message();
Fill_Message(str5,NULL);
}
GoToXY(51,7);
for(i=0;i<=25;++i)
{
printf(" ");
}
GoToXY(51,7);
}while(1);
stu.data.age=atoi(s);
//================================语文成绩===================================//
Clear_Message();
do
{
GoToXY(60,8);
GetString(s,10);
flag=IsInvalid(s,2);
if(flag==0)
{
GoToXY(60,8);
for(i=0;i<=15;++i)
{
printf(" ");
}
GoToXY(60,8);
printf("%s",s);
break;
}
else if(flag==1)
{
Clear_Message();
Fill_Message(str6,NULL);
}
else if(flag==2)
{
Clear_Message();
Fill_Message(str3,NULL);
}
else if(flag==3)
{
Clear_Message();
Fill_Message(str10,NULL);
}else if(flag==4)
{
Clear_Message();
Fill_Message(str11,NULL);
}else if(flag==5)
{
Clear_Message();
Fill_Message(str9,NULL);
}
GoToXY(60,8);
for(i=0;i<=15;++i)
{
printf(" ");
}
GoToXY(60,8);
}while(1);
stu.data.score[0]=atof(s);
//===================================英语成绩================================================//
Clear_Message();
do
{
GoToXY(60,9);
GetString(s,10);
flag=IsInvalid(s,2);
if(flag==0)
{
GoToXY(60,9);
for(i=0;i<=15;++i)
{
printf(" ");
}
GoToXY(60,9);
printf("%s",s);
break;
}
else if(flag==1)
{
Clear_Message();
Fill_Message(str6,NULL);
}
else if(flag==2)
{
Clear_Message();
Fill_Message(str3,NULL);
}
else if(flag==3)
{
Clear_Message();
Fill_Message(str10,NULL);
}else if(flag==4)
{
Clear_Message();
Fill_Message(str11,NULL);
}else if(flag==5)
{
Clear_Message();
Fill_Message(str9,NULL);
}
GoToXY(60,9);
for(i=0;i<=15;++i)
{
printf(" ");
}
GoToXY(60,9);
}while(1);
stu.data.score[1]=atof(s);
//=====================================数学成绩==============================================//
Clear_Message();
do
{
GoToXY(57,10);
GetString(s,10);
flag=IsInvalid(s,2);
if(flag==0)
{
GoToXY(57,10);
for(i=0;i<=15;++i)
{
printf(" ");
}
GoToXY(57,10);
printf("%s",s);
break;
}
else if(flag==1)
{
Clear_Message();
Fill_Message(str6,NULL);
}
else if(flag==2)
{
Clear_Message();
Fill_Message(str3,NULL);
}
else if(flag==3)
{
Clear_Message();
Fill_Message(str10,NULL);
}else if(flag==4)
{
Clear_Message();
Fill_Message(str11,NULL);
}else if(flag==5)
{
Clear_Message();
Fill_Message(str9,NULL);
}
GoToXY(57,10);
for(i=0;i<=15;++i)
{
printf(" ");
}
GoToXY(57,10);
}while(1);
stu.data.score[2]=atof(s);
//=================================物理成绩==============================================//
Clear_Message();
do
{
GoToXY(60,11);
GetString(s,10);
flag=IsInvalid(s,2);
if(flag==0)
{
GoToXY(60,11);
for(i=0;i<=15;++i)
{
printf(" ");
}
GoToXY(60,11);
printf("%s",s);
break;
}
else if(flag==1)
{
Clear_Message();
Fill_Message(str6,NULL);
}
else if(flag==2)
{
Clear_Message();
Fill_Message(str3,NULL);
}
else if(flag==3)
{
Clear_Message();
Fill_Message(str10,NULL);
}else if(flag==4)
{
Clear_Message();
Fill_Message(str11,NULL);
}else if(flag==5)
{
Clear_Message();
Fill_Message(str9,NULL);
}
GoToXY(60,11);
for(i=0;i<=15;++i)
{
printf(" ");
}
GoToXY(60,11);
}while(1);
stu.data.score[3]=atof(s);
//==================================化学成绩===========================================//
Clear_Message();
do
{
GoToXY(62,12);
GetString(s,10);
flag=IsInvalid(s,2);
if(flag==0)
{
GoToXY(62,12);
for(i=0;i<=15;++i)
{
printf(" ");
}
GoToXY(62,12);
printf("%s",s);
break;
}
else if(flag==1)
{
Clear_Message();
Fill_Message(str6,NULL);
}
else if(flag==2)
{
Clear_Message();
Fill_Message(str3,NULL);
}
els