员工管理系统课程设计报告.doc_第1页
员工管理系统课程设计报告.doc_第2页
员工管理系统课程设计报告.doc_第3页
员工管理系统课程设计报告.doc_第4页
员工管理系统课程设计报告.doc_第5页
已阅读5页,还剩15页未读 继续免费阅读

下载本文档

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

文档简介

软件课程设计课题名称: 软件课程设计 专 业: 电子信息工程 班 级: 电信1班 学 号: 122207301107 姓 名: 范润杰 指导教师: 张瑞华 2015年 12 月 21 日一题目与要求实习二员工管理系统 问题描述 每个员工的信息包括:编号、姓名、性别、出生年月、学历、职务、电话、住址等 。 基本 要求 根据实验内容编程 , 上机调试 、 得出正确的运行程序 。 系统能够完成员工信息的查询 、更新、插入、删除、排序功能。 写出实验报告(包括源程序和运行结果 ) 。 实现提示 ( 1 ) 建立一个带头结点的单向链表(无序 ) 。( 2 ) 对单链表进行插入,删除,更新操作。( 3 ) 在主函数中设计一个简单的菜单,分别调试上述算法。二需求分析本员工管理系统由C语言编写,主要掌握单链表插入,更新,删除,查找等功能。1. 输入的形式和输出的范围:插入元素时需要输入插入的位置和元素的值;删除元素时输入删除元素的位置;查找操作时需要输入元素的值。在所有输入中,元素的值都是整数。2. 输出的形式:在所有三种操作中都显示操作是否正确以及操作后单链表的内容。其中删除操作后显示删除的元素的值,查找操作后显示要查找元素的位置。3. 程序所能到达的功能:完成员工的查询,插入,删除,以及系统的退出三概要设计(1) 为了实现上述程序功能,需要定义图的抽象数据类型:(2) 本程序包含了10个函数1 创建员工编号信息表函数readfile()2 查找员工编号数据函数seek()3 修改员工编号信息函数 modify()4 删除员工编号信息函数 del()5 排序员工编号函数 SortStudent()6 打印员工编号信息函数 PrintStudent()7 清除已经删除的数据函数 ClearStudent()8 备份员工编号文件 BackStudent()9 恢复员工编号文件 UpStudent()10 主函数(菜单)main()(3)模块函数构造根据上述描述,可以构造出该系统的抽象数据类型和相对应的函数,其方法名和功能如表1所示。表1 函数功能表模块函数或数据结构功能链表数据类型struct record定义链表结点struct StuLink 定义员工信息系统处理模块charu(struct emplink *p)插入员工信息void readfile()创建员工信息void del()删除员工信息void modify()修改员工信息void BackStudent()备份员工信息void ClearStudent()清除员工信息void seek()查询员工信息void UpStudent()恢复员工信息void SortStudent()员工信息排序输出模块void PrintStudent()打印员工信息 四详细设计实现概要设计中定义的所有的数据类型,对每个操作给出伪代码,对主程序和其他模块也都需要写出伪代码算法。1、抽象数据类型定义1)定义员工信息结构体(typedef struct record)typedef struct record int code; /* 员工编号 */ char name15; /* 姓名 */ char sex3; /* 性别 */ char birthday15; /* 生日*/ char add30; /* 地址*/ char tel13; /* 电话号码 */ char mail20; /*邮箱 */ char qq20;(2)员工编号信息链节点(typedef struct StuLink )typedef struct StuLink /*员工编号信息链节点*/ int code; /* 员工编号 */ char name15; /* 姓名 */ char sex3; /* 性别 */ char birthday15; /* 生日*/ char add30; /* 地址*/ char tel13; /* 电话号码 */ char mail20; /*邮箱 */ char qq20; struct StuLink *next;2、主函数设计(1)根据详细设计要求,可以得到主函数代码,在主函数中,实现了友好的界面设计。系统需要输入员工的基本信息:员工编号,姓名,性别,生日,地址,电话号码,邮箱,QQ等。这个系统还利用键盘输入提供的主菜单服务,在主菜单中,有十四种操作的调用:创建员工信息void readfile()删除员工信息void del()修改员工信息void modify()查询员工信息void seek()员工信息排序void SortStudent()打印员工信息void PrintStudent()录入文字void InputWord(char *lx,char *p)检测员工编号int exist(int n,FILE *fp) 检测员工姓名char exist_name(char a,FILE *fp) 计算文件长度int FileLenth(FILE *fp)(2) 详细设计/*录入文字*/void InputWord(char *lx,char *p) char word20; printf(请输入%s:,lx); scanf(%s,word); strcpy(p,word);/*检测员工编号是否存在,若存在返回 1*/int exist(int n,FILE *fp) struct record *p; int flag=0; p=(struct record*)malloc(sizerecord); /*申请一个新节点,用于读文件内容*/ rewind(fp); while(!feof(fp) fread(p,sizerecord,1,fp); /*读出文件内容*/ if(p-code=n) flag=1;break; return flag;/*检测姓名是否存在,若存在返回 1*/char exist_name(char a,FILE *fp) struct record *p; int flag=0; p=(struct record*)malloc(sizerecord); /*申请一个新节点,用于读文件内容*/ rewind(fp); while(!feof(fp) fread(p,sizerecord,1,fp); /*读出文件内容*/ if(strcmp(p-name,a)=0) flag=1;break; return flag;/*计算文件长度*/int FileLenth(FILE *fp) long flen; fseek(fp,0L,2); /*到文件末尾*/ flen=ftell(fp); /*取位置*/ rewind(fp); /*回到文件头*/ return flen;/*创建员工编号信息表*/void readfile() long start,filelen; FILE *fp; struct record *s; int amount=0;/记录员工编号个数 if(fp=fopen(stuinf,a+)=NULL) fp=fopen(stuinf,w+); start=FileLenth(fp); s=(struct record*)malloc(sizerecord); /*申请一个结构体空间*/ while(1) printf(请输入员工编号(输入0退回上一步):); scanf(%d,&s-code); if(s-code=0) /*退出*/ if (amount=0) break; /*无录入数据直接退出*/ filelen=FileLenth(fp); fseek(fp,start,0); printf(t|员工编号tt|姓名tt|性别t| 生日tt | 地址ttt| 电话号码tt | 邮箱tt | qq tt|n); while(ftell(fp)code,s-name,s-sex,s-birthday,s-add,s-tel,s-mail,s-qq); break; if(s-codecode,fp)=1) /*检测员工编号是否存在*/ printf(输入员工编号已存在!n); continue; InputWord(姓名,s-name); /*录入数据*/ InputWord(性别,s-sex); /*录入数据*/ InputWord(生日,s-birthday); /*录入数据*/ InputWord(地址,s-add); /*录入数据*/ InputWord(电话号码,s-tel); /*录入数据*/ InputWord(邮箱,s-mail); /*录入数据*/ InputWord(qq,s-qq); /*录入数据*/ printf(|%dt|%st|%st| %st|%st|%st|%st|%stn,s-code,s-name,s-sex,s-birthday,s-add,s-tel,s-mail,s-qq); fwrite(s,sizerecord,1,fp); /*把数据写进文件*/ amount+; fclose(fp);/*查找员工编号数据*/void seek() char a15; int num; int item; FILE *fp; struct record *s; if(fp=fopen(stuinf,r+)=NULL) printf(无数据可查n);return; s=(struct record*)malloc(sizerecord); /*申请一个结构体空间*/ printf(-n); printf(1.按员工编号查询n); printf(2.按姓名查询n); printf(3.退出本菜单n); printf(-n); while(1) printf(请选择子菜单编号:); scanf(%d,&item); switch(item) case 1: printf(请输入员工编号(输入0返回):); scanf(%d,&num); if(num=0) break; /*退出*/ if(exist(num,fp)=1) /*检测员工编号是否存在*/ fseek(fp,-1L*sizerecord,1); /*回滚一个记录*/ fread(s,sizerecord,1,fp); /*读出文件内容*/ printf(|%dt|%st|%st| %st|%st|%st|%st|%stn,s-code,s-name,s-sex,s-birthday,s-add,s-tel,s-mail,s-qq); else printf(无此员工编号信息n); break; case 2: printf(请输入姓名:); scanf(%s,a); if(exist_name(a,fp)=1) /*检测姓名是否存在*/ fseek(fp,-1L*sizerecord,1); /*回滚一个记录*/ fread(s,sizerecord,1,fp); /*读出文件内容*/ printf(|%dt|%st|%st| %st|%st|%st|%st|%stn,s-code,s-name,s-sex,s-birthday,s-add,s-tel,s-mail,s-qq); else printf(无此员工编号信息n); break; case 3:return; fclose(fp);/*修改员工编号信息*/void modify() int num,item; char a15; FILE *fp; struct record *s; if(fp=fopen(stuinf,r+)=NULL) printf(无信息可修改n);return; s=(struct record*)malloc(sizerecord); /*申请一个结构体空间*/ printf(-n); printf(1.按员工编号修改n); printf(2.按姓名修改n); printf(3.退出本菜单n); printf(-n); while(1) printf(请选择子菜单编号:); scanf(%d,&item); switch(item) case 1: printf(请输入员工编号(输入0返回):); scanf(%d,&num); if(num=0) break; /*退出*/ if(exist(num,fp)=1) /*检测员工编号是否存在*/ fseek(fp,-1L*sizerecord,1); /*回滚一个记录*/ fread(s,sizerecord,1,fp); /*读出文件内容*/ printf(修改前信息n); printf(|%dt|%st|%st| %st|%st|%st|%st|%stn,s-code,s-name,s-sex,s-birthday,s-add,s-tel,s-mail,s-qq); InputWord(姓名,s-name); /*录入数据*/ InputWord(性别,s-sex); /*录入数据*/ InputWord(生日,s-birthday); /*录入数据*/ InputWord(地址,s-add); /*录入数据*/ InputWord(电话号码,s-tel); /*录入数据*/ InputWord(邮箱,s-mail); /*录入数据*/ InputWord(qq,s-qq); /*录入数据*/ printf(|%dt|%st|%st| %st|%st|%st|%st|%stn,s-code,s-name,s-sex,s-birthday,s-add,s-tel,s-mail,s-qq); fseek(fp,-1L*sizerecord,1); /*回滚一个记录*/ fwrite(s,sizerecord,1,fp); /*写新文件内容*/ fseek(fp,-1L*sizerecord,1); /*回滚一个记录*/ fread(s,sizerecord,1,fp); /*读出文件内容*/ printf(修改后信息n); printf(|%dt|%st|%st| %st|%st|%st|%st|%stn,s-code,s-name,s-sex,s-birthday,s-add,s-tel,s-mail,s-qq); else printf(无此员工编号信息n); break; case 2: printf(请输入姓名:); scanf(%s,a); if(exist_name(a,fp)=1) /*检测姓名是否存在*/ fseek(fp,-1L*sizerecord,1); /*回滚一个记录*/ fread(s,sizerecord,1,fp); /*读出文件内容*/ printf(修改前信息n); printf(|%dt|%st|%st| %st|%st|%st|%st|%stn,s-code,s-name,s-sex,s-birthday,s-add,s-tel,s-mail,s-qq); InputWord(姓名,s-name); /*录入数据*/ InputWord(性别,s-sex); /*录入数据*/ InputWord(生日,s-birthday); /*录入数据*/ InputWord(地址,s-add); /*录入数据*/ InputWord(电话号码,s-tel); /*录入数据*/ InputWord(邮箱,s-mail); /*录入数据*/ InputWord(qq,s-qq); /*录入数据*/ printf(|%dt|%st|%st| %st|%st|%st|%st|%stn,s-code,s-name,s-sex,s-birthday,s-add,s-tel,s-mail,s-qq); fseek(fp,-1L*sizerecord,1); /*回滚一个记录*/ fwrite(s,sizerecord,1,fp); /*写新文件内容*/ fseek(fp,-1L*sizerecord,1); /*回滚一个记录*/ fread(s,sizerecord,1,fp); /*读出文件内容*/ printf(修改后信息n); printf(|%dt|%st|%st| %st|%st|%st|%st|%stn,s-code,s-name,s-sex,s-birthday,s-add,s-tel,s-mail,s-qq); else printf(无此员工编号信息n); case 3:return; fclose(fp);/*删除员工编号信息*/void del() int num,yn,item; char a15; FILE *fp; struct record *s; if(fp=fopen(stuinf,r+)=NULL) printf(无数据可删除n);return; s=(struct record*)malloc(sizerecord); /*申请一个结构体空间*/ printf(-n); printf(1.按员工编号删除n); printf(2.按姓名删除n); printf(3.退出本菜单n); printf(-n); while(1) printf(请选择子菜单编号:); scanf(%d,&item); switch(item) case 1: printf(请输入要删除的员工编号(输入0返回):); scanf(%d,&num); if(num=0) break; /*退出*/ if(exist(num,fp)=1) /*检测员工编号是否存在*/ printf(员工编号信息非常重要,您确认要删除吗?(1 确认 其他 退回)); scanf(%d,&yn); if(yn!=1) break; printf(再确认一次(1 确认 其他 退回)); scanf(%d,&yn); if(yn!=1) break; s-code=0; fseek(fp,-1L*sizerecord,1); /*回滚到原记录*/ fwrite(s,sizerecord,1,fp); /*清掉员工编号,写回*/ else printf(无此员工编号信息n); break; case 2: printf(请输入姓名:); scanf(%s,a); if(exist_name(a,fp)=1) /*检测姓名是否存在*/ printf(员工编号信息非常重要,您确认要删除吗?(1 确认 其他 退回)); scanf(%d,&yn); if(yn!=1) break; printf(再确认一次(1 确认 其他 退回)); scanf(%d,&yn); if(yn!=1) break; s-code=0; fseek(fp,-1L*sizerecord,1); /*回滚到原记录*/ fwrite(s,sizerecord,1,fp); /*清掉员工编号,写回*/ else printf(无此员工编号信息n); case 3:return; fclose(fp);/*拷贝数据到链节点*/void copytoL(struct StuLink *to,struct record*s)to-code=s-code;strcpy(to-name,s-name);strcpy(to-sex,s-sex);strcpy(to-name,s-birthday);strcpy(to-add,s-add);strcpy(to-tel,s-tel);strcpy(to-mail,s-mail);strcpy(to-qq,s-qq);/*拷贝数据到员工编号结点*/void copytorec(struct record *to,struct StuLink *s)to-code=s-code;strcpy(to-name,s-name);strcpy(to-sex,s-sex);strcpy(to-name,s-birthday);strcpy(to-add,s-add);strcpy(to-tel,s-tel);strcpy(to-mail,s-mail);strcpy(to-qq,s-qq);/*排序员工编号表*/*算法思想: 1、把数据拷贝到一个链表中,在接入链表的时候,每次从链表头开始查找,直到找到 合适的位置,然后插入链表,这样就完成了排序。 2、将排好序的链表重新考入原文件中(用W方式打开,可清除原有数据)*/void SortStudent() int n=0; long ft=0L,filelen; FILE *fp; struct record *p; /*存放员工编号数据节点*/ struct StuLink *head,*p1,*k,*q;/*链指针,head链首指针,p1存放员工编号数据节点,k当前指针,q前向指针*/ if(fp=fopen(stuinf,r)=NULL) printf(没有员工编号资料!);return; filelen=FileLenth(fp); p=(struct record*)malloc(sizerecord); p1=(struct StuLink*)malloc(sizeof(struct StuLink);/*申请一个空节点,做头节点*/ p1-next=NULL; head=p1; while(ftcode!=0) p1=(struct StuLink*)malloc(sizeof(struct StuLink);p1-next=NULL; /*申请一个节点,用于存放数据*/ copytoL(p1,p); /*拷贝数据到链节点*/ if (n=0) head-next=p1; else q=head; k=head-next; while(q-next!=NULL & k-codecode) /*挪动链指针*/ q=k; k=k-next; p1-next=k; q-next=p1; n+; ft=ftell(fp); fclose(fp); fp=fopen(stuinf,w); k=head-next; while(k-next!=NULL) /*把文件内容写回文件*/ copytorec(p,k); /*拷贝数据到员工编号结点*/ fwrite(p,sizerecord,1,fp); /*写文件内容*/ k=k-next; copytorec(p,k); /*拷贝数据到员工编号结点*/ fwrite(p,sizerecord,1,fp); /*写文件内容*/ fclose(fp);/*打印员工编号信息*/void PrintStudent() long filelen; FILE *fp; struct record *s; s=(struct record*)malloc(sizerecord); if(fp=fopen(stuinf,r)=NULL) printf(没有员工编号资料!);return; filelen=FileLenth(fp); printf(| 员工编号t| 姓名t| 性别t | t生日t| t地址t| 电话号码t | t邮箱t | tqqt |n); while (ftell(fp)code,s-name,s-sex,s-birthday,s-add,s-tel,s-mail,s-qq); fclose(fp);/*主程序(菜单)*/void main() int menunum; char c; long s; printf(ttttt-n); printf(tttttt1 管理员登陆n); printf(tttttt2 普通用户登陆n); printf(tttttt0 退出程序n); printf(ttttt-n); printf(ttttt 操作方式:); scanf(%d,&menunum); switch(menunum) case 0:return; case 1: printf(请输入密码(管理员验证):); scanf(%ld,&s); if(s=N) while(menunum) printf(按回车键继续n);c=getchar();c=getchar(); system(cls);/*清屏*/ printf(nttttt 员工编号管理系统(可输入汉字)n); printf(ttt |n); printf(ttt |1 输入员工编号信息tt2 修改员工编号信息t3 查找员工编号信息|n); printf(ttt |4 排列员工编号信息tt5 打印员工编号信息t6 删除员工编号信息|n); printf(ttt |0 结束程序 ttttt |n); printf(ttt n); printf(tttn 操作方式:); scanf(%d,&menunum); switch(menunum) case 0:return; case 1:readfile();break; case 2:modify();break; case 3:seek();break; case 4:SortStudent();break; case 5:PrintStudent();break; case 6:del();break; break; case 2: while(menunum) printf(按回车键继续n);c=getchar();c=getchar(); system(cls);/*清屏*/ printf(-n); printf(1 查找员工编号信息n); printf(0 结束程序n); printf(-n); printf(操作方式:); scanf(%d,&menunum); switch(menunum) case 0:return; case 1:seek(); 5 调试分析测试是使用人工或者自动手段来运行或测试某个系统的过程,其目的在于检验是否满足规定的需求或弄清预期结果与实际结果之间的差别。在调试查询修改功能过程中,查询的总是不正确,查询的结果显示,没有找到员工信息,最后发现查找的结点不正确,查询应该与输入的值和头结点next比较,而不是头结点。还有就是查询结点不知道如何循环,最后又看看了记得笔记和

温馨提示

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

评论

0/150

提交评论