C语言课程设计报告―职工信息管理系统

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

课课程程设设计计报报告告设计者:苏龙班级序号:055071-12学号:20071001569-2-课程设计报告一C语言课程设计的目的设计一职工信息管理系统,使之能提供以下功能:(1)系统以菜单方式工作(2)职工信息录入功能(职工信息用文件保存)(3)职工信息浏览功能(4)职工信息查询功能,查询方式可按学历查询或按职工号查询(5)职工信息删除修改功能(可选项)二课程设计报告正文1题目要求设计职工信息管理系统,要求职工心想包括职工号、姓名、性别、年龄、学历、工资、住址、电话等(职工号不重复)。设计一职工信息管理系统,使之能提供以下功能:(6)系统以菜单方式工作(7)职工信息录入功能(职工信息用文件保存)(8)职工信息浏览功能(9)职工信息查询功能,查询方式可按学历查询或按职工号查询(10)职工信息删除修改功能(可选项)2需求分析根据题目要求,由于职工信息是存放在文件中,所以应-3-提供文件的输入、输出等操作;在程序中需要浏览职工的信息,应提供显示、查找、排序等操作;另外还应提供键盘式选择菜单实现功能选择。3总体设计根据上面的需求分析,可以将这个系统设计分为以下模块:数据添加、数据查找、数据修改、数据删除、数据输出。系统功能模块如下:4详细设计1主函数主函数设计要简洁,只提供部分函数的调用。其中各功能模块用菜单方式选择。【程序】voidmain(){intm;while(1){printf(\n\n\n\t\t______________________________________\n);printf(\t\t欢迎进入中国地质大学(武汉)员工信息系统\n);printf(\t\t设计者:055071-12苏龙学号20071001569\n);printf(\t\t~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n);printf(\n\t\t\t\t添加,请按1);printf(\n\t\t\t\t查找,请按2);printf(\n\t\t\t\t修改,请按3);printf(\n\t\t\t\t删除,请按4);printf(\n\t\t\t\t输出,请按5);职工信息管理系统数据添加数据查找数据修改数据删除数据输出-4-printf(\n\t\t\t\t退出,请按0\n);scanf(%d,&m);if(m=0&&m=5){switch(m){case1:append();break;case2:search();break;case3:modify();break;case4:delete();break;case5:output();break;case0:exit();}printf(\n\n操作完毕,请再次选择!);}elseprintf(\n\n选择错误,请再次选择!);}}2数据添加【程序】voidappend(){if((fp=fopen(worker.xls,a))==NULL){printf(\n不能打开该文件!);exit();}printf(\n请输入添加职工信息(姓名、职工号、性别、年龄、学历、职位、工资、电话、地址)\n);scanf(%s%s%s%s%s%s%s%s%s,one.name,one.num,one.sex,one.age,one.record,one.position,one.wanges,one.tel,one.addr);fprintf(fp,%-10s%-8s%-5s%-5s%-10s%-8s%-8s%-10s%-15s\n,one.name,one.num,one.sex,one.age,one.record,one.position,one.wanges,one.tel,one.addr);fclose(fp);}3数据查找数据查找共分为职工号、姓名等方式查找【程序】-5-voidsearch(){intl;printf(\t\t\t\t*姓名查找按:1*\n);printf(\t\t\t\t*学历查找按:2*\n);printf(\t\t\t\t*职工号查按:3*\n);scanf(%d,&l);if(l0&&l4){switch(l){case1:nameway();break;case2:xueliway();break;case3:numway();break;}printf(\n\n操作完毕!!!);}elseprintf(\t\t\t\t输入有误!!!);}voidnameway(){intk=0;charnam[8];printf(\n请输入您要查找的职工姓名:);scanf(%s,nam);if((fp=fopen(worker.xls,rb))==NULL){printf(\n不能打开文件!);exit();}while(!feof(fp)){fscanf(fp,%s%s%s%s%s%s%s%s%s\n,one.name,one.num,one.sex,one.age,one.record,one.position,one.wanges,one.tel,one.addr);if(strcmp(nam,one.name)==0){printf(\n\n已查到,记录为:);-6-printf(\n%-10s%-8s%-5s%-5s%-10s%-8s%-8s%-10s%-15s\n,one.name,one.num,one.sex,one.age,one.record,one.position,one.wanges,one.tel,one.addr);k=1;}}if(k==0)printf(\n\n对不起,查无此人!。);fclose(fp);}voidxueliway(){intj=0;charxueli[10];printf(\t\t\t\t输入你要查询的学历\n);scanf(%s,xueli);if((fp=fopen(worker.xls,rb))==NULL){printf(\n不能打开文件!);exit();}while(!feof(fp)){fscanf(fp,%s%s%s%s%s%s%s%s%s\n,one.name,one.num,one.sex,one.age,one.record,one.position,one.wanges,one.tel,one.addr);if(strcmp(xueli,one.record)==0){printf(\n\n已查到,记录为:);printf(\n%-10s%-8s%-5s%-5s%-10s%-8s%-8s%-10s%-15s\n,one.name,one.num,one.sex,one.age,one.record,one.position,one.wanges,one.tel,one.addr);j=1;}}if(j==0)printf(\n\n对不起,查无此人!。);fclose(fp);}voidnumway(){inti=0;charnumb[10];printf(\t\t\t\t输入你要查询的职工号\n);scanf(%s,numb);if((fp=fopen(worker.xls,rb))==NULL)-7-{printf(\n不能打开文件!);exit();}while(!feof(fp)){fscanf(fp,%s%s%s%s%s%s%s%s%s\n,one.name,one.num,one.sex,one.age,one.record,one.position,one.wanges,one.tel,one.addr);if(!strcmp(numb,one.num)){printf(\n\n已查到,记录为:);printf(\n%-10s%-8s%-5s%-5s%-10s%-8s%-8s%-10s%-15s\n,one.name,one.num,one.sex,one.age,one.record,one.position,one.wanges,one.tel,one.addr);i=1;}}if(!i)printf(\n\n对不起,查无此人!。);fclose(fp);}4数据修改【程序】voidmodify(){intm,k=0;longa;charnamekey[8];printf(\n请输入您要修改的职工的姓名:);scanf(%s,namekey);if((fp=fopen(worker.xls,r+))==NULL){printf(\n不能打开该文件!);exit();}while(!feof(fp)){a=ftell(fp);fscanf(fp,%s%s%s%s%s%s%s%s%s\n,one.name,one.num,one.sex,one.age,one.record,one.position,one.wanges,one.tel,one.addr);if(!strcmp(namekey,one.name)){k=1;break;-8-}}if(k){printf(\n已查到,记录为:);printf(\n%-10s%-8s%-5s%-5s%-10s%-8s%-8s%-10s%-15s\n,one.name,one.num,one.sex,one.age,one.record,one.position,one.wanges,one.tel,one.addr);printf(\n请输入信息(按照姓名、工号、性别、年龄、学历、职位、工资、电话、地址的顺序输入):);scanf(%s%s%s%s%s%s%s%s%s,one.name,one.num,one.sex,one.age,one.record,one.position,one.wanges,one.tel,one.addr);fseek(fp,a,0);fprintf(fp,%-10s%-8s%-5s%-5s%-10s%-8s%-8s%-10s%-15s\n,one.name,one.num,one.sex,one.age,one.record,one.position,one.wanges,one.tel,one.addr);}elseprintf(\n对不起,查无此人,无法进行修改。);fclose(fp);}5数据删除【程序】voiddelete(){intm,k=0;longa,b;charnamekey[8],valid[4];printf(\n请输入您要删除的职工姓名:);scanf(%s,namekey);if((fp=fopen(worker.xls,r+))==NULL){printf(\n不能打开该文件!);exit();}while(!feof(fp)){a=ftell(fp);fscanf(fp,%s%s%s%s%s%s%s%s%s\n,one.name,one.num,one.sex,one.age,one.record,one.position,one.wanges,one.tel,one.addr);if(strcmp(namekey,one.name)==0){k=1;break;}}-9-if(k==1){printf(\n已查到,记录为);printf(\n%-10s%-8s%-5s%-5s%-10s%-8s%-8s%-10s%-15s\n,one.name,one.num,one.sex,one.age,one.record,one.position,one.wanges,one.tel,one.addr);printf(\n确实要删除,按1;不删除,按0:);scanf(%d,&m);if(m==1){fseek(fp,a,0);fprintf(fp,%-10s%-8s%-5s%-5s%-10s%-8s%-8s%-10s%-15s\n,,,,,,,,);}}elseprintf(\n对不起,查无此人。);fclose(fp);}6数据输出【程序】voidoutput(){if((fp=fopen(worker.xls

1 / 20
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功