/**由于时间关系,模糊查询只写了姓名查找***/
/***模糊查询可能建链表有问题,还有填写工资单也可能有一点问题**/
#include <dos.h>
#include <bios.h>
#include <conio.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define R 8
#define T 60 /****addlist有问题******************************************************************************************/
#define LEFT 0x4b00 /*左*/
#define RIGHT 0x4d00 /*右*/
#define DOWN 0x5000 /*下*/
#define UP 0x4800 /*上*/
#define SPACE 0x3920 /*空格*/
#define ESC 0x011b /* ESC键*/
#define ENTER 0x1c0d /*回车键*/
#define Backspace 0xe08 /*擦除键*/
#define ALT_B 12288 /*组合键ALT_B */
#define ALT_M 12800/*组合键ALT_M */
#define ALT_H 8960/*组合键ALT_H */
#define N 10
#define M 20
int clst,tvst; /*清洁费&&闭路电视费*/
int or=1;/*-1做了更改,1未做更改*/
char zhws[N][M],zhchs[N][M],departs[N][M]; /*存储职务名&&技术职称名&&部门名*/
char months[][5]={"0","Jan","Feb","Mar","Apr","May","Jun","July","Arg","Sep","Oct","Nov","Dec"};/*月份名,1月对应1*/
char sexs[][7]={"male","female"};
int zhwsp[N],zhchsp[N]; /*职务工资&&职称(基本)工资*/
FILE *fp;
typedef struct _paylist
{
int cardnum; /*工资卡号*/
char name[M];
int month; /*月份,进行选择*/
int jbsalary; /*基本工资*/
int zhwsalary; /*职务工资*/
int addition; /*补助*/
int ysalary; /*应发工资*/
int praise; /*特别奖励*/
int tax; /*税金*/
int water; /*水费*/
int elec; /*电费*/
int clean; /*清洁费*/
int tv; /*电视费*/
int salary; /*实发工资*/
struct _paylist *left,*right;
} PAYLIST;
typedef struct _worker
{
char name[M];
int sex; /*0男1女*/
char idnum[M]; /*身份证号*/
int cardnum; /*工资卡号*/
int age;
int wkage; /*工龄*/
int depart; /*选择,部门*/
int zhw; /*选择,职务*/
int zhch; /*选择,职称*/
long zhchnum; /*职称编号*/
long homeph; /*家庭电话*/
char mobile[M]; /*手机*/
int paymons; /*已经记录n个月的工资单*/
struct _worker *front,*down;
PAYLIST *right;
} WORKER;
typedef struct _depart
{
int name; /*选择,部门名*/
char path[M]; /*存储路径名*/
int wknum; /*该部门职工人数*/
struct _depart *left,*right;
WORKER *down;
} DEPART;
typedef struct _tjw
{
WORKER *wp;
struct _tjw *next;
}TJW;
DEPART *headd,*dep;
WORKER *zhp,*wwp;/*起指向作用,不要随便更改; 起流动作用*********/
TJW *head1; /**头指针**/
void load(void); /*从文件中导入部门,职工及工资单信息*/
void start(void); /*读取基本数据*/
void readdep(DEPART **pp,FILE *fp); /*从文件中读取部门信息*/
void writedep(DEPART *p,FILE *fp); /*逐个将部门信息写入文件*/
void shchx(WORKER *wp); /*详细输出*/
void readw(WORKER **wp,FILE *fp); /*从文件中读取职工信息*/
PAYLIST * whtailp(WORKER *wp); /*查找职工------链尾,返回链尾*/
void xianshw(void); /************显示第n个部门的职工信息********/
PAYLIST * insertp(WORKER *wp,PAYLIST *p,PAYLIST *tail); /*插入新职工,返回链尾*/
void addnew(DEPART *dep); /*增加新职工*/
PAYLIST * whtailp(WORKER *wp); /*查找职工------链尾,返回链尾*/
void changeshuju(void); /*更改基本工资等固定信息*/
PAYLIST * rulup(WORKER *wp); /*录入工资单信息*/
void addlist(WORKER *zhp); /*增加新职工*/
void Dzhg(void); /*****确定某一个具体职工****/
void xiansh2(DEPART *dep);
void insertdep(void); /****添加新的部门***/
void addzh(void); /***添加职务和职称***/
void savedep(void); /*保存部门信息*/
void savew(void); /*保存职工信息和工资信息***/
void day1(void); /***直接打印职工信息**/
void day2(void); /****将统计结果打印出来**/
void delall(DEPART *dep); /**删除整个部门**/
void delone(DEPART *dep,WORKER *p); /*删除一个职工及其工资信息*/
void changew(WORKER *p); /*修改职工基本信息*/
WORKER * search1(); /*通过身分证号查询*/
void search3(void); /*通过姓名查询*/
void mhsearch(); /*模糊查询*/
WORKER * search0(); /*通过职称编号查询*/
void jqsearch(void); /*精确查询*/
void Ashuijin(); /*统计税金总额及排出前十名**/
void changep(WORKER *p); /*修改工资单信息*/
WORKER * search2(); /*通过工资卡号查找*/
int key;/*按键变量*/
int textx,texty;/*光标坐标,x行,y列*/
struct menustruct/*菜单用的结构体*/
{
char name[10];/*主菜单名*/
char str[10][20];/*选项*/
int n;/*选项数*/
}ml[R];/*使用了R个,可根据需要增删*/
char save[4096],savee[4096];/*保存文本区域空间*/
/*char sav1[4096];*/
char c[4096];/*清屏专用空间*/
int i,j;/*常用变量*/
void Menu();/*初始化界面*/
void Selectitem();/*定义菜单*/
void DrawSelectitem();/*显示主菜单*/
void BlackText(int x,int y,char *z);/*选中菜单*/
void RedText(int x,int y,char *z);/*正常菜单*/
void Run();/*具体操作过程*/
void DrawMl(int n);/*显示下拉菜单*/
void MoveMl(int n,int x);/*菜单选项的控制*/
void Enter(int m,int n);/*菜单选项的具体功能*/
void ClrScr();/*自定义清屏函数*/
void DingWei(void);
void DrawFrame(int left,int up,int right,int down,int textcolor,int backgroundcolor);/*画边框*/
/***主函数****/
void loadmenu(void)
{
Menu();/*初始化界面*/
Run();/*具体操作过程*/
}
/*初始化界面*/
void Menu()
{ int a;
system("cls"); /*调用系统的清屏命令*/
textbackground(GREEN);/*将背景设置为蓝色*/
window(1,1,25,80);
clrscr();
textx=3;/*光标初始化位置*/
texty=2;
gotoxy(1,2);
printf("%c",218);/*画左上角*/
for(i=0;i<78;i++)
printf("%c",196); /*画水平直线*/
printf("%c",191);/*画右上角*/
for(i=3;i<=23;i++)
{
gotoxy(1,i);
printf("%c",179); /*画垂直线*/
gotoxy(80,i);
printf("%c",179);
}
printf("%c",192); /*画左下角*/
for(i=0;i<78;i++)
printf("%c",196);
printf("%c",217); /*画右下角*/
gotoxy(1,1);
textcolor(7); /*设置灰色*/
for(i=0;i<80;i++)
cprintf("%c",219);/*用符号实现画主菜单的灰色背景区*/
for(a=3;a<=23;a++)
{gotoxy(T,a);cprintf("%c",179);} /********************************************************************/
DingWei();
Selectitem(); /*调用选项函数*/
DrawSelectitem(); /*画选项*/
gettext(2,3,78,23,c); /*保存当前文本区域*/
}
/*定义菜单*/
void Selectitem()
{
strcpy(ml[0].name,"FILE");/*下面的具体选项补空格是为了各菜单黑色背景相同*/ /**************************************************************************/
strcpy(ml[0].str[0],"Load ");/*导入某一部门职工信息*/
strcpy(ml[0].str[1],"Shemi ");/*设置密码*/
strcpy(ml[0].str[2],"Gaimi ");/*修改密码*/
strcpy(ml[0].str[3],"Print ");/*打印*/
strcpy(ml[0].str[4],"Save ");/*保存*/
strcpy(ml[0].str[5],"Exit ");/*退出系统*/
ml[0].n=6; /*保存菜单的项数*/
strcpy(ml[1].name,"INSERT");
strcpy(ml[1].str[0],"Newers ");/*插入新职工*/
strcpy(ml[1].str[1],"Paylist ");/*填写工资单*/
strcpy(ml[1].str[2],"Depart ");/*新增部门*/
strcpy(ml[1].str[3],"Zhchs "); /*新增职称*/
strcpy(ml[1].str[4],"Zhws "); /*新增职务*/
ml[1].n=5;
strcpy(ml[2].name,"EDIT");/*编辑修改*/
strcpy(ml[2].str[0],"Imfor "); /*职工信息*/
strcpy(ml[2].str[1],"Paylist "); /*工资单*/
strcpy(ml[2].str[2],"Tongshu ");/*修改基本工资等固定数据*/
ml[2].n=3;
strcpy(ml[3].name,"SEARCH"); /*查询*/
strcpy(ml[3].str[0],"Jingque "); /*精确查询*/
strcpy(ml[3].str[1],"* "); /*模糊查询*/
ml[3].n=2;
strcpy(ml[4].name,"TONGJI"); /*统计*/
strcpy(ml[4].str[0],"Paixu "); /*排序*/
strcpy(ml[4].str[1],"Agongzi "); /*各类工资总额*/
strcpy(ml[4].str[2],"Ashuijin "); /*税金总额(月/年) */
strcpy(ml[4].str[3],"Gzhjigz "); /*各工种总数及平均工资*/
ml[4].n=4;
strcpy(ml[5].name,"DEL");
strcpy(ml[5].str[0],"One ");
strcpy(ml[5].str[1],"All ");
ml[5].n=2;
strcpy(ml[6].name,"HELP");
strcpy(ml[6].str[0],"About ");
ml[6].n=1;
}
/*显示主单名*/
void DrawSelectitem()
{
for(i=0;i<R;i++)
RedText(i,1,ml[i].name); /*显示主菜单名,且首字母为红色*/
}
/*正常显示菜单*/
void RedText(int x,int y,char *z)
{
textbackground(7); /*设置背景颜色为浅灰色*/
gotoxy(3+x*10,y);
for(j=0;z[j];j++)
{
if(j==0)
textcolor(RED);/*第一个字母显示红色*/
else
textcolor(BLACK); /*设置黑色*/
cprintf("%c",z[j]); /*输出菜单名*/
}
}
/*显示选中菜单*/
void BlackText(int x,int y,char *z)
{
textbackground(0); /*设置背景颜色为黑色*/
textcolor(15); /*设置文本颜色为白色*/
gotoxy(3+10*x,y);/*定位坐标*/
cputs(z); /*输出菜单名字符串*/
}
/*按键操作过程*/
void Run()
{ gettext(1,1,80,25,savee);
while(1)
{
gotoxy(texty,textx);
key=bioskey(0);/*接收按键*/
switch(key)
{
case ALT_B:
case ESC: DrawMl(0);break; /*显示下拉菜单1*/
case ALT_M: DrawMl(1);break;/*显示下拉菜单2*/
case ALT_H: DrawMl(2);/*显示下拉菜单3*/
case UP: /*上光标键的操作控制*/
{
if(textx==3)
textx=23;
textx--;
gotoxy(texty,textx);
}break;
case DOWN: /*下光标键的操作控制*/
{
if(textx==23)
textx=3;
textx++;
gotoxy(texty,textx);
}break;
case LEFT: /*左光标键的操作控制*/
{
if(texty==2)
texty=T-1;
texty--;
gotoxy(texty,textx);
}break;
case Backspace: /*擦除键的设置*/
{
if(texty==2&&textx==3)
continue;
else
{
if(texty!=2)
texty--; /*擦除键的细节问题,先擦去东西,然后光标还要往后退一格*/
else
if(texty==2)
{
texty=78;
textx--;
}
gotoxy(texty,textx);
printf(" ");
gotoxy(texty,textx);
}
}break;/*end case 0xe08*/
case RIGHT: /*右光标键的操作控制*/
{
if(texty==T-1)
texty=2;
texty++;
gotoxy(texty,textx);
}break;
case SPACE: /*空格键的操作*/
{
if(texty==79)
continue;
else
{
gotoxy(texty,textx); /*空格的细节操作*/
printf(" ");
texty++;
gotoxy(texty,textx);
}
}break;
case ENTER: /*回车的控制操作*/
{
if(textx==23)
continue;
textx++;
texty=2;
gotoxy(texty,textx);
}break;
default : /*非控制键的结果*/
{
if(texty==79&&textx==23)/*到达最后就不再输出*/
continue;
else
if(texty==79&&textx!=23) /*到行的最后*/
{
textx++;
texty=2;
}
gotoxy(texty,textx);/*输出结果*/
printf("%c",key);
if(texty==79) /*如果texty==79就不执行*/
continue;
else /*如果没到行尾就继续执行,使光标向前移动一位*/
texty++;
}
}
}/*大循环的大括号*/
}
/*画边框函数*/
void DrawFrame(int l,int u,int r,int d,int tcolor,int bcolor)
{
textbackground(bcolor); /*背景颜色*/
textcolor(bcolor); /*文本颜色*/
for(i=l;i<=r;i++) /*输出背景区域*/
{
for(j=u;j<=d;j++)
{
gotoxy(i,j);
printf("%c",219); /*输出背景字符*/
}
}
textcolor(tcolor);/*边框颜色*/
for(i=u+1;i<d;i++) /*在背景区域内输出边框线*/
{
gotoxy(l,i);
cprintf("%c",179); /*垂直线*/
gotoxy(r,i);
cprintf("%c",179);
}
for(i=l+1;i<r;i++)
{
gotoxy(i,u);
cprintf("%c",196); /*水平线*/
gotoxy(i,d);
cprintf("%c",196);
}
gotoxy(l,u);
cprintf("%c",218);/*左上角*/
gotoxy(r,u);
cprintf("%c",191);/*右上角*/
gotoxy(l,d);
cprintf("%c",192);/*左下角*/
gotoxy(r,d);
cprintf("%c",217); /*右下角*/
/* gettext(l+1,u+1,r-1,d-1,save1);*//*保存边框内区域*/
}
/*显示具体下拉选择项目*/
void DrawMl(int n)
{
gettext(1,1,80,25,save);/*保存被掩盖的地方*/
BlackText(n,1,ml[n].name);/*反选显示主菜单*/
DrawFrame(3+10*n-1,2,3+10*n+9,3+ml[n].n,0,7);/*下拉菜单的边框*/
for(i=3;i<3+ml[n].n;i++)/*输出所选菜单各选项*/
{
if(i==3)
BlackText(n,i,ml[n].str[i-3]);/*默认选中第一项*/
else
RedText(n,i,ml[n].str[i-3]);/*其余各项首字符红色显示*/
}
gotoxy(79,1);
MoveMl(n,3);/*菜单选项的控制*/
}
/*菜单选项的控制,n决定水平项,x决定下拉的选项*/
void MoveMl(int n,int x)
{
int flag=1;
while(flag)
{
gotoxy(79,1);
key=bioskey(0);/*接收按键*/
gotoxy(79,1);
switch(key)
{
case ESC:/*退出循环*/
puttext(1,1,80,25,save);/*恢复打开菜单前的样子*/
flag=0;
break;
case LEFT:/*移到左边的选项*/
puttext(1,1,80,25,save);/*恢复打开菜单前的样子*/
if(n==0)/*往左移动越界的话移到最后一个选项*/ /*II***************************************************************注意改******************************/
DrawMl(6);
else
DrawMl(n-1);
flag=0;
break;
case RIGHT:/*移动右边的选项*/
puttext(1,1,80,25,save);/*恢复打开菜单前的样子*/
if(n==6)/*往右移动越界的话移到第一个选项*/ /*********************注意改**********************/
DrawMl(0);
else
DrawMl(n+1);
flag=0;
break;
case UP:/*具体选项往上移动*/
RedText(n,x,ml[n].str[x-3]);/*输出红色字体*/
if(x==3)/*移到最上面再按上键,就移到最下面*/
x=3+ml[n].n-1;
else
x--;/*移动到新的要显示的内容*/
BlackText(n,x,ml[n].str[x-3]);/*输出黑色字体*/
flag=1;
break;
case DOWN:/*具体选项往下移动*/
RedText(n,x,ml[n].str[x-3]);
if(x==(3+ml[n].n-1))/*移动到最底下再按下键就移到最上面*/
x=3;
else
x++;/*移动到新的要显示的内容*/
BlackText(n,x,ml[n].str[x-3]);
flag=1;
break;
case ENTER:
puttext(1,1,80,25,save);/*恢复打开菜单前的样子*/
Enter(n,x-3);/*菜单选项的具体功能*/
flag=0;
break;
}
gotoxy(79,1);
}
}
/*菜单选项的具体功能*/
void Enter(int m,int n) /*m主菜单;n子菜单*/
{
switch(m)
{
case 0:switch(n)
{
case 0:xianshw();break;
case 1:break;
case 2:break;
case 3:day1();break;
case 4:savedep();savew();printf("Save successfully!!");
puttext(1,1,80,25,save);break;
case 5:exit(0);break;
} break;/*退出系统*/
case 1: switch(n)
{
case 0:addnew(dep);puttext(1,1,80,25,save); /***********************************后面还要在接一个关闭窗口函数*****/
break;
case 1: addlist(zhp); puttext(1,1,80,25,save); break; /*填写工资单*/
case 2:insertdep(); break;/****添加新的部门***/
case 3:
case 4:addzh(); puttext(1,1,80,25,save); /*添加新的职务和职称***/
}break;
case 2:switch(n)
{
case 0:changew(zhp);break;
case 1:changep(zhp);puttext(1,1,80,25,save);break;
case 2:clrscr();changeshuju();puttext(1,1,80,25,save); break;
}break;
case 3:switch(n)
{
case 0:jqsearch();break;
case 1:mhsearch();break;
}break;
case 4:switch(n)
{
case 0:
case 1:
case 2:
case 3:Ashuijin();puttext(1,1,80,25,save);break;
}break;
case 5:switch(n)
{
case 0:delone(dep,zhp); break;
case 1:delall(dep);break;
}break;
case 6:switch(n)
{
case 0:break;
}break;
}/*结束外switch*/
}
void DingWei(void)
{int a=3;
gotoxy(T+1,a);cprintf("name:");
gotoxy(T+1,a+1);cprintf("sex:");
gotoxy(T+1,a+2);cprintf("id:");
gotoxy(T+1,a+3);cprintf("cd:");
gotoxy(T+1,a+4);cprintf("ag:");
gotoxy(T+1,a+5);cprintf("wg:");
gotoxy(T+1,a+6);cprintf("dp:");
gotoxy(T+1,a+7);cprintf("zw:");
gotoxy(T+1,a+8);cprintf("zc:");
gotoxy(T+1,a+9);cprintf("zcn:");
gotoxy(T+1,a+10);cprintf("hp:");
gotoxy(T+1,a+11);cprintf("mb:");
gotoxy(T+1,a+13);cprintf("paylist of:");
gotoxy(T+1,a+14);cprintf("jb:");gotoxy(T+10,a+14);cprintf("pr:");
gotoxy(T+1,a+15);cprintf("wp:");gotoxy(T+10,a+15);cprintf("tax:");
gotoxy(T+1,a+16);cprintf("ad:");gotoxy(T+10,a+16);cprintf("wt:");
gotoxy(T+1,a+17);cprintf("ys:");gotoxy(T+10,a+17);cprintf("el:");
gotoxy(T+1,a+18);cprintf("cn:");gotoxy(T+10,a+18);cprintf("tv:");
gotoxy(T+1,a+19);cprintf("sy:");
}
void start(void) /*读取基本数据*/
{
FILE *fp; int i,j;
DEPART *p,*tail;
if((fp=fopen("d://sal//zong.dat","r"))==NULL)
{
printf("Cannot open the file d://sal//zong.dat");
exit(-1);
}
fscanf(fp,"%d%d",&clst,&tvst);
fscanf(fp,"%d",&j);
for(i=0;i<N&&i<j;i++)
fscanf(fp,"%s",departs[i]);
if(i<N)for(i=j;i<N;i++)departs[i][0]='/0';
fscanf(fp,"%d",&j);
for(i=0;i<N&&i<j;i++)
fscanf(fp,"%s",zhchs[i]);
if(i<N)for(i=j;i<N;i++)zhchs[i][0]='/0';
fscanf(fp,"%d",&j);
for(i=0;i<N&&i<j;i++)
fscanf(fp,"%s",zhws[i]);
if(i<N)for(i=j;i<N;i++)zhws[i][0]='/0';
for(i=0;i<N;i++)
fscanf(fp,"%d",&zhchsp[i]);
for(i=0;i<N;i++)
fscanf(fp,"%d",&zhwsp[i]);
if((p=malloc(sizeof(DEPART)))==NULL)
{
printf("Nei Cun Bu Zu!");exit(-1);
}
readdep(&p,fp); /*从文件中读取部门信息*/
headd=p;
headd->left=NULL;
headd->right=NULL;
headd->down=NULL;
if((p=malloc(sizeof(DEPART)))==NULL)
{
printf("Nei Cun Bu Zu!");exit(-1);
}
readdep(&p,fp);
tail=p;
tail->right=NULL;
tail->left=headd;
tail->down=NULL;
headd->right=tail;
while(!feof(fp))
{
if((p=malloc(sizeof(DEPART)))==NULL)
{
printf("Nei Cun Bu Zu!");exit(-1);
}
readdep(&p,fp);
tail->right=p;
p->left=tail;
tail=p;
tail->right=NULL;
tail->down=NULL;
}
fclose(fp);
return;
}
void savedep(void) /*保存部门信息*/
{
FILE *fp;int i;
DEPART *p;
if((fp=fopen("d://sal//zong.dat","w+"))==NULL)
{
printf("Cannot open the file d://sal//zong.dat");
exit(-1);
}
fprintf(fp,"%10d%10d",clst,tvst);
for(i=0;i<N&&departs[i][0]!=NULL;i++);
fprintf(fp," %d ",i);
for(i=0;i<N;i++)
fprintf(fp," %s ",departs[i]); putchar('/n');
for(i=0;i<N&&zhchs[i][0]!=NULL;i++);
fprintf(fp," %d ",i);
for(i=0;i<N;i++)
fprintf(fp," %s ",zhchs[i]); putchar('/n');
for(i=0;i<N&&zhws[i][0]!=NULL;i++);
fprintf(fp," %d ",i);
for(i=0;i<N;i++)
fprintf(fp," %s ",zhws[i]); putchar('/n');
for(i=0;i<N;i++)
fprintf(fp," %d ",zhchsp[i]); putchar('/n');
for(i=0;i<N;i++)
fprintf(fp," %d ",zhwsp[i]); putchar('/n');
for(p=headd;p->right!=NULL;p=p->right)
{writedep(p,fp); putchar('/n'); }
fclose(fp);
return;
}
void changeshuju(void) /*更改基本工资等固定信息*/
{
int i;
char ch;
textbackground(GREEN);textcolor(15);clrscr();
printf("/nThe clean cost:%7d",clst);
printf("/nThe tv cost:%7d",tvst);
printf("/nIs there anything to be changed?(y/n):");
scanf("%1s",&ch);
if(ch=='y'||ch=='Y')
{
printf("/nThe clean cost:");
scanf("%d",&clst);
printf("/nthe tv cost:");
scanf("%d",&tvst);
}
printf("/nThe zhiwu salary as follow:");
for(i=0;i<N&&zhws[i][0]!=NULL;i++)
printf("/n%20s: %7d",zhws[i],zhwsp[i]);
printf("/nIs there anything to be changed.?(y/n):");
scanf("%1s",&ch);
if(ch=='y'||ch=='Y')
{
printf("/nOk,please input the new result:");
for(i=0;i<N;i++)
{
printf("/n%s:",zhws[i]);
scanf("%d",&zhwsp[i]);
}
}
printf("/nThe zhi cheng salary as follow:");
for(i=0;i<N&&zhchs[i][0]!=NULL;i++)
printf("/n%20s: %7d",zhchs[i],zhchsp[i]);
printf("/nIs there anything to be changed.?(y/n):");
scanf("%1s",&ch);
if(ch=='y'||ch=='Y')
{
printf("/nOk,please input the new result:");
for(i=0;i<N;i++)
{
printf("/n%s:",zhchs[i]);
scanf("%d",&zhchsp[i]);
}
}
return;
}
WORKER * ruluw(void) /*录入职工基本信息*/
{
int i;
WORKER *p;
if((p=malloc(sizeof(WORKER)))==NULL)
{
printf("Nei Cun Bu Zu!");exit(-1);
}
printf("**********Add New Ones*******************");
printf("/nname:"); scanf("%s",p->name);
printf("/nsex:0(male) 1(female),please select:"); scanf("%d",&p->sex);
printf("/nshen fen zhenghao:"); scanf("%s",p->idnum);
printf("/ngong zi kahao:"); scanf("%d",&p->cardnum);
printf("/nage:"); scanf("%d",&p->age);
printf("/ngong ling(wkage):"); scanf("%d",&p->wkage);
printf("/nzhi wu :");
for(i=0;i<N&&zhws[i][0]!=NULL;i++)
printf("/n%d: %20s",i,zhws[i]);
if(i<N)printf("/n%d Add new zhi wu.",i);
printf("/nplease select:"); scanf("%d",&p->zhw);
if(zhws[p->zhw][0]==NULL)
{
printf("/nplease input the name of the new zhiwu:");
scanf("%s",zhws[p->zhw]);
printf("/nplease input jbsalary to the %s",zhws[p->zhw]);
scanf("%d",&zhwsp[p->zhw]);
}
for(i=0;i<N&&zhws[i][0]!=NULL;i++)
printf("/n%d: %20s",i,zhchs[i]);
if(i<N)printf("/n%d Add new zhi ch.",i);
printf("/nplease select:"); scanf("%d",&p->zhch);
if(zhchs[p->zhch][0]==NULL)
{
printf("/nplease input the name of the new zhich:");
scanf("%s",zhchs[p->zhch]);
printf("/nplease input jbsalary to the %s",zhchs[p->zhch]);
scanf("%d",&zhchsp[p->zhch]);
}
printf("/nzhi chen bianhao:"); scanf("%ld",&p->zhchnum);
printf("/nhome telephone number:");scanf("%ld",&p->homeph);
printf("/nmobilephone number:"); scanf("%s",p->mobile);
p->paymons=0;
p->depart=dep->name;
return(p);
}
WORKER * whtailw(DEPART *dep) /*查找职工------链尾,返回链尾*/
{
WORKER *head,*tail;
head=dep->down;
if(head==NULL||head->down==NULL)
{tail=head; return(tail);}
for(tail=head;tail->down!=NULL;tail=tail->down)
return(tail->down);
}
WORKER * insertw(DEPART *dep,WORKER *p,WORKER *tail) /*插入新职工,返回链尾*/
{
p->down=NULL;
p->right=NULL;
if(tail==NULL) /*判断tail是否为链头*/
{
dep->down=p;
p->front=NULL;
p->right=NULL;
tail=p;
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!**********************/
return(tail);
}
tail->down=p;
p->front=tail;
p->right=NULL;
tail=p;
return(p);
}
void delone(DEPART *dep,WORKER *p) /*删除一个职工及其工资信息*/
{
WORKER *p1,*p2; PAYLIST *py1,*py2;char ch;
gotoxy(6,20);printf("Are you sure to delet %s(y/n):",p->name); /**询问是否要删除该职工**/
scanf("%s",&ch);
if(ch=='N'||ch=='n')return;
p1=p->front;
p2=p->down; /*判断p是否是链头*/
if(zhp==p) /*****如果删除的时zhp所指的结构就要修改起指向**/
if(zhp->front!=NULL) zhp=zhp->front;
else if(zhp->down!=NULL)zhp=zhp->down;
else { dep=dep->right;zhp=dep->down;}
if(p1==NULL)
{ dep->down=p2; p2->front=NULL;}
else if(p2==NULL) p1->down=NULL; /*判断p是否是链尾*/
else { p1->down=p2;
p2->front=p1;
}
for(py1=p->right;py1->right!=NULL;py1=py2)
{
py2=py1->right;
free(py1);
}
free(p);
}
void delall(DEPART *dep) /**删除整个部门**/
{
WORKER *p; PAYLIST *py1,*py2; char ch;
gotoxy(20,6);printf("Are you sure to delet %s(y/n):",p->name); /**询问是否要删除该职工**/
scanf("%s",&ch);
if(ch=='N'||ch=='n')return;
if(dep->left!=NULL) { dep->left->right=dep->right; /**修改部门链**/
dep->right->left=dep->left;zhp=dep->down;}
else {headd=dep->right;dep->right->left=headd;}
for(p=dep->down;p!=NULL;p=p->down)
{
for(py1=p->right;py1->right!=NULL;py1=py2)
{
py2=py1->right;
free(py1);
}
free(p);
}
return;
}
void addnew(DEPART *dep) /*增加新职工*/
{
WORKER *p,*tail;
int a=3,b=3,i; char ch;
textbackground(GREEN);textcolor(15);
tail=whtailw(dep);
do{
clrscr();
p=ruluw(); /*录入职工信息*/
tail=insertw(dep,p,tail);
dep->wknum++;
printf("Go On?(y/n):");
scanf("%1s",&ch);
}while(ch=='y'||ch=='Y');
clrscr();
puttext(1,1,80,25,savee);/*恢复打开菜单前的样子*/
gotoxy(b,a);cprintf("Cardnum Name sex depart zhw zhch ");
for(i=1,wwp=dep->down;wwp!=NULL&&i<22;wwp->down,i++)
{
gotoxy(b,a+i);cprintf("%d",wwp->cardnum);
gotoxy(b+7,a+i);cprintf("%s",wwp->name);
gotoxy(b+17,a+i);cprintf("%s",sexs[wwp->sex]);
gotoxy(b+25,a+i);cprintf("%s",departs[wwp->depart]);
gotoxy(b+35,a+i);cprintf("%s",zhws[wwp->zhw]);
gotoxy(b+45,a+i);cprintf("%s",zhchs[wwp->zhch]);
}
wwp=dep->down;
shchx(wwp);
return;
}
PAYLIST * rulup(WORKER *wp) /*录入工资单信息*/
{
PAYLIST *p;
if((p=malloc(sizeof(PAYLIST)))==NULL)
{
printf("Nei Cun Bu Zu!");exit(-1);
}
printf("******************Finlish The Paylist***************");
printf("/nCard number: %d",wp->cardnum);p->cardnum=wp->cardnum;
printf("/nName: %s",wp->name); strcpy(p->name,wp->name);
printf("/nMonth(digit):");scanf("%d",&p->month);
printf("/nAddition:");scanf("%d",&p->addition);
printf("/nPraise:");scanf("%d",&p->praise);
printf("/nwater cost:");scanf("%d",&p->water);
printf("/nelectronic cost:");scanf("%d",&p->elec);
p->jbsalary=zhchsp[wp->zhch];
p->zhwsalary=zhwsp[wp->zhw];
p->clean=clst;
p->tv=tvst;
p->ysalary=p->jbsalary+p->zhwsalary+p->addition;
p->tax=p->ysalary<=800?0:(p->ysalary<=1400?p->ysalary/20:p->ysalary/10);
p->salary=p->ysalary+p->praise-p->water-p->elec-p->clean-p->tv;
wp->paymons++;
return(p); /*填写的时候paymons记得加一*/
}
void readdep(DEPART **pp,FILE *fp) /*从文件中读取部门信息*/
{
DEPART *p;
p=*pp;
fscanf(fp,"%d",&p->name);
fscanf(fp,"%s",p->path);
fscanf(fp,"%d",&p->wknum);
return;
}
void writedep(DEPART *p,FILE *fp) /*保存部门信息*/
{
fprintf(fp,"% 5d ",p->name);
fprintf(fp,"% 21s ",p->path);
fprintf(fp,"% 5d ",p->wknum);
return;
}
void readw(WORKER **wp,FILE *fp) /*从文件中读取职工信息*/
{
WORKER *p;
p=*wp;
fscanf(fp,"%s",p->name);
fscanf(fp,"%d",&p->sex);
fscanf(fp,"%s",p->idnum);
fscanf(fp,"%d",&p->cardnum);
fscanf(fp,"%d",&p->age);
fscanf(fp,"%d",&p->wkage);
fscanf(fp,"%d",&p->depart);
fscanf(fp,"%d",&p->zhw);
fscanf(fp,"%d",&p->zhch);
fscanf(fp,"%ld",&p->zhchnum);
fscanf(fp,"%ld",&p->homeph);
fscanf(fp,"%s",p->mobile);
fscanf(fp,"%d",&p->paymons);
return;
}
void writew(WORKER *p,FILE *fp) /*将职工信息写入文件中*/
{
fprintf(fp,"/n %21s ",p->name);
fprintf(fp,"/n %7d ",p->sex);
fprintf(fp,"/n %s ",p->idnum);
fprintf(fp,"/n %7d ",p->cardnum);
fprintf(fp,"/n %7d ",p->age);
fprintf(fp,"/n %7d ",p->wkage);
fprintf(fp,"/n %7d ",p->depart);
fprintf(fp,"/n %7d ",p->zhw);
fprintf(fp,"/n %7d ",p->zhch);
fprintf(fp,"/n %9ld ",p->zhchnum);
fprintf(fp,"/n %9ld ",p->homeph);
fprintf(fp,"/n %s ",p->mobile);
fprintf(fp,"/n %7d /n",p->paymons);
return;
}
void readp(PAYLIST **pp,FILE *fp) /*从文件中读取工资单信息*/
{
PAYLIST *p;
p=*pp;
fscanf(fp,"%d",&p->cardnum);
fscanf(fp,"%s",p->name);
fscanf(fp,"%d",&p->month);
fscanf(fp,"%d",&p->jbsalary);
fscanf(fp,"%d",&p->zhwsalary);
fscanf(fp,"%d",&p->addition);
fscanf(fp,"%d",&p->ysalary);
fscanf(fp,"%d",&p->praise);
fscanf(fp,"%d",&p->tax);
fscanf(fp,"%d",&p->water);
fscanf(fp,"%d",&p->elec);
fscanf(fp,"%d",&p->clean);
fscanf(fp,"%d",&p->tv);
fscanf(fp,"%d",&p->salary);
return;
}
void writep(PAYLIST *p,FILE *fp) /*将工资单信息写入文件中*/
{
fprintf(fp," %7d ",p->cardnum);
fprintf(fp,"%21s",p->name);
fprintf(fp," %7d ",p->month);
fprintf(fp," %7d ",p->jbsalary);
fprintf(fp," %7d ",p->zhwsalary);
fprintf(fp," %7d ",p->addition);
fprintf(fp," %7d ",p->ysalary);
fprintf(fp," %7d ",p->praise);
fprintf(fp," %7d ",p->tax);
fprintf(fp," %7d ",p->water);
fprintf(fp," %7d ",p->elec);
fprintf(fp," %7d ",p->clean);
fprintf(fp," %7d ",p->tv);
fprintf(fp," %7d ",p->salary);
return;
}
void shchx(WORKER *wp) /*详细输出*/
{ int a=3;
PAYLIST *p;
gotoxy(T+4,a);cprintf("%s",wp->name);
gotoxy(T+4,a+1);cprintf("%s",sexs[wp->sex]);
gotoxy(T+3,a+2);cprintf("%s",wp->idnum);
gotoxy(T+4,a+3);cprintf("%d",wp->cardnum);
gotoxy(T+4,a+4);cprintf("%d",wp->age);
gotoxy(T+4,a+5);cprintf("%d",wp->wkage);
gotoxy(T+4,a+6);cprintf("%s",departs[wp->depart]);
gotoxy(T+4,a+7);cprintf("%s",zhws[wp->zhw]);
gotoxy(T+4,a+8);cprintf("%s",zhchs[wp->zhch]);
gotoxy(T+4,a+9);cprintf("%ld",wp->zhchnum);
gotoxy(T+4,a+10);cprintf("%ld",wp->homeph);
gotoxy(T+4,a+11);cprintf("%s",wp->mobile);
p=wp->right;if(p==NULL)return;
for(;p->right!=NULL;p=p->right);
gotoxy(T+12,a+13);cprintf("%s",months[p->month]);
gotoxy(T+4,a+14);cprintf("%d",p->jbsalary); gotoxy(T+14,a+14);cprintf("%d",p->praise);
gotoxy(T+4,a+15);cprintf("%d",p->zhwsalary); gotoxy(T+14,a+15);cprintf("%d",p->tax);
gotoxy(T+4,a+16);cprintf("%d",p->addition); gotoxy(T+14,a+16);cprintf("%d",p->water);
gotoxy(T+4,a+17);cprintf("%d",p->ysalary); gotoxy(T+14,a+17);cprintf("%d",p->elec);
gotoxy(T+4,a+18);cprintf("%d",p->clean); gotoxy(T+14,a+18);cprintf("%d",p->tv);
gotoxy(T+4,a+19);cprintf("%d",p->salary);
}
void loadw(DEPART *dep)
{
WORKER *p,*tail,*head;
if((p=malloc(sizeof(WORKER)))==NULL)
{
printf("Nei Cun Bu Zu!");exit(-1);
}
readw(&p,fp);
tail=whtailw(dep);
tail=insertw(dep,p,tail);
return;
}
void loadp(WORKER *wp,FILE *fp)
{
int i;
PAYLIST *p,*tail;
if((p=malloc(sizeof(PAYLIST)))==NULL)
{
printf("Nei Cun buzu!");exit(-1);
}
tail=whtailp(wp);
readp(&p,fp);
tail=insertp(wp,p,tail);
return;
}
PAYLIST * whtailp(WORKER *wp) /*查找职工------链尾,返回链尾*/
{
PAYLIST *head,*tail;
head=wp->right;
if(head==NULL||head->right==NULL)
{tail=head; return(tail);}
for(tail=head;tail->right!=NULL;tail=tail->right)
return(tail); /*为什么tail不行????????????????????????????*********/
}
PAYLIST * insertp(WORKER *wp,PAYLIST *p,PAYLIST *tail) /*插入新职工,返回链尾*/
{
p->right=NULL;
if(tail==NULL) /*判断tail是否为链头*/
{
tail->right=p;
p->left=tail;
tail=p;
wp->right=tail; /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!**********************/
return(tail);
}
tail->right=p;
p->left=tail;
tail=p;
return(tail);
}
void load(void) /*从文件中导入部门,职工及工资单信息*/
{
start();
for(dep=headd;dep->right!=NULL;dep=dep->right)
{if((fp=fopen(dep->path,"r"))==NULL)
{
printf("Cannot open the file %s",dep->path); getch();
exit(-1);
}
for(i=0;i<dep->wknum;i++) loadw(dep);
for(wwp=dep->down;wwp!=NULL;wwp=wwp->down)
for(i=0;i<wwp->paymons;i++)
loadp(wwp,fp);
fclose(fp);
/******************************************************************************************************为什么return放到外面就不行呢*/
}
return;
}
void xianshw(void) /************显示第n个部门的职工信息********/
{
int i,n,a=3,b=3;
dep=headd;
textbackground(GREEN);textcolor(15);
gotoxy(6,10);cprintf("please select the department:");
for(i=0;departs[i][0]!=NULL;i++){gotoxy(6,11+i);cprintf("%d: %s",i,departs[i]);}
scanf("%d",&n);
clrscr();
puttext(1,1,80,25,savee);/*恢复打开菜单前的样子*/
for(i=0,dep=headd;i<n;i++,dep=dep->right);
wwp=dep->down; zhp=dep->down;
if(wwp==NULL){gotoxy(6,10);printf("The department of %s is NULL.",departs[dep->name]);return;}
gotoxy(b,a);cprintf("Cardnum Name sex depart zhw zhch ");
for(i=1;wwp!=NULL&&i<22;wwp=wwp->down,i++)
{ if(wwp==zhp){
gotoxy(2,a+i);printf("D");
}
gotoxy(b,a+i);cprintf("%d",wwp->cardnum);
gotoxy(b+7,a+i);cprintf("%s",wwp->name);
gotoxy(b+17,a+i);cprintf("%s",sexs[wwp->sex]);
gotoxy(b+25,a+i);cprintf("%s",departs[wwp->depart]);
gotoxy(b+35,a+i);cprintf("%s",zhws[wwp->zhw]);
gotoxy(b+45,a+i);cprintf("%s",zhchs[wwp->zhch]);
}
shchx(zhp); /*****详细显示该部门第一个职工的详细信息和工资信息***/
Dzhg();
return;
}
void main(void)
{
load();
loadmenu();
}
void addlist(WORKER *zhp) /*填写工资单*/
{
PAYLIST *p,*tail;
int a=3,b=3,i; char ch;
clrscr();textbackground(GREEN);textcolor(15);changeshuju(); /****填写工资单前先确定一下基本数据是否正确**/
GOlist:
textbackground(GREEN);textcolor(15);
tail=whtailp(zhp);
clrscr();
p=rulup(zhp); /*录入工资单信息*/
tail=insertp(zhp,p,tail);
zhp->paymons++;
printf("Go On to finish the following man's(y/n):");
scanf("%1s",&ch);
if(ch=='y'||ch=='Y')
{if(zhp->down==NULL){ printf("All in this department finished!");getch();}
else { zhp=zhp->down;goto GOlist;}
}
clrscr();
puttext(1,1,80,25,save);/*恢复打开菜单前的样子*/ getch();
return;
}
void xiansh2(DEPART *dep)
{
int i,j,a=3,b=3;
clrscr();Menu(); textbackground(GREEN);textcolor(WHITE);
gotoxy(b,a);cprintf("Cardnum Name sex depart zhw zhch ");
wwp=dep->down;
for(i=1;wwp!=NULL&&i<22;wwp=wwp->down,i++)
{ if(wwp==zhp){
gotoxy(2,a+i);printf("D");
}
gotoxy(b,a+i);cprintf("%d",wwp->cardnum);
gotoxy(b+7,a+i);cprintf("%s",wwp->name);
gotoxy(b+17,a+i);cprintf("%s",sexs[wwp->sex]);
gotoxy(b+25,a+i);cprintf("%s",departs[wwp->depart]);
gotoxy(b+35,a+i);cprintf("%s",zhws[wwp->zhw]);
gotoxy(b+45,a+i);cprintf("%s",zhchs[wwp->zhch]);
}
shchx(zhp); /*****详细显示该部门第一个职工的详细信息和工资信息***/
}
void Dzhg(void) /*****确定某一个具体职工****/
{ while(1)
{
key=bioskey(0);/*接收按键*/
switch(key)
{
case ESC: DrawMl(0);break; /*显示下拉菜单1*/
case DOWN: if(zhp->down!=NULL)zhp=zhp->down;
else zhp=dep->down;
xiansh2(dep);break;
case UP: if(zhp->front!=NULL)zhp=zhp->front;
else for(;zhp->down!=NULL;zhp=zhp->down);
xiansh2(dep); break;
}
}
return;
}
void insertdep(void) /****添加新的部门***/
{
DEPART *p,*tail;int i;char ch;
do{
textbackground(GREEN);clrscr();
if((p=malloc(sizeof(DEPART)))==NULL)
{
printf("Nei Cun buzu!");exit(-1);
}
for(i=0,tail=headd;tail->right!=NULL;tail=tail->right,i++);
p->name=i; textcolor(WHITE);
gotoxy(6,6);cprintf("please input the name of the department:");
scanf("%s",departs[i]);
strcpy(p->path,"d://sal//aaaaa.dat");
for(i=9;i<14&&departs[i][0]!=NULL;i++)p->path[i]=departs[i-9]; /****自动为部门设置保存路径***/
p->wknum=0; /***部门人员初始化为0***/
tail->right=p;
p->left=tail;
p->right=NULL;
p->down=NULL;
cprintf("Insert department success!!goon(y/n)");
scanf("%1s",&ch);
}while(ch=='y'||ch=='Y');
puttext(1,1,80,25,save);/*恢复打开菜单前的样子*/
return;
}
void addzh(void) /***添加职务和职称***/
{
int i;
clrscr(); textbackground(GREEN);textcolor(WHITE);
for(i=0;i<N&&zhws[i][0]!=NULL;i++)
printf("/n%d: %20s",i,zhws[i]);
if(i<N)
{
printf("/nplease input the name of the new zhiwu:");
scanf("%s",zhws[i]);
printf("/nplease input jbsalary to the %s",zhws[i]);
scanf("%d",&zhwsp[i]);
}
else printf("The room is full!");
for(i=0;i<N&&zhws[i][0]!=NULL;i++)
printf("/n%d: %20s",i,zhchs[i]);
if(i<N)
{
printf("/nplease input the name of the new zhich:");
scanf("%s",zhchs[i]);
printf("/nplease input jbsalary to the %s",zhchs[i]);
scanf("%d",&zhchsp[i]);
}
}
void savew(void) /*保存职工信息和工资信息***/
{
DEPART *dp;
WORKER *wp;PAYLIST *pp;
for(dp=headd;dp->right!=NULL;dp=dp->right)
{if((fp=fopen(dp->path,"w"))==NULL)
{
printf("Cannot open the file: %s",dp->path); getch();
exit(-1);
}
for(wp=dp->down;wp!=NULL;wp=wp->down)
writew(wp,fp);
for(wp=dp->down;wp!=NULL;wp=wp->down)
for(pp=wp->right;pp!=NULL;pp=pp->right) writep(pp,fp);
fclose(fp); /***切记不要忘了关闭文件***/
}
}
void day1(void) /***直接打印当前窗口内的职工信息**/
{
FILE *fp;WORKER *wp;
if((fp=fopen("PRN","r"))==NULL)
{
printf("Cannot open the printer or it isnot exit."); getch();return;
}
for(wp=dep->down;wp!=NULL;wp=wp->down)
writew(wp,fp);
return;
}
void day2(void)
{
FILE *fp; TJW *p;
if((fp=fopen("PRN","r"))==NULL)
{
printf("Cannot open the printer or it isnot exit."); getch();
}
for(p=head1;p!=NULL;p=p->next)
writew(p->wp,fp);
return;
}
void changew(WORKER *p) /*修改职工基本信息*/
{
int i;
char ch;
textbackground(GREEN);textcolor(WHITE);clrscr();
printf("/nname: %s change:",p->name); scanf("%s",p->name);
printf("/nsex: %7d change(0:male 1:female): ",p->sex); scanf("%d",&p->sex);
printf("/nidnum: %s change:",p->idnum); scanf("%s",p->idnum);
printf("/ncard: %7d change:",p->cardnum); scanf("%d",&p->cardnum);
printf("/nage: %7d change:",p->age); scanf("%d",&p->age);
printf("/nwkage: %7d change:",p->wkage); scanf("%d",&p->wkage);
printf("/nzhw: %7d change:",p->zhw);
for(i=0;i<N&&zhws[i][0]!=NULL;i++)printf("/n%d %21s ",i,zhws[i]);scanf("%d",&p->zhw);
printf("/nzhch: %7d change:",p->zhch);
for(i=0;i<N&&zhchs[i][0]!=NULL;i++)printf("/n%d %21s ",i,zhchs[i]);scanf("%d",&p->zhch);
printf("/nzhchnum: %9ld change:",p->zhchnum); scanf("%ld",&p->zhchnum);
printf("/nhomeph: %9ld change:",p->homeph); scanf("%ld",&p->homeph);
printf("/nmobile: %s change:",p->mobile); scanf("%s",p->mobile);
printf("/npaymons: %7d (!!!)change:",p->paymons); scanf("%d",&p->paymons);
clrscr();
puttext(1,1,80,25,save);/*恢复打开菜单前的样子*/
return;
}
WORKER * search2() /*通过工资卡号查找*/
{
DEPART *head;int card;
WORKER *p;
head=headd;
printf("/nplease input the card number of the person thar you search:");
scanf("%d",&card);
for(;head!=NULL;head=head->right)
{
p=head->down;
for(;p!=NULL;p=p->down)
if(p->cardnum==card) return(p);
}
p=NULL;
return(p);
}
void jqsearch(void) /*精确查询*/
{
int num;
WORKER *p;
p=NULL;
textbackground(GREEN);clrscr();
printf("Exact Search:/n");
printf("0:As Zhecheng number;/n1:As Id number;/n2:As Card number;/nplease select:");
scanf("%d",&num);
switch(num)
{
case 0:p=search0();break; /**通过职称编号查询****/
case 1:p=search1();break; /*通过身分证号查询*/
case 2:p=search2();break; /*通过工资卡号查询*/
}
if(p==NULL)printf("/nthe person you searched is not exited!!");
else printf("The person is:%s/nis in partment:%s",p->name,departs[p->depart]);
getch();
clrscr();
puttext(1,1,80,25,save);/*恢复打开菜单前的样子*/
return;
}
WORKER * search0() /*通过职称编号查询*/
{
DEPART *head;long zhchnum;
WORKER *p;
head=headd;
printf("/nplease input the zhicheng number of the person thar you search:");
scanf("%ld",&zhchnum);
for(;head!=NULL;head=head->right)
{
p=head->down;
for(;p!=NULL;p=p->down)
if(p->zhchnum==zhchnum) return(p);
}
p=NULL;
return(p);
}
WORKER * search1() /*通过身分证号查询*/
{
DEPART *head;char id[M];
WORKER *p;
head=headd;
printf("/nplease input the ID number of the person thar you search:");
scanf("%s",id);
for(;head!=NULL;head=head->right)
{
p=head->down;
for(;p!=NULL;p=p->down)
if(!strcmp(p->idnum,id)) return(p);
}
p=NULL;
return(p);
}
void mhsearch() /*模糊查询*/
{
int num;
TJW *p1;
textbackground(GREEN);clrscr();
head1=NULL; /**初始化设为空**/
printf("* Search:/n");
printf("0:As Name;/n1:As Age;/n2:As Work age;/nplease select:");
scanf("%d",&num);
switch(num)
{
case 0: /**通过姓名查询****/
case 1: /*通过年龄查询*/
case 2:search3(); /*通过工龄查询*/
}
if(head1==NULL)printf("/nthe person you searched is not exited!!");
else for(p1=head1;p1!=NULL;p1=p1->next)
printf("The person is:%s is in partment:%s",p1->wp->name,departs[p1->wp->depart]);
getch();
clrscr();
puttext(1,1,80,25,save);/*恢复打开菜单前的样子*/
return;
}
void search3(void) /*通过姓名查询*/
{
DEPART *head;char name[M];int i=0;
WORKER *p;TJW *tp,*tail;
head=headd;
printf("/nplease input the NAME of the person thar you search:");
scanf("%s",name);
for(;head!=NULL;head=head->right)
{
p=head->down;
for(;p!=NULL;p=p->down)
if(!strcmp(p->name,name))
{
if((tp=malloc(sizeof(TJW)))==NULL)
{
printf("Nei Cun buzu!");exit(-1);
}
tp->wp=p; tp->next=NULL;
if(i==0) {head1=tp;tail=tp;}
else {tail->next=tp;tail=tp;}
}
}
return;
}
void Ashuijin() /*统计税金总额及排出前十名**/
{
int i,all=0;char ch;
WORKER *p;DEPART *head;TJW *tp1,*tp2,*tp3;
textbackground(GREEN);clrscr();
head1=NULL;
for(head=headd;head!=NULL;head=head->right)
{
for(p=head->down;p!=NULL;p=p->down)
{ all+=p->tax;
tp1=malloc(sizeof(TJW));
tp1->wp=p;
if(head1==NULL) {head1=tp1;head1->next=NULL;}
for(tp2=head1;tp2!=NULL;tp2=tp2->next)
{ tp3=tp2->next;
if(tp1->wp->tax>=head1->wp->tax) {tp1->next=head1;head1=tp1;}
if(tp1->wp->tax>=tp3->wp->tax){tp2->next=tp1;tp1->next=tp3;}
else if(tp1->wp->tax<tp3->wp->tax&&tp3->next==NULL)
{tp3->next=tp1;tp1->next=NULL;}
}
}
}
printf("all of the tax is: %d /n",all);
for(tp1=head1,i=0;tp1!=NULL&&i<10;tp1=tp1->next,i++)
printf(" %s %d/n",tp1->wp->name,tp1->wp->tax);
printf("printf(y/n)?");scanf("%1s",&ch);
if(ch=='y'||ch=='Y') day2();
else return;
}
void changep(WORKER *p) /*修改工资单信息*/
{
PAYLIST *pay;
pay=p->right;
textbackground(GREEN);clrscr();
printf("********* chage the paylist**********/n");
if(pay==NULL)
{ printf("The paylist is NULL;Please write a paylist for him before!");
return; }
for(;pay->right!=NULL;pay=pay->right);
printf("/nmonth: %7d ",pay->month); scanf("%d",&pay->month);
printf("/njbsalary: %7d ",pay->jbsalary); scanf("%d",&pay->jbsalary);
printf("/nzhwsalary: %7d ",pay->zhwsalary); scanf("%d",&pay->zhwsalary);
printf("/naddition: %7d ",pay->addition); scanf("%d",&pay->addition);
pay->ysalary=pay->jbsalary+pay->zhwsalary+pay->addition;
printf("/npraise: %7d ",pay->praise); scanf("%d",&pay->praise);
pay->tax=pay->ysalary<=800?0:(pay->ysalary<=1400?pay->ysalary/20:pay->ysalary/10);
printf("/nwater cost: %7d ",pay->water); scanf("%d",&pay->water);
printf("/nelec cost: %7d ",pay->elec); scanf("%d",&pay->elec);
printf("/nclean cost: %7d ",pay->clean); scanf("%d",&pay->clean);
printf("/ntv cost: %7d ",pay->tv); scanf("%d",&pay->tv);
pay->salary=pay->ysalary+pay->praise-pay->water-pay->elec-pay->clean-pay->tv;
printf("/nNow,the new salary is:/n");
printf("tax: %7d /n",pay->tax);printf("ysalary: %7d /n",pay->ysalary);
printf("salary: %7d /n",pay->salary);
return;
}
参考资料:
1、《C语言程序设计教程(第二版)》 秦友淑、曹化工编著 华中科技大学出版社 2002年12月
2、《C高级实用程序设计》 王士元 编著 清华大学出版社 2000年3月
3、《Turbo C使用大全第一册,第二册》 徐金梧等编译 北京科海培训中心
此外,也上网找过一些资料。