C语言课程设计人事管理系统.doc
《C语言课程设计人事管理系统.doc》由会员分享,可在线阅读,更多相关《C语言课程设计人事管理系统.doc(36页珍藏版)》请在三一办公上搜索。
1、C语言课程设计人事管理系统 题目要求:人事管理管理系统要求某高校主要人员有:在职人员(行政人员、教师、一般员工)、退休人员和临时工。现在,需要存储这些人员的人事档案信息:编号、姓名、性别、年龄、职务、职称、政治面貌、最高学历、任职时间、来院时间、人员类别。其中,人员编号唯一,不能重复。(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);系统功能模块图如下:三、 详细设计;1、 主函数:1需求分析:为使系统执行完每
4、部分功能后能够方便的回到系统主界面,main()函数设计的较简单,只包含一个menu()函数,其余的全部功能都通过menu()函数调用来实现,并通过menu()函数的递归调用实现返回主界面的功能。main()函数定义如下:main() menu();而menu()定义如下:2流程图:menu() int n,w1;doprintf(nttttMENUn);printf(tt0tbuild new datann);printf(tt1tdelete datann);printf(tt2tadd datann);printf(tt3tsearch by numbernn);printf(tt4ts
5、earch by namenn);printf(tt5tbrowse allnn);printf(tt6tmodify the datann);printf(tt7torder the volumenn);printf(tt8tdata a volumenn);printf(tt9texitnn);printf(tplease choice and enter a number bb);scanf(%d,&n);if(n8)w1=1; getchar(); else w1=0;while(w1=1);switch(n)case 0:build();break; /*调用新建数据文件函数*/ca
6、se 1:del();break; /*调用删除数据函数*/case 2:add();break; /*调用添加数据函数*/case 3:snum();break; /*调用按工号搜索函数*/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:prin
7、tf(input error! please input a number between 0 and 8);menu();2、各功能模块设计:(1)、新建数据文件模块:、数据结构;看各个数据信息,编号、姓名、性别、年龄、职务、职称、政治面貌、最高学历、任职时间、来院时间、人员类别,均为字符串类型,在文件中以文本形式存放,每条记录对应一个人员的信息,可以方便信息的管理;而数据读进内存中时,可以以结构体的形式,每一个结构体包含了一个人员的全部信息,多的人员的信息组成了一个结构体数组。定义如下:struct worker char num11; char name10; char sex2; ch
8、ar age3; char zhiwu15; char zhicheng15; char zhengzhi15; char xueli15; char 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);prin
9、tf_back();printf(how many workers do you want to input(0-%d)?:,N);scanf(%d,&m);k=m;for(i=0;ik;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.name,wkp.sex,wkp.age,wkp.zhiwu,wkp. zhicheng,wkp.zhengzhi,wkp.xueli,wkp.renzhi
10、sj,wkp.laiyansj,wkp.leibie)!=1)printf(cannot write the datann);fclose(fp);printf_back();(2)、追加模块:1需求分析该模块的功能是拥护需要增加新的员工记录,从键盘输入并逐条写入到原来的文件中去,其中输入号码是要防止号码重复,重复时报告错误,重新输入。为方便用户管理和查看,该模块采用的方式是用先把原来文件中的数据读入内存,保存在内存中,然后在内存中的数据后面增加新的数据,操作完成后用写的方式打开文件,用覆盖的方式写入。2流程图:3程序:add() int i,m,n,k,p;FILE *fp;n=load()
11、;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)=NULL) /*将数据保存到文件*/printf(can not open filen); printf_back();for(p=0;pk;p+)fprintf(fp,%st%st%1st%st%st%st%st%s
12、t%st%st%sn,wkp.num,wkp.name,wkp.sex,wkp.age,wkp.zhiwu,wkp. zhicheng,wkp.zhengzhi,wkp.xueli,wkp.renzhisj,wkp.laiyansj,wkp.leibie);fclose(fp);printf_back();(3)修改模块:1 需求分析:该模块的功能是显示所有信息,考虑到记录较多,采用分屏显示,显示完所有的记录后,由用户输入需要修改的人员的号码,查找成功后,显示查找结果,并询问拥护修改人员的哪部分记录,根据用户选择修改相应的信息,然后保存修改后的结果;2 流程图3 程序;modify() int
13、 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 modify.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;in;i+) if(strcmp(s.nu
14、m,wki.num)=0); k=i; s=wki; if(k=-1) printf(nnNO exit ! please again); while(k=-1);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; else w0=0; if(w2=1) wkk=s; wkk=s; if(w0!=1&w2=1) fp=f
15、open(worker00.txt,w); for(p=0;pnntt1tNO.ntt2tnamentt3tsexntt4tagentt5tzhiwuntt6tzhichengntt7tzhengzhimianmaontt8txuelintt9trenzhishijianntt10tlaiyuanshijianntt11trenyuanleibiennttt bb);scanf(%d,&c);if(c11|c11|c1);doswitch(c)case 1:printf(the old number is %s,wki.num);input_num(i,i-1);break;case 2:pr
16、intf(the old name is %s,enter the new name:,wki.name);scanf(%s,wki.name);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,wki.age);break;case 5:printf(the old zhiwu is %s,enter the new zhiw
17、u:,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 zhengzhimianmao is %s,enter the new zhengzhimiainmao:,wki.zhengzhi);scanf(%s,wki.zhengzhi);break;case 8:printf(the old zuigaoxueli is
18、%s,enter the new zuigaoxueli:,wki.xueli);scanf(%s,wki.xueli);break;case 9:printf(the old renzhishijian is %s,enter the new renzhishijian:,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;ca
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 语言 课程设计 人事管理系统
![提示](https://www.31ppt.com/images/bang_tan.gif)
链接地址:https://www.31ppt.com/p-2384837.html