📄 function1.c
字号:
#include "Pre-defined.h"
//================================通用边框界面函数===================================//
void Border()
{
int i;
char buf[25];
time_t now=time(NULL);//定义当前时间变量!
for(i=1;i<23;i++)
{
GoToXY(1,i);
printf("%c",4);
GoToXY(78,i);
printf("%c",4);
}
for(i=2;i<26;i++)
{
GoToXY(i,1);
printf("%c",4);
}
for(i=52;i<78;i++)
{
GoToXY(i,1);
printf("%c",4);
}
for(i=2;i<35;i++)
{
GoToXY(i,19);
printf("%c",4);
}
for(i=42;i<78;i++)
{
GoToXY(i,19);
printf("%c",4);
}
for(i=2;i<78;i++)
{
GoToXY(i,22);
printf("%c",4);
}
for(i=2;i<5;i++)
{
GoToXY(30,i);
printf("%c",4);
GoToXY(47,i);
printf("%c",4);
}
for(i=30;i<48;i++)
{
GoToXY(i,2);
printf("%c",4);
GoToXY(i,2);
printf("%c",4);
GoToXY(i,4);
printf("%c",4);
}
GoToXY(26,1);
printf("Student Information System");
GoToXY(35,19);
printf("Message");
GoToXY(2,23);
printf("Ver 1.0 Auther: Ye Min Kun Date:");
strftime(buf,24,"%Y-%m-%d",localtime(&now));//输出当前时间!
printf("%s",buf);
}
//================================登录界面函数===================================//
void Lond_Interface()
{
char *lond[7]={"Enter UserName:","","Enter PassWord:","","[The length of UserName is 10]","","[The length of PassWord is 6]"};
int i;
Border();
GoToXY(2,20);
printf("Hello World!!");
GoToXY(33,3);
printf("Landing Minu");
for(i=0;i<7;i++)
{
if(i<3)
{
GoToXY(3,8+i);
printf("%s",lond[i]);
}
else
{
GoToXY(43,8+i-4);
printf("%s",lond[i]);
}
}
}
//================================排序界面函数===================================//
void Sort_Interface()
{
int i;
char *sort[7]={"1. Order up by student's sno","2. Order down by student's sno",
"3. Order up by student's totals","4. Order down by student's totals",
"0. Return main menu","","please Make a choices[0-4]:"};
Border();//边框函数
GoToXY(34,3);
printf("Data Sort");
for(i=0;i<7;i++)
{
GoToXY(30,i+7);
printf("%s",sort[i]);
}
}
//================================查询界面函数===================================//
void Search_Interface()
{
int i;
char *search[5]={"1.search student by sno","2.search student by name",
"0.return main menu","","Please Make a returnLables[0-2]:"};
Border();//边框函数
GoToXY(32,3);
printf("SearchStudent");
for(i=0;i<5;i++)
{
GoToXY(30,i+7);
printf("%s",search[i]);
}
}
//================================增加界面函数===================================//
void Add_Interface()
{
int i;
char *add[17]={"sno:","name:","age:","chinese:","english:","math:",
"physics:","chemistry:","[Space or letter]","[7-50]",
"[0-100]","[0-100]","[0-100]","[0-100]","[0-100]","","[Press Esc to return]"};
Border();
GoToXY(32,3);
printf("Add Info");
for(i=0;i<17;i++)
{
if(i<8)
{
GoToXY(9,6+i);
printf("%10s",add[i]);
}
else
{
GoToXY(53,i-1);
printf("%s",add[i]);
}
}
}
//================================打印界面函数===================================//
void Print_Interface()
{
int lenght;
lenght=GetLinkLen(head);
Border();
GoToXY(32,3);
printf("Print Menu");
GoToXY(5,5);
printf("%3s %-15s %4s %5s %5s %5s %5s %6s %6s %5s\n","sno","name","age","chin","engl","math","phys","chemi","total","avg");
if(lenght>0)
{
GoToXY(2,16);
printf("please choice key-press:");
GoToXY(2,17);
printf("[0]return; home; pagedown; pageup; end; [5]gotopage;");
}
}
//================================保存文件函数===================================//
void SaveFile()
{
int x,y;
char ch;
int lenght;
int i;
char *save[3]={"1. Auto save","2. Save as","0. Return"};
lenght=GetLinkLen(head);//计算原链表结点数!
if(lenght==0)//原链表为空!
{
Empty(2,20,60,20);
printf("no data to save! do you want to add data?[y/n]:");
Exit_Judge();//判断函数!
if(key=='Y'||key=='y')
{
system("cls");
Add_Function();
return;
}
else if(key=='N'||key=='n')
return;
}
system("cls");
for(i=0;i<3;i++)
{
GoToXY(30,6+i);
printf("%s",save[i]);
}
GoToXY(32,3);
printf("save data");
Border();
GoToXY(2,17);
printf("The file is not include '*' '?' '<' '>' '\"' '|'");
GoToXY(30,10);
printf("please input a choice[0-2]:");
WhereXY(&x,&y);
do
{
Empty(x,y,70,y);
ch=Personalized_Tips(x,y,2);
switch(ch)
{
case '1':
Auto_Save("ymk.txt");//默认保存!
return;
case '2':
Empty(2,20,70,21);
if(Save_As()==-1)//按ESC时返回重新选择!否则另存!
{
break;
}
else
{
return;
}
case '0':
return;
}
}while(1);
}
//================================读取文件函数===================================//
void LoadFile()
{
int x,y;
char ch;
int i;
char *load[3]={"1. Auto load","2. Load as","0. Return"};
if(isSave==0)
{
Empty(2,20,70,21);
printf("you have data not saved! do you want to save[y/n]:");
Exit_Judge();//判断函数!
if(key=='Y'||key=='y')
{
system("cls");
SaveFile();
}
}
system("cls");
Border();//调用边框函数!
for(i=0;i<3;i++)
{
GoToXY(30,6+i);
printf("%s",load[i]);
}
GoToXY(32,3);
printf("load data");
GoToXY(2,17);
printf("The file is not include '*' '?' '<' '>' '\"' '|'");
GoToXY(30,10);
printf("please input a choice[0-2]:");
WhereXY(&x,&y);
do
{
Empty(2,20,70,21);
Empty(x,y,70,y);
ch=Personalized_Tips(x,y,2);
switch(ch)
{
case '1':
Auto_Load("ymk.txt");//默认加载!
return;
case '2':
if(Load_As()==-1)//按ESC时返回重新选择!否则另加载!
{
break;
}
else
{
return;
}
case '0':
return;
}
}while(1);
}
//================================统计分数界面函数===================================//
void Stasco_Interface(int wage)
{
int lenght;
char *a[6]={"chin","engl","math","phys","chemi","tatal"};
lenght=GetLinkLen(head);
Border();
GoToXY(32,3);
printf("stat score");
GoToXY(2,16);
printf("please choice key-press:");
if(wage==0)
{
GoToXY(2,17);
printf("[0]return; [1]chin; [2]engl; [3]math; [4]phys; [5]chemi;[6]total;[7]avg;");
}
if(lenght>0)
{
if(wage==7)
{
GoToXY(5,5);
printf("%22s %6s %6s %6s %6s\n","chin","engl","math","phys","chemi");
}
if(wage>=1&&wage<=6)
{
GoToXY(2,18);
printf("[0]return; home; pagedown; pageup; end; [5]gotopage;");
GoToXY(5,5);
printf("%22s %6s %18s","sno","name",a[wage-1]);
}
}
}
//================================退出界面函数===================================//
void Exit_Interface()
{
int i;
GoToXY(32,3);
printf("exit menu");
Border();
if(isSave==1)
{
char *exit[4]={"1. Exit","0. return menu","","please make a returnlables[0-1]:"};
GoToXY(32,3);
printf("exit menu");
for(i=0;i<4;i++)
{
GoToXY(30,6+i);
printf("%s",exit[i]);
}
}
else
{
char *exit[4]={"1. Save and exit","2. No save and exit","0. Reture main Menu","please make a returnlables[0-1]:"};
for(i=0;i<4;i++)
{
GoToXY(30,6+i);
printf("%s",exit[i]);
}
}
}
//================================输出主菜单界面函数===================================//
void Main_Menu_Interface()
{
int i;
char *menu[11]={"1. Add student's info","2. Sort data","3. Print student's report",
"4. Save data to file","5. Load data to file","6. Search students",
"7. Stat Score","0. Exit","","","Please Make a returnLables[0-7]:"};
Border();
GoToXY(2,21);
printf("Hello World!!");
GoToXY(34,3);
printf("Main List");
for(i=0;i<11;i++)
{
GoToXY(27,6+i);
printf("%s",menu[i]);
}
}
//================================统计分数功能函数===================================//
void Stasco_Function()
{
int x,y;
char ch;
int lenght;
int len=0;
lenght=GetLinkLen(head);//计算链表结点数!
if(lenght==0)
{
Empty(2,20,70,21);
printf("no data to Stasco! do you want to add data?[y/n]:");
Exit_Judge();
if(key=='Y'||key=='y')
{
system("cls");
Add_Function();
return;
}
else if(key=='N'||key=='n')
return;
}
else
{
do
{
system("cls");
Print_Function(head,0,0,7);
Stasco_Interface(0);
GoToXY(26,16);
WhereXY(&x, &y);
ch=Personalized_Tips(x,y,7);//人性化提示!
switch(ch)
{
case '1':
Print_Function(head,0,0,1);
break;
case '2':
Print_Function(head,0,0,2);
break;
case '3':
Print_Function(head,0,0,3);
break;
case '4':
Print_Function(head,0,0,4);
break;
case '5':
Print_Function(head,0,0,5);
break;
case '6':
Print_Function(head,0,0,6);
break;
case '7':
break;
case '0':
return;
}
}while(1);
}
}
//================================查询功能函数===================================//
void Search_Function()
{
char ch;
int x,y;
int lenght;
lenght=GetLinkLen(head);
if(lenght==0)//无记录时的提示!
{
Empty(2,20,70,21);
printf("no data to search! do you want to add data?[y/n]:");
Exit_Judge();
if(key=='Y'||key=='y')
{
system("cls");
Add_Function();
return;
}
else if(key=='N'||key=='n')
{
return;
}
}
else
{
system("cls");
Search_Interface();
WhereXY(&x, &y);
do
{
Empty(2,20,60,20);
GoToXY(x,y);
ch=Personalized_Tips(x,y,2);
switch(ch)
{
case '1':
{
if(SearchSno()==-1)//查询学号!
break;
else
return;
}
case '2':
{
if(SearchName()==-1)//查询姓名!
break;
else
{
DeleteAll(temphead);
return;
}
}
case '0':
return;
}
} while (1);
}
}
//================================登录功能函数===================================//
int Lond_Function() //返回值为1时则用户登录成功!为0时用户登录失败!
{
int count=0;
int i=2;
int p=0;
char username[10],password[6];
Lond_Interface(); //调用登录界面函数!
GoToXY(2,21);
printf("Please input UserName!");
GoToXY(18,8);
GetStr(username,10,0);
do
{
if(strcmp(username,"admin")==0) //判断用户名是否存在!
{
Empty(2,21,70,21);//调用清空函数!
printf("please input PassWord!");
Empty(18,10,28,10);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -