职工信息管理系统设计.doc

上传人:精*** 文档编号:1031206 上传时间:2024-03-24 格式:DOC 页数:23 大小:181.08KB
下载 相关 举报
职工信息管理系统设计.doc_第1页
第1页 / 共23页
职工信息管理系统设计.doc_第2页
第2页 / 共23页
职工信息管理系统设计.doc_第3页
第3页 / 共23页
职工信息管理系统设计.doc_第4页
第4页 / 共23页
职工信息管理系统设计.doc_第5页
第5页 / 共23页
点击查看更多>>
资源描述

1、目录1 课程设计的目的12 需求概述12.1 需求分析12.2 需求说明13总体设计23.1功能划分23.2数据结构与程序流程34详细设计44.1数据结构44.2各个功能模块的处理流程45调试和测试结果分析86 个人总结107 参考文献108 原程序代码10程序设计基础课程设计职工信息管理系统设计1 课程设计的目的 根据需求分析文档,初步提出问题的解决方案,以及软件系统的体系结构和数据结构的设计方案,并写出书面文档总体设计说明书,为下一步进行详细设计做准备。2 需求概述2.1 需求分析(1)职工信息录入功能;(2)职工信息浏览功能;(3)职工信息查询(或排序)功能;(4)职工信息删除功能;(5

2、)职工信息修改功能;2.2 需求说明(1)职工信息包括职工号、姓名、性别、出生年月、学历、职务、工资、住址、电话等,并且要求职工号不重复。(2)录入的职工信息要求用文件形式保存,并可以对其进行浏览、查询、修改、删除等基本操作。(3)职工信息的显示要求有一定的规范格式。 (4)对职工信息应能够分别安编号及按姓名两种方式进行查询,要求能返回所有符合条件的职工的信息。(5)对职工信息的修改应逐个地进行,在一个职工的信息的更改不影响其他的职工记录。(6)所设计的系统应以菜单方式工作,应为用户提供清晰的使用提示,依据用户的选择来进行各种处理,并要求在此过程中能尽可能地兼容用户使用过程中的异常情况。3总体

3、设计3.1功能划分该系统可以按功能进行模块划分,如图1所示。 职工信息管理系统信息输入信息浏览信息查询信息修改信息删除按编号查询按姓名查询菜单选择图1 系统模块图其中:(1)菜单选择模块完成用户命令的接受,此模块也是职工信息管理的入口,用户所要进行的各种操作均需在此模块中进行选择,并进而调用其他模块实现相应的功能。(2)信息输入模块完成职工信息的输入功能,输入信息包括职工号、姓名、性别。出生年月、学历、职务、工资、住址、电话等。(3)信息浏览模块完成已录入职工信息的显示。(4)信息查询模块完成职工信息的查询,查询时对应有按编号查询和按姓名查询两种方式。(5)信息修改模块完成职工信息的修改功能。

4、(6)信息删除功能模块完成职工信息的删除功能。3.2数据结构与程序流程本系统中主要的数据结构就是职工的信息,包含职工号、姓名、性别、出生年月、学历、职务、工资、住址、电话等,在处理过程中各项可以作为一个职工的不同属性来进行处理。系统的执行应从功能菜单选择开始,依据用户的选择来进行后续的处理,直到用户选择退出系统为止,其间应对用户的选择做出判断及异常处理。系统的流程图如图2所示:开始菜单选择输入?浏览?查询?修改?否否删除?信息输入信息浏览信息查询信息修改信息删除是是是是是结束否否否 图2 程序流程图4详细设计4.1数据结构(1)性别:emum Sexmale,female;(2)学历:enum

5、 Educationhigh,junior,college,master,doctor;(3)日期: Struct Date int year; int month; int day; ;(4)职工信息:Struct Info char num5; /*职工号*/ char name8; /*姓名*/ enum Sex sex; /*性别*/ struct Date birthday; /*出生年月*/ enum Education education; /*学历*/ char duty8; /*职务*/ double wage; /*工资*/ char addr12; /*地址*/ char

6、 phone8; /*电话*/; 4.2各个功能模块的处理流程对应于总体设计时的系统模块图,各个功能模块的处理流程如下:(1)信息输入模块 打开职工信息文件; while(继续输入) 读入职工信息; 将读入的信息添加到职工信息文件中; 提示是否继续输入; 关闭职工信息文件;(2)信息浏览模块 打开职工信息文件; while(不到文件结束) 从文件中顺序读出一个职工的信息; 按指定格式输出该职工的信息; 关闭职工信息文件;(3)信息查询模块 while(继续查询) if(按编号查询) 读入查询的职工编号; 打开职工信息文件; while(不到文件结束) 顺序读出一个职工的信息; if(该职工信息

7、的编号符合条件) 输出该职工的信息; 关闭职工信息文件; 提示共有几条符合调价的记录; else if(按姓名查询) 读入查询的职工姓名; 打开职工信息文件; while(不到文件结束) 顺序读出一个职工的信息; if(该职工信息的姓名符合条件) 输出该职工的信息; 关闭职工信息文件; 提示共有几条符合条件的记录; else 提示输入不合适; 提示是否继续查询; (4)信息修改模版 while (继续修改) 打开职工信息文件; 打开临时文件; 提示并读入待修改的职工的编号; While (不到文件结束) 顺序读出一个职工的信息; if (该职工信息的编号符合条件) 将职工的信息进行修改; 将职

8、工的信息写入临时文件中; 关闭原信息文件; 关闭临时文件; 删除原信息文件; 将临时文件的名字改为原信息文件的名字; (5)信息删除模块 while (继续删除) 提示并读入待删除的职工号; 打开职工信息文件; 查找是否有符合条件的职工记录; if (有符合条件的记录) 创建一个新的临时文件; while (原信息文件中记录未读完) 读出原信息文件中的下一条记录; if (此条记录不是待删除记录) 写入临时文件中间去; 关闭原信息文件; 关闭临时文件; 删除原信息文件; 将临时文件的名字改为原信息文件的名字; else 提示没有符合条件的记录存在; (6)菜单选择模板 给出信息提示; 清屏;

9、绘制菜单(包含输入 显示 查询 修改 删除 退出); 提示菜单选择并读入到变量; 返回变量的值;5调试和测试结果分析(1)职工信息录入分析图如图3所示:图3录入界面(2)职工信息查询分析图如图4所示:图4查询界面(3)职工浏览如图5所示图5 浏览界面(4)职工信息退出分析图如图6所示:图6 退出界面6 个人总结通过开发这个系统,我掌握了的项目基本开发过程,用到的知识巩固了我组对C语言的学习,但在这次设计中的最大收获并不是掌握这几门开发工具的应用,而是学会了设计系统的思维方法。7 参考文献【1】 谢延红、王付山.C语言程序设计教程【M】.北京:国防工业出版社,2010,99-120.【2】 谭浩

10、强.C程序设计(第三版)【M】.北京:清华大学出版社,2011,125-137.【3】 杨路明.C语言程序设计(第二版)【M】.北京:北京邮电大学出版社,2005,102-110.【4】 张志航.程序设计语言【M】.北京:清华大学出版社,2007,25-36.【5】 何钦铭,颜晖.C语言程序设计【M】.北京:高等教育出版社,2008,89-110.8 原程序代码#include #include #include #include enum Sexmale,female; /*性别*/enum Educationhigh,junior,college,master,doctor; /*学历*/

11、struct Date /*日期*/int year;int month;int day;struct Infochar num10; /*职工号*/char name15; /*姓名*/enum Sex sex; /*性别*/struct Date birthday; /*出生年月*/enum Education education; /*学历*/char duty15; /*职务*/double wage; /*工资*/char addr30; /*地址*/char phone15; /*电话*/;char menu() /*菜单选择函数*/char n; /*n记录选择的菜单*/clrs

12、cr(); /*清屏*/puts(tt Welcome to employee management system );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(Choose your number(1-6):bb);while(1)n=getchar();getchar();if(n6)printf(Inpu

13、t error,please input again(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(tCan not open the inform file!);getch();exit(1);doprintf(tnum:);gets(info.num);printf(tname:);gets(info.name);printf(tsex(male or femal

14、e):);gets(temp);if(!strcmp(temp,female) info.sex=female;else info.sex=male;printf(tbirthday(yyyy/mm/dd):);scanf(%d/%d/%d,&info.birthday.year,&info.birthday.month,&info.birthday.day);getchar();printf(teducation:);gets(temp);if(!strcmp(temp,doctor) info.education=doctor;else if (!strcmp(temp,master) i

15、nfo.education=master;else if (!strcmp(temp,college) info.education=college;else if (!strcmp(temp,junior) info.education=junior;else info.education=high;printf(tduty:);gets(info.duty);printf(twage:);gets(temp); info.wage=atof(temp);printf(taddress:);gets(info.addr);printf(tphone:);gets(info.phone); f

16、write(&info,sizeof(info),1,fp);printf(tAny more?(Y/N):bb);ch=getchar();getchar();while(ch=Y|ch=Y);fclose(fp);void print1()printf(%-8s%-10s%-8s%-12s%-15s%-8s%-15s%-15s%-10s%n,nun,name,sex,birthday,education,duty,wage,address,phone);void print2(struct Info info);printf(%-8s%-10s%,info.num,info.name);i

17、f(info.sex=male) printf(%s-8s,male);else printf(%-8s,female);printf(%-4d/%-2d/%-4d,info.birthday.year,info.birthday.month,info.birthday.day);if(info.education=high) printf(%-15s,high);else if(info.education=junior) printf(%-15s,junior);else if(info.education=college) printf(%-15s,college);else if (i

18、nfo.education=master ) printf(%-15s,master);else printf(%-15s,doctor);printf(%-8s%-15.2lf,info.duty,info.wage);printf(%-15s%-10sn,info.addr,info.phone);void display() /*职工信息显示函数*/struct Info info;FILE * fp;int total=0;if(fp=fopen(inform.txt,rb)=NULL)printf(tCan not open the inform file!);getch();exi

19、t(1);while(fread(&info, sizeof(info),1,fp)=1)total+;if(total=1)print1();print2(info);if(total!=0)&(total%5=0)printf(nntPress any key to continue.);getch();puts(nn);print1();fclose(fp);printf(nntThere are %d record in all!,total);getch();void search() /*信息查询函数*/struct Info info;FILE * fp;int flag; /*

20、flag为1按编号查询,flag为2按姓名查询*/int total=0; /*记录符合条件的记录的个数*/char ch10;char f;if(fp=fopen(inform.txt,rb)=NULL)printf(tCan not open the inform file!);getch();exit(1);dorewind(fp);printf(nnSearch by(1:num 2:name): bb);while(1)scanf(%d,&flag);getchar();if(flag2)printf(Input error,please input again(1:num 2:na

21、me): bb);elsebreak;if(flag=1) /*按编号进行查询*/printf(Please input the num you want to search:);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(Please input the name you want to search:);gets(ch);

22、total=0; /*符合条件的记录数*/while(fread(&info, sizeof(info),1,fp)=1)if(strcmp(ch,info.name)=0)total+;if(total=1)print1();print2(info);printf(nntThere are %d record included!n,total);printf(Search any more?(Y/N): bb);f=getchar();getchar();while(f=Y|f=Y);fclose(fp);void modify() /*信息修改函数*/struct Info info;FI

23、LE * fp1,*fp2;int flag;char ch10;char f;char temp10;doif(fp1=fopen(inform.txt,rb)=NULL)printf(tCan not open the inform file!);getch();exit(1);if(fp2=fopen(temp.txt,wb)=NULL)printf(tCan not creat the temp file!);getch();exit(1);printf(please input thenum you want to modify:);gets(ch);flag=0;while(fre

24、ad(&info,sizeof(info),1,fp1)=1)if(strcmp(ch,info.num)=0)print1();print2(info);printf(nnplease input the new information:n);printf(tnum:);gets(info.num);printf(tname:);gets(info.name);printf(tsex(male or female):);gets(temp);if(!strcmp(temp,female)info.sex=female;else info.sex=male;printf(tbirthday(y

25、yyy/mm/dd:);scanf(%d/%d/%d,&info.birthday.year,&info.birthday.month,&info.birthday.day);getchar();printf(teducation:);gets(temp);if(!strcmp(temp,doctor) info.education=doctor;else if(!strcmp(temp,master) info.education=master; else if(!strcmp(temp,college) info.education=college;else if(!strcmp(temp

26、,junior) info.education=junior;else info.education=high;printf(tduty:);gets(info.duty);printf(teage:);gets(temp);info.wage=atof(temp);printf(taddress:);gets(info.addr);printf(tphone:);gets(info.phone);flag=1;break;fwrite(&info,sizeof(info),1,fp2);fclose(fp1);fclose(fp2);if(flag=1)printf(Modify suces

27、s!n);remove(inform.txt);rename(temp.txt,inform.txt);elseprintf(Can not find this record!n);printf(Modify any more?(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(tC

28、an not open the inform file!);getch();exit(1);if(fp2=fopen(temp.txt,wb)=NULL)printf(tCan not creat the temp file!);getch();exit(1);printf(Please input the num you want to delete:);gets(ch);flag=0;while(fread(&info,sizeof(info),1,fp1)=1) if(strcmp(ch,info.num)=0)print1();print2(info);flag=1;break;els

29、e fwrite(&info,sizeof(info),1,fp2);fclose(fp1);fclose(fp2);if(flag=1)printf(Delete sucess!n);remove(inform.txt);rename(temp.txt,inform.txt);else printf(Can not find this record!n); printf(Delete any more?(Y/N):bb); f=getchar();getchar();while(f=Y|f=y); main() while(1) switch(menu() case1:append();break; case2:display();break; case3:search();break; case4:modify();break; case5:delete();break; case6:exit(0);break; - 22 -

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

当前位置:首页 > 学术论文 > 毕业论文

版权声明:以上文章中所选用的图片及文字来源于网络以及用户投稿,由于未联系到知识产权人或未发现有关知识产权的登记,如有知识产权人并不愿意我们使用,如有侵权请立即联系:2622162128@qq.com ,我们立即下架或删除。

Copyright© 2022-2024 www.wodocx.com ,All Rights Reserved |陕ICP备19002583号-1 

陕公网安备 61072602000132号     违法和不良信息举报:0916-4228922