人事管理系统代码.docx
- 文档编号:4687503
- 上传时间:2022-12-07
- 格式:DOCX
- 页数:14
- 大小:17.26KB
人事管理系统代码.docx
《人事管理系统代码.docx》由会员分享,可在线阅读,更多相关《人事管理系统代码.docx(14页珍藏版)》请在冰豆网上搜索。
人事管理系统代码
#include
#include
#include
structstaff/*定义结构体*/
{
charnum[10];/*编号*/
charname[20];/*姓名*/
charsex[10];/*性别*/
intage;/*年龄*/
charduty[20];/*职务*/
chartitle[20];/*职称*/
charp_landscape[30];/*政治面貌*/
charQualifications[30];/*学历*/
intService_time;/*任职时间*/
charcome_time[30];/*来院时间*/
charcategory[30];/*人员类别*/
}staff[100];
structstaffs;
intn;
voidmenu();
voidprintf_face()/*显示数据结构项目函数*/
{
printf("numnamesexagedutytitilelandscapequilificationservicetimecometimecategory\n");
}
voidprintf_one(structstaffp)/*输出单个数据函数*/
{
printf("%-4s%-7s%-6s%-3d%-11s%-7s%-8s%-18s%-7d%-12s%-3s\n",p.num,p.name,p.sex,p.age,p.duty,p.title,p.p_landscape,p.Qualifications,p.Service_time,e_time,p.category);
}
intload()/*加载函数*/
{
inti=0;
FILE*fp;
if((fp=fopen("text.txt","rb"))==NULL){
return0;exit(0);}
for(i=0;!
feof(fp);i++){/*输出数据到结构体*/
fscanf(fp,"%s%s%s%d%s%s%s%s%d%s%s\n",staff[i].num,staff[i].name,staff[i].sex,&staff[i].age,staff[i].duty,staff[i].title,staff[i].p_landscape,staff[i].Qualifications,&staff[i].Service_time,staff[i].come_time,staff[i].category);}
fclose(fp);
returni;
}
intsearch_data()/*查找单个数据函数*/
{
inti,flag;
chars[30],w0;
system("cls");/*清屏*/
n=load();
do{
fflush(stdin);/*清除缓冲区输入*/
printf("By1)Number2)Name[]\b\b");
w0=getchar();}while(w0<'1'||w0>'2');
if(w0=='1'){/*按编号查找*/
flag=0;
puts("Enterstaff'snumber:
");
scanf("%s",s);
for(i=0;i if(strcmp(s,staff[i].num)==0){ printf_face();printf_one(staff[i]); flag=1;break;} elsecontinue; } if(flag==0)puts("Thestaff'snamedosenotexsist! "); } else{/*按姓名查找*/ flag=0; puts("Enterstaffname: "); scanf("%s",s); for(i=0;i if(strcmp(s,staff[i].name)==0){ printf_face(); printf_one(staff[i]); flag=1;break;} elsecontinue; } if(flag==0)puts("Thestaff'smessagedosenotexsist! "); } returni; } voidsave_all()/*保存所有数据函数*/ { inti; FILE*fp; if((fp=fopen("text.txt","wb"))==NULL){ printf("Cannotopenfile! ");exit(0);} for(i=0;i if(staff[i].age! =0) fprintf(fp,"%s%s%s%d%s%s%s%s%d%s%s\n",staff[i].num,staff[i].name,staff[i].sex,staff[i].age,staff[i].duty,staff[i].title,staff[i].p_landscape,staff[i].Qualifications,staff[i].Service_time,staff[i].come_time,staff[i].category); elsecontinue;} fclose(fp); } inttest(charh[10])/*检查编号是否重复*/ { inti; n=load(); for(i=0;i if(strcmp(h,staff[i].num)==0){ puts("Thenumberhasexsist! pleasenteragain! ");system("pause"); return1;} return0; } voidsave(structstaffp)/*保存单个数据函数*/ { FILE*fp; if((fp=fopen("text.txt","ab+"))==NULL){ printf("Cannotopenfile! ");exit(0);} fprintf(fp,"%s%s%s%d%s%s%s%s%d%s%s\n",p.num,p.name,p.sex,p.age,p.duty,p.title,p.p_landscape,p.Qualifications,p.Service_time,e_time,p.category); printf("Succesefultosavemessage! \n"); fclose(fp); } /*********************************修改模块**********************************/ voidmodify() { intk=0,w0,g; charh[30],w1,w2; loop: g=search_data(); if(g do{ puts("\t\t\tModify: 1)Numder"); puts("\t\t\t2)Name"); puts("\t\t\t3)Sex"); puts("\t\t\t4)Age"); puts("\t\t\t5)Duty"); puts("\t\t\t6)Title"); puts("\t\t\t7)Landscape"); puts("\t\t\t8)Qualifications"); puts("\t\t\t9)Servicetime"); puts("\t\t\t10)Cometime"); puts("\t\t\t11)Category"); printf("Pleasechoice: []\b\b"); scanf("%d",&w0);}while(w0<1||w0>11); switch(w0) {case1: puts("EnterNewNumber: "); scanf("%s",h);strcpy(staff[g].num,h);break; case2: puts("Entername: "); scanf("%s",h);strcpy(staff[g].name,h);break; case3: puts("Entersex: "); scanf("%s",h);strcpy(staff[g].sex,h);break; case4: puts("Enterage: "); scanf("%d",&k);staff[g].age=k;break; case5: puts("Enterduty: "); scanf("%s",h);strcpy(staff[g].duty,h);break; case6: puts("Entertitile: "); scanf("%s",h);strcpy(staff[g].title,h);break; case7: puts("Enterlandscape: "); scanf("%s",h);strcpy(staff[g].p_landscape,h);break; case8: puts("Enterqualiications: "); scanf("%s",h);strcpy(staff[g].Qualifications,h);break; case9: puts("Enterservicetime: "); scanf("%d",&k);staff[g].Service_time=k;break; case10: puts("Entercometime: "); scanf("%s",h);strcpy(staff[g].come_time,h);break; case11: puts("Entercategory: "); scanf("%s",h);strcpy(staff[g].category,h);break; } do{ fflush(stdin);/*清除缓冲区输入*/ printf("Areyousuretosave? 1)Yes2)No[]\b\b"); w1=getchar();}while(w1<'1'||w1>'2'); if(w1=='1'){save_all();puts("Succesefulltosave! ");} } do{ fflush(stdin);/*清除缓冲区输入*/ printf("1)Continuetomodify2)Backtomenu3)Exist[]\b\b"); w2=getchar();}while(w2<'1'||w2>'3'); if(w2=='1')gotoloop; elseif(w2=='2')menu(); elseexit(0); } /************************保存模块******************************/ voidzhun() { charw0; save_all(); printf("Havesaveallmessage! \n"); do{ fflush(stdin);/*清除缓冲区输入*/ printf("1)Backtomenu2)Exist[]\b\b"); w0=getchar();}while(w0<'1'||w0>'2'); if(w0=='1')menu(); elseexit(0); } /*************************查找模块*****************************/ voidsearch() { intk;charw1; loop: k=search_data(); do{ fflush(stdin);/*清除缓冲区输入*/ printf("1)Backtomenu2)Exist3)Continuetosearch[]\b\b"); w1=getchar();}while(w1<'1'||w1>'3'); if(w1=='1')menu(); elseif(w1=='2')exit(0); elsegotoloop; } /***************************增加模块*****************************/ voidadd() { charw0,w1; loop: system("cls"); puts("munder(exmple001): "); scanf("%s",s.num); if(test(s.num))gotoloop;/*编号重复*/ puts("name: "); scanf("%s",s.name); puts("sex(male,female): "); scanf("%s",s.sex); puts("age: "); scanf("%d",&s.age); puts("duty(jiaochoufujiaochoujiangshizhujiaoxueshenghoujin): "); scanf("%s",s.duty); puts("title(NOlowhight): "); scanf("%s",s.title); puts("landscape(partynot): "); scanf("%s",s.p_landscape); puts("hightestqualifications(xiaoxuezhuzhonggaozhongdaxueshuoshigengao): "); scanf("%s",s.Qualifications); puts("servetime: "); scanf("%d",&s.Service_time); puts("cometime(example20050101): "); scanf("%s",e_time); puts("category(massengerteacherstaffenteirlinshigong): "); scanf("%s",s.category); do{ fflush(stdin);/*清除缓冲区输入*/ printf("Saveornot? 1)Yes2)No[]\b\b"); w0=getchar();}while(w0<'1'||w0>'2'); switch(w0-48) { case1: save(s);break; case2: break; } do{ fflush(stdin);/*清除缓冲区输入*/ printf("1)Coninnuetoadd2)Backtomenu3)Exist[]\b\b"); w1=getchar();}while(w1<'1'||w1>'3'); if(w1=='1')gotoloop; elseif(w1=='2')menu(); elseexit(0); } /*******************************删除模块*****************************/ voiddelete_data() { intk;charw0,w1; loop: k=search_data(); if(k do{ fflush(stdin);/*清除缓冲区输入*/ printf("Areyousuretodelete? 1)Yes2)No[]\b\b"); w0=getchar();}while(w0<'1'||w0>'2'); if(w0=='1'){ staff[k].age=0; save_all();puts("Thisstaffmassegehasdeleteed! ");} } do{ fflush(stdin);/*清除缓冲区输入*/ printf("1)Continuetodelete2)Backtomenu3)Exisi[]\b\b"); w1=getchar();}while(w1<'1'||w1>'3'); if(w1=='1')gotoloop; elseif(w1=='2')menu(); elseexit(0); } /********************************统计模块*******************************/ voidstastic() { inti,count;charw0,w1; n=load(); if(n==0){ puts("Nodata! ");getchar();menu();} loop: system("cls"); do{ fflush(stdin);/*清除缓冲区输入*/ printf("By1)Staffonwork2)partymember\n"); printf("3)femalecount4)Highestqualifications[]\b\b"); w0=getchar();}while(w0<'1'||w0>'4'); if(w0=='1'){/*统计在职人员*/ printf_face(); for(i=0,count=0;i if(strcmp(staff[i].category,"enteir")! =0&&strcmp(staff[i].category,"linshigong")! =0){ count++;printf_one(staff[i]);} printf("\t\t\t\tTotal%dmessages",count); } elseif(w0=='2'){/*统计党员*/ printf_face(); for(i=0,count=0;i if(strcmp(staff[i].p_landscape,"party")==0){ count++;printf_one(staff[i]);} printf("\t\t\t\tTotal%dmessages",count); } elseif(w0=='3'){/*统计女工人员*/ printf_face(); for(i=0,count=0;i if(strcmp(staff[i].sex,"femal")==0){ count++;printf_one(staff[i]);} printf("\t\t\t\tTotal%dmessage",count); } else{/*统计高学历人员*/ printf_face(); for(i=0,count=0;i if(strcmp(staff[i].Qualifications,"shuoshi")==0||strcmp(staff[i].Qualifications,"更高")==0){ count++;printf_one(staff[i]);} printf("\t\t\t\tTotal%dmessages",count);} do{ fflush(stdin);/*清除缓冲区输入*/ printf("\n1)Continuetostastic2)Backtomenu3)Exist[]\b\b"); w1=getchar();}while(w1<'1'||w1>'3'); if(w1=='1')gotoloop; elseif(w1=='2')menu(); elseexit(0); } /*******************************排序模块***********************************/ voidsort() { inti,j;charw0,w1; structstaffs1; loop: n=load(); system("cls"); do{ fflush(stdin);/*清除缓冲区输入*/ printf("By1)age2)Cometime[]\b\b"); w0=getchar();}while(w0<'1'||w0>'2'); if(w0=='1'){/*按年龄排序*/ for(i=0;i for(j=i+1;j if(staff[i].age>staff[j].age){ s1=staff[i];staff[i]=staff[j];staff[j]=s1;} } else{/*按来院时间排序*/ for(i=0;i for(j=i+1;j if(strcmp(staff[i].come_time,staff[j].come_time)>0){ s1=staff[i];staff[i]=staff[j];staff[j]=s1;} } printf_face(); for(i=0;i printf_one(staff[i]); do{ fflush(stdin);/*清除缓冲区输入*/ printf("\n1)Backtomenu2)Continue3)Exist[]\b\b"); w1=getchar();}while(w1<'1'||w1>'3'); if(w1=='1')menu(); elseif(w1=='2')gotoloop; elseexit(0); } /********************************浏览模块**************************************/ voidbrowse() { inti;charw0; n=load(); system("cls"); printf_face(); for(i=0;i printf_one(staff[i]); printf("\t\t\t\tTatal(%d)message\n",n); do{ fflush(stdin);/*清除缓冲区输入*/ printf("1)Backtom
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 人事管理系统 代码
![提示](https://static.bdocx.com/images/bang_tan.gif)