C语言毕业课程设计报告职工信息管理系统1.docx
《C语言毕业课程设计报告职工信息管理系统1.docx》由会员分享,可在线阅读,更多相关《C语言毕业课程设计报告职工信息管理系统1.docx(20页珍藏版)》请在冰豆网上搜索。
![C语言毕业课程设计报告职工信息管理系统1.docx](https://file1.bdocx.com/fileroot1/2023-1/9/609fa339-8df7-4ed8-b9f0-23034078bb53/609fa339-8df7-4ed8-b9f0-23034078bb531.gif)
C语言毕业课程设计报告职工信息管理系统1
课程设计报告
设计者:
苏龙
班级序号:
学号:
课程设计报告
一C语言课程设计的目的
设计一职工信息管理系统,使之能提供以下功能:
(1)系统以菜单方式工作
(2)职工信息录入功能(职工信息用文件保存)
(3)职工信息浏览功能
(4)职工信息查询功能,查询方式可按学历查询或按职工号查询
(5)职工信息删除修改功能(可选项)
二课程设计报告正文
1题目要求
设计职工信息管理系统,要求职工心想包括职工号、姓名、性别、年龄、学历、工资、住址、电话等(职工号不重复)。
设计一职工信息管理系统,使之能提供以下功能:
(6)系统以菜单方式工作
(7)职工信息录入功能(职工信息用文件保存)
(8)职工信息浏览功能
(9)职工信息查询功能,查询方式可按学历查询或按职工号查询
(10)职工信息删除修改功能(可选项)
2需求分析
根据题目要求,由于职工信息是存放在文件中,所以应提供文件的输入、输出等操作;在程序中需要浏览职工的信息,应提供显示、查找、排序等操作;另外还应提供键盘式选择菜单实现功能选择。
3总体设计
根据上面的需求分析,可以将这个系统设计分为以下模块:
数据添加、数据查找、数据修改、数据删除、数据输出。
系统功能模块如下:
4详细设计
1主函数
主函数设计要简洁,只提供部分函数的调用。
其中各功能模块用菜单方式选择。
【程序】
voidmain()
{
intm;
while
(1)
{printf("\n\n\n\t\t______________________________________\n");
printf("\t\t欢迎进入内蒙古科技大学员工信息系统\n");
printf("\t\t设计者:
计算机-3班学号\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");
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操作完毕,请再次选择!
");
}
else
printf("\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数据查找数据查找共分为职工号、姓名等方式查找
【程序】
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(l>0&&l<4)
{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已查到,记录为:
");
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)
{
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;
}
}
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);
}
else
printf("\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;
}
}
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""","","","","","","","","");
}
}
else
printf("\n对不起,查无此人。
");
fclose(fp);
}
6数据输出
【程序】
voidoutput()
{
if((fp=fopen("worker.xls","r"))==NULL)
{
printf("\n不能打开该文件!
");
exit();
}
printf("\n\n%20s\n","职工信息管理系统");
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);
printf("%-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);
}
5运行与测试报告:
三后记/课程设计过程中遇到的问题以及解决方法,课程设计的体会。
这次课程设计让我掌握了许多的有用知识。
首先我能够熟练的应用软件MicrosoftVisualC++6.0了。
再就是我能够根据自己的需要设计程序,这将对我以后的生活有非常重要的影响。
同时我掌握了解决问题的方法,这无论是对以后的学习、生活都有无比重要的价值。
在设计中,我遇到了不少的困难,比如不能清晰的建立设计模块,然后我向同学寻求帮助,向他们学习,最终通过自己努力建立了模块。
还有就是起初我设计的程序总是有错误,我细心的修改,不断的改进,最终我做出了自己非常理想的程序!
附录:
源程序清单
#include
struct
{
charname[8];
charnum[10];
charsex[10];
charage[10];
charrecord[10];
charposition[15];
charwanges[10];
chartel[15];
charaddr[50];
}one;
FILE*fp;
voidoutput();
voidsearch();
voidappend();
voidmodify();
voiddelete();
voidnameway();
voidxueliway();
voidnumway();
voidmain()
{
intm;
while
(1)
{printf("\n\n\n\t\t______________________________________\n");
printf("\t\t欢迎进入中国地质大学(武汉)员工信息系统\n");
printf("\t\t设计者:
苏龙学号\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");
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操作完毕,请再次选择!
");
}
else
printf("\n\n选择错误,请再次选择!
");
}
}
voidoutput()
{
if((fp=fopen("worker.xls","r"))==NULL)
{
printf("\n不能打开该文件!
");
exit();
}
printf("\n\n%20s\n","职工信息管理系统");
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);
printf("%-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);
}
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);
}
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(l>0&&l<4)
{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已查到,记录为:
");
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)
{
printf("\n不能打开文件!
");
exit();
}
while(!
feof(fp))
{
fscanf(fp,"%s%s%s%s%s%s%s