职工信息管理系统源代码(共10页).doc

上传人:飞****2 文档编号:14509751 上传时间:2022-05-05 格式:DOC 页数:10 大小:36KB
返回 下载 相关 举报
职工信息管理系统源代码(共10页).doc_第1页
第1页 / 共10页
职工信息管理系统源代码(共10页).doc_第2页
第2页 / 共10页
点击查看更多>>
资源描述

《职工信息管理系统源代码(共10页).doc》由会员分享,可在线阅读,更多相关《职工信息管理系统源代码(共10页).doc(10页珍藏版)》请在得力文库 - 分享文档赚钱的网站上搜索。

1、精选优质文档-倾情为你奉上#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; /*电话*/;/*菜单选择函数

2、*/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)

3、: 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(info.name);printf(t

4、性别:);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(info.education);printf(t职务:);gets(info.duty);printf(t工资:);gets(temp); info.wage=atof(temp);printf(t地址:);gets(info.addr);printf(t电话:);gets(info.phone)

5、; 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.name,info.sex);printf(%-

6、4d/%-2d/%-4d,info.birthday.year,info.birthday.month,info.birthday.day);printf(%-10s%-10s%-15.2lf,info.education,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();ex

7、it(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按姓名

8、查询*/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);tota

9、l=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,info.name)=0)total+;if(total=1)print1();print2(info);printf

10、(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文件创建

11、失败!);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(info.name);printf(t性别:);gets(info.sex);printf(t出生日期(yyyy/mm/dd):); scanf(%d/%d/%d,&info.bi

12、rthday.year,&info.birthday.month,&info.birthday.day);getchar();printf(t学历:);gets(info.education);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(fla

13、g=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(

14、);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)

15、;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;

16、/*密码系统*/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(输入错误,

17、请重新选择你要使用的功能(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

18、密码:);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请输入账号和密码:n);printf(t账号:);gets(ch);printf(t密码:);gets(ch1);while(fread(&infe, sizeof(infe),1,fp)=1)if(strcmp(ch,infe.zhanghao)=0)&(strcmp(ch1,infe.mima)=0)fclose(fp);caozuo();elseprintf(t账号或密码错误!n); main() while(1) switch(men() case1:zhuce();break; case2:dl(); case3:exit(0);break; 专心-专注-专业

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 教育专区 > 教案示例

本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知得利文库网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

工信部备案号:黑ICP备15003705号-8 |  经营许可证:黑B2-20190332号 |   黑公网安备:91230400333293403D

© 2020-2023 www.deliwenku.com 得利文库. All Rights Reserved 黑龙江转换宝科技有限公司 

黑龙江省互联网违法和不良信息举报
举报电话:0468-3380021 邮箱:hgswwxb@163.com