C语言课设之人事管理系统(精编版)_第1页
C语言课设之人事管理系统(精编版)_第2页
C语言课设之人事管理系统(精编版)_第3页
C语言课设之人事管理系统(精编版)_第4页
C语言课设之人事管理系统(精编版)_第5页
已阅读5页,还剩31页未读 继续免费阅读

下载本文档

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

文档简介

1、C 语言课程设计人事管理系统36欢迎下载题目要求: 要求人事管理管理系统某高校主要人员有:在职人员(行政人员、教师、一般员工)、退休人员和临时工。现在, 需要存储这些人员的人事档案信息:编号、姓名、性别、年龄、职务、职称、政治面貌、最高学历、任职时间、来院时间、人员类别。其中,人员编号唯一,不能重复。(1) 添加删除功能:能根据学院人事的变动情况,添加删除记录;(2) 查询功能:能根据编号和姓名进行查询;(3) 编辑功能(高级) :根据查询对相应的记录进行修改,并存储;(4) 统计功能:能根据多种参数进行人员的统计(在职人数、党员人数、女工人数、高学历高职称人数(硕士学位以上或者副教授以上),

2、统计要求同时显示被统计者的信息;(5) 排序功能:按照年龄、来院时间进行排序;(6) 保存功能:能对输入的数据进行相应的存储;一、需求分析:根据题目要求,职工信息是存放在文件中的,所以应该提供相应的文件的输入输出的功能, 在程序中应该有添加删除,查询,编辑,统计,排序,保存等程序实现相应的操作,另外菜单式的选择方式选择程序的功能也是必须需的。另外程序中要求存储的模块,采用的方式均为将原文件中的所有数据读入内存,在内存中处理之后以覆盖的方式写入文件存贮,这样的方法在一定程度上提高了对数据处理的灵活性,较容易理解, 但存在处理中遇到以外情况而丢失数据的风险,另外当文件中的数据量很大时,这种方法也存

3、在一定的难度,在本程序中将 N 定为 100,基本上能满足要求;二、总体设计:根据以上需求分析,将程序分成以下几个模块: 1、 新建数据文件( build new data); 2、 添加记录( add data);3、 删除记录( delete data);4、 按工号搜索( search by number); 5、 按姓名搜索( search by name); 6、 浏览全部数据(browse all );7、 修改数据( modify the data );8、 排序功能( order the volume ); 9、 统计功能( data a volume);系统功能模块图如下:三

4、、详细设计;1、 主函数:1需求分析:为使系统执行完每部分功能后能够方便的回到系统主界面,main() 函数设计的较简单,只包含一个 menu()函数,其余的全部功能都通过递归调用实现返回主界面的功能。main() 函数定义如下: main()menu();而 menu() 定义如下:2流程图:menu()函数调用来实现,并通过menu()函数的menu()int n,w1; doprintf("nttttMENUn"); printf("tt0tbuild newdatann"); printf("tt1tdelete datann"

5、;); printf("tt2tadd datann"); printf("tt3tsearch by numbernn");printf("tt4tsearch by namenn"); printf("tt5tbrowse allnn"); printf("tt6tmodify the datann"); printf("tt7torder the volumenn"); printf("tt8tdata a volumenn"); printf(&q

6、uot;tt9texitnn");printf("tplease choice and enter a number bb"); scanf("%d",&n);if(n<0|n>8)w1=1;getchar(); else w1=0;while(w1=1); switch(n)case 0:build();break;/*调用新建数据文件函数*/case 1:del();break;/*调用删除数据函数*/case 2:add();break;/*调用添加数据函数*/case 3:snum();break;/*调用按工号搜索

7、函数*/case 4:sname();break;/*调用按姓名搜索函数*/case 5:browse();break;/*调用浏览数据函数*/case 6:modify();break;/*调用修改数据函数*/case 7:order();break;/*调用排序函数函数*/case 8:data();break;/*调用统计函数*/case 9:exit(0);/*退出 */default:printf("input error! please input a number between 0 and 8");menu();2、各功能模块设计:(1) 、新建数据文件模块

8、:<1>、数据结构;看各个数据信息,编号、姓名、性别、年龄、职务、职称、政治面貌、最高学历、任职时间、来院时间、 人员类别,均为字符串类型,在文件中以文本形式存放,每条记录对应一个人员的信息,可以方便信息的管理;而数据读进内存中时,可以以结构体的形式,每一个结构体包含了一个人员的全部信息,多的人员的信息组成了一个结构体数组。定义如下:struct workerchar num11; char name10; char sex2; char age3; char zhiwu15;char zhicheng15; char zhengzhi15; char xueli15; char

9、renzhisj8;char laiyansj8; char leibie15;wkN,s;其中 N 是宏定义形式定义的字符,临时定义为100, wkN, 为存放人员信息的结构体数组,而 S 为临时的结构体,用来保存信息处理过程中的临时数据。2、流程图如下:3、程序:build()int i,m,k,p; FILE *fp;if(fp=fopen("worker00.txt","w ")=NULL)printf("can not build filen"); printf_back();printf("howmanywork

10、ersdoyou want to input(0-%d)?:",N); scanf("%d",&m);k=m;for(i=0;i<k;i+)printf("nInput record.n",i+1); input(i);%dthworkerfor(p=0;p<=i;p+) if(fprintf(fp,"%st%st%1st%st%st%st%st%st%st%st%sn",wkp.num,,wkp.s ex,wkp.age,wkp.zhiwu,wkp.zhicheng,wkp.zhengz

11、hi,wkp.xueli,wkp.renzhisj,wkp.laiyansj,wkp.leibie)!=1) printf("cannot write the datann");fclose(fp); printf_back();(2) 、追加模块:1 需求分析 该模块的功能是拥护需要增加新的员工记录,从键盘输入并逐条写入到原来的文件中去,其中输入号码是要防止号码重复,重复时报告错误,重新输入。 为方便用户管理和查看,该模块采用的方式是用先把原来文件中的数据读入内存,保存在内存中, 然后在内存中的数据后面增加新的数据,操作完成后用写的方式打开文件,用覆盖的方式写入。2流程图

12、:3程序:add()int i,m,n,k,p; FILE *fp; n=load();if(n=-1)menu();printf("how many workers do you want to add(0-%d)?:bbb",N-n); scanf("%d",&m);k=m+n; for(i=n+1;i<=k;i+)printf("nInput %dth worker record.n",i-n+1);input(i);if(fp=fopen("worker00.txt","w"

13、;)=NULL)/*将数据保存到文件*/printf("can not open filen"); printf_back();for(p=0;p<k;p+) fprintf(fp,"%st%st%1st%st%st%st%st%st%st%st%sn",wkp.num,,wkp.sex, wkp.age,wkp.zhiwu,wkp.zhicheng,wkp.zhengzhi,wkp.xueli,wkp.renzhisj,wkp.laiyansj,wkp.leibie); fclose(fp);printf_back();(3) 修

14、改模块:1需求分析: 该模块的功能是显示所有信息, 考虑到记录较多, 采用分屏显示, 显示完所有的记录后,由用户输入需要修改的人员的号码, 查找成功后, 显示查找结果, 并询问拥护修改人员的哪部分记录,根据用户选择修改相应的信息,然后保存修改后的结果;2 流程图3程序;modify()int i,n,k,p,w0=1,w1,w2=0;FILE *fp;n=load(); dok=-1;printf_face(); for(i=0;i<=n;i+) if(i!=0)&&(i%10=0)printf("nnRemember the No.which need mod

15、ify.npress any key to continue."); getch();puts("nn");printf_one(i);doprintf("nnEnter NO. that you want to modify!nttNO.bb");scanf("%s",s.num); for(i=0;i<n;i+)if(strcmp(s.num,wki.num)=0);k=i;s=wki;if(k=-1)printf("nnNO exit ! please again");while(k=-1);

16、printf_face(); printf_one(k); w1=modify_data(k);if(w1=1)printf("nsuccessful!nnDo yuo want to modify another?nntt1tYesnntt2tBack with savent bb");scanf("%d",&w0); w2=1;elsew0=0;if(w2=1)wkk=s;wkk=s;if(w0!=1&&w2=1)fp=fopen("worker00.txt","w");for(p=0;

17、p<=n;p+)fprintf(fp,"%st%st%1st%st%st%st%st%st%st%st%sn",wkp.num,,wkp.sex, wkp.age,wkp.zhiwu,wkp.zhicheng,wkp.zhengzhi,wkp.xueli,wkp.renzhisj,wkp.laiyansj,wkp.leibie); fclose(fp);while(w0=1); menu();修改数据函数如下:modify_data(int i)int c,w1; doprintf("nmodifyby=>nntt1tNO.ntt2tn

18、amentt3tsexntt4tagentt5tzhiwuntt6tzhichengntt7nnttt bb"); scanf("%d",&c); if(c>11|c<1)printf("choice error!please choose again!"); getchar();while(c>11|c<1); doswitch(c)case 1:printf("the old number is %s,",wki.num);input_num(i,i-1);break; case 2:pr

19、intf("the old name is %s,enter the new name:",);scanf("%s",);break;case 3:printf("the old sex is %s,enter the new sex:",wki.sex);scanf("%1s",wki.sex);break;case 4:printf("the old age is %s,enter the new age:",wki.age);scanf("%s&q

20、uot;,wki.age);break; case 5:printf("the old zhiwu is %s,enter the new zhiwu:",wki.zhiwu);scanf("%s",wki.zhiwu);break;case 6:printf("the old zhicheng is %s,enter the new zhicheng:",wki.zhicheng);scanf("%s",wki.zhicheng);break; case 7:printf("the old zhengz

21、himianmao is %s,enter the new zhengzhimiainmao:",wki.zhengzhi);scanf("%s",wki.zhengzhi);break;case 8:printf("the old zuigaoxueli is %s,enter the new zuigaoxueli:",wki.xueli);scanf("%s",wki.xueli);break; case 9:printf("the old renzhishijian is %s,enter the newr

22、enzhishijian:",wki.renzhisj);scanf("%s",wki.renzhisj);break; case 10:printf("the old laiyuanshijian is %s,enter the new laiyuanshijian:",wki.laiyansj);scanf("%s",wki.laiyansj);break; case 11:printf("the old renyuanleibie is %s,enter the new renyuanleibie:"

23、;,wki.leibie);scanf("%s",wki.leibie);break;printf("now:nn"); printf_face(); printf_one(i);printf("nareyousure?nntt1tsurentt2tNoand remodifyntt3tbackwithoutsave inthis timentttbbb");scanf("%d",&w1);while(w1=2); return(w1);(4)删除模块:1 需求分析 :该模块的运行方式与修改模块类似,首先分

24、屏显示所有人员的记录,显示完所有的记录后,由用户输入要删除的人员的号码,根据号码查找相应的记录并将结果显示出来,经用户确认后删除, 删除的方法是将文件中的数据读入内存,赋给相应的结构体,并将结构体数组中将删除的后面的数据赋给前一个结构体,然后将相应数据写入文件并保存;2流程图:Y3程序; del()char c;int i,j,n,k,m,w0=1,w1=0,w2=0; FILE *fpt;n=load(); dok=-1;printf_face(); for(i=0;i<=n;i+) if(i!=0)&&(i%10=0)printf("nnRemember t

25、he No.which need delete.npress any key to continue."); getch();printf("nn");printf_one(i);doprintf("nnEnter NO. that you want to delete!nttNO.bb"); scanf("%s",s.num);for(i=0;i<=n;i+) if(strcmp(s.num,wki.num)=0);k=i;s=wki;if(k=-1)printf("nnNO exit ! please a

26、gain");while(k=-1); printf_face(); printf_one(k);printf("are you sure to delete the data? ty/nntt bb"); scanf("%1s",&c);if(c='y')for(j=i;j<=n;j+) wkj=wkj+1; w1=1;else menu(); if(w1=1)printf("nsuccessful!nnDoyuowanttodelete another?nntt1tYesnntt2tBack with

27、 saventbb");scanf("%d",&w0); w2=1;if(w0!=1&&w2=1)fpt=fopen("worker00.txt","w"); for(m=0;m<n;m+)fprintf(fpt,"%st%st%1st%st%st%st%st%st%st%st%sn",wkm.num,,wkm.sex,wkm.age,wkm.zhiwu,wkm. zhicheng,wkm.zhengzhi,wkm.xueli,wkm.renzhisj,wkm

28、.laiyansj,wkm.leibie); fclose(fpt); while(w0=1);menu();(5)、按号码搜索:1 需求分析 :该模块的功能是按照输入的人员的号码查找对应的记录,并将其显示,查找成功以后,增加删除和修改等功能,其中删除和修改功能可以通过调用相应的函数来实现。2流程图;3、程序;snum()FILE *fp;int i,n,k,p,w1=1,w2,w3,w4; n=load();dodok=-1;printf("nnEnter the number that you want to search!nttnumber:bbbbb"); scan

29、f("%s",s.num);for(i=0;i<=n;i+) if(strcmp(s.num,wki.num)=0)k=i; printf_one(k);break;if(k=-1)printf("nnNO exist!please");printf("nnAre you again?ntt1tagainntt2tNO and backnttbb"); scanf("%d",&w1);if(w1=1)snum(); break;if(w1=2) menu();break; while(k=-1&

30、;&w1=1); w4=0;w3=0;if(k!=-1);printf("nnWhat do you want to do ?ntt1tsearch anotherntt2tmodifyntt3tDeletentt4tback menunttbb");scanf("%d",&w2); switch(w2)case 1:snum();break;case 2:w3=modify_data(k);break;/*调用修改数据函数*/case 3:printf("nAre you sure?ntt1tsurentt2tno and b

31、acknttbb"); scanf("%d",&w4);if(w4=1) for(p=i;p<=n;p+)wkp=wkp+1; break;case 4:menu();break;if(w3=1|w4=1)fp=fopen("worker00.txt","w"); for(p=0;p<=n;p+)fprintf(fp,"%st%st%1st%st%st%st%st%st%st%st%sn",wkp.num,,wkp.sex,wkp.age,wkp.zhiwu,wkp.

32、zhicheng,wkp.zhengzhi,wkp.xueli,wkp.renzhisj,wkp.laiyansj,wkp.leibie);fclose(fp); printf("nnttsuccessful!n");printf("nnWhat do you want to do?ntt1tSearch anotherntt2tBacknttbb"); scanf("%d",&w2);while(w2=1);menu();(7) 按姓名搜索。该模块的结构与按号码查询的结构基本相同;(8) 浏览模块;1需求分析:该模块的功能是

33、显示所有保存在文件中的记录,考虑到记录较多, 采用分屏显示的方式;2、流程图;3程序: browse()int i,j,n;n=load(); printf_face(); for(i=0;i<=n;i+) if(i!=0)&&(i%10=0)printf("nnRemember the No.which need delete.npress any key to continue."); getch();printf("nn");printf_one(i);printf("tThere are %d record.n&q

34、uot;,n+1); printf("press any key to continue."); getch();menu();(9) 、排序模块;1、需求分析 ;该模块的功能是要求将记录按照年龄或者来院时间进行排序,总体结构是先用n=load() 函数将文件中的数据调入内存,然后按照选择法排序,并将结果显示出来,然后将排序后的结果保存。2流程图;3程序;order()int i,j,k,n,p,m; FILE *fp; n=load();printf("which do you like to follow?ntt1tagentt2tlaiyuanshijian

35、nn"); scanf("%d",&p);if(p=1)for(i=0;i<=n-1;i+)for(j=i+1;j<=n;j+)if(strcmp(wki.age,wkj.age)<0)s=wki;wki=wkj;wkj=s; if(p=2)for(i=0;i<=n-1;i+)for(j=i+1;j<=n;j+)if(strcmp(wki.laiyansj,wkj.laiyansj)<0)s=wki;wki=wkj; wkj=s;fp=fopen("worker00.txt","w+&quo

36、t;); for(m=0;m<=n;m+)if(fprintf(fp,"%st%st%1st%st%st%st%st%st%st%st%sn",wkm.num,,wkm.sex,wkm.age,wkm.zhiwu,wkm. zhicheng,wkm.zhengzhi,wkm.xueli,wkm.renzhisj,wkm.laiyansj,wkm.leibie)=NULL)printf("cannot open the file,press any key to continue.");getchar();menu();fclose(

37、fp);printf("nn"); printf_back();(10) 、统计模块1、需求分析 ;该模块的功能是按照用户的要求统计出满足符合条件的所有记录的个数,并将满足条件的记录显示出来。 该模块没有涉及到文件的保存,过程中数据的丢失。2流程图;所以将文件用只读的方式打开,可以防止操作3、程序data()int p;printf("what kind do you want to data?ntt1tthe number on dutyntt2tthe number of Party memberntt3tthenumberofwomenntt4tthenum

38、berofhigh educationntt5texitnntt bb");scanf("%d",&p);switch(p)case 1:numduty();break; case 2:numpm();break;case 3:numwm();break; case 4:hiedcation();break; case 5:menu();break;dafault:printf("the number must be between 1 and 4,please choose again!"); data();该过程中调用了四个函数,n

39、umduty()(统计在职人员人数) ,numpm()(统计党员人数) ,numwm () ( 统计女工人数), hieduction ()(统计高学历高职称人数),函数的具体定义见后面附录源程序。并通过在四个函数中调用menu()函数返回到主菜单。上机操作:1:数据源2:编译,连接和运行下面是各个模块的运行结果的界面图:1、 主菜单函数界面:2、输入模块:新建文件和添加模块的输入界面基本相同:3、删除模块:4、浏览模块;5、编辑模块:6、统计模块:7、排序模块:附所有源程序: #define N 100 #include<stdio.h> struct workerchar nu

40、m11; char name10; char sex2; char age3; char zhiwu15;char zhicheng15; char zhengzhi15; char xueli15; char renzhisj8; char laiyansj8; char leibie15;wkN,s,h;menu()/*菜单函数 */int n,w1; doprintf("nttttMENUn"); printf("tt0tbuild newdatann"); printf("tt1tdelete datann"); printf

41、("tt2tadd datann"); printf("tt3tsearch by numbernn"); printf("tt4tsearch by namenn"); printf("tt5tbrowse allnn"); printf("tt6tmodify the datann"); printf("tt7torder the volumenn"); printf("tt8tdata a volumenn"); printf("tt9te

42、xitnn");printf("tplease choice and enter a number bb");scanf("%d",&n); if(n<0|n>8)w1=1;getchar();else w1=0;while(w1=1);switch(n)case 0:build();break; case 1:del();break; case 2:add();break; case 3:snum();break; case 4:sname();break; case 5:browse();break; case 6:mo

43、dify();break; case 7:order();break; case 8:data();break; case 9:exit(0);default:printf("input error! please input a number between 0 and 8");menu();build()/*新建文件 */int i,m,k,p;FILE *fp;if(fp=fopen("worker00.txt","w")=NULL)printf("can not build filen"); printf_

44、back();printf("how many workers do you want to input(0-%d)?:",N); scanf("%d",&m);k=m;for(i=0;i<k;i+)printf("nInput %dth worker record.n",i+1); input(i);for(p=0;p<=i;p+) if(fprintf(fp,"%st%st%1st%st%st%st%st%st%st%st%sn",wkp.num,,wkp.s ex,wkp.

45、age,wkp.zhiwu,wkp. zhicheng,wkp.zhengzhi,wkp.xueli,wkp.renzhisj,wkp.laiyansj,wkp.leibie)!=1) printf("cannot write the datann");fclose(fp); printf_back();add()/*add*/int i,m,n,k,p; FILE *fp; n=load();if(n=-1)menu();printf("how many workers do you want to add(0-%d)?:bbb",N-n);scanf

46、("%d",&m); k=m+n; for(i=n+1;i<=k;i+)printf("nInput %dth worker record.n",i-n+1); input(i);if(fp=fopen("worker00.txt","a+")=NULL)printf("can not open filen"); printf_back();for(p=0;p<k;p+) fprintf(fp,"%st%st%1st%st%st%st%st%st%st%st%sn&

47、quot;,wkp.num,,wkp.sex, wkp.age,wkp.zhiwu,wkp. zhicheng,wkp.zhengzhi,wkp.xueli,wkp.renzhisj,wkp.laiyansj,wkp.leibie);fclose(fp); printf_back();input(int i)/*输入一个记录*/input_num(i,i-1);printf("nenter the name:tbbbbbbbbbbb"); scanf("%s",);printf("nenter the age:t

48、bbbb"); scanf("%s",wki.age);printf("nenter the sexM for man and W for woman:t bb"); scanf("%1s",wki.sex);printf("nenter the zhiwu:tbbbbbbbbbbbbbbbb");scanf("%s",wki.zhiwu);printf("nenter the zhicheng:tbbbbbbbbbbbbbbbb"); scanf("%s

49、",wki.zhicheng);printf("nenter the zhengzhimiannao:tbbbbbbbbbbbbbbbb"); scanf("%s",wki.zhengzhi);printf("nenter the xueli:tbbbbbbbbbbbbbbbb"); scanf("%s",wki.xueli);printf("nenter the renzhishijian:tbbbbbbbbb"); scanf("%s",wki.renzhisj

50、);printf("nenter the laiyanshijian:tbbbbbbbbb");scanf("%s",wki.laiyansj);printf("nenter the leibie:tbbbbbbbbbbbbbbbb"); scanf("%s",wki.leibie);load()/*加载函数 */FILE *fp; int i;if(fp=fopen("worker00.txt","r")=NULL)printf("cannot open file

51、n");return NULL; elsefor(i=0;!feof(fp);i+) fscanf(fp,"%st%st%1st%st%st%st%st%st%st%st%sn",wki.num,,wki.sex,w ki.age,wki.zhiwu,wki. zhicheng,wki.zhengzhi,wki.xueli,wki.renzhisj,wki.laiyansj,wki.leibie);return(i-1);input_num(int i,int n)/*输入号码 */int j,k,w1; dow1=0;printf("e

52、nter the number:bbbbbbbbbbbb"); scanf("%s",wki.num);for(j=0;wki.numj!='0'j+)if(wki.numj<'0')|(wki.numj>'9')printf("Input error!Only be made up of (0-9).Please input again!nn"); w1=1;break;if(w1!=1)for(k=0;k<n;k+)if(k!=i&&strcmp(wkk.nu

53、m,wki.num)=0)while(w1=1);printf("this record is exit.please input again!nn"); w1=1;break;printf_back()/*函数 printf_back*/int w; printf("nntsuccessful.nn");printf("What do you want to do ?nntt1tBrowse all nownntt2tbacknnttbb"); scanf("%d",&w);if(w=1) browse(

54、); else menu();browse()/*浏览函数 */int i,j,n;n=load(); printf_face(); for(i=0;i<=n;i+) for(i=0;i<=n;i+) if(i!=0)&&(i%10=0)printf("nnRemember the No.which need modify.npress any key to continue."); getch();puts("nn");printf("tThere are %d record.n",n+1); printf("press any key to continue."); getch();menu();printf_face()/*显示数据结构*/n");p

温馨提示

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

评论

0/150

提交评论