📄 gzgl.c
字号:
#include <stdio.h>
#include <conio.h>
#include <string.h>
#include <stdlib.h>
#include "gzgl.h"
void main()
{
FILE *fp;
struct worker *head,*p;
int count=0;
int i,key1;
char *menu[8]={"增加","删除","修改","查询","上记录","下记录","统计","退出"};
head=malloc(sizeof( struct worker));
head->next=NULL;
LoadDate(fp,head,&count);
CreateMenu(menu);
CreateWorkspace();
PaintWorkspace();
p=head->next;
if(p!=NULL) /*如果文件中有记录,显示出来*/
Display(p);
i=0;
while(1) /*以下代码段都是响应键盘按键所进行的处理*/
{
gotoxy(i*10+1,1);
window(i*10+1,1,i*10+10,1);
textbackground(GREEN);
textcolor(RED);
clrscr();
cprintf("%s",menu[i]);
switch(getch())
{
case 77:if(i<7)
i++;
key1=77;
break;
case 75:if(i>0)
i--;
key1=75;
break;
case 13:
switch(i)
{
case 0:Add_Record(head,p,&count); /*选择添加产生的事件*/
break;
case 1:Delete_Record(p,&count);
break;
case 2:Modify_Record(p);
break;
case 3:p=Find_Record(head,p);
Display(p);
break;
case 4:if(p->pre!=head)
p=p->pre;
Display(p);
break;
case 5:if(p->next!=NULL)
p=p->next;
Display(p);
break;
case 6:Tongji(head,count);
break;
case 7:while(1) /*选择退出产生的事件*/
{
PaintMsgbox();
cprintf("Do you want to save your date?(Y/N)");
key1=getch();
if(key1=='Y'||key1=='y') /*选择是否保存数据*/
{
SaveDate(fp,head,&count);
exit(0);
}
else if(key1=='N'||key1=='n')
exit(0);
}
break;
}
break;
}
if(key1==77) /*以下条件语句和while和switch之间的语句配对,用来对选中的菜单显示*/
{
window((i-1)*10+1,1,(i-1)*10+10,1);
textbackground(WHITE);
textcolor(BLACK);
clrscr();
cprintf("%s",menu[i-1]);
}
else if(key1==75)
{
window((i+1)*10+1,1,(i+1)*10+10,1);
textbackground(WHITE);
textcolor(BLACK);
clrscr();
cprintf("%s",menu[i+1]);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -