高校人事管理系统课程设计.docx
《高校人事管理系统课程设计.docx》由会员分享,可在线阅读,更多相关《高校人事管理系统课程设计.docx(32页珍藏版)》请在冰豆网上搜索。
![高校人事管理系统课程设计.docx](https://file1.bdocx.com/fileroot1/2023-1/5/43cf288a-e77c-4d1f-bde2-4de11754e0fd/43cf288a-e77c-4d1f-bde2-4de11754e0fd1.gif)
高校人事管理系统课程设计
一.需求分析
1.目的与意义
、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、
2.系统流程图
12
34
56
87
二.总体设计
1.系统功能分析
执行程序后,按界面的显示,选择1—8种操作。
选1,增加人员资料,资料包括编号、职工类别、姓名、性别、年龄、来院时间、职务、职称、党派、学历。
选2,删除人员信息。
选3,修改人员信息,可以选择要修改的内容。
选4,查询人员信息,可按编号或姓名查询。
选5,数据存盘。
选6,数据装入。
选7,显示所有信息。
选8,退出。
2.系统功能模块划分与设计
三.详细设计
1.源程序代码
#include
#include
#include
#include
classperson
{
private:
intno;//编号
chartype[20];//职工类型
charname[20];//姓名
charsex[10];//性别
intage;//年龄
chartime[20];//来院时间
charpos[20];//职务
chartechpos[20];//职称
charparty[20];//党派
charstudy[30];//最高学历
person*mynext;//指针语
public:
person(intnnum,charntype[],charnname[],charnsex[],intnage,charntime[],charnpos[],charntechpos[],charnparty[],charnstudy[])
{
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;
}
person(intnnum,charntype[],charnname[],charnsex[],intnage,charntime[],
charnpos[],charntechpos[],charnparty[],charnstudy[],person*next)
//某高校,主要人员有:
在职人员(行政人员、教师、一般员工)、退休人员、返聘人员和临时工。
//现在,需要存储这些人员的人事档案信息:
编号、姓名、性别、年龄、职务、职称、政治面貌、最高学历、来院时间。
{
no=nnum;
strcpy(type,ntype);
strcpy(name,nname);
strcpy(sex,nsex);
age=nage;
strcpy(time,ntime);
strcpy(pos,npos);
strcpy(techpos,ntechpos);
strcpy(party,nparty);
strcpy(study,nstudy);
mynext=next;
}
voidsetnext(person*next)
{
mynext=next;
}
person*getnext()
{
returnmynext;
}
intgetnum()
{
returnno;
}
char*getname()
{
returnname;
}
char*getsex()
{
returnsex;
}
char*getpos()
{
returnpos;
}
char*gettechpos()
{
returntechpos;
}
char*gettime()
{
returntime;
}
char*getparty()
{
returnparty;
}
char*getstudy()
{
returnstudy;
}
intgetage()
{
returnage;
}
voidgetag(intas)
{
age=as;
}
char*gettype()
{
returntype;
}
};
classSchool
{
private:
person*myfirst;
intfirstnum;
public:
School()//无参构造函数
{
myfirst=NULL;//将指针置空
}
School(intnnu,charntyp[],charnnam[],charnse[],intnag,charntim[],charnpo[],charntechpo[],charnpart[],charnstud[])//有参构造函数
{
myfirst=newperson(nnu,ntyp,nnam,nse,nag,ntim,npo,ntechpo,npart,nstud);
}
//在信息最后添加新的信息
voidinsertatlast(intnnum,charntype[],charnname[],charnsex[],intnage,charntime[],charnpos[],charntechpos[],charnparty[],charnstudy[])
{
person*next=myfirst;//定义对象指针并付初值
if(next==NULL)
myfirst=newperson(nnum,ntype,nname,nsex,nage,ntime,npos,ntechpos,nparty,nstudy);
else
{
while(next->getnext()!
=NULL)
next=next->getnext();
next->setnext(newperson(nnum,ntype,nname,nsex,nage,ntime,npos,ntechpos,nparty,nstudy,next->getnext()));
}
}
voidprintf(intr)//获取信息
{
intnage;
charntype[20],nname[20],nsex[20],ntime[20],npos[20],ntechpos[20],nparty[20],nstudy[20];
cout<<"请输入编号为"<cout<<"输入职工分类码[行政人员,教师,一般员工,退休人员,返聘人员,临时工]:
"<cin>>ntype;
cout<<"输入姓名:
"<cin>>nname;
cout<<"输入性别:
"<cin>>nsex;
cout<<"输入年龄:
"<cin>>nage;
cout<<"输入来院时间:
"<cin>>ntime;
cout<<"输入职务[无,科级,处级,地级]:
"<cin>>npos;
cout<<"输入职称[无,初级,中级,高级]:
"<cin>>ntechpos;
cout<<"输入加入党派[群众,中共党员,民主党派]:
"<cin>>nparty;
cout<<"输入学历[小学,初中,高中,大专,大学,硕士,博士]:
"<cin>>nstudy;
insertatlast(r,ntype,nname,nsex,nage,ntime,npos,ntechpos,nparty,nstudy);
}
voidprintf1(person*ahead)//输出信息
{
cout<<"编号:
"<:
left)<getnum()<<"姓名:
"<getname()<cout<<"性别:
"<:
left)<getsex()<<"年龄:
"<getage()<cout<<"职工类型:
"<:
left)<gettype()<<"职务:
"<getpos()<cout<<"职称:
"<:
left)<gettechpos()<<"学历:
"<getstudy()<cout<<"政治面貌:
"<:
left)<getparty()<<"来院时间:
"<gettime()<}
voidprintf()
{
person*ahead=myfirst;
cout<<"编号---姓名---性别---年龄---职工类型---职务---职称---学历---政治面貌---来院时间\n"<while(ahead!
=NULL){cout<:
left)<getnum()<:
left)<getname();cout<:
left)<getsex()<:
left)<getage();cout<:
left)<gettype()<:
left)<getpos();cout<:
left)<gettechpos()<:
left)<getstudy();
cout<:
left)<getparty()<:
left)<gettime()<ahead=ahead->getnext();
}
}
voidadd()//添加新信息
{
inti,a,b;
person*p1=myfirst;
if(p1==NULL)
{
cout<<"请输入编号:
";
cin>>i;
printf(i);
}
else
{
if(p1->getnext()==NULL)//如果p1的后继指针为空,则执行“printf(a)”
{
a=p1->getnum()+1;
printf(a);
}
else
{
while(p1->getnext()!
=NULL)//p1的后继指针不为空,则执行“printf(b)”
{
p1=p1->getnext();
}
b=p1->getnum()+1;
printf(b);
}
}
}
boolremovedatnum()//删除信息
{
intbh;
person*ahead=myfirst;
person*follow=ahead;
cout<<"请输入要删除人员的编号:
";
cin>>bh;
if(ahead==NULL)
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()//按编号查找
{
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;
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;
}
}
boolupperson()//修改信息
{
intiid;
person*ahead=myfirst;
person*follow=ahead;
cout<<"请输入要修改人员的编号:
";
cin>>iid;
if(ahead==NULL)
{
cout<<"无人员信息"<returnfalse;
}
else
{
while(ahead!
=NULL)
{
if(ahead->getnum()==iid)
{
printf1(ahead);
intnu=-1;
for(inti=1;nu!
=0;i++)
{
intml;
intmll;
charty[30];
cout<<"请选择要修改的内容:
"<cout<<"1:
姓名2:
性别3:
年龄4:
职工类型5:
职务"<cout<<"6:
职称7:
学历8:
政治面貌9:
来院时间"<cout<<"选择(1-10):
";
cin>>ml;
switch(ml)
{
case1:
{
cout<<"请输入姓名:
";
cin>>ty;
strcpy(follow->getname(),ty);
};break;
case2:
{
cout<<"请输入性别:
";
cin>>ty;
strcpy(ahead->getsex(),ty);
};break;
case3:
{
cout<<"请输入年龄:
";
cin>>mll;
ahead->getag(mll);
};break;
case4:
{
cout<<"请输入职工类型:
";
cin>>ty;
strcpy(ahead->gettype(),ty);
};break;
case5:
{
cout<<"请输入职务:
";
cin>>ty;
strcpy(ahead->getpos(),ty);
};break;
case6:
{
cout<<"请输入职称:
";
cin>>ty;
strcpy(ahead->gettechpos(),ty);
};break;
case7:
{
cout<<"请输入学历:
";
cin>>ty;
strcpy(ahead->getstudy(),ty);
};break;
case8:
{
cout<<"请输入政治面貌:
";
cin>>ty;
strcpy(ahead->getparty(),ty);
};break;
case9:
{
cout<<"请输入来院时间:
";
cin>>ty;
strcpy(ahead->gettime(),ty);
};break;
}
returntrue;
}
}
else
{
ahead=ahead->getnext();
follow=ahead;
}
}
cout<<"没有此人"<returnfalse;
}
}
voidload()
{
intnnum,nage;
charntype[20],nname[20],nsex[20],ntime[20],npos[20],ntechpos[20],nparty[20],nstudy[20];
ifstreamfperson;
fperson.open("person.txt",ios:
:
in);
while(fperson.good())
{
fperson>>nnum>>ntype>>nname>>nsex>>nage>>ntime>>npos>>ntechpos>>nparty>>nstudy;insertatlast(nnum,ntype,nname,nsex,nage,ntime,npos,ntechpos,nparty,nstudy);
}
fperson.close();
cout<<"\n人员和相关数据已经装入.....\n";
}
voidsave()//保存文件到文件中
{
ofstreamfperson;
fperson.open("person.txt",ios:
:
out);
person*p=myfirst;
while(p)
{
fperson<getnum()<<"\t"<gettype()<<"\t"<getname()<<"\t"<getsex()<<"\t"<getage()<<"\t"<gettime()<<"\t"<getpos()<<"\t"<gettechpos()<<"\t"<getparty()<<"\t"<getstudy();
fperson<p=p->getnext();
}
fperson.close();
cout<<"保存数据已经完成"<}
~School()//析构函数,删除各指针!
{person*next=myfirst,*temp;
while(next!
=NULL)
{
temp=next;
next=next->getnext();
deletetemp;
}
myfirst=NULL;
}
};
voidmain()
{
Schools;//定义对象
intc;
do
{
cout<<"**************************************************"<cout<<"高校人事管理系统"