职工信息管理系统源代码.doc_第1页
职工信息管理系统源代码.doc_第2页
职工信息管理系统源代码.doc_第3页
职工信息管理系统源代码.doc_第4页
职工信息管理系统源代码.doc_第5页
已阅读5页,还剩5页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

#include #include #include #includestruct Date /*日期*/int year;int month;int day;struct Infochar num15; /*职工号*/char name15; /*姓名*/char sex10; /*性别*/struct Date birthday; /*出生年月*/char education10; /*学历*/char duty15; /*职务*/double wage; /*工资*/char addr30; /*地址*/char phone15; /*电话*/;/*菜单选择函数*/char menu() char n; /*n记录选择的菜单*/int system(const char *string); /*清屏*/system(cls); /*清屏*/puts(tt 欢迎使用职工信息管理系统 );puts(tt*MENU*n);puts(tttt1. 职工信息录入功能n); puts(tttt2. 职工信息浏览功能n); puts(tttt3. 职工信息查询功能n); puts(tttt4. 职工信息修改功能n); puts(tttt5. 职工信息删除功能n); puts(tttt6. 退出n); puts(tt*n);printf(选择你要使用的功能(1-6): bb);while(1)n=getchar();getchar();if(n6)printf(输入错误,请重新选择你要使用的功能(1-6): bb);elsebreak;return n; /*信息输入函数*/void append() struct Info info;FILE * fp;char ch;char temp10;if(fp=fopen(inform.txt,ab)=NULL)printf(t文件打开错误!);getch();exit(1);doprintf(t号码:);gets(info.num);printf(t姓名:);gets();printf(t性别:);gets(info.sex);printf(t出生日期(yyyy/mm/dd):);scanf(%d/%d/%d,&info.birthday.year,&info.birthday.month,&info.birthday.day);getchar();printf(t学历:);gets(cation);printf(t职务:);gets(info.duty);printf(t工资:);gets(temp); info.wage=atof(temp);printf(t地址:);gets(info.addr);printf(t电话:);gets(info.phone); fwrite(&info,sizeof(info),1,fp);printf(t还有更多的吗?(Y/N): bb);ch=getchar();getchar();while(ch=Y|ch=y);fclose(fp);void print1()printf(%-10s%-10s%-10s%-12s%-10s%-10s%-15s%-30s%-15s%n,号码,姓名,性别,出生日期,学历,职务,工资,地址,电话);void print2(struct Info info);printf(%-10s%-10s%-10s,info.num,,info.sex);printf(%-4d/%-2d/%-4d,info.birthday.year,info.birthday.month,info.birthday.day);printf(%-10s%-10s%-15.2lf,cation,info.duty,info.wage);printf(%-30s%-15sn,info.addr,info.phone); /*职工信息显示函数*/void display() struct Info info;FILE * fp;int total=0;if(fp=fopen(inform.txt,rb)=NULL)printf(t文件打开错误!);getch();exit(1);while(fread(&info, sizeof(info),1,fp)=1)total+;if(total=1)print1();print2(info);if(total!=0)&(total%10=0)printf(nnt按任意键继续。);getch();puts(nn);print1();fclose(fp);printf(nnt这儿一共有%d个记录!nnt按任意键返主菜单。,total);getch();/*信息查询函数*/void search() struct Info info;FILE * fp;int flag; /*flag为1按编号查询,flag为2按姓名查询*/int total=0; /*记录符合条件的记录的个数*/char ch10;char f;if(fp=fopen(inform.txt,rb)=NULL)printf(t文件打开错误!);getch();exit(1);dorewind(fp);printf(nn使用(1:号码 2:姓名)查找: bb);while(1)scanf(%d,&flag);getchar();if(flag2)printf(输入错误,请重新输入(1:号码 2:姓名): bb);elsebreak;if(flag=1) /*按编号进行查询*/printf(请输入你要查找的号码:);gets(ch);total=0; /*符合条件的记录数*/while(fread(&info, sizeof(info),1,fp)=1)if(strcmp(ch,info.num)=0)total+;if(total=1)print1();print2(info);else /*按姓名进行查询*/printf(请输入你要查找的姓名:);gets(ch);total=0; /*符合条件的记录数*/while(fread(&info, sizeof(info),1,fp)=1)if(strcmp(ch,)=0)total+;if(total=1)print1();print2(info);printf(nnt共有%d项符合条件!n,total);printf(继续查找?(Y/N): bb);f=getchar();getchar();while(f=Y|f=y);fclose(fp);/*信息修改函数*/void modify() struct Info info;FILE * fp1,*fp2;int flag;char ch10;char f;char temp10;doif(fp1=fopen(inform.txt,rb)=NULL)printf(t文件打开错误!);getch();exit(1);if(fp2=fopen(temp.txt,wb)=NULL)printf(t文件创建失败!);getch();exit(1);printf(请输入你要修改的号码:);gets(ch);flag=0;while(fread(&info,sizeof(info),1,fp1)=1)if(strcmp(ch,info.num)=0)print1();print2(info);printf(nn请输入新的信息:n);printf(t号码:);gets(info.num);printf(t姓名:);gets();printf(t性别:);gets(info.sex);printf(t出生日期(yyyy/mm/dd):); scanf(%d/%d/%d,&info.birthday.year,&info.birthday.month,&info.birthday.day);getchar();printf(t学历:);gets(cation);printf(t职务:);gets(info.duty);printf(t工资:);gets(temp);info.wage=atof(temp);printf(t地址:);gets(info.addr);printf(t电话:);gets(info.phone);flag=1;fwrite(&info,sizeof(info),1,fp2);fclose(fp1);fclose(fp2);if(flag=1)printf(修改成功!n);remove(inform.txt);rename(temp.txt,inform.txt);elseprintf(没有找到记录!n);printf(继续修改?(Y/N): bb);f=getchar();getchar();while(f=Y|f=y);/*信息删除函数*/void delete() struct Info info;FILE * fp1,*fp2;int flag;char ch10;char f;char temp10;doif(fp1=fopen(inform.txt,rb)=NULL)printf(t文件打开错误!);getch();exit(1);if(fp2=fopen(temp.txt,wb)=NULL)printf(t文件创建失败!);getch();exit(1);printf(请输入你要删除的号码:);gets(ch);flag=0;while(fread(&info,sizeof(info),1,fp1)=1) if(strcmp(ch,info.num)=0)print1();print2(info);flag=1;continue;else fwrite(&info,sizeof(info),1,fp2);fclose(fp1);fclose(fp2);if(flag=1)printf(删除成功!n);remove(inform.txt);rename(temp.txt,inform.txt);else printf(没找到要删除的号码!n); printf(继续删除?(Y/N): bb); f=getchar();getchar();while(f=Y|f=y); caozuo() while(1) switch(menu() case1:append();break; case2:display();break; case3:search();break; case4:modify();break; case5:delete();break; case6:exit(0);break; /*密码系统*/struct Infechar zhanghao15;char mima15;char men() char n; int system(const char *string); system(cls); puts(tt 欢迎使用职工信息管理系统 );puts(tt*MENU*n);puts(tttt1. 注册管理员账号n); puts(tttt2. 登陆管理员账号n); puts(tttt3. 退出n); puts(tt*n);printf(选择你要使用的功能(1-3): bb);while(1)n=getchar();getchar();if(n3)printf(输入错误,请重新选择你要使用的功能(1-3): bb);elsebreak;return n; /*账号注册函数*/void zhuce() struct Infe infe;FILE * fp;int total=0;if(fp=fopen(mima.txt,ab+)=NULL)printf(t文件打开错误!);getch();exit(1);while(fread(&infe, sizeof(infe),1,fp)=1)total+;if(total=1)printf(nnt对不起,管理员已存在。无法注册。);elseprintf(t账号:);gets(infe.zhanghao);printf(t密码:);gets(infe.mima);fwrite(&infe,sizeof(infe),1,fp);printf(恭喜你,注册成功!);fclose(fp);getch();/*账号登陆函数*/void dl() struct Infe infe;FILE * fp; char ch15;char ch115;if(fp=fopen(mima.txt,rb)=NULL)printf(t账号文件打开错误!);getch();exit(1);printf(t请

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论