📄 工资管理系统.txt
字号:
struct department1 tema;
struct employee1 temb;
struct salary1 temc;
struct award1 temd;
char filename[30];
long i,j;
FILE *f;
printf("\nPlease input name of the file you want to open\n");
scanf("%s",filename);
f=fopen(filename,"rb");
if(f==NULL)
{
printf("\nCan't open file %s\n",filename);
exit(-1);
}
fread(&i,sizeof(long),1,f);
pa=malloc(sizeof(struct department));
fread(&tema,sizeof(struct department1),1,f);
strcpy(pa->name,tema.name);
pa->num1=tema.num1;
pa->p1=head;
head=pa;
taila=pa;
for(j=1;j<i;j++)
{
pa=malloc(sizeof(struct department));
fread(&tema,sizeof(struct department1),1,f);
strcpy(pa->name,tema.name);
pa->num1=tema.num1;
pa->p1=NULL;
taila->p1=pa;
taila=pa;
}
pa=head;
while(pa!=NULL)
{
pa->p2=NULL;
pb=malloc(sizeof(struct employee));
fread(&temb,sizeof(struct employee1),1,f);
pb->num2=temb.num2;
strcpy(pb->name,temb.name);
pb->gzkh=temb.gzkh;
strcpy(pb->ID,temb.ID);
pb->sex=temb.sex;
pb->standing=temb.standing;
pb->age=temb.age;
strcpy(pb->tel,temb.tel);
strcpy(pb->mobile,temb.mobile);
strcpy(pb->jszc,temb.jszc);
pb->zcbh=temb.zcbh;
pb->p3=pa->p2;
pa->p2=pb;
tailb=pb;
for(j=1;j<pa->num1;j++)
{
pb=malloc(sizeof(struct employee));
fread(&temb,sizeof(struct employee1),1,f);
pb->num2=temb.num2;
strcpy(pb->name,temb.name);
pb->gzkh=temb.gzkh;
strcpy(pb->ID,temb.ID);
pb->sex=temb.sex;
pb->standing=temb.standing;
pb->age=temb.age;
strcpy(pb->tel,temb.tel);
strcpy(pb->mobile,temb.mobile);
strcpy(pb->jszc,temb.jszc);
pb->zcbh=temb.zcbh;
pb->p3=NULL;
tailb->p3=pb;
tailb=pb;
}
pa=pa->p1;
}
pa=head;
while(pa!=NULL)
{
pb=pa->p2;
while(pb!=NULL)
{
pb->p4=NULL;
pc=malloc(sizeof(struct salary));
fread(&temc,sizeof(struct salary1),1,f);
pc->num3=temc.num3;
strcpy(pc->month,temc.month);
pc->zcbh=temc.zcbh;
strcpy(pc->title,temc.title);
pc->jbgz=temc.jbgz;
pc->zwgz=temc.zwgz;
pc->subsidy=temc.subsidy;
pc->p5=pb->p4;
pb->p4=pc;
tailc=pc;
for(j=1;j<(pa->p2)->num2;j++)
{
pc=malloc(sizeof(struct salary));
fread(&temc,sizeof(struct salary1),1,f);
pc->num3=temc.num3;
strcpy(pc->month,temc.month);
pc->zcbh=temc.zcbh;
strcpy(pc->title,temc.title);
pc->jbgz=temc.jbgz;
pc->zwgz=temc.zwgz;
pc->subsidy=temc.subsidy;
pc->p5=NULL;
tailc->p5=pc;
tailc=pc;
}
pb=pb->p3;
}
pa=pa->p1;
}
pa=head;
while(pa!=NULL)
{
pb=pa->p2;
while(pb!=NULL)
{
pc=pb->p4;
while(pc!=NULL)
{
pc->p6=NULL;
pd=malloc(sizeof(struct award));
fread(&temd,sizeof(struct award1),1,f);
strcpy(pd->reason,temd.reason);
pd->amount=temd.amount;
pd->p=pc->p6;
pc->p6=pd;
taild=pd;
for(j=1;j<pc->num3;j++)
{
pd=malloc(sizeof(struct award));
fread(&temd,sizeof(struct award1),1,f);
strcpy(pd->reason,temd.reason);
pd->amount=temd.amount;
pd->p=NULL;
taild->p=pd;
taild=pd;
}
pc=pc->p5;
}
pb=pb->p3;
}
pa=pa->p1;
}
fclose(f);
return(head);
}
void save(struct department * ph) /*保存一个文件*/
{
char filename[30];
struct department *pa,*head;
struct employee *pb;
struct salary *pc;
struct award *pd;
struct department1 tema;
struct employee1 temb;
struct salary1 temc;
struct award1 temd;
long i=0,j;
FILE *f;
head=ph;
pa=head;
while(pa!=NULL)
{
pa=pa->p1;
i++;
}
printf("\nPlease input the filename:\n");
scanf("%s",filename);
f=fopen(filename,"wb");
if(f==NULL)
{
printf("Can't open %s\n",filename);
exit(-1);
}
fwrite(&i,sizeof(long),1,f);
pa=head;
while(pa!=NULL)
{
tema.num1=pa->num1;
strcpy(tema.name,pa->name);
fwrite(&tema,sizeof(struct department1),1,f);
pa=pa->p1;
}
pa=head;
while(pa!=NULL)
{
pb=pa->p2;
while(pb!=NULL)
{
temb.num2=pb->num2;
strcpy(temb.name,pb->name);
temb.gzkh=pb->gzkh;
strcpy(temb.ID,pb->ID);
temb.sex=pb->sex;
temb.standing=pb->standing;
strcpy(temb.tel,pb->tel);
strcpy(temb.mobile,pb->mobile);
strcpy(temb.jszc,pb->jszc);
temb.zcbh=pb->zcbh;
fwrite(&temb,sizeof(struct employee1),1,f);
pb=pb->p3;
}
pa=pa->p1;
}
pa=head;
while(pa!=NULL)
{
pb=pa->p2;
while(pb!=NULL)
{
pc=pb->p4;
while(pc!=NULL)
{
temc.num3=pc->num3;
strcpy(temc.month,pc->month);
temc.zcbh=pc->zcbh;
strcpy(temc.title,pc->title);
temc.jbgz=pc->jbgz;
temc.zwgz=pc->zwgz;
temc.subsidy=pc->subsidy;
fwrite(&temc,sizeof(struct salary1),1,f);
pc=pc->p5;
}
pb=pb->p3;
}
pa=pa->p1;
}
pa=head;
while(pa!=NULL)
{
pb=pa->p2;
while(pb!=NULL)
{
pc=pb->p4;
while(pc!=NULL)
{
pd=pc->p6;
while(pd!=NULL)
{
strcpy(temd.reason,pd->reason);
temd.amount=pd->amount;
fwrite(&temd,sizeof(struct award),1,f);
pd=pd->p;
}
pc=pc->p5;
}
pb=pb->p3;
}
pa=pa->p1;
}
fclose(f);
}
struct department *de(struct department *phe) /*修改部门信息*/
{
struct department *head,*pa;
short flag=1;
char dename[24],ch;
head=phe;
while(flag)
{
pa=head;
while(pa!=NULL)
{
printf("\nAll the department:\n");
printf("%s\t",pa->name);
pa=pa->p1;
}
printf("\nPlease input the name of department you want to change:\n");
scanf("%s",dename);
pa=head;
while(pa!=NULL)
{
if(!strcmp(dename,pa->name))
{
printf("\nPlease input the new information:\n"
"New name of the department\n");
scanf("%s",pa->name);
break;
}
else pa=pa->p1;
}
printf("\nContinue or not?[n or y](change department)\n");
scanf("%1s",&ch);
if(ch=='n'||ch=='N')
flag=0;
else flag=1;
}
return (head);
}
struct department *em(struct department *phe) /*修改工人的信息*/
{
struct department *head,*pa;
struct employee *pb;
short flag=1;
char ch,dename[24],emname[30];
head=phe;
while(flag)
{
pa=head;
while(pa==NULL)
{
printf("\nAll the department:\n");
printf("%s\t",pa->name);
pa=pa->p1;
}
printf("\nPlease input the name of department you want to change:\n");
scanf("%s",dename);
pa=head;
while(pa!=NULL)
{
if(!strcmp(dename,pa->name))
{
pb=pa->p2;
while(pb!=NULL)
{
printf("\nPlease input the name of employee:\n");
scanf("%s",emname);
if(!strcmp(emname,pb->name))
{
printf("\nPlease input the name of the worker:");
scanf("%s",pb->name);
printf("\nPlease input ID of worker:");
scanf("%s",pb->ID);
printf("\nPlease input telephone number of worker:");
scanf("%s",pb->tel);
printf("\nPlease input mobile number of worker:");
scanf("%s",pb->mobile);
printf("\nPlease input title of worker(jishuzhicheng):");
scanf("%s",pb->jszc);
printf("\nPlease input:\n"
"Gongzikahao,Sex,Age,Standing(Gongling),Zhichengbianhao\n");
scanf("%ld,%c,%hd,%hd",&pb->gzkh,&pb->sex,&pb->age,&pb->standing,&pb->zcbh);
break;
}
else pb=pb->p3;
}
break;
}
else pa=pa->p1;
}
printf("\nContinue or not?[n or y](change employee)\n");
scanf("%1s",&ch);
if(ch=='n'||ch=='N')
flag=0;
else flag=1;
}
return (head);
}
struct department *sa(struct department *phe) /*修改工资的信息*/
{
struct department *head,*pa;
struct employee *pb;
struct salary *pc;
short flag=1;
char ch,dename[24],emname[30],month1[10];
head=phe;
while(flag)
{
pa=head;
while(pa!=NULL)
{
printf("\nAll the departments:\n");
printf("%s\t",pa->name);
pa=pa->p1;
}
printf("\nPlease input the name of department you want to change:\n");
scanf("%s",dename);
pa=head;
while(pa!=NULL)
{
if(!strcmp(dename,pa->name))
{
pb=pa->p2;
while(pb!=NULL)
{
printf("\nPlease input the name of employee:\n");
scanf("%s",emname);
if(!strcmp(emname,pb->name))
{
pc=pb->p4;
while(pc!=NULL)
{
printf("\nPlease input the name of month\n");
scanf("%s",month1);
if(!strcmp(month1,pc->month))
{
printf("\nPlease input the month:");
scanf("%s",pc->month);
printf("\nPlease input the title of the worker:");
scanf("%s",pc->title);
printf("\nPlease inupt :\n"
"Zhichengbianhao,Jibengongzi,Zhiwugongzi,Subsidy(buzhu):\n");
scanf("%ld,%f,%f,%f",&pc->zcbh,&pc->jbgz,&pc->zwgz,&pc->subsidy);
break;
}
else pc=pc->p5;
}
break;
}
else pb=pb->p3;
}
break;
}
else pa=pa->p1;
}
printf("\nContinue or not?[n or y](change salary)\n");
scanf("%1s",&ch);
if(ch=='n'||ch=='N')
flag=0;
else flag=1;
}
return(head);
}
struct department *aw(struct department *phe) /*修改奖金的信息*/
{
struct department *head,*pa;
struct employee *pb;
struct salary *pc;
struct award *pd;
short flag=1;
char ch,dename[24],emname[30],month1[10],reason1[20];
head=phe;
while(flag)
{
pa=head;
while(pa!=NULL)
{
printf("\nAll the departments:\n");
printf("%s\t",pa->name);
pa=pa->p1;
}
printf("\nPlease input the name of department you want to change:\n");
scanf("%s",dename);
pa=head;
while(pa!=NULL)
{
if(!strcmp(dename,pa->name))
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -