资源描述
目 录
1 问题描述 4
2 概要设计 5
2.1系统设计 5
2.2系统类层次及结构图 5
3.1类与对象的设计 8
3.1.1类属性的详细设计 8
3.1.2类行为的详细设计 10
4 系统测试及结果 12
总结 17
参考文献 18
摘 要
该人事系统作为信息管理系统的一个分支,已逐渐成为高校信息化建设的重要组成部分,为学校管理全校的院系的教职工提供了一个功能强大、安装部署方便、使用成本低、操作简捷的信息查询管理系统。实现对数据的增加、查找、修改、删除等操作,并且对异常信息给出错误提示等。
关键字:添加,删除,修改,读取,显示,查找,统计,保存。
前 言
该设计是以计算机与通信学院教师人事管理为背景,设计的一个可以进行简单操作的人事管理系统。按照任务书的要求,一步步的进行设计,最终基本完成了课程设计的要求,由于本人水平有限,有些高要求还未实现,如图操作早作界面。
人事管理系统是典型的信息管理系统(MIS),其开发主要包括后台数据库的建立和维护以及前端应用程序的开发两个方面。对于前者要求建立起数据一致性和完整性强、数据安全性好的库。而对于后者则要求应用程序功能完备,易使用等特点。
在这次课程设计中先后使用了TC2.0、VC++6.0等开发工具,最后调试、生成可执行文件等是在VC下进行的。
在这个简单的人事管理程序中,使用了链表这个动态数据结构。链表是动态数据结构中最简单的一种。它是一种用前后链指针连接的若干个有限结点的集合,其连接是前一个结点的尾指针指向下一个结点的起始地址,从而连接成的一个链,所以它是一种线性的动态数据结构。在该程序中,采用了动态存储分配技术,这样可以有效地利用有限的内存空间。要实现它,就必须使用malloc()和free()函数。该程序主要使用了链表的插入、删除、查询。使用链表。
正文
1 问题描述
编写一个C++程序,包含高校主要教职工类型,如在职人员(行政人员、教师、一般员工)、退休员工、反聘人员和临时工,同时存储这些人员的人事档案信息:编号、姓名、性别、年龄、职务、职称、政治面貌、最高学历、来院时间等。为学校管理全校的院系的教职工提供了一个功能强大、安装部署方便、使用成本低、操作简捷的信息查询管理系统。实现对数据的增加、查找、修改、删除等操作,并且对异常信息给出错误提示等。在系统中能够添加和删除人事变动情况,能够进行修改和查询,并存储运行记录。
2 概要设计
2.1系统设计
程序设计的基本目标是用算法对问题的原始数据进行处理,从而获得所期望的效果。但这仅仅是程序设计的基本要求。要全面提高程序的质量,提高编程效率,使程序具有良好的可读性、可靠性、可维护性以及良好的结构,编制出好的程序来,应当是每位程序设计工作者追求的目标。而要做到这一点,就必须掌握正确的程序设计方法和技术。而C++语言是一种结构化语言。它层次清晰,便于按模块化方式组织程序,易于调试和维护。所以采用结构化程序设计方法,对管理系统进行自顶向下,逐步细化,模块化设计.
2.1.1系统分析
高校人事管理系统所需要完成的功能主要有:
人事信息的输入,包括:编号、姓名、性别、年龄、职务、职称、政治面貌、最高学历、任职时间、来院时间等。
人事信息的查询,包括:编号、姓名、性别、年龄、职务、职称、政治面貌、最高学历、任职时间、来院时间等。
人事信息的修改。
添加删除功能:能根据学院的变动情况,添加删除记录;
保存功能:能对输入的数据进行相应的存储,要求重载插入和提取符以完成数据的保存和打开。
2.2系统类层次及结构图
定义两个类,一个person类,包含在职人员(行政人员、教师、一般员工)、退休人员、返聘人员和临时工。员工信息包括编号、姓名、性别、年龄、职务、职称、政治面貌、最高学历、来院时间。定义一个school类,在里面实现数据的添加、删除、修改、查找、显示和退出。
类person
void getag(int as)
int getage()
char *getname()
person *getnext()
int getnum()
char *getparty()
char *getpos()
char *getsex()
char *getstudy()
char *gettechpos()
char *gettime()
char *gettype()
void setnext(person *next)
类School
void add()//添加新信息
bool find1()//按编号查找
bool find2( )//按姓名查找
void load()
void pri()
void printf(int r)//获取信息
void printf1(person *ahead)//输出信息
bool removedatnum( )//删除信息
void save()//保存文件到文件中
School()//无参构造函数
~School()//析构函数,删除各指针!
bool upperson()//修改信息
类的结构关系图
person
School
2.3系统功能模块图
高校人事管理系统
添加人员信息
修改人员信息
退出
数据装入
查找人员信息
删除人员信息
显示人员信息
3 详细设计
3.1类与对象的设计
类class person
School s;//定义对象
类class School
3.1.1类属性的详细设计
类class person
class person
{
private:
int no; //编号
char type[20]; //职工类型
char name[20]; //姓名
char sex[10]; //性别
int age; //年龄
char time[20]; //来院时间
char pos[20]; //职务
char techpos[20]; //职称
char party[20]; //党派
char study[30]; //最高学历
person *mynext; //指针语
public:
person(int nnum,char ntype[],char nname[],char nsex[],int nage,char ntime[],char npos[],char ntechpos[],char nparty[],char nstudy[])
{
no=nnum;
strcpy(type,ntype);//将ntype的值复制给type
strcpy(name,nname);
strcpy(sex,nsex);
age=nage;
strcpy(time,ntime);
strcpy(pos,npos);
strcpy(techpos,ntechpos);
strcpy(party,nparty);
strcpy(study,nstudy);
mynext=NULL;
}
School s;//定义对象
类class School
{
private:
person *myfirst;
int firstnum;
public:
School()//无参构造函数
{
myfirst=NULL;//将指针置空
}
3.1.2类行为的详细设计
类class person
void getag(int as)
int getage()
char *getname()
person *getnext()
int getnum()
char *getparty()
char *getpos()
char *getsex()
char *getstudy()
char *gettechpos()
char *gettime()
char *gettype()
void setnext(person *next)
类School
void add()//添加新信息
bool find1()//按编号查找
bool find2( )//按姓名查找
void load()
void pri()
void printf(int r)//获取信息
void printf1(person *ahead)//输出信息
bool removedatnum( )//删除信息
void save()//保存文件到文件中
School()//无参构造函数
~School()//析构函数,删除各指针!
bool upperson()//修改信息
4 系统测试及结果
1.运行首界面:
2.人员添加及删除人员
3. 修改人员及查询人员
4统计人员及数据存储
5显示信息及退出界面
总结
通过三星期关于算法与数据结构设计,我从中受益匪浅。尤其对程序设计的相关知识有了更深一步的认识。在课设中,我们可以把所学的理论知识和实践联系起来,在所要开发的项目中渐渐成长。虽然我们对这些程序语言知识运用得还不是很熟练,但是相信我们也在滴水穿石地成长起来。发现问题,提出问题,然后解决问题,使我们的不足之处得以弥补,寻找新的学习方向。
在此次课程设计中,我设计了一组对人事进行管理的系统,它基本满足工作人员的添加删除功能,查询功能,编辑功能,保存功能以及统计功能。我感觉更利于用户操作方便,运行简单,从而达到对高校人事更加有效系统管理的目的,并且速度更快内容更直接,达到用户所想要的效果。此次课程设计中,我一边课设一边探索,发现要把理论和实践充分地结合,达到一个新的水平,不仅仅需要扎实的基本功,而且需要扎实的实际操作训练。这就表明学好基础知识是理论付诸实践的前提。在此次课程设计中我对以前的知识巩固许多,也加深了许多,当然在此基础上更是学到了很多新的操作实战技能,希望在以后,学校或者学院能给同学门提供更多关于实际操作这方面的锻炼机会,同学们虽然学了一点基础知识但是我觉得这对于计算机专业的学生是远远不够的。
参考文献
[1]陈维兴,林小茶.c++面向对象程序设计教程. 北京: 清华大学出版社,1996.2004.
[2]张国峰. C++程序设计实用教程. 北京: 清华大学出版社,1996.
[3]张松梅. C++语言教程. 电子科技大学出版社,1993.
[4]阎龙. C程序员的C++指南. 北京航空航天大学出版社,1992.
[5]王博. 面向对象的建模、设计技术与方法. 北京希望电脑公司,1990.
致 谢
经过这三周的课设,我们获得了许多在课堂上听课而不能获得的知识,首先我们要感谢学校给我们安排的这次的算法与数据结构设计实习,然后我要感谢张老师对我们热心的指导和帮助,是他教会了我们怎样解决问题的方法,这样我的程序设计才会更加顺利地进行,并且充分掌握了设计程序的方法。我们还要感谢许多同学的帮助,他们的帮助对于我们来说也是必不可少的。总之,是有了他的帮助,我才能顺利地完成程序设计,在这里我要向他说一句:谢谢,非常感谢!感谢所有帮助过我的老师和同学!
附录-源 程 序
#include<iostream.h>
#include<string.h>
#include<fstream.h>
#include<iomanip.h>
class person
{
//人员类 似有数据成员
private:
int no;
char type[20];
char name[20];
char sex[10];
int age;
char time1[20];
char time2[20];
char pos[20];
char techpos[20];
char party[20];
char study[30];
person *mynext;
public:
//构造函数一
person(int nnum,char ntype[],char nname[],char nsex[],int nage,char ntime1[],char ntime2[],char npos[],char ntechpos[],char nparty[],char nstudy[])
{
no=nnum;
strcpy(type,ntype);
strcpy(name,nname);
strcpy(sex,nsex);
strcpy(time1,ntime1);
age=nage;
strcpy(time2,ntime2);
strcpy(pos,npos);
strcpy(techpos,ntechpos);
strcpy(party,nparty);
strcpy(study,nstudy);
mynext=NULL;
}
//构造函数二
person(int nnum,char ntype[],char nname[],char nsex[],int nage,char ntime1[],char ntime2[],
char npos[],char ntechpos[],char nparty[],char nstudy[],person *next)
/*某高校,主要人员有:在职人员(行政人员、教师、一般员工)、退休人员、返聘人员和临时工。
现在,需要存储这些人员的人事档案信息:编号、姓名、性别、年龄、职务、职称、政治面貌、最高学历、任职时间、来院时间。*/
{
no=nnum;
strcpy(type,ntype);
strcpy(name,nname);
strcpy(sex,nsex);
strcpy(time1,ntime1);
age=nage;
strcpy(time2,ntime2);
strcpy(pos,npos);
strcpy(techpos,ntechpos);
strcpy(party,nparty);
strcpy(study,nstudy);
mynext=next;
}
void setnext(person *next)
{
mynext=next;
}
person *getnext()
{
return mynext;
}
//获取对对象的各个私有数据函数
int getnum()
{
return no;
}
char *getname()
{
return name;
}
char *getsex()
{
return sex;
}
char *getpos()
{
return pos;
}
char *gettechpos()
{
return techpos;
}
char *gettime1()
{
return time1;
}
char *gettime2()
{
return time2;
}
char *getparty()
{
return party;
}
char *getstudy()
{
return study;
}
int getage()
{
return age;
}
void getag(int as)
{
age=as;
}
char *gettype()
{
return type;
}
};
class School
{
private:
person *myfirst;
int firstnum;
public:
School()
{
myfirst=NULL;
}
//构造函数,将数据初始化
School(int nnu,char ntyp[],char nnam[],char nse[],int nag,char ntim1[],char ntim2[],char npo[],char ntechpo[],char npart[],char nstud[])
{
myfirst=new person(nnu,ntyp,nnam,nse,nag,ntim1,ntim2,npo,ntechpo,npart,nstud);
}
//在最后插入新成员 函数
void insertatlast(int nnum,char ntype[],char nname[],char nsex[],int nage,char ntime1[],char ntime2[],char npos[],char ntechpos[],char nparty[],char nstudy[])
{
person *next=myfirst;
if(next==NULL)
myfirst=new person(nnum,ntype,nname,nsex,nage,ntime1,ntime2,npos,ntechpos,nparty,nstudy);
else
{
while(next->getnext()!=NULL)
next=next->getnext();
next->setnext(new person(nnum,ntype,nname,nsex,nage,ntime1,ntime2,npos,ntechpos,nparty,nstudy,next->getnext()));
}
}
//从键盘输入数据,并创建相应对象 函数,
void input(int r)
{
int nage;
char ntype[20],nname[20],nsex[20],ntime1[20],ntime2[20],npos[20],ntechpos[20],nparty[20],nstudy[20];
cout<<"请输入编号为"<<r<<"的成员的信息"<<endl;
cout<<"输入职工分类码[行政人员,教师,一般员工,退休人员,返聘人员,临时工]:"<<endl;
cin>>ntype;
cout<<"输入姓名:"<<endl;
cin>>nname;
cout<<"输入性别:"<<endl;
cin>>nsex;
cout<<"输入年龄:"<<endl;
cin>>nage;
cout<<"参加工作时间:"<<endl;
cin>>ntime1;
cout<<"输入来院时间:"<<endl;
cin>>ntime2;
cout<<"输入职务[无,科级,处级,地级]:"<<endl;
cin>>npos;
cout<<"输入职称[无,初级,中级,高级]:"<<endl;
cin>>ntechpos;
cout<<"输入加入党派[群众,中共党员,民主党派]:"<<endl;
cin>>nparty;
cout<<"输入学历[小学,初中,高中,大专,大学,硕士,博士]:"<<endl;
cin>>nstudy;
insertatlast(r,ntype,nname,nsex,nage,ntime1,ntime2,npos,ntechpos,nparty,nstudy);
}
//从键盘输入数据,并创建相应对象 函数二,
void input1(person *ahead)
{
cout<<"编号:"<<setiosflags(ios::left)<<" "<<ahead->getname()<<endl;
cout<<"性别:"<<setiosflags(ios::left)<<" "<<ahead->getsex()<<endl;
cout<<"年龄:"<<setiosflags(ios::left)<<" "<<ahead->getage()<<endl;
cout<<"职工类型:"<<setiosflags(ios::left)<<" "<<ahead->gettype()<<endl;
cout<<"职务:"<<setiosflags(ios::left)<<" "<<ahead->getpos()<<endl;
cout<<"职称:"<<setiosflags(ios::left)<<" "<<ahead->gettechpos()<<endl;
cout<<"学历:"<<setiosflags(ios::left)<<" "<<ahead->getstudy()<<endl;
cout<<"政治面貌:"<<setiosflags(ios::left)<<" "<<ahead->getparty()<<endl;
cout<<"来院时间:"<<setiosflags(ios::left)<<" "<<ahead->gettime1()<<endl;
cout<<"参加工作时间:"<<setiosflags(ios::left)<<ahead->gettime2()<<endl;
}
//输出数据函数二
void pri()
{
person *ahead=myfirst;
cout<<"编号姓名 性别 年龄 职工类型 职务 职称 学历 政治面貌 来院时间 参加工作时间\n";
while(ahead!=NULL)
{
cout<<setiosflags(ios::left)<<setw(4)<<ahead->getnum()<<setiosflags(ios::left)<<setw(6)<<ahead->getname()
<<setiosflags(ios::left)<<setw(5)<<ahead->getsex()<<setiosflags(ios::left)<<setw(4)<<ahead->getage()
<<setiosflags(ios::left)<<setw(10)<<ahead->gettype()<<setiosflags(ios::left)<<setw(6)<<ahead->getpos()
<<setiosflags(ios::left)<<setw(6)<<ahead->gettechpos()<<setiosflags(ios::left)<<setw(6)<<ahead->getstudy()
<<setiosflags(ios::left)<<setw(9)<<ahead->getparty()<<setiosflags(ios::left)<<setw(12)<<ahead->gettime1()
<<ahead->gettime2()<<endl;
ahead=ahead->getnext();
}
}
//增加员工函数
void add()
{
int i,a,b;
person *p1=myfirst;
if(p1==NULL)
{
cout<<"请输入编号:";
cin>>i;
input(i);
}
else
{
if(p1->getnext()==NULL)
{
a=p1->getnum()+1;
input(a);
}
else
{
while(p1->getnext()!=NULL)
{
p1=p1->getnext();
}
b=p1->getnum()+1;
input(b);
}
}
}
//删除人员函数
bool removedatnum( )
{
int bh;
person *ahead=myfirst;
person *follow=ahead;
cout<<"请输入要删除人员的编号:";
cin>>bh;
if(ahead==NULL)
return false;
else
if(ahead->getnum()==bh)
{
myfirst=myfirst->getnext();
cout<<"编号为"<<bh<<"的成员以被删除"<<endl;
delete ahead;
return true;
}
else
{
ahead=ahead->getnext();
while(ahead!=NULL)
{
if(ahead->getnum()==bh)
{
follow->setnext(ahead->getnext());
cout<<"编号为"<<bh<<"的成员以被删除\n";
delete ahead;
return true;
}
follow=ahead;
ahead=ahead->getnext();
}
cout<<"要删除的成员不存在!"<<endl;
return false;
}
}
//查找人员函数
bool find1()
{
int id;
person *ahead=myfirst;
person *follow=ahead;
cout<<"请输入编号:"<<endl;
cin>>id;
cout<<endl;
cout<<"信息如下:"<<endl;
if(ahead==NULL)
{
cout<<"无人员信息!"<<endl;
return false;
}
else
{
while(ahead!=NULL)
{
if(ahead->getnum()==id)
{
input1(ahead);
return true;
}
else
{
follow=ahead;
ahead=ahead->getnext();
}
}
cout<<"无此人信息:"<<endl;
return false;
}
}
//查找人员函数
bool find2( )
{
char nm[20];
person *ahead=myfirst;
person *follow=ahead;
cout<<"输入姓名";
cin>>nm;
cout<<endl;
cout<<"信息如下:"<<endl;
if(ahead==NULL)
{
cout<<"无人员信息"<<endl;
return false;
}
else
{
while(ahead!=NULL)
{
if(strcmp(ahead->getname(),nm)==0)
{
input1(ahead);
return true;
}
else
{
follow=ahead;
ahead=ahead->getnext();
}
}
cout<<"查无此人:"<<endl;
return false;
}
}
//统计人数函数
void stat()
{
int xx,sz=0;
cout<<"请选择统计对象: "<<endl;
cout<<" 1 在职人数"<<endl;
cout<<" 2 党员人数"<<endl;
cout<<" 3 女工人数"<<endl;
cout<<" 4 高学历高职称人数"<<endl;
cout<<" 请选择:";
cin>>xx;
switch(xx)
{
case 1: {
person *ahead=myfirst;
if(ahead==NULL)
cout<<"无人员信息"<<endl;
else
{
while(ahead!=NULL)
{
if(strcmp(ahead->gettype(),"行政人员")==0||strcmp(ahead->gettype(),"教师")==0||strcmp(ahead->gettype(),"一般员工")==0)
{
ahead=ahead->getnext();
sz++;
}
else
ahead=ahead->getnext();
}
}
cout<<"在职人数:"<<sz<<endl;
};
break;
case 2:{
person *ahead=myfirst;
if(ahead==NULL)
cout<<"无人员信息\n";
else
{
while(ahead!=NULL)
{
if(strcmp(ahead->getparty(),"中共党员")==0)
{
ahead=ahead->getnext();
sz++;
}
else
ahead=ahead->getnext();
}
}
cout<<"中共党员人数:"<<sz<<endl;
};
break;
case 3:{
person *ahead=myfirst;
person *follow=ahead;
if(ahead==NULL)
cout<<"无人员信息\n";
else
{
while(ahead!=NULL)
{
if(strcmp(ahead->getsex(),"女")==0)
{
ahead=ahead->getnext();
sz++;
}
else
ahead=ahead->getnext();
}
}
cout<<"女职工人数:"<<sz<<endl;
};
break;
case 4:{
person *ahead=myfirst;
person *follow=ahead;
if(ahead==NULL)
cout<<"无人员信息"<<endl;
else
{
while(ahead!=NULL)
{
if(strcmp(ahead->getstudy(),"博士")==0||strcmp(ahead->getstudy(),"硕士")==0&&strcmp(ahead->gettechpos(),"高级")==0)
{
ahead=ahead->getnext();
sz++;
}
else
ahead=ahead->getnext();
}
}
cout<<"高学历高职称人数:"<<sz<<endl;
};
break;
}
cout<<"统计结果:"<<sz<<endl;
}
bool upperson()
{
int iid;
person *ahead=myfirst;
person *follow=ahead;
cout<<"请输入要修改人员的编号:";
cin>>iid;
if(ahead==NULL)
{
cout<<"无人员信息"<<endl;
return false;
}
else
{
while(ahead!=NULL)
{
if(ahead->getnum()==iid)
{
input1(ahead);
int nu=-1;
for(int i=1;nu!=0;i++)
{
int ml;
int mll;
char ty[30];
cout<<"请选择要修改的内容:"<<endl;
cout<<" 1:姓名 2:性别 3:年龄 4:职工类型 5:职务"<<endl;
cout<<" 6:职称 7:学历 8:政治面貌 9:来院时间 10:参加工作时间"<<endl;
cout<<" 选择(1-10):";
cin>>ml;
switch(ml)
{
case 1:{
cout<<"请输入姓名:";
cin>>ty;
strcpy(follow->getname(),ty);
};
break;
case 2:{
cout<<"请输入性别:";
cin>>ty;
strcpy(ahead->getsex(),ty);
};
break;
展开阅读全文