|
|
@ -8,7 +8,6 @@ void dele_num();
|
|
|
|
void modi_num();
|
|
|
|
void modi_num();
|
|
|
|
void browse();
|
|
|
|
void browse();
|
|
|
|
void count();
|
|
|
|
void count();
|
|
|
|
void load();
|
|
|
|
|
|
|
|
void add();
|
|
|
|
void add();
|
|
|
|
void menu();
|
|
|
|
void menu();
|
|
|
|
int n; //员工的总数
|
|
|
|
int n; //员工的总数
|
|
|
@ -16,12 +15,13 @@ struct emploee //ְ
|
|
|
|
{
|
|
|
|
{
|
|
|
|
char no[5];
|
|
|
|
char no[5];
|
|
|
|
char name[8];
|
|
|
|
char name[8];
|
|
|
|
float wage1; //员工的基本工资
|
|
|
|
int wage1; //员工的基本工资
|
|
|
|
float wage2; //员工的职务工资
|
|
|
|
int wage2; //员工的职务工资
|
|
|
|
float funds; //员工的公积金
|
|
|
|
int funds; //员工的公积金
|
|
|
|
float ylbx; //员工的医疗保险
|
|
|
|
int ylbx; //员工的医疗保险
|
|
|
|
float jt; //员工的津贴
|
|
|
|
int jt; //员工的津贴
|
|
|
|
float wage3; //员工的实发工资
|
|
|
|
int wage3; //员工的实发工资
|
|
|
|
|
|
|
|
int wage4; //前3项工资之和
|
|
|
|
}emp[NUM],newemp;
|
|
|
|
}emp[NUM],newemp;
|
|
|
|
int main()
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -31,18 +31,17 @@ void menu()//
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int n;
|
|
|
|
int n;
|
|
|
|
do{
|
|
|
|
do{
|
|
|
|
printf("************* 职工工资管理系统 **************\n");
|
|
|
|
printf("**************** 职工工资管理系统 ***********\n");
|
|
|
|
printf("* 1-----输入职工信息------ *\n");
|
|
|
|
printf("* 1-----输入职工信息------ *\n");
|
|
|
|
printf("* 2-----查询职工信息------ *\n");
|
|
|
|
printf("* 2-----查询职工信息------ *\n");
|
|
|
|
printf("* 3-----根据职工ID号删除-- *\n");
|
|
|
|
printf("* 3-----删除职工信息------ *\n");
|
|
|
|
printf("* 4-----根据职工ID号修改-- *\n");
|
|
|
|
printf("* 4-----修改职工信息------ *\n");
|
|
|
|
printf("* 5-----据工资统计并浏览-- *\n");
|
|
|
|
printf("* 5-----工资统计信息------ *\n");
|
|
|
|
printf("* 6-----从文件载入信息---- *\n");
|
|
|
|
printf("* 6-----浏览职工信息------ *\n");
|
|
|
|
printf("* 7-----浏览全部职工信息-- *\n");
|
|
|
|
printf("* 7-----添加职工信息------ *\n");
|
|
|
|
printf("* 8-----添加职工信息------ *\n");
|
|
|
|
printf("* 8-------退出程序-------- *\n");
|
|
|
|
printf("* 9-----退出程序---------- *\n");
|
|
|
|
|
|
|
|
printf("*********************************************\n");
|
|
|
|
printf("*********************************************\n");
|
|
|
|
printf("输入你的选择(1-9):");
|
|
|
|
printf("输入你的选择(1-8):");
|
|
|
|
scanf("%d",&n);
|
|
|
|
scanf("%d",&n);
|
|
|
|
switch(n)
|
|
|
|
switch(n)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -51,25 +50,29 @@ switch(n)
|
|
|
|
case 3:dele_num(); break;
|
|
|
|
case 3:dele_num(); break;
|
|
|
|
case 4:modi_num(); break;
|
|
|
|
case 4:modi_num(); break;
|
|
|
|
case 5:count(); break;
|
|
|
|
case 5:count(); break;
|
|
|
|
case 6:load(); break;//保存加载的信息
|
|
|
|
case 6:browse(); break;//加载信息
|
|
|
|
case 7:browse(); break;//加载信息
|
|
|
|
case 7:add(); break;
|
|
|
|
case 8:add(); break;
|
|
|
|
case 8:printf("*******欢迎下次使用!*******");
|
|
|
|
case 9:printf("*******欢迎下次使用!*******");
|
|
|
|
|
|
|
|
default:exit(0);//退出系统.exit(0)函数功能是退出程序
|
|
|
|
default:exit(0);//退出系统.exit(0)函数功能是退出程序
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}while(n!=0);
|
|
|
|
}while(n!=0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/*************************开始的地方**********************/
|
|
|
|
/*************************输入**********************/
|
|
|
|
void enter()
|
|
|
|
void enter()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
FILE *fp;
|
|
|
|
FILE *fp;
|
|
|
|
int n,i;
|
|
|
|
int n,i;
|
|
|
|
|
|
|
|
fp=fopen("emp.txt","ab+");
|
|
|
|
|
|
|
|
if(fp==NULL)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
if ((fp=fopen("emp.txt","wb"))==NULL)
|
|
|
|
if ((fp=fopen("emp.txt","wb"))==NULL)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
printf("不能建立emp文件\n");
|
|
|
|
printf("不能建立emp文件\n");
|
|
|
|
exit(1);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
printf("输入职工人数:");
|
|
|
|
printf("输入职工人数:");
|
|
|
|
scanf("%d",&n);
|
|
|
|
scanf("%d",&n);
|
|
|
|
for(i=0;i<n;i++) /* 循环获取n个职工记录 */
|
|
|
|
for(i=0;i<n;i++) /* 循环获取n个职工记录 */
|
|
|
@ -80,16 +83,17 @@ void enter()
|
|
|
|
printf("姓名:");
|
|
|
|
printf("姓名:");
|
|
|
|
scanf("%s",&emp[i].name);
|
|
|
|
scanf("%s",&emp[i].name);
|
|
|
|
printf("基本工资:");
|
|
|
|
printf("基本工资:");
|
|
|
|
scanf("%f",&emp[i].wage1);
|
|
|
|
scanf("%d",&emp[i].wage1);
|
|
|
|
printf("职务工资:");
|
|
|
|
printf("职务工资:");
|
|
|
|
scanf("%f",&emp[i].wage2);
|
|
|
|
scanf("%d",&emp[i].wage2);
|
|
|
|
printf("津贴:");
|
|
|
|
printf("津贴:");
|
|
|
|
scanf("%f",&emp[i].jt);
|
|
|
|
scanf("%d",&emp[i].jt);
|
|
|
|
printf("医疗保险:");
|
|
|
|
printf("医疗保险:");
|
|
|
|
scanf("%f",&emp[i].ylbx);
|
|
|
|
scanf("%d",&emp[i].ylbx);
|
|
|
|
printf("公积金:");
|
|
|
|
printf("公积金:");
|
|
|
|
scanf("%f",&emp[i].funds);
|
|
|
|
scanf("%d",&emp[i].funds);
|
|
|
|
emp[i].wage3=emp[i].wage1+emp[i].wage2-emp[i].ylbx+emp[i].jt-emp[i].funds;
|
|
|
|
emp[i].wage3=emp[i].wage1+emp[i].wage2-emp[i].ylbx+emp[i].jt-emp[i].funds;
|
|
|
|
|
|
|
|
emp[i].wage4=emp[i].wage1+emp[i].wage2+emp[i].jt;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for(i=0;i<n;i++) /*将n个职工记录写入文件*/
|
|
|
|
for(i=0;i<n;i++) /*将n个职工记录写入文件*/
|
|
|
|
fwrite(&emp[i],sizeof(struct emploee),1,fp);
|
|
|
|
fwrite(&emp[i],sizeof(struct emploee),1,fp);
|
|
|
@ -99,36 +103,31 @@ void enter()
|
|
|
|
void count()
|
|
|
|
void count()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
FILE *fp;
|
|
|
|
FILE *fp;
|
|
|
|
int n,num;
|
|
|
|
int n,i;
|
|
|
|
|
|
|
|
int a=0,b=0,c=0;
|
|
|
|
if((fp=fopen("emp.txt","rb"))==NULL)
|
|
|
|
if((fp=fopen("emp.txt","rb"))==NULL)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
printf("不能打开emp文件\n");
|
|
|
|
printf("不能打开emp文件\n");
|
|
|
|
exit(1);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
printf("请输入工资数:");
|
|
|
|
|
|
|
|
scanf("%d",&num);
|
|
|
|
|
|
|
|
printf("记录号 ID 姓名 基本工资 职务工资 津贴 医疗保险 公积金 实发工资\n");
|
|
|
|
|
|
|
|
for(n=0;fread(&emp[n],sizeof(struct emploee),1,fp)!=0;n++)
|
|
|
|
for(n=0;fread(&emp[n],sizeof(struct emploee),1,fp)!=0;n++)
|
|
|
|
if(emp[n].wage3>=num)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
printf("第%d个职工:\n",n+1);
|
|
|
|
if(emp[n].wage4>=1000&&emp[i].wage4<2000)
|
|
|
|
printf("ID:");
|
|
|
|
{
|
|
|
|
scanf("%s",emp[n].no);
|
|
|
|
a++;
|
|
|
|
printf("姓名:");
|
|
|
|
}
|
|
|
|
scanf("%s",&emp[n].name);
|
|
|
|
if(emp[n].wage4>=2000&&emp[i].wage4<3000)
|
|
|
|
printf("基本工资:");
|
|
|
|
{
|
|
|
|
scanf("%f",&emp[n].wage1);
|
|
|
|
b++;
|
|
|
|
printf("职务工资:");
|
|
|
|
}
|
|
|
|
scanf("%f",&emp[n].wage2);
|
|
|
|
if(emp[n].wage4>=3000)
|
|
|
|
printf("津贴:");
|
|
|
|
{
|
|
|
|
scanf("%f",&emp[n].jt);
|
|
|
|
c++;
|
|
|
|
printf("医疗保险:");
|
|
|
|
|
|
|
|
scanf("%f",&emp[n].ylbx);
|
|
|
|
|
|
|
|
printf("公积金:");
|
|
|
|
|
|
|
|
scanf("%f",&emp[n].funds);
|
|
|
|
|
|
|
|
printf("总工资:");
|
|
|
|
|
|
|
|
scanf("%f",&emp[n].wage3);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("前三项之和在1000~2000元的占的百分之%d\n",a*100/n);
|
|
|
|
|
|
|
|
printf("前三项之和在2000~3000元的占的百分之%d\n",b*100/n);
|
|
|
|
|
|
|
|
printf("前三项之和在3000元以上占的百分之%d\n",c*100/n);
|
|
|
|
fclose(fp);
|
|
|
|
fclose(fp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/********************删除信息的地方*******************/
|
|
|
|
/********************删除信息的地方*******************/
|
|
|
@ -142,35 +141,33 @@ void dele_num()
|
|
|
|
printf("不能打开emp文件\n");
|
|
|
|
printf("不能打开emp文件\n");
|
|
|
|
exit(1);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
printf("删除前:\n");
|
|
|
|
printf("ID 姓名 基本工资 职务工资 津贴 医疗保险 公积金 实发工资\n");
|
|
|
|
printf("记录号 ID 姓名 基本工资 职务工资 津贴 医疗保险 公积金 实发工资\n");
|
|
|
|
|
|
|
|
for(n=0;fread(&emp[n],sizeof(struct emploee),1,fp);n++)
|
|
|
|
for(n=0;fread(&emp[n],sizeof(struct emploee),1,fp);n++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
printf("第%d个职工:\n",n+1);
|
|
|
|
|
|
|
|
printf("ID:");
|
|
|
|
printf("ID:");
|
|
|
|
scanf("%s",emp[i].no);
|
|
|
|
scanf("%-6s",emp[i].no);
|
|
|
|
printf("姓名:");
|
|
|
|
printf("姓名:");
|
|
|
|
scanf("%s",&emp[i].name);
|
|
|
|
scanf("%-6s",&emp[i].name);
|
|
|
|
printf("基本工资:");
|
|
|
|
printf("基本工资:");
|
|
|
|
scanf("%f",&emp[i].wage1);
|
|
|
|
scanf("%-8d",&emp[i].wage1);
|
|
|
|
printf("职务工资:");
|
|
|
|
printf("职务工资:");
|
|
|
|
scanf("%f",&emp[i].wage2);
|
|
|
|
scanf("%-8d",&emp[i].wage2);
|
|
|
|
printf("津贴:");
|
|
|
|
printf("津贴:");
|
|
|
|
scanf("%f",&emp[i].jt);
|
|
|
|
scanf("%-8d",&emp[i].jt);
|
|
|
|
printf("医疗保险:");
|
|
|
|
printf("医疗保险:");
|
|
|
|
scanf("%f",&emp[i].ylbx);
|
|
|
|
scanf("%-8d",&emp[i].ylbx);
|
|
|
|
printf("公积金:");
|
|
|
|
printf("公积金:");
|
|
|
|
scanf("%f",&emp[i].funds);
|
|
|
|
scanf("%-8d",&emp[i].funds);
|
|
|
|
printf("总工资:");
|
|
|
|
printf("总工资:");
|
|
|
|
scanf("%f",&emp[i].wage3);
|
|
|
|
scanf("%-8d",&emp[i].wage3);
|
|
|
|
}/*n为emp文件中记录数*/
|
|
|
|
}/*n为emp文件中记录数*/
|
|
|
|
printf("要删除的职工号:");
|
|
|
|
printf("要删除的ID:");
|
|
|
|
scanf("%s",num);
|
|
|
|
scanf("%s",num);
|
|
|
|
for(i=0;(strcmp(emp[i].no,num)!=0&&i<n);i++)
|
|
|
|
for(i=0;(strcmp(emp[i].no,num)!=0&&i<n);i++)
|
|
|
|
if(i>=n)
|
|
|
|
if(i>=n)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
printf("\t没有%s职工号的职工\n",num);
|
|
|
|
printf("\t没有%s职工号的职工\n",num);
|
|
|
|
exit(2);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fclose(fp);
|
|
|
|
fclose(fp);
|
|
|
|
fp=fopen("emp.dat","w+");
|
|
|
|
fp=fopen("emp.dat","w+");
|
|
|
@ -187,23 +184,22 @@ void dele_num()
|
|
|
|
fseek(fp,0,SEEK_SET);
|
|
|
|
fseek(fp,0,SEEK_SET);
|
|
|
|
for(i=0;fread(&emp[i],sizeof(struct emploee),1,fp);i++)
|
|
|
|
for(i=0;fread(&emp[i],sizeof(struct emploee),1,fp);i++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
printf("第%d个职工:\n",i+1);
|
|
|
|
|
|
|
|
printf("ID:");
|
|
|
|
printf("ID:");
|
|
|
|
scanf("%s",emp[i].no);
|
|
|
|
scanf("%-6s",emp[i].no);
|
|
|
|
printf("姓名:");
|
|
|
|
printf("姓名:");
|
|
|
|
scanf("%s",&emp[i].name);
|
|
|
|
scanf("%-6s",&emp[i].name);
|
|
|
|
printf("基本工资:");
|
|
|
|
printf("基本工资:");
|
|
|
|
scanf("%f",&emp[i].wage1);
|
|
|
|
scanf("%-8d",&emp[i].wage1);
|
|
|
|
printf("职务工资:");
|
|
|
|
printf("职务工资:");
|
|
|
|
scanf("%f",&emp[i].wage2);
|
|
|
|
scanf("%-8d",&emp[i].wage2);
|
|
|
|
printf("津贴:");
|
|
|
|
printf("津贴:");
|
|
|
|
scanf("%f",&emp[i].jt);
|
|
|
|
scanf("%-8d",&emp[i].jt);
|
|
|
|
printf("医疗保险:");
|
|
|
|
printf("医疗保险:");
|
|
|
|
scanf("%f",&emp[i].ylbx);
|
|
|
|
scanf("%-8d",&emp[i].ylbx);
|
|
|
|
printf("公积金:");
|
|
|
|
printf("公积金:");
|
|
|
|
scanf("%f",&emp[i].funds);
|
|
|
|
scanf("%-8d",&emp[i].funds);
|
|
|
|
printf("总工资:");
|
|
|
|
printf("总工资:");
|
|
|
|
scanf("%f",&emp[i].wage3);
|
|
|
|
scanf("%-8d",&emp[i].wage3);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fclose(fp);
|
|
|
|
fclose(fp);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -218,35 +214,34 @@ void modi_num()
|
|
|
|
printf("不能 打开emp文件\n");
|
|
|
|
printf("不能 打开emp文件\n");
|
|
|
|
exit(1);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
printf("要修改的职工号:");
|
|
|
|
printf("要修改的ID:");
|
|
|
|
scanf("%s",num);
|
|
|
|
scanf("%s",num);
|
|
|
|
for(i=0;fread(&emp[i],sizeof(struct emploee),1,fp);i++)
|
|
|
|
for(i=0;fread(&emp[i],sizeof(struct emploee),1,fp);i++)
|
|
|
|
if(!strcmp(emp[i].no,num))break;
|
|
|
|
if(!strcmp(emp[i].no,num))break;
|
|
|
|
if(feof(fp))
|
|
|
|
if(feof(fp))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
printf("\t没有%s职工号的职工\n",num);
|
|
|
|
printf("\t没有%s职工号的职工\n",num);
|
|
|
|
exit(2);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
printf("记录号 职工号 姓名 基本工资 职务工资 津贴 医疗保险 公积金 实发工资\n");
|
|
|
|
printf("ID 姓名 基本工资 职务工资 津贴 医疗保险 公积金 实发工资\n");
|
|
|
|
printf("%6d %6s %9s %.1f %.1f %.1f %.1f %.1f %.1f\n",i+1,emp[i].no,emp[i].name,emp[i].wage1,emp[i].wage2,emp[i].jt,emp[i].ylbx,emp[i].funds,emp[i].wage3);
|
|
|
|
printf(" %-6s %-6s %-8d %-8d %-8d %-8d %-8d %-8d\n",emp[i].no,emp[i].name,emp[i].wage1,emp[i].wage2,emp[i].jt,emp[i].ylbx,emp[i].funds,emp[i].wage3);
|
|
|
|
printf("输入格式:职工号 姓名 基本工资 职务工资 津贴 医疗保险 公积金\n");
|
|
|
|
printf("ID 姓名 基本工资 职务工资 津贴 医疗保险 公积金\n");
|
|
|
|
printf("第%d个记录:",i+1);
|
|
|
|
scanf("%s%s%d%d%d%d%d",newemp.no,newemp.name,&newemp.wage1,&newemp.wage2,&newemp.jt,&newemp.ylbx,&newemp.funds);//获取新的职工记录
|
|
|
|
scanf("%s%s%f%f%f%f%f",newemp.no,newemp.name,&newemp.wage1,&newemp.wage2,&newemp.jt,&newemp.ylbx,&newemp.funds);//获取新的职工记录
|
|
|
|
|
|
|
|
newemp.wage3=newemp.wage1+newemp.wage2+newemp.jt-newemp.ylbx-newemp.funds;
|
|
|
|
newemp.wage3=newemp.wage1+newemp.wage2+newemp.jt-newemp.ylbx-newemp.funds;
|
|
|
|
fseek(fp,-(long)sizeof(struct emploee),SEEK_CUR); //文件指针指向该修改的记录开头
|
|
|
|
fseek(fp,-(long)sizeof(struct emploee),SEEK_CUR); //文件指针指向该修改的记录开头
|
|
|
|
fwrite(&newemp,sizeof(struct emploee),1,fp); //用newemp覆盖当前记录
|
|
|
|
fwrite(&newemp,sizeof(struct emploee),1,fp); //用newemp覆盖当前记录
|
|
|
|
printf(" 修改后:\n");
|
|
|
|
printf(" 修改后:\n");
|
|
|
|
fseek(fp,0,SEEK_SET); //显示修改后的文件数据
|
|
|
|
fseek(fp,0,SEEK_SET); //显示修改后的文件数据
|
|
|
|
printf("记录号 职工号 姓名 基本工资 职务工资 津贴 医疗保险 公积金 实发工资\n");
|
|
|
|
printf("ID 姓名 基本工资 职务工资 津贴 医疗保险 公积金 实发工资\n");
|
|
|
|
for(i=0;fread(&emp[i],sizeof(struct emploee),1,fp)!=0;i++)
|
|
|
|
for(i=0;fread(&emp[i],sizeof(struct emploee),1,fp)!=0;i++)
|
|
|
|
printf("%6d %6s %9s %.1f %.1f %.1f %.1f %.1f %.1f\n",i+1,emp[i].no,emp[i].name,emp[i].wage1,emp[i].wage2,emp[i].jt,emp[i].ylbx,emp[i].funds,emp[i].wage3);
|
|
|
|
printf(" %-6s %-6s %-8d %-8d %-8d %-8d %-8d %-8d\n",emp[i].no,emp[i].name,emp[i].wage1,emp[i].wage2,emp[i].jt,emp[i].ylbx,emp[i].funds,emp[i].wage3);
|
|
|
|
fclose(fp);
|
|
|
|
fclose(fp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/*************************查询信息的地方***********************/
|
|
|
|
/*************************查询信息的地方***********************/
|
|
|
|
void search_num()
|
|
|
|
void search_num()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
FILE *fp;
|
|
|
|
FILE *fp;
|
|
|
|
int i;
|
|
|
|
int i,n;
|
|
|
|
char num[5];
|
|
|
|
char num[5];
|
|
|
|
if((fp=fopen("emp.txt","rb"))==NULL)
|
|
|
|
if((fp=fopen("emp.txt","rb"))==NULL)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -260,10 +255,18 @@ void search_num()
|
|
|
|
if(feof(fp))
|
|
|
|
if(feof(fp))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
printf("\t查无此人\n");
|
|
|
|
printf("\t查无此人\n");
|
|
|
|
exit(2);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
printf("记录号 职工号 姓名 基本工资 职务工资 津贴 医疗保险 公积金 实发工资\n");
|
|
|
|
printf("职工号 姓名 基本工资 职务工资 津贴 医疗保险 公积金 实发工资\n");
|
|
|
|
printf("%6d %6s %9s %.1f %.1f %.1f %.1f %.1f %.1f\n",i+1,emp[i].no,emp[i].name,emp[i].wage1,emp[i].wage2,emp[i].jt,emp[i].ylbx,emp[i].funds,emp[i].wage3);
|
|
|
|
printf(" %-6s %-6s %-8d %-8d %-8d %-8d %-8d %-8d\n",emp[i].no,emp[i].name,emp[i].wage1,emp[i].wage2,emp[i].jt,emp[i].ylbx,emp[i].funds,emp[i].wage3);
|
|
|
|
|
|
|
|
printf("继续请按1,不继续请按0\n");
|
|
|
|
|
|
|
|
scanf("%d",&n);
|
|
|
|
|
|
|
|
switch(n)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
case 1:search_num();break;
|
|
|
|
|
|
|
|
case 0:break;
|
|
|
|
|
|
|
|
default:break;
|
|
|
|
|
|
|
|
}
|
|
|
|
fclose(fp);
|
|
|
|
fclose(fp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/*******************浏览信息的地方********************/
|
|
|
|
/*******************浏览信息的地方********************/
|
|
|
@ -278,15 +281,15 @@ void browse()
|
|
|
|
printf("记录号 职工号 姓名 基本工资 职务工资 津贴 医疗保险 公积金 实发工资\n");
|
|
|
|
printf("记录号 职工号 姓名 基本工资 职务工资 津贴 医疗保险 公积金 实发工资\n");
|
|
|
|
for(i=0;fread(&emp[i],sizeof(struct emploee),1,fp)!=0;i++)
|
|
|
|
for(i=0;fread(&emp[i],sizeof(struct emploee),1,fp)!=0;i++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
printf("%6d %6s %9s %.1f %.1f %.1f %.1f %.1f %.1f\n",i+1,emp[i].no,emp[i].name,emp[i].wage1,emp[i].wage2,emp[i].jt,emp[i].ylbx,emp[i].funds,emp[i].wage3);
|
|
|
|
printf("%-6d %-6s %-6s %-8d %-8d %-8d %-8d %-8d %-8d\n",i+1,emp[i].no,emp[i].name,emp[i].wage1,emp[i].wage2,emp[i].jt,emp[i].ylbx,emp[i].funds,emp[i].wage3);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fclose(fp);
|
|
|
|
fclose(fp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/******************追加信息的地方*******************/
|
|
|
|
/******************修改信息的地方*******************/
|
|
|
|
void add()
|
|
|
|
void add()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
FILE *fp;
|
|
|
|
FILE *fp;
|
|
|
|
int n,i,j;
|
|
|
|
int n,i,t;
|
|
|
|
if((fp=fopen("emp.txt","ab+"))==NULL)
|
|
|
|
if((fp=fopen("emp.txt","ab+"))==NULL)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
printf("不能打开emp文件\n");
|
|
|
|
printf("不能打开emp文件\n");
|
|
|
@ -294,43 +297,34 @@ void add()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
printf("要追加的职工人数:");
|
|
|
|
printf("要追加的职工人数:");
|
|
|
|
scanf("%d",&n);
|
|
|
|
scanf("%d",&n);
|
|
|
|
for(i=0;i<n;i++)
|
|
|
|
for(i=0;i<n;i++) /* 循环获取n个职工记录 */
|
|
|
|
{
|
|
|
|
{
|
|
|
|
printf("职工号 姓名 基本工资 职务工资 津贴 医疗保险 公积金\n");
|
|
|
|
printf("第%d个职工:\n",i+1);
|
|
|
|
printf("追加记录:\n");
|
|
|
|
printf("ID:");
|
|
|
|
scanf("%s%s%f%f%f%f%f",newemp.no,newemp.name,&newemp.wage1,&newemp.wage2,&newemp.jt,&newemp.ylbx,&newemp.funds );
|
|
|
|
scanf("%s",emp[i].no);
|
|
|
|
newemp.wage3=newemp.wage1+newemp.wage2-newemp.funds+newemp.jt-newemp.ylbx;//获取一个新的职工记录
|
|
|
|
printf("姓名:");
|
|
|
|
fwrite(&newemp,sizeof(struct emploee),1,fp); //将该职工记录写入文件
|
|
|
|
scanf("%s",&emp[i].name);
|
|
|
|
}
|
|
|
|
printf("基本工资:");
|
|
|
|
|
|
|
|
scanf("%d",&emp[i].wage1);
|
|
|
|
|
|
|
|
printf("职务工资:");
|
|
|
|
|
|
|
|
scanf("%d",&emp[i].wage2);
|
|
|
|
|
|
|
|
printf("津贴:");
|
|
|
|
|
|
|
|
scanf("%d",&emp[i].jt);
|
|
|
|
|
|
|
|
printf("医疗保险:");
|
|
|
|
|
|
|
|
scanf("%d",&emp[i].ylbx);
|
|
|
|
|
|
|
|
printf("公积金:");
|
|
|
|
|
|
|
|
scanf("%d",&emp[i].funds);
|
|
|
|
|
|
|
|
emp[i].wage3=emp[i].wage1+emp[i].wage2-emp[i].ylbx+emp[i].jt-emp[i].funds;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
for(i=0;i<n;i++) /*将n个职工记录写入文件*/
|
|
|
|
|
|
|
|
fwrite(&emp[i],sizeof(struct emploee),1,fp);
|
|
|
|
|
|
|
|
printf("继续请按1,不继续请按0\n");
|
|
|
|
|
|
|
|
scanf("%d",&t);
|
|
|
|
|
|
|
|
switch(t)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
case 1:add();break;
|
|
|
|
|
|
|
|
case 0:break;
|
|
|
|
|
|
|
|
default:break;
|
|
|
|
|
|
|
|
}
|
|
|
|
fclose(fp);
|
|
|
|
fclose(fp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************载入信息的地方**********************/
|
|
|
|
|
|
|
|
void load() //加载记录或可以计算记录个数的函数
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
FILE *fp;
|
|
|
|
|
|
|
|
int i,w;
|
|
|
|
|
|
|
|
w=1;
|
|
|
|
|
|
|
|
system( "cls" );
|
|
|
|
|
|
|
|
if((fp=fopen("emp.txt","rb"))==NULL) //以输出打开方式,在此前的记录被覆盖
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("\nCannot open file\n");
|
|
|
|
|
|
|
|
w=0;
|
|
|
|
|
|
|
|
return ;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
n=0;
|
|
|
|
|
|
|
|
for(i=0;!feof(fp);i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
fread(&emp[i],sizeof(struct emploee),1,fp);
|
|
|
|
|
|
|
|
n++;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
n=n-1;
|
|
|
|
|
|
|
|
fclose(fp);
|
|
|
|
|
|
|
|
if(w==1)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("Load file ok!");
|
|
|
|
|
|
|
|
getchar();
|
|
|
|
|
|
|
|
getchar();
|
|
|
|
|
|
|
|
menu();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|