高校人事管理系统.docx
《高校人事管理系统.docx》由会员分享,可在线阅读,更多相关《高校人事管理系统.docx(38页珍藏版)》请在冰豆网上搜索。
高校人事管理系统
课程设计报告
课程:
面向对象程序设计
学号:
姓名:
班级:
教师:
Xx大学
课程设计名称:
高校人事管理系统
1.设计内容
某高校主要人员有:
在职人员(行政人员、教师、一般员工)、退休人员、返聘人员和临时工。
现在,需要存储这些人员的人事档案信息:
编号、姓名、性别、年龄、职务、职称、政治面貌、最高学历、任职时间、来院时间。
要求:
1)添加删除功能:
能根据学院人事的变动情况,添加删除记录;
2)查询功能:
能根据编号和姓名进行查询;
3)编辑功能(高级):
根据查询对相应的记录进行修改,并存储;
4)统计功能:
能根据多种参数进行人员的统计(在职人数、党员人数、女工人数、高学历高职称人数);
5)保存功能:
能对输入的数据进行相应的存储,要求重载插入和提取符以完成数据的保存和打开。
6)人员编号在生成人员信息时同时生成,每输入一个人员信息编号顺序加1。
3.3基本功能要求
1.功能选择用菜单实现
例如:
***************************************************
高校人事管理系统
——————————————————————————
1--增加人员资料
2--删除人员信息
3--修改人员信息
4--查询人员信息
5—统计人员信息
6—数据保存
7—显示所有信息
8—退出
****************************************************
请选择<1--9>:
用户通过输入不同的数字进入不同的菜单。
次级菜单主要显示本程序的功能,主要的功能有增加人员资料,删除人员信息,修改人员信息,修改人员信息,查询人员信息,统计人员信息,数据保存,显示所有信息和退出功能。
2.运行时给出明确的提示信息
比如,选择1,系统会提醒用户输入编号,输入完系统会进一步提醒用户输入其他信息和选择,进入相应的选择后会提醒用户选择其他子选择和输入;
比如,输入增加人员,又选择“在职人员(行政人员、教师、一般员工)、退休人员、返聘人员和临时工”再输入信息。
比如在删除人员信息中又显示“所要删除的编号是”和“无此人员”或“已被删除”等
比如在查找人员信息中又显示“所要查找的编号是”或“所要查找的姓名是”和“无此人员”和显示相关信息等。
在统计人员信息中又显示
————————————————————————————
请选择统计对象:
1在职人数
2党员人数
3女工人数
4高学历高职称人数
请选择:
————————————————————————————
界面来供选择。
比如修改功能则会出现下面的界面
————————————————————————————
请选择要修改的内容:
1:
姓名2:
性别3:
年龄4:
职工类型5:
职务
6:
职称7:
学历8:
政治面貌9:
来院时间10:
参加工作时间"
选择(1-10):
————————————————————————————
在实现完菜单中的子程序功能,系统会提醒用户按任意键继续(就是重新返回到主菜单进行其他操作),最后根据提示信息输入8退出系统,结束本次操作。
4.系统结构设计
本程序的功能结构如图1所示:
图1程序功能结构图
5.源程序代码
/*****************************************************************************/
#include
#include
#include//文件流,数据流输入/输出
#include//是常用的函数system()、exit()的头文件
#include//参数化输入/输出是setw()函数的头文件
//person类和school类的主体以及主函数由本人和合作者何婷婷共同完成
//文中没有标注由谁完成的,代表由本人和合作者何婷婷共同完成
classperson
{
private:
intno;//编号
chartype[20];//职员分类
charname[20];//姓名
charsex[10];//性别
intage;//年龄
chartime1[20];//任职时间
chartime2[20];//来院时间
charpos[20];//职务
chartechpos[20];//职称
charparty[20];//政治面貌
charstudy[30];//最高学历
person*mynext;//指向下一个指针
public:
person(intnnum,charntype[],charnname[],charnsex[],intnage,charntime1[],charntime2[],char
npos[],charntechpos[],charnparty[],charnstudy[])//构造函数
{
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(intnnum,charntype[],charnname[],charnsex[],intnage,charntime1[],charntime2[],
charnpos[],charntechpos[],charnparty[],charnstudy[],person*next)//构造函数2,即重载
{
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;//下一个为有
}
voidsetnext(person*next)//关于next的函数
{
mynext=next;
}
person*getnext()//指针函数,把数据从被调函数返回到主调函数
{
returnmynext;
}
intgetnum()
{
returnno;
}
char*getname()//name是数组用指针
{
returnname;
}
char*getsex()//sex是数组用指针
{
returnsex;
}
char*getpos()//pos是数组用指针
{
returnpos;
}
char*gettechpos()//techpos是数组用指针
{
returntechpos;
}
char*gettime1()//time1是数组用指针
{
returntime1;
}
char*gettime2()//time2是数组用指针
{
returntime2;
}
char*getparty()//party是数组用指针
{
returnparty;
}
char*getstudy()//study是数组用指针
{
returnstudy;
}
intgetage()
{
returnage;
}
voidgetag(intas)
{
age=as;
}
char*gettype()//type是数组用指针
{
returntype;
}
};
//链表类
classSchool
{
private:
person*myfirst;
intfirstnum;
public:
School()
{
myfirst=NULL;
}
School(intnnu,charntyp[],charnnam[],charnse[],intnag,charntim1[],charntim2[],charnpo[],charntechpo[],charnpart[],charnstud[])
{
myfirst=newperson(nnu,ntyp,nnam,nse,nag,ntim1,ntim2,npo,ntechpo,npart,nstud);//动态分配内存创立节点
}//初始化
voidinsertatlast(intnnum,charntype[],charnname[],charnsex[],intnage,charntime1[],charntime2[],charnpos[],charntechpos[],charnparty[],charnstudy[])//成员函数
{
person*next=myfirst;
if(next==NULL)
myfirst=newperson(nnum,ntype,nname,nsex,nage,ntime1,ntime2,npos,ntechpos,nparty,nstudy);
else
{
while(next->getnext()!
=NULL)//已经有至少一个编号内容
next=next->getnext();
next->setnext(newperson(nnum,ntype,nname,nsex,nage,ntime1,ntime2,npos,ntechpos,nparty,nstudy,next->getnext()));//调用构造函数2
}
}
voidprintf(intr)//输入函数*由合作者何婷婷完成
{
intnage;
charntype[20],nname[20],nsex[20],ntime1[20],ntime2[20],npos[20],ntechpos[20],nparty[20],nstudy[20];
cout<<"请输入编号为"<cout<<"输入职工分类码[poli(行政人员),teac(老师),work(一般人员),outwork(退休人员),rework(返聘人员),timework(临时工)]:
"<cin>>ntype;
cout<<"输入姓名:
"<cin>>nname;
cout<<"输入性别:
(女性—f,男性—m)"<cin>>nsex;
cout<<"输入年龄:
"<cin>>nage;
cout<<"参加工作时间:
"<cin>>ntime1;
cout<<"输入来院时间:
"<cin>>ntime2;
cout<<"输入职务[no(无),ke(科级),chu(处级),di(地级)]:
"<cin>>npos;
cout<<"输入职称[no(无),chu(初级),zhong(中级),gao(高级)]:
"<cin>>ntechpos;
cout<<"输入加入党派[qz(群众),gd(中共党员),mzd(民主党派)]:
"<cin>>nparty;
cout<<"输入学历[xiao(小学),chu(初中),gao(高中),zhuan(大专),da(大学),suo(硕士),bo(博士)]:
"<cin>>nstudy;
insertatlast(r,ntype,nname,nsex,nage,ntime1,ntime2,npos,ntechpos,nparty,nstudy);//调用函数
}
voidprintf1(person*ahead)//定义一个指针对象*由本人完成
{//setiosflags(ios:
:
left)左对齐,setw是操作子,设定下一次输出输入宽度
cout<<"编号:
"<:
left)<getnum()<<"姓名:
"<getname()<cout<<"性别:
"<:
left)<getsex()<<"年龄:
"<getage()<cout<<"职工类型:
"<:
left)<gettype()<<"职务:
"<getpos()<cout<<"职称:
"<:
left)<gettechpos()<<"学历:
"<getstudy()<cout<<"政治面貌:
"<:
left)<getparty()<<"来院时间:
"<gettime1()<cout<<"参加工作时间:
"<gettime2()<}
voidpri()//显示所有信息*由本人完成
{
person*ahead=myfirst;
cout<<"编号姓名性别年龄职工类型职务职称学历政治面貌来院时间参加工作时间\n";
while(ahead!
=NULL)
{
cout<:
left)<getnum()<:
left)<getname()
<:
left)<getsex()<:
left)<getage()
<:
left)<gettype()<:
left)<getpos()
<:
left)<gettechpos()<:
left)<getstudy()
<:
left)<getparty()<:
left)<gettime1()
<gettime2()<ahead=ahead->getnext();//一个一个输出
}
}
voidadd()//增加函数*由合作者何婷婷完成
{
inti,a,b;
person*p1=myfirst;//初始化对象指针
if(p1==NULL)
{
cout<<"请输入编号:
";
cin>>i;
printf(i);//调用前面的printf函数
}
else
{
if(p1->getnext()==NULL)//获得节点
{
a=p1->getnum()+1;//
printf(a);
}
else
{
while(p1->getnext()!
=NULL)
{
p1=p1->getnext();//在原由的基础上加内容
}
b=p1->getnum()+1;//数字加1>=2
printf(b);
}
}
}
boolremovedatnum()//删除函数*由合作者何婷婷完成
{
intbh;
person*ahead=myfirst;
person*follow=ahead;
cout<<"请输入要删除人员的编号:
";
cin>>bh;
if(ahead==NULL)//判断链表是否为空。
若为空,返回false,否则返回true。
returnfalse;
else
if(ahead->getnum()==bh)
{
myfirst=myfirst->getnext();
cout<<"编号为"<deleteahead;//销毁链表
returntrue;
}
else
{
ahead=ahead->getnext();
while(ahead!
=NULL)
{
if(ahead->getnum()==bh)
{
follow->setnext(ahead->getnext());
cout<<"编号为"<deleteahead;
returntrue;
}
follow=ahead;
ahead=ahead->getnext();
}
cout<<"要删除的成员不存在!
"<returnfalse;
}
}
boolfind1()//根据编号查找,返回是真OR假*由合作者何婷婷完成
{
intid;
person*ahead=myfirst;
person*follow=ahead;
cout<<"请输入编号:
"<cin>>id;
cout<<"**********************************"<if(ahead==NULL)
{
cout<<"无人员信息!
"<returnfalse;
}
else
{
while(ahead!
=NULL)
{
if(ahead->getnum()==id)
{
printf1(ahead);
returntrue;
}
else
{
follow=ahead;//继续查找,比如输入了一个没有的id,就用到这里
ahead=ahead->getnext();
}
}
cout<<"无此人信息:
"<returnfalse;
}
}
boolfind2()//根据姓名查找*由合作者何婷婷完成
{
charnm[20];
person*ahead=myfirst;
person*follow=ahead;
cout<<"输入姓名";
cin>>nm;
cout<<"**********************************"<if(ahead==NULL)
{
cout<<"无人员信息"<returnfalse;
}
else
{
while(ahead!
=NULL)
{
if(strcmp(ahead->getname(),nm)==0)
{
printf1(ahead);
returntrue;
}
else
{
follow=ahead;
ahead=ahead->getnext();
}
}
cout<<"查无此人:
"<returnfalse;
}
}
voidstat()//统计函数*由本人完成
{
intxx,sz=0;
cout<<"请选择统计对象:
"<cout<<"1在职人数"<cout<<"2党员人数"<cout<<"3女工人数"<cout<<"4高学历高职称人数"<cout<<"请选择:
";
cin>>xx;
switch(xx)
{
case1:
{
person*ahead=myfirst;
if(ahead==NULL)
cout<<"无人员信息"<else
{
while(ahead!
=NULL)
{//strcmp是字符串函数,比较大小
if(strcmp(ahead->gettype(),"poli")==0||strcmp(ahead->gettype(),"teac")==0||strcmp(ahead->gettype(),"work")==0)
{
ahead=ahead->getnext();
sz++;
}
else
ahead=ahead->getnext();
}
}
cout<<"在职人数:
"<};
break;
case2:
{
person*ahead=myfirst;
if(ahead==NULL)
cout<<"无人员信息\n";
else
{
while(ahead!
=NULL)