源代码-职工薪酬管理系统

合集下载

c语言课程设计职工工资管理系统源代码

c语言课程设计职工工资管理系统源代码

绝对可以完美运行,下面有运行图片#include<stdio.h> //调用库函数#include<string.h> //字符串处理#include<conio.h> //控制台输入输出#include<stdlib.h> //定义杂项函数及内存分配函数#define N 2 //宏定义以3代替N/******************************************************************************函数声明*******************************************************************************/ void enter();int menu();void input();void output();void search();void search_employeeid();void search_name();void edit();void array();void array_basesalary();void array_postwage();void array_totalwage();void statistics();void save();void load();/******************************************************************************职工类型定义*******************************************************************************/ struct employee{char employeeid[10];char name[10];char sex[10];int age;float basesalary;float postwage;float totalwage;};/******************************************************************************职工变量定义******************************************************************************/ struct employee emp[N];struct employee replace;struct employee *p=emp;/*****************************************************************************系统主函数******************************************************************************/ void main(){int c;while(1){printf(" \n\n\n\n");printf(" 欢迎进入职工工资管理系统\n\n\n");printf(" 1 进入管理系统\n\n");printf(" 0 退出\n\n");printf(" \n\n\n\n");printf(" 请输入你选择:\n");scanf("%d",&c);switch(c){case 1:enter();break;case 0:printf(" 谢谢使用!\n");exit(0);}}}/***************************************************************************** 功能:登陆函数,进行密码验证*****************************************************************************/ void enter(){char q;char key[10],password[10]="china";int k=1,i;printf(" 请输入密码:\n");for(i=0;i<5;i++){q=getch();key[i]=q;printf("*");}while(k<=3){if(strncmp(key,password,5)==0){while(1){int a;//system("cls");a=menu();switch(a){case 1:input();break;case 2:output();break;case 3:search();break;case 4:edit();break;case 5:array();break;case 6:load();statistics();break;case 0:printf("\n\n 谢谢使用!\n\n\n\n");save();exit(0);}}}else{k++;printf(" 输入密码错误!请再次输入:");for(i=0;i<5;i++){q=getch();key[i]=q;printf("*");}if(k>2){if(strncmp(password,key,5)==0)continue;else{printf(" 输入密码错误三次,系统将自动退出!\n");exit(0);}}}}}/************************************************************************功能: 主菜单函数参数:a类型:int说明: 变量返回值: a************************************************************************/int menu(){int a ;printf("\n\n");printf("|*****************欢迎进入职工工资管理系统************************|\n");printf("| |\n");printf("| |\n");printf("| 1 职工信息输入|\n");printf("| |\n");printf("| 2 职工信息输出|\n");printf("| |\n");printf("| 3 职工信息查询|\n");printf("| |\n");printf("| 4 职工信息修改|\n");printf("| |\n");printf("| 5 工资排序|\n");printf("| |\n");printf("| 6 工资统计|\n");printf("| |\n");printf("| 0 退出|\n");printf("| |\n");printf("| |\n");printf("|*****************************************************************|\n");printf("\n\n");printf(" 请输入你所选择的选项:");scanf("%d",&a);while(a>6||a<0){printf(" error!\n");printf(" 请重新输入你所选择的选项:");scanf("%d",&a);}return a;}/********************************************************************************* ***功能:职工信息输入********************************************************************************** ***/void input(){int c;p=emp;printf(" 进入职工信息输入模块\n\n\n");for(c=0;c<N;c++,p++){p[c].totalwage=p[c].basesalary+p[c].postwage;printf(" 请输入第%d个职工信息:\n\n",c+1);printf(" 请输入职工号:\n");scanf("%s",p->employeeid);if(strcmp(p->employeeid,"0")!=0){printf(" 请输入职工姓名:\n");scanf("%s",p->name);printf(" 请输入职工性别: \n");scanf("%s",&p->sex);printf(" 请输入职工年龄: \n");scanf("%d",&p->age);printf(" 请输入职工基本工资:\n");scanf("%f",&p->basesalary);printf(" 请输入职工岗位工资:\n");scanf("%f",&p->postwage);printf(" 职工信息输入完成!\n\n");}elsereturn;}save();}/******************************************************************************* 功能:职工信息输出********************************************************************************/ void output(){int j;load();p=emp;printf(" 进入职工信息输出模块\n\n\n");printf("-------------------------------------------------------------------------------\n");printf("| 职工号|姓名|性别|年龄|基本工资|岗位工资|总工资|\n");printf("-------------------------------------------------------------------------------\n");for(j=0;j<N;j++){p[j].totalwage=p[j].postwage+p[j].basesalary;printf("|%10s|%9s|%7s| %5d| %10.2f| %10.2f| %10.2f|\n",p[j].employeeid,p[j].name,p [j].sex,p[j].age,p[j].basesalary,p[j].postwage,p[j].totalwage);printf("-------------------------------------------------------------------------------\n");}printf("\n\n 职工信息输出完成!\n\n");getchar();}/******************************************************************************功能:职工信息查询******************************************************************************/ void search(){int j;while(1){printf("*********************职工信息查询*********************\n\n\n");printf(" 1 按职工号查询\n");printf(" 2 按职工姓名查询\n");printf(" 0 退出该项操作\n");printf("\n\n");while(1){printf(" 请输入你的选择\n");scanf("%d",&j);if(j>=0&&j<=2){switch(j){case 1:search_employeeid();break;case 2:search_name();break;case 0:return;}}else{printf(" 输入错误!\n\n");printf(" 请再次输入你的选择: \n\n");}}}}/******************************************************************************* 功能:按职工号查询函数*******************************************************************************/ void search_employeeid(){char employeeid[10];int k,j;p=emp;printf("*********************按职工号查询职工信息*****************************\n\n\n\n");printf(" 请输入要查询职工的职工号:\n\n");scanf("%s",employeeid);for(k=0;k<N;k++){if(strcmp(employeeid,p->employeeid)==0){j=k;p[j].totalwage=p[j].postwage+p[j].basesalary;printf("-------------------------------------------------------------------------------\n");printf("| 职工号|姓名|性别|年龄|基本工资|岗位工资|总工资|\n");printf("|%10s|%9s|%7s| %5d| %10.2f| %10.2f| %10.2f|\n",p[j].employeeid,p[j].name,p [j].sex,p[j].age,p[j].basesalary,p[j].postwage,p[j].totalwage);printf("-------------------------------------------------------------------------------\n");break;}else{printf(" not found\n");return;}}}/*****************************************************************************功能:按职工姓名查询函数*****************************************************************************/ void search_name(){char name[10];int flog=0;int f,j;p=emp;printf("******************************按职工姓名查询职工信息***********************\n\n\n");printf(" 请输入要查询职工的姓名:\n\n");scanf("%s",name);for(f=0;f<N;f++,p++){if(strcmp(name,p->name)==0){j=f;p[j].totalwage=p[j].postwage+p[j].basesalary;printf("-------------------------------------------------------------------------------\n");printf("| 职工号|姓名|性别|年龄|基本工资|岗位工资|总工资|\n");printf("|%10s|%9s|%7s| %5d| %10.2f| %10.2f| %10.2f|\n",p[j].employeeid,p[j].name,p [j].sex,p[j].age,p[j].basesalary,p[j].postwage,p[j].totalwage);printf("-------------------------------------------------------------------------------\n");break;}else{printf(" not found \n\n");return;}}getchar();}/*******************************************************************************功能:职工信息修改函数*******************************************************************************/ void edit(){char e[10];int g=0,j;char flog;p=emp;printf(" 请输入你要修改职工的职工号:\n");scanf("%s",e);for(g=0;g<N;g++){// if(*e==p[g].employeeid)if(strcmp(e,p->employeeid)==0){j=g;p[j].totalwage=p[j].postwage+p[j].basesalary;printf("-------------------------------------------------------------------------------\n");printf("| 职工号|姓名|性别|年龄|基本工资|岗位工资|总工资|\n");printf("|%10s|%9s|%7s| %5d| %10.2f| %10.2f| %10.2f|\n",p[j].employeeid,p[j].name,p[j].sex ,p[j].age,p[j].basesalary,p[j].postwage,p[j].totalwage);printf("-------------------------------------------------------------------------------\n");printf(" 是否要修改该职工信息?y(是)or n(否)?\n\n");getchar();scanf("%c",&flog);if(flog == 'y'){printf(" 请输入新姓名:\n");scanf("%s",p->name);printf(" 请输入性别:\n");scanf("%s",&p->sex);printf(" 请输入年龄:\n");scanf("%d",&p->age);printf(" 请输入基本工资:\n");scanf("%f",&p->basesalary);printf(" 请输入岗位工资:\n");scanf("%f",&p->postwage);printf(" 修改职工信息成功!\n\n");}if(flog == 'n'){printf(" 退出该项操作!\n\n");return;}save();}if(g==N){printf(" not found \n\n\n");return;}}}/************************************************************************ 功能:职工工资排列函数************************************************************************/ void array(){int j;while(1){printf("*************************工资排序*********************\n\n");printf(" 1 按基本工资排序\n\n");printf(" 2 按岗位工资排序\n\n");printf(" 3 按总工资排列\n\n");printf(" 0 退出\n\n");printf("\n\n\n");while(1){printf(" 请输入你的选择:\n\n");scanf("%d",&j);if(j>=0&&j<=3){switch(j){case 1:array_basesalary();break;case 2:array_postwage();break;case 3:array_totalwage();break;case 0:return;}}else{printf(" 输入错误!\n\n\n");printf(" 请再次输入你的选择:\n\n");}}}}/**************************************************************************功能:按基本工资排列(选择法)***************************************************************************/void array_basesalary(){int i,j,k;p=emp;for(i=0;i<N-1;i++){k=i;for(j=i+1;j<N;j++){if(p[k].basesalary<p[j].basesalary)k=j;}if(k!=i){replace=emp[k];emp[k]=emp[i];emp[i]=replace;}}for(j=0;j<N;j++){p[j].totalwage=p[j].postwage+p[j].basesalary;printf("-------------------------------------------------------------------------------\n");printf("| 职工号|姓名|性别|年龄|基本工资|岗位工资|总工资|\n");printf("|%10s|%9s|%7s| %5d| %10.2f| %10.2f| %10.2f|\n",p[j].employeeid,p[j].name,p [j].sex,p[j].age,p[j].basesalary,p[j].postwage,p[j].totalwage);}printf("-------------------------------------------------------------------------------\n");}/************************************************************************功能:按岗位工资排列(冒泡法)*************************************************************************/void array_postwage(){int i,j;p=emp;for(i=0;i<N;i++){for(j=0;j<N-i;j++){if(p[j].postwage<p[j+1].postwage){replace=emp[j];emp[j]=emp[j+1];emp[j+1]=replace;}}}for(j=0;j<N;j++){p[j].totalwage=p[j].postwage+p[j].basesalary;printf("------------------------------------------------------------------------------\n");printf("| 职工号|姓名|性别|年龄|基本工资|岗位工资|总工资|\n");printf("|%10s|%9s|%7s| %5d| %10.2f| %10.2f| %10.2f|\n",p[j].employeeid,p[j].name,p [j].sex,p[j].age,p[j].basesalary,p[j].postwage,p[j].totalwage);}printf("-------------------------------------------------------------------------------\n");}/************************************************************************功能:按总工资排列(插入法)************************************************************************/void array_totalwage(){int i,j;p=emp;for(i=1;i<N;i++){replace=emp[i];for(j=i-1;j>=0&&p[i].totalwage>p[i].totalwage;j--){emp[j+1]=emp[j];emp[j+1]=replace;}}for(j=N-1;j>=0;j--){p[j].totalwage=p[j].postwage+p[j].basesalary;printf("-------------------------------------------------------------------------------\n");printf("| 职工号|姓名|性别| 年龄|基本工资|岗位工资|总工资|\n");printf("|%10s|%9s|%7s| %5d| %10.2f| %10.2f| %10.2f|\n",p[j].employeeid,p[j].name,p [j].sex,p[j].age,p[j].basesalary,p[j].postwage,p[j].totalwage);}printf("-------------------------------------------------------------------------------\n");}/*************************************************************************功能:工资统计函数**************************************************************************/void statistics(){int z,a=0,b=0,c=0;p=emp;for(z=0;z<N;z++){if(p[z].totalwage>3000){a++;continue;}if(p[z].totalwage>=2000&&p[z].totalwage<=3000){b++;continue;}if(p[z].totalwage<=2000&&p[z].totalwage>0){c++;continue;}}printf(" 总工资在3000元以上的职工人数有:%d\n\n",a);printf(" 总工资在2000元至3000元的职工人数有:%d\n\n",b);printf(" 总工资在2000元以下的职工人数有:%d\n\n",c);getchar();}/*************************************************************************** 功能:导出函数***************************************************************************/ void save(){int k;FILE *fp;p=emp;if((fp=fopen("emp_list","wb"))==NULL){printf(" Create file error!\n");return;}for(k=0;k<N;k++,p++){if(fwrite(p,sizeof(struct employee),1,fp)!=1){printf(" file save error!\n\n");break;}elsecontinue;}getchar();fclose(fp);}/***********************************************************************功能:导入函数***********************************************************************/ void load(){int l;FILE *fp;p=emp;if((fp=fopen("emp_list","rb"))==NULL){printf(" Create file error!\n");exit(0);}for(l=0;l<N;l++,p++){if(fread(p,sizeof(struct employee),1,fp)!=1){printf(" file read error!\n\n");break;}elsecontinue;}getchar();fclose(fp);}下面是实验结果。

员工工资管理系统源代码

员工工资管理系统源代码

#include<stdio.h>#include<string.h> typedefstruct {int basic;// 基本工资int position;// 岗位工资int subsidy;// 津贴intwages;// 奖金int sum;// 总工资}money;typedef struct{char num[20];// 职工号char name[20];// 姓名int age;// 年龄charsex[20];// 性别moneysalary;// 工资}employee;int Print_jinru();// 账号密码输入void Fscan_information();// “职工信息.txt ”文件写入void Print_staff();// 全体员工void Print_empl1(char x[51]);// 按职工号查询void Print_empl2(char s[51]);// 按姓名查询void Print_MainInterface();// 主界面void Print_Interface_1();// 职工信息录入界面void Print_Interface_2();// 职工信息查询界面void Print_Interface_3();// 职工工资排序界面void Print_Interface_4();// 职工总工资void Print_Interface_5();// 文件读出void qsort(int l,int r);// 快速排序voidPrint_delete(int t);// 删除职工信息void Print_Interface_2_1(int t);// 职工信息修改界面int fyanzheng(char s1[],char s2[]);// 密码验证函数employee st[500];// 记录职工信息的函数int n;// 职工总数void main(){int x;employee em;printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@\n");printf("@@@@ 欢迎使用员工工资管理系统@@@@\n");printf("@@@@ 制作人:刘爽@@@@\n");printf("@@@@ 在使用中产生的任何问题,欢迎进行批评指正@@@@\n");printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@\n");printf("\n");printf("\n");printf("\n");if (Print_jinru()){Fscan_information();Print_MainInterface();}else return;}void Fscan_information(){FILE *fp;int i;if ((fp=fopen(" 职工信息.txt","r"))==NULL){printf("cannot open this file\n");return ;}fscanf(fp,"%d",&n);for (i=1;i<=n;i++){fscanf(fp,"%s%s%d%s%d%d%d",st[i].num,st[i].name,&st[i].age,st[i].sex,&st[i].salary.basic,&s t[i].salary.subsidy,&st[i].salary.wages);st[i].salary.sum=st[i].salary.basic+st[i].salary.subsidy+st[i].salary.wages;}fclose(fp);}int fyanzheng(char s1[],char s2[]){FILE *fp1,*fp2;char str1[40]="",str2[40]="",st;int t;if ((fp1=fopen(" 账号验证.in","r"))==NULL){printf("cannot open this file\n");return 0;} t=0;st=fgetc(fp1);while (st!='#'){str1[t]=st;t++;st=fgetc(fp1);}if ((fp2=fopen(" 密码验证.in","r"))==NULL){printf("cannot open this file\n");return 0;}t=0;st=fgetc(fp2);while (st!='#'){str2[t]=st;t++;st=fgetc(fp2);}fclose(fp1);fclose(fp2);if ((strcmp(str1,s1)==0)&&(strcmp(str2,s2)==0)) return 1;elsereturn 0;}int Print_jinru(){int f,d;char x[20],y[20];f=0;d=0;while(1){printf(" 请输入账号:"); scanf("%s",x); getchar();printf(" 请输入密码:"); scanf("%s",y); getchar();f=fyanzheng(x,y);if (d>3)printf(" 错误次数太多,退出系统 \n");return 0;}if (f>0) break;else{printf(" 账号或密码输入错误,请重新输入 \n"); d++;}}printf("\n");printf(" 欢迎进入员工工资管理系统!!!\n");return 1;}else void Print_MainInterface(){int x;printf("\n");printf(" *************************printf("\n");printf("1. 职工信息录入 \n");printf("2. 职工信息查询 \n");printf("3. 职工工资排序 \n");printf("4. 统计职工总工资 \n");printf("5. 保存到文件 \n");printf("6. 退出职工工资系统 \n");printf(" 请选择所需操作 :");scanf("%d",&x);if (x==1)Print_Interface_1();elseif (x==2)Print_Interface_2();elseif (x==3)Print_Interface_3();elseif (x==4)Print_Interface_4();elseif (x==5)Print_Interface_5();华丽的分割线 *********************** **\n");if (x==6){printf(" ******printf("*printf("*printf(" ****** printf(" printf(" printf(" ****** ******** ************ ********************** ******\n");*\n");*\n");*\n");*\n");*\n");\n");printf("233333333333333333333333333333333333333333333333333333\n"); return;} else{printf(" 输入命令错误,返回主菜单 (再乱输入我找人打你啊 )\n");Print_MainInterface(); }}void Print_Interface_1(){n++;if (n>500){printf(" 超出职工最大数 \n");Print_MainInterface();} printf("\n");printf(" ************************* printf("\n");printf(" 新建职工号 :");scanf("%s",st[n].num);printf(" 姓名 :"); scanf("%s",st[n].name);printf(" 年龄 :"); scanf("%d",&st[n].age);printf(" 性别 :"); scanf("%s",st[n].sex);printf(" 基本工资 :"); scanf("%d",&st[n].salary.basic);printf(" 津贴 :"); scanf("%d",&st[n].salary.subsidy);printf(" 奖金 :"); scanf("%d",&st[n].salary.wages);st[n].salary.sum=st[n].salary.basic+st[n].salary.subsidy+st[n].salary.wages; // 妖精的分割线 *************************\n");printf(" 职工信息已成功录入\n");Print_MainInterface();}void Print_Interface_2(){int x;char s[50],y[50];printf("\n");printf(" ************************* 逗比的分割线*********************** **\n");printf("\n");printf("1. 查询所有职工\n");printf("2. 按职工号查询\n"); printf("3. 按职工姓名查询\n");printf("4. 返回主菜单\n"); printf(" 请选择查找方式:\n");scanf("%d",&x);if (x==1)Print_staff();elseif (x==2){printf(" 请输入职工工号:"); scanf("%s",y);Print_empl1(y);}elseif (x==3){printf(" 请输入职工姓名:"); scanf("%s",s);Print_empl2(s);}elseif (x==4)Print_MainInterface();else{printf(" 输入命令错误,返回上一层\n"); Print_Interface_2();}}void Print_Interface_3(){char ch[10];printf("\n");qsort(1,n);printf(" 排序完成!排序后结果请从查询全体职工处查看\n");Print_MainInterface();}void Print_Interface_4(){int i,All=0;char ch[10];printf("\n");for (i=1;i<=n;i++)All=All+st[i].salary.sum;printf(" 所有职工的总工资为:%d\n",All);printf(" 请输入任意字符并敲回车键返回主菜单\n");scanf("%s",&ch);Print_MainInterface();}void Print_Interface_5(){FILE *fp;char ch[10];int i;if ((fp=fopen(" 职工信息.txt","w"))==NULL){printf("cannot open this file\n");return ;}fprintf(fp,"%d\n",n);for (i=1;i<=n;i++)fprintf(fp,"%s %s %d %s %d %d %d\n",st[i].num,st[i].name,st[i].age,st[i].sex,st[i].salary.basic, st[i].salary.subsidy,st[i].salary.wages);fclose(fp);printf("\n");printf(" 已保存到文件\n");printf("\n");printf(" 请输入任意字符返回主菜单\n");scanf("%s",&ch);Print_MainInterface();}void Print_staff(){int i;printf("\n");printf(" ************************* 帅比的分割线*************************" );printf("\n");for (i=1;i<=n;i++){printf(" 职工工号:%s\n",st[i].num);printf(" 姓名:%s\n",st[i].name);printf(" 年龄:%d\n",st[i].age);printf(" 性别:%s\n",st[i].sex);printf(" 基本工资:%d\n",st[i].salary.basic);printf(" 津贴:%d\n",st[i].salary.subsidy);printf(" 奖金:%d\n",st[i].salary.wages);printf(" 总工资:%d\n",st[i].salary.sum); printf("\n");}printf(" 返回上一层\n");Print_Interface_2();}void Print_empl1(char x[]) {int i,t,y,d=0;printf("\n");for (i=1;i<=n;i++)if (strcmp(x,st[i].num)==0) { t=i;d=1;printf(" 职工工号:%s\n",st[i].num);printf(" 姓名:%s\n",st[i].name);printf(" 年龄:%d\n",st[i].age);printf(" 性别:%s\n",st[i].sex);printf(" 基本工资:%d\n",st[i].salary.basic);printf(" 津贴:%d\n",st[i].salary.subsidy); printf(" 奖金:%d\n",st[i].salary.wages);printf(" 总工资:%d\n",st[i].salary.sum); printf("\n");break;}if (d>0){printf(" 如需删除请按2,修改请按1,返回请按0\n"); scanf("%d",&y);if (y==2)Print_delete(t);else if (y==1)Print_Interface_2_1(t);else if (y==0) Print_Interface_2();else{printf(" 输入命令错误,返回上一层(再乱输入我找人打你啊)\n");Print_Interface_2();}}else{printf(" 对不起,查无此人(本系统不包括路人甲乙丙,不要乱输-_-! )\n");printf(" 请重新选择查询方式\n");Print_Interface_2();}}void Print_empl2(char s[]){int i,t,x,y=0;printf("\n");for (i=1;i<=n;i++)if (strcmp(s,st[i].name)==0){t=i;y=1;printf(" 职工工号:%s\n",st[i].num);printf(" 姓名:%s\n",st[i].name);printf(" 年龄:%d\n",st[i].age);printf(" 性别:%s\n",st[i].sex);printf(" 基本工资:%d\n",st[i].salary.basic);printf(" 津贴:%d\n",st[i].salary.subsidy);printf(" 奖金:%d\n",st[i].salary.wages);printf(" 总工资:%d\n",st[i].salary.sum);printf("\n");break;}if (y>0){printf(" 如需删除请按2,修改请按1,返回请按0(再乱输入我找人打你啊)\n");scanf("%d",&x);if (x==2)Print_delete(t);elseif (x==1) Print_Interface_2_1(t);else if (x==0) Print_Interface_2();else{ printf(" 输入命令错误,返回上一层\n"); Print_Interface_2();}}else{printf(" 对不起,查无此人(本系统不包括路人甲乙丙,不要乱输-_-! )\n");printf(" 请重新选择查询方式\n");Print_Interface_2();}}void Print_delete(int t){st[t].salary.sum=0;qsort(1,n);n--;printf(" 已删除该职工并排序,自动返回主菜单\n");Print_MainInterface();}void Print_Interface_2_1(int t){int x;printf("\n");printf(" 请选择以下选项:\n");printf("1. 职工号\n");printf("2. 姓名\n");printf("3. 年龄\n");printf("4. 性别\n");printf("5. 基本工资\n");printf("6. 津贴\n");printf("7. 奖金\n");printf("8. 返回上一层\n");printf("9. 返回主菜单\n");scanf("%d",&x);switch(x){case 1:scanf("%s",st[t].num);break;case 2: scanf("%s",st[t].name);break;case 3: scanf("%d",st[t].age);break;case 4: scanf("%s",st[t].sex);break;case 5: scanf("%s",st[t].salary.basic);break;case 6: scanf("%d",st[t].salary.subsidy);break;case 7: scanf("%d",st[t].salary.wages);break;} st[t].salary.sum=st[t].salary.basic+st[t].salary.subsidy+st[t].salary.wages;if (x<=8)Print_Interface_2();elseif (x==9) Print_MainInterface();}void qsort(int l,int r){int i,j,mid;employee tt;i=l;j=r;mid=st[(l+r)/2].salary.sum;do{while (st[i].salary.sum>mid) i++;while (st[j].salary.sum<mid) j--;if (i<=j){tt=st[i];st[i]=st[j];st[j]=tt;i++;j--;}}while(i<=j);if (i<r) qsort(i,r);if (l<j) qsort(l,j);。

员工工资管理系统源代码

员工工资管理系统源代码

#include<stdio.h>#include<string.h>typedef struct{int basic;//基本工资int position;//岗位工资int subsidy;//津贴int wages;//奖金int sum;//总工资}money;typedef struct{char num[20];//职工号char name[20];//姓名int age;//年龄char sex[20];//性别money salary;//工资}employee;int Print_jinru();//账号密码输入void Fscan_information();//“职工信息.txt”文献写入void Print_staff();//全体员工void Print_empl1(char x[51]);//按职工号查询void Print_empl2(char s[51]);//按姓名查询void Print_MainInterface();//主界面void Print_Interface_1();//职工信息录入界面void Print_Interface_2();//职工信息查询界面void Print_Interface_3();//职工工资排序界面void Print_Interface_4();//职工总工资void Print_Interface_5();//文献读出void qsort(int l,int r);//快速排序void Print_delete(int t);//删除职工信息void Print_Interface_2_1(int t);//职工信息修改界面int fyanzheng(char s1[],char s2[]);//密码验证函数employee st[500];//记录职工信息的函数int n;//职工总数void main(){int x;employee em;printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@\n");printf("@@@@ 欢迎使用员工工资管理系统@@@@\n");printf("@@@@ 制作人:刘爽@@@@\n");printf("@@@@在使用中产生的任何问题, 欢迎进行批评指正@@@@\n");printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");printf("\n");printf("\n");printf("\n");if (Print_jinru()){Fscan_information();Print_MainInterface();}else return;}void Fscan_information(){FILE *fp;int i;if ((fp=fopen("职工信息.txt","r"))==NULL){printf("cannot open this file\n");return ;}fscanf(fp,"%d",&n);for (i=1;i<=n;i++){fscanf(fp,"%s%s%d%s%d%d%d",st[i].num,st[i].name,&st[i].age,st[i].sex,&st[i].salary.basic,&st[i].salary.subsidy,&st[i].salary.wages);st[i].salary.sum=st[i].salary.basic+st[i].salary.subsidy+st[i].salary.wages;}fclose(fp);}int fyanzheng(char s1[],char s2[]){FILE *fp1,*fp2;char str1[40]="",str2[40]="",st;int t;if ((fp1=fopen("账号验证.in","r"))==NULL){printf("cannot open this file\n");return 0;}t=0;st=fgetc(fp1);while (st!='#'){str1[t]=st;t++;st=fgetc(fp1);}if ((fp2=fopen("密码验证.in","r"))==NULL){printf("cannot open this file\n");return 0;}t=0;st=fgetc(fp2);while (st!='#'){str2[t]=st;t++;st=fgetc(fp2);}fclose(fp1);fclose(fp2);if ((strcmp(str1,s1)==0)&&(strcmp(str2,s2)==0)) return 1;elsereturn 0;}int Print_jinru(){int f,d;char x[20],y[20];f=0;d=0;while(1){printf("请输入账号:");scanf("%s",x);getchar();printf("请输入密码:");scanf("%s",y);getchar();f=fyanzheng(x,y);if (d>3){printf("错误次数太多, 退出系统\n");return 0;}if (f>0) break;else{printf("账号或密码输入错误, 请重新输入\n");d++;}}printf("\n");printf("欢迎进入员工工资管理系统\n");return 1;}void Print_MainInterface(){int x;printf("\n");printf("*************************华丽的分割线*************************\n");printf("\n");printf("1.职工信息录入\n");printf("2.职工信息查询\n");printf("3.职工工资排序\n");printf("4.记录职工总工资\n");printf("5.保存到文献\n");printf("6.退出职工工资系统\n");printf("请选择所需操作:");scanf("%d",&x);if (x==1)Print_Interface_1();elseif (x==2)Print_Interface_2();elseif (x==3)Print_Interface_3();elseif (x==4)Print_Interface_4();elseif (x==5)Print_Interface_5();elseif (x==6){printf(" ****** **** **** * * ***** * *\n");printf("* * * * * * * * * * *\n");printf("* * * * * * * * * * *\n");printf(" ****** ******** ******** ** * * * *\n");printf(" * * * ** * * * *\n");printf(" * * * ** * * * *\n");printf(" ****** **** **** ** ***** ***** \n");// printf("333333\n");return;}else{printf("输入命令错误, 返回主菜单(再乱输入我找人打你啊)\n");Print_MainInterface();}}void Print_Interface_1(){n++;if (n>500){printf("超过职工最大数\n");Print_MainInterface();}printf("\n");printf("*************************妖精的分割线*************************\n"); printf("\n");printf("新建职工号:");scanf("%s",st[n].num);printf("姓名:");scanf("%s",st[n].name);printf("年龄:");scanf("%d",&st[n].age);printf("性别:");scanf("%s",st[n].sex);printf("基本工资:");scanf("%d",&st[n].salary.basic);printf("津贴:");scanf("%d",&st[n].salary.subsidy);printf("奖金:");scanf("%d",&st[n].salary.wages);st[n].salary.sum=st[n].salary.basic+st[n].salary.subsidy+st[n].salary.wages;printf("职工信息已成功录入\n");Print_MainInterface();}void Print_Interface_2(){int x;char s[50],y[50];printf("\n");printf("*************************逗比的分割线*************************\n");printf("\n");printf("1.查询所有职工\n");printf("2.按职工号查询\n");printf("3.按职工姓名查询\n");printf("4.返回主菜单\n");printf("请选择查找方式:\n");scanf("%d",&x);if (x==1)Print_staff();elseif (x==2){printf("请输入职工工号:");scanf("%s",y);Print_empl1(y);}elseif (x==3){printf("请输入职工姓名:");scanf("%s",s);Print_empl2(s);}elseif (x==4)Print_MainInterface();else{printf("输入命令错误, 返回上一层\n");Print_Interface_2();}}void Print_Interface_3(){char ch[10];printf("\n");qsort(1,n);printf("排序完毕!排序后结果请从查询全体职工处查看\n");Print_MainInterface();}void Print_Interface_4(){int i,All=0;char ch[10];printf("\n");for (i=1;i<=n;i++)All=All+st[i].salary.sum;printf("所有职工的总工资为:%d\n",All);printf("请输入任意字符并敲回车键返回主菜单\n");scanf("%s",&ch);Print_MainInterface();}void Print_Interface_5(){FILE *fp;char ch[10];int i;if ((fp=fopen("职工信息.txt","w"))==NULL){printf("cannot open this file\n");return ;}fprintf(fp,"%d\n",n);for (i=1;i<=n;i++)fprintf(fp,"%s %s %d %s %d %d %d\n",st[i].num,st[i].name,st[i].age,st[i].sex,st[i].salary.basic,st[i].salary.subsidy,st[i].salary.wages);fclose(fp);printf("\n");printf("已保存到文献\n");printf("\n");printf("请输入任意字符返回主菜单\n");scanf("%s",&ch);Print_MainInterface();}void Print_staff(){int i;printf("\n");printf("*************************帅比的分割线*************************");printf("\n");for (i=1;i<=n;i++){printf("职工工号:%s\n",st[i].num);printf("姓名:%s\n",st[i].name);printf("年龄:%d\n",st[i].age);printf("性别:%s\n",st[i].sex);printf("基本工资:%d\n",st[i].salary.basic);printf("津贴:%d\n",st[i].salary.subsidy);printf("奖金:%d\n",st[i].salary.wages);printf("总工资:%d\n",st[i].salary.sum);printf("\n");}printf("返回上一层\n");Print_Interface_2();}void Print_empl1(char x[]){int i,t,y,d=0;printf("\n");for (i=1;i<=n;i++)if (strcmp(x,st[i].num)==0){t=i;d=1;printf("职工工号:%s\n",st[i].num);printf("姓名:%s\n",st[i].name);printf("年龄:%d\n",st[i].age);printf("性别:%s\n",st[i].sex);printf("基本工资:%d\n",st[i].salary.basic);printf("津贴:%d\n",st[i].salary.subsidy);printf("奖金:%d\n",st[i].salary.wages);printf("总工资:%d\n",st[i].salary.sum);printf("\n");break;}if (d>0){printf("如需删除请按2,修改请按1,返回请按0\n");scanf("%d",&y);if (y==2)Print_delete(t);elseif (y==1)Print_Interface_2_1(t);elseif (y==0)Print_Interface_2();else{printf("输入命令错误, 返回上一层(再乱输入我找人打你啊)\n");Print_Interface_2();}}else{printf("对不起,查无此人(本系统不涉及路人甲乙丙, 不要乱输-_-!)\n");printf("请重新选择查询方式\n");Print_Interface_2();}}void Print_empl2(char s[]){int i,t,x,y=0;printf("\n");for (i=1;i<=n;i++)if (strcmp(s,st[i].name)==0){t=i;y=1;printf("职工工号:%s\n",st[i].num);printf("姓名:%s\n",st[i].name);printf("年龄:%d\n",st[i].age);printf("性别:%s\n",st[i].sex);printf("基本工资:%d\n",st[i].salary.basic);printf("津贴:%d\n",st[i].salary.subsidy);printf("奖金:%d\n",st[i].salary.wages);printf("总工资:%d\n",st[i].salary.sum);printf("\n");break;}if (y>0){printf("如需删除请按2,修改请按1,返回请按0(再乱输入我找人打你啊)\n");scanf("%d",&x);if (x==2)Print_delete(t);elseif (x==1)Print_Interface_2_1(t);elseif (x==0)Print_Interface_2();else{printf("输入命令错误, 返回上一层\n");Print_Interface_2();}}else{printf("对不起,查无此人(本系统不涉及路人甲乙丙, 不要乱输-_-!)\n");printf("请重新选择查询方式\n");Print_Interface_2();}}void Print_delete(int t){st[t].salary.sum=0;qsort(1,n);n--;printf("已删除该职工并排序, 自动返回主菜单\n");Print_MainInterface();}void Print_Interface_2_1(int t){int x;printf("\n");printf("请选择以下选项:\n");printf("1.职工号\n");printf("2.姓名\n");printf("3.年龄\n");printf("4.性别\n");printf("5.基本工资\n");printf("6.津贴\n");printf("7.奖金\n");printf("8.返回上一层\n");printf("9.返回主菜单\n");scanf("%d",&x);switch(x){case 1:scanf("%s",st[t].num);break;case 2:scanf("%s",st[t].name);break;case 3:scanf("%d",st[t].age);break;case 4:scanf("%s",st[t].sex);break;case 5:scanf("%s",st[t].salary.basic);break;case 6:scanf("%d",st[t].salary.subsidy);break;case 7:scanf("%d",st[t].salary.wages);break;}st[t].salary.sum=st[t].salary.basic+st[t].salary.subsidy+st[t].salary.wages;if (x<=8)Print_Interface_2();elseif (x==9)Print_MainInterface();}void qsort(int l,int r){int i,j,mid;employee tt;i=l;j=r;mid=st[(l+r)/2].salary.sum;do{while (st[i].salary.sum>mid) i++;while (st[j].salary.sum<mid) j--;if (i<=j){tt=st[i];st[i]=st[j];st[j]=tt;i++;j--;}}while(i<=j);if (i<r) qsort(i,r);if (l<j) qsort(l,j);}。

教职工工资信息管理系统源代码

教职工工资信息管理系统源代码
break;
case 5: output();/*用户选择5号菜单,程序执行输出数据录的函数*/
break;
case 6: save();/*用户选择6号菜单,程序执行保存数据的函数*/
break;
case 7: read();/*用户选择7号菜单,程序执行读取文件的函数*/
break;
case 8: sort();/*用户选择8号菜单,程序执行排序数据的函数*/
printf("请选择(0--8):");
}
/*添加函数*/
void append()
{int number,i;
FILE *fp;
char filepn[MAX_NUM];
system("cls");
printf("\n您选择的是添加职工!\n");
printf("\n请输入本次添加的职工人数: ");
char findName[30];
system("cls");
printf("\n您选择的是档案查询!\n");
printf(" *****************************请选择查询方式********************************\n");
printf("\t \t 1--按编号查找;\t \t \t \t 2--按姓名查找\n"); /*以下可以修改为子菜单方式:1--按编号查找,2--按姓名查找*/
}
work[MAX_NUM];
void main()
{
void showmenu(); /*声明主菜单函数*/

c语言课程实践《职工工资管理系统》源代码

c语言课程实践《职工工资管理系统》源代码
else if(mn==0)
fprintf(report,"\n\tAverage wage\t\t%.2f\t\t0.00\t\t%.2f",(float)(fsum/fn),(float)(fsum/fn));//如果男性人数是0,则只输出女性的平均工资
else
fprintf(report,"\n\tAverage wage\t\t%.2f\t\t%.2f\t\t%.2f",(float)(fsum/fn),(float)(msum/mn),(float)((fsum+msum)/(fn+mn)));//如果男女都不为0的话,那么则把平均工资都输出
p=temp;//temp指针变量往后移
temp=temp->next;//temp指针变量往后移
}
if(fnum==temp->num)//如果找到了,就执行下面的程序
{
find=1;//标记变量:find是1的时候说明找到,0则说明没找到
printf("\n");
unsigned int age; // 年龄
unsigned long telephone,wage,num; // 电话,工资,编号
struct workers *next; // 指向下一条记录的指针(链表使用)
};
struct workers *head,*bottom,*temp,*p;//定义指向结构体的指针变量
insert();//调用创建链表,录入信息的函数
}
getchar();//输入任意字符
return main();//返回主调函数
}

企业职工工资管理系统_附代码

企业职工工资管理系统_附代码

#include <stdio.h>#include <string.h> #include <stdlib.h>#define E 50void Creat();void Creat2();void Creat3();void Chakan();void Chakan2();void Chakan3();void add();void del();void xiugai();void findnum();void findname(); void findname2(); void findshijian(); void gengxin();void findtime();void jisuan();void jisuan2();void jisuan3();void pai();void put();int number;float sum;struct employee{char num[5];char name[10];char sex[3];char shengri[10];char degree[10];int nianxian; } emp[E];struct emp_kao{char num[5];char name[10];char riqi[10];int tianshu;}emp_kaoqin[E];struct emp_gong{char num[5];char name[10];floatzhiwugongzi,zhiwubutie,zhufangbutie,kaoqin,yingfagongzi,yanglaobaoxian,zhufang,shifagongzi; }emp_gongzi[E];void main (){char YN[3];char *Y="Y";char *N="N";int i;int LL;//put();printf(" ********企业职工工资管理系统********\n");kaishi: printf("\n创建文件(请选【1】)\n 操作文件(请选【2】)\n 查看文件(请选【3】)\n 更新文件(请选【4】)\n");scanf("%d",&LL);if(LL==1){Creat();printf("\n创建考勤记录文件??Y/N(注意大写)\n");scanf("%s",&YN);if (strcmp(YN,Y) == 0){Creat2();printf("\n创建工资信息文件??Y/N(注意大写)\n");scanf("%s",&YN);if (strcmp(YN,Y) == 0){Creat3();goto kaishi;}else{goto kaishi;}}else{goto kaishi;}}else if (LL==2){caozuo: printf("增加人事基本信息(请选【1】)\n");printf("删除人事基本信息(请选【2】)\n");printf("修改人事基本信息(请选【3】)\n");printf("查询人事基本信息(请选【4】)\n");printf("输出某月份的职工工资信息(请选【5】)\n");printf("职工工资信息进行统计(请选【6】)\n");printf("退出(请选【7】)\n");scanf("%d",&LL);if (LL==1){add();goto caozuo;}else if (LL==2){shanchu :del();printf(" 是否继续删除??(注意大写)\n");scanf("%s",&YN);if (strcmp(YN,Y) == 0){goto shanchu;}else if (strcmp(YN,N) == 0){goto caozuo;}else{printf("操作错误!!返回->\n");goto caozuo;}}else if (LL==3){xiugai:xiugai();printf(" 是否继续修改??(注意大写)\n");scanf("%s",&YN);if (strcmp(YN,Y) == 0){goto xiugai;}else if (strcmp(YN,N) == 0){goto caozuo;}else{printf("操作错误!!返回->\n");goto caozuo;}}else if (LL==4){chaxun: printf("编号查询(请选【1】)\n 全名查询(请选【2】)\n 姓查询(请选【3】)\n 月份查询(请选【4】)\n 退出(请选【5】)\n\n");scanf("%d",&LL);if (LL==1){findnum();goto chaxun;}if (LL==2){findname();goto chaxun;}if (LL==3){findname2();goto chaxun;}if (LL==4){findtime();goto chaxun;}if(LL==5){goto caozuo;}else{printf("操作错误!!返回->\n");goto caozuo;}}if(LL==5){findshijian();goto caozuo;}if (LL==6){jisuan: printf("职工人数...(请选【1】)\n 平均实发工资(请选【2】)\n低于平均工资(请选【3】)\n 退出(请选【4】)\n");scanf("%d",&LL);if (LL==1){jisuan();goto jisuan;}else if (LL==2){jisuan2();goto jisuan;}else if (LL==3){jisuan3();goto jisuan;}else if (LL==4){goto caozuo;}else{printf("操作错误!!返回->\n");goto jisuan;}}if (LL==7){goto kaishi;}}else if(LL==3){chakan: printf("\n查看基本信息文件(请选【1】)\n查看考勤记录文件(请选【2】)\n查看工资信息文件(请选【3】)\n退出(请选【4】)\n");scanf("%d",&LL);if (LL==1){Chakan();goto chakan;}else if(LL==2){Chakan2();goto chakan;}else if(LL==3){Chakan3();goto chakan;}else if(LL==4){goto kaishi;}else{printf("操作错误!!返回->\n");goto chakan;}}else if (LL==4){gengxin();goto kaishi;}int aa;scanf("%d",&aa);}void Creat(){FILE *fp;int i,j;printf("创建【一】基本信息文件.....\n");printf(" 请您输入创建人数:");scanf("%d",&number);if ((fp = fopen("number.dat", "wb+")) == NULL){printf("Can't open file\n");exit(0);}fwrite(&number,sizeof(int),1,fp);fclose(fp);if ((fp = fopen("employee.dat", "wb+")) == NULL){printf("Can't open file\n");exit(0);}printf(" 编号姓名性别出生日期职称工作年限\n");for (i=0;i<number;i++){j=i+1;printf("->【%d】",j);scanf(" %s %s %s %s %s %d",emp[i].num,emp[i].name,emp[i].sex,emp[i].sh engri,emp[i].degree,&emp[i].nianxian);printf("\n");}pai();fwrite(emp,sizeof(struct employee),number, fp);fclose(fp);if ((fp = fopen("employee.dat", "rb+")) == NULL){printf("Can't open file\n");exit(0);}printf(" 创建成功!!\n");printf(" 编号姓名性别出生日期职称工作年限\n");for (i = 0; fread(&emp[i],sizeof(struct employee),1,fp) == 1 ; i++){printf(" %s %s %s %s %s %d\n",emp[i].num,emp[i].name,emp[i].s ex,emp[i].shengri,emp[i].degree,emp[i].nianxian);}fclose(fp);}void Creat2(){FILE *fp,*fp2;int i,j;printf("创建【二】考勤记录文件.....\n");printf(" 目前需创建人数:%d\n",number);printf(" 编号姓名日期出勤次数\n",number);if ((fp = fopen("employee.dat", "rb")) == NULL){printf("Can't open file\n");exit(0);}fread(emp,sizeof(struct employee),number, fp);if ((fp2 = fopen("emp_kao.dat", "wb")) == NULL){printf("Can't open file\n");exit(0);}for (i=0;i<number;i++){j=i+1;strcpy(emp_kaoqin[i].name, emp[i].name);strcpy(emp_kaoqin[i].num, emp[i].num);printf("->【%d】%s %s",j,emp_kaoqin[i].num,emp_kaoqin[i].name);scanf(" %s %d",emp_kaoqin[i].riqi,&emp_kaoqin[i].tianshu);printf("\n");}fwrite(emp_kaoqin, sizeof(struct emp_kao),number, fp2);fclose(fp);fclose(fp2);if ((fp = fopen("emp_kao.dat", "rb+")) == NULL){printf("Can't open file\n");exit(0);}printf(" 创建成功!!\n");printf(" 编号姓名日期出勤天数\n");for (i = 0; fread(&emp_kaoqin[i],sizeof(struct emp_kao),1,fp) == 1 ; i++){printf(" %s %s %s %d\n",emp_kaoqin[i].num,emp_kaoqin[i].name,emp_ka oqin[i].riqi,emp_kaoqin[i].tianshu);}fclose(fp);}void Creat3(){FILE *fp,*fp2,*fp3;int i,j;char *zhugong="助工";char *gongchengshi="工程师";char *gaojigongchengshi="高级工程师";floatzhiwugongzi,zhiwubutie,zhufangbutie,kaoqin,yingfagongzi,yanglaobaoxian,zhufang,shifagongzi;printf("创建【三】工资信息文件.....\n");printf(" 共创建人数:%d\n",number);if ((fp = fopen("employee.dat", "rb")) == NULL){printf("Can't open file\n");exit(0);}fread(emp,sizeof(struct employee),number, fp);if ((fp2 = fopen("emp_kao.dat", "rb")) == NULL){printf("Can't open file\n");exit(0);}fread(emp_kaoqin,sizeof(struct emp_kao),number, fp2);if ((fp3 = fopen("emp_gong.dat", "wb")) == NULL){printf("Can't open file\n");exit(0);}for (i=0;i<number;i++){j=i+1;strcpy(emp_gongzi[i].name, emp[i].name);strcpy(emp_gongzi[i].num, emp[i].num);floatzhiwugongzi,zhiwubutie,zhufangbutie,kaoqin,yingfagongzi,yanglaobaoxian,zhufang,shifagongzi; if (strcmp(emp[i].degree,zhugong) == 0){zhiwugongzi=720*(1+(emp[i].nianxian*2)/100);zhiwubutie=zhiwugongzi*25/100;zhufangbutie=(zhiwugongzi+zhiwubutie)*25/100;if (emp_kaoqin[i].tianshu>=20){kaoqin=10*emp_kaoqin[i].tianshu;}else if ((emp_kaoqin[i].tianshu>=10)&&(emp_kaoqin[i].tianshu<20)){kaoqin=5*emp_kaoqin[i].tianshu;}else{kaoqin=0;}yingfagongzi=zhiwugongzi+zhiwubutie+zhufangbutie+kaoqin;yanglaobaoxian=(zhiwugongzi+zhiwubutie)*0.1;zhufang=yingfagongzi*0.05;shifagongzi=yingfagongzi-yanglaobaoxian-zhufang;emp_gongzi[i].zhiwugongzi=zhiwugongzi;emp_gongzi[i].zhiwubutie=zhufangbutie;emp_gongzi[i].zhufangbutie=zhufangbutie;emp_gongzi[i].kaoqin=kaoqin;emp_gongzi[i].yingfagongzi=yingfagongzi;emp_gongzi[i].yanglaobaoxian=yanglaobaoxian;emp_gongzi[i].zhufang=zhufang;emp_gongzi[i].shifagongzi=shifagongzi;}if (strcmp(emp[i].degree,gongchengshi) == 0){zhiwugongzi=960*(1+(emp[i].nianxian*3)/100);zhiwubutie=zhiwugongzi*25/100;zhufangbutie=(zhiwugongzi+zhiwubutie)*25/100;if (emp_kaoqin[i].tianshu>=20){kaoqin=10*emp_kaoqin[i].tianshu;}else if ((emp_kaoqin[i].tianshu>=10)&&(emp_kaoqin[i].tianshu<20)) {kaoqin=5*emp_kaoqin[i].tianshu;}else{kaoqin=0;}yingfagongzi=zhiwugongzi+zhiwubutie+zhufangbutie+kaoqin;yingfagongzi=zhiwugongzi+zhiwubutie+zhufangbutie+kaoqin;yanglaobaoxian=(zhiwugongzi+zhiwubutie)*0.1;zhufang=yingfagongzi*0.05;shifagongzi=yingfagongzi-yanglaobaoxian-zhufang;emp_gongzi[i].zhiwugongzi=zhiwugongzi;emp_gongzi[i].zhiwubutie=zhufangbutie;emp_gongzi[i].zhufangbutie=zhufangbutie;emp_gongzi[i].kaoqin=kaoqin;emp_gongzi[i].yingfagongzi=yingfagongzi;emp_gongzi[i].yanglaobaoxian=yanglaobaoxian;emp_gongzi[i].zhufang=zhufang;emp_gongzi[i].shifagongzi=shifagongzi;}if (strcmp(emp[i].degree,gaojigongchengshi) == 0){zhiwugongzi=1350*(1+(emp[i].nianxian*5)/100);zhiwubutie=zhiwugongzi*25/100;zhufangbutie=(zhiwugongzi+zhiwubutie)*25/100;if (emp_kaoqin[i].tianshu>=20){kaoqin=10*emp_kaoqin[i].tianshu;}else if ((emp_kaoqin[i].tianshu>=10)&&(emp_kaoqin[i].tianshu<20)) {kaoqin=5*emp_kaoqin[i].tianshu;}else{kaoqin=0;}yingfagongzi=zhiwugongzi+zhiwubutie+zhufangbutie+kaoqin;yingfagongzi=zhiwugongzi+zhiwubutie+zhufangbutie+kaoqin;yanglaobaoxian=(zhiwugongzi+zhiwubutie)*0.1;zhufang=yingfagongzi*0.05;shifagongzi=yingfagongzi-yanglaobaoxian-zhufang;emp_gongzi[i].zhiwugongzi=zhiwugongzi;emp_gongzi[i].zhiwubutie=zhufangbutie;emp_gongzi[i].zhufangbutie=zhufangbutie;emp_gongzi[i].kaoqin=kaoqin;emp_gongzi[i].yingfagongzi=yingfagongzi;emp_gongzi[i].yanglaobaoxian=yanglaobaoxian;emp_gongzi[i].zhufang=zhufang;emp_gongzi[i].shifagongzi=shifagongzi;}printf("\n");}fwrite(emp_gongzi, sizeof(struct emp_gong),number, fp3);fclose(fp);fclose(fp2);fclose(fp3);if ((fp = fopen("emp_gong.dat", "rb+")) == NULL){printf("Can't open file\n");exit(0);}printf(" 自动创建成功!!\n\n\n");for (i = 0; fread(&emp_gongzi[i],sizeof(struct emp_gong),1,fp) == 1 ; i++){printf("编号%s 姓名%s 职务工资%f 职务补贴%f 住房补贴%f\n考勤管理奖%f 应发工资%f 养老保险%f 住房公积金%f 实发工资%f\n",emp_gongzi[i].num,emp_gongzi[i].name,emp_gongzi[i].zhiwugongzi,emp_gongzi[i].zhiwubutie, emp_gongzi[i].zhufangbutie,emp_gongzi[i].kaoqin,emp_gongzi[i].yingfagongzi,emp_gongzi[i].yanglaobaoxian,emp_gongzi[i].zhufang,emp_gongzi[i].shifagongzi);printf("\n\n\n");}fclose(fp);}void pai(){int i,j;int t;char temp[10];for (i=0;i<number;i++){for (j=i+1;j<number;j++){if (strcmp(emp[i].num,emp[j].num)>0){strcpy(temp, emp[i].num);strcpy(emp[i].num,emp[j].num);strcpy( emp[j].num,temp);strcpy(temp, emp[i].name);strcpy(emp[i].name,emp[j].name);strcpy(emp[j].name,temp);strcpy(temp, emp[i].sex);strcpy(emp[i].sex,emp[j].sex);strcpy( emp[j].sex,temp);strcpy(temp, emp[i].shengri);strcpy(emp[i].shengri,emp[j].shengri);strcpy( emp[j].shengri,temp);strcpy(temp, emp[i].degree);strcpy(emp[i].degree,emp[j].degree);strcpy( emp[j].degree,temp);t=emp[i].nianxian;emp[i].nianxian=emp[j].nianxian;emp[j].nianxian=t;}}}}void put(){printf(" ********企业职工工资管理系统********\n");printf("创建:\n【一】基本信息文件\n【二】考勤记录文件(每个月1份)\n【三】工资信息文件(每个月1份)\n");printf("操作:\n");printf("【1】增加人事基本信息|\n");printf("【2】删除人事基本信息|\n");printf("【3】修改人事基本信息|\n");printf("【4】查询人事基本信息|\n");printf("【5】输出某月份的职工的工资信息|\n");printf("【6】职工工资信息进行统计|\n");}void Chakan(){FILE *fp;int i;if ((fp = fopen("employee.dat", "rb+")) == NULL){printf("Can't open file\n");exit(0);}printf(" 查看成功!!\n");printf(" 编号姓名性别出生日期职称工作年限\n");for (i = 0; fread(&emp[i],sizeof(struct employee),1,fp) == 1 ; i++){printf(" %s %s %s %s %s %d\n",emp[i].num,emp[i].name,emp[i].s ex,emp[i].shengri,emp[i].degree,emp[i].nianxian);}fclose(fp);//goto chakan;}void Chakan2(){FILE *fp;int i;char name[15];printf("请您输入要查看的考勤文件:\n");scanf("%s",name);if ((fp = fopen(name, "rb+")) == NULL){printf("Can't open file\n");exit(0);}printf(" 查看成功!!\n");printf(" 编号姓名日期出勤天数\n");for (i = 0; fread(&emp_kaoqin[i],sizeof(struct emp_kao),1,fp) == 1 ; i++){printf(" %s %s %s %d\n",emp_kaoqin[i].num,emp_kaoqin[i].name,emp_ka oqin[i].riqi,emp_kaoqin[i].tianshu);}fclose(fp);//goto chakan;}void Chakan3(){FILE *fp;int i;char name[15];printf("请您输入要查看的工资文件:\n");scanf("%s",name);if ((fp = fopen(name, "rb+")) == NULL){printf("Can't open file\n");exit(0);}printf(" 查看成功!!\n");for (i = 0; fread(&emp_gongzi[i],sizeof(struct emp_gong),1,fp) == 1 ; i++){printf("编号%s 姓名%s 职务工资%f 职务补贴%f 住房补贴%f\n考勤管理奖%f 应发工资%f 养老保险%f 住房公积金%f 实发工资%f\n",emp_gongzi[i].num,emp_gongzi[i].name,emp_gongzi[i].zhiwugongzi,emp_gongzi[i].zhiwubutie,emp_gongzi[i].zhufangbutie,emp_gongzi[i].kaoqin,emp_gongzi[i].yingfagongzi,emp_gongzi[i].yanglaobaoxian, emp_gongzi[i].zhufang,emp_gongzi[i].shifagongzi);printf("\n\n\n");}fclose(fp);//goto chakan;}void add(){FILE *fp;int i;if ((fp = fopen("number.dat", "rb+")) == NULL){printf("Can't open file\n");exit(0);fread(&number,sizeof(int),1,fp);fclose(fp);if ((fp = fopen("employee.dat", "rb+")) == NULL){printf("Can't open file\n");exit(0);}fread(emp,sizeof(struct employee),number,fp);fclose(fp);if ((fp = fopen("employee.dat", "wb+")) == NULL){printf("Can't open file\n");exit(0);}printf("编号姓名性别出生日期职称工作年限\n");scanf(" %s %s %s %s %s %d",emp[number].num,emp[number].name,emp[n umber].sex,emp[number].shengri,emp[number].degree,&emp[number].nianxian);number++;pai();fwrite(emp,sizeof(struct employee),number, fp);fclose(fp);if ((fp = fopen("number.dat", "wb+")) == NULL){printf("Can't open file\n");exit(0);}fwrite(&number,sizeof(int),1,fp);fclose(fp);if ((fp = fopen("employee.dat", "rb+")) == NULL){printf("Can't open file\n");exit(0);}printf(" 添加成功!!\n");printf(" 编号姓名性别出生日期职称工作年限\n");for (i = 0; fread(&emp[i],sizeof(struct employee),1,fp) == 1 ; i++)printf(" %s %s %s %s %s %d\n",emp[i].num,emp[i].name,emp[i].s ex,emp[i].shengri,emp[i].degree,emp[i].nianxian);}fclose(fp);}void del(){FILE *fp;int i;char num[5];if ((fp = fopen("number.dat", "rb+")) == NULL){printf("Can't open file\n");exit(0);}fread(&number,sizeof(int),1,fp);fclose(fp);if ((fp = fopen("employee.dat", "rb+")) == NULL){printf("Can't open file\n");exit(0);}fread(emp,sizeof(struct employee),number,fp);fclose(fp);if ((fp = fopen("employee.dat", "wb+")) == NULL){printf("Can't open file\n");exit(0);}printf("请您输入编号:\n");scanf("%s",num);for (i=0;i<number;i++){if (strcmp(num, emp[i].num) != 0){fwrite(&emp[i], sizeof(struct employee), 1, fp);}number--;fclose(fp);if ((fp = fopen("number.dat", "wb+")) == NULL){printf("Can't open file\n");exit(0);}fwrite(&number,sizeof(int),1,fp);fclose(fp);if ((fp = fopen("employee.dat", "rb+")) == NULL){printf("Can't open file\n");exit(0);}printf(" 删除成功!!\n");printf(" 编号姓名性别出生日期职称工作年限\n");for (i = 0; fread(&emp[i],sizeof(struct employee),1,fp) == 1 ; i++){printf(" %s %s %s %s %s %d\n",emp[i].num,emp[i].name,emp[i].s ex,emp[i].shengri,emp[i].degree,emp[i].nianxian);}fclose(fp);}void xiugai(){FILE *fp;int i;char num[5];int flag=1;if ((fp = fopen("number.dat", "rb+")) == NULL){printf("Can't open file\n");exit(0);}fread(&number,sizeof(int),1,fp);fclose(fp);if ((fp = fopen("employee.dat", "rb+")) == NULL){printf("Can't open file\n");exit(0);}fread(emp,sizeof(struct employee),number,fp);fclose(fp);if ((fp = fopen("employee.dat", "wb+")) == NULL){printf("Can't open file\n");exit(0);}printf("请您输入编号:\n");scanf("%s",num);for (i=0;i<number;i++){if (strcmp(num,emp[i].num)==0){printf("搜索到!!请您修改:\n");printf("职称:现任年限:\n");scanf("%s %d",emp[i].degree,&emp[i].nianxian);flag=2;}}fwrite(emp, sizeof(struct employee), number, fp);fclose(fp);if(flag==2){if ((fp = fopen("employee.dat", "rb+")) == NULL){printf("Can't open file\n");exit(0);}printf(" 修改成功!!\n");printf(" 编号姓名性别出生日期职称工作年限\n");for (i = 0; fread(&emp[i],sizeof(struct employee),1,fp) == 1 ; i++){printf(" %s %s %s %s %s %d\n",emp[i].num,emp[i].name,emp[i].s ex,emp[i].shengri,emp[i].degree,emp[i].nianxian);}fclose(fp);}else{printf("该信息不存在\n");}}void gengxin(){char nian[15];char nian2[15];FILE *fp,*fp2,*fp3;int i,j;printf("更新考勤记录文件.....\n");printf(" 请输入年月(k.dat):\n");scanf("%s",nian);printf(" 编号姓名日期出勤次数\n",number);if ((fp = fopen("number.dat", "rb+")) == NULL){printf("Can't open file\n");exit(0);}fread(&number,sizeof(int),1,fp);fclose(fp);if ((fp = fopen("employee.dat", "rb")) == NULL){printf("Can't open file\n");exit(0);}fread(emp,sizeof(struct employee),number, fp);if ((fp2 = fopen(nian, "wb")) == NULL){printf("Can't open file\n");exit(0);}for (i=0;i<number;i++){j=i+1;strcpy(emp_kaoqin[i].name, emp[i].name);strcpy(emp_kaoqin[i].num, emp[i].num);printf("->【%d】%s %s",j,emp_kaoqin[i].num,emp_kaoqin[i].name);scanf(" %s %d",emp_kaoqin[i].riqi,&emp_kaoqin[i].tianshu);printf("\n");}fwrite(emp_kaoqin, sizeof(struct emp_kao),number, fp2);fclose(fp);fclose(fp2);if ((fp = fopen(nian, "rb+")) == NULL){printf("Can't open file\n");exit(0);}printf("更新成功!!\n");printf(" 编号姓名日期出勤天数\n");for (i = 0; fread(&emp_kaoqin[i],sizeof(struct emp_kao),1,fp) == 1 ; i++){printf(" %s %s %s %d\n",emp_kaoqin[i].num,emp_kaoqin[i].name,emp_ka oqin[i].riqi,emp_kaoqin[i].tianshu);}fclose(fp);printf("更新工资文件.....\n");printf(" 请输入年月(g.dat):\n");scanf("%s",nian);char *zhugong="助工";char *gongchengshi="工程师";char *gaojigongchengshi="高级工程师";floatzhiwugongzi,zhiwubutie,zhufangbutie,kaoqin,yingfagongzi,yanglaobaoxian,zhufang,shifagongzi;if ((fp = fopen("employee.dat", "rb")) == NULL){printf("Can't open file\n");exit(0);}fread(emp,sizeof(struct employee),number, fp);if ((fp2 = fopen("emp_kao.dat", "rb")) == NULL){printf("Can't open file\n");exit(0);}fread(emp_kaoqin,sizeof(struct emp_kao),number, fp2);if ((fp3 = fopen(nian, "wb")) == NULL){printf("Can't open file\n");exit(0);}for (i=0;i<number;i++){j=i+1;strcpy(emp_gongzi[i].name, emp[i].name);strcpy(emp_gongzi[i].num, emp[i].num);floatzhiwugongzi,zhiwubutie,zhufangbutie,kaoqin,yingfagongzi,yanglaobaoxian,zhufang,shifagongzi;if (strcmp(emp[i].degree,zhugong) == 0){zhiwugongzi=720*(1+(emp[i].nianxian*2)/100);zhiwubutie=zhiwugongzi*25/100;zhufangbutie=(zhiwugongzi+zhiwubutie)*25/100;if (emp_kaoqin[i].tianshu>=20){kaoqin=10*emp_kaoqin[i].tianshu;}else if ((emp_kaoqin[i].tianshu>=10)&&(emp_kaoqin[i].tianshu<20)){kaoqin=5*emp_kaoqin[i].tianshu;}else{kaoqin=0;}yingfagongzi=zhiwugongzi+zhiwubutie+zhufangbutie+kaoqin;yanglaobaoxian=(zhiwugongzi+zhiwubutie)*0.1;zhufang=yingfagongzi*0.05;shifagongzi=yingfagongzi-yanglaobaoxian-zhufang;emp_gongzi[i].zhiwugongzi=zhiwugongzi;emp_gongzi[i].zhiwubutie=zhufangbutie;emp_gongzi[i].zhufangbutie=zhufangbutie;emp_gongzi[i].kaoqin=kaoqin;emp_gongzi[i].yingfagongzi=yingfagongzi;emp_gongzi[i].yanglaobaoxian=yanglaobaoxian;emp_gongzi[i].zhufang=zhufang;emp_gongzi[i].shifagongzi=shifagongzi;}if (strcmp(emp[i].degree,gongchengshi) == 0){zhiwugongzi=960*(1+(emp[i].nianxian*3)/100);zhiwubutie=zhiwugongzi*25/100;zhufangbutie=(zhiwugongzi+zhiwubutie)*25/100;if (emp_kaoqin[i].tianshu>=20){kaoqin=10*emp_kaoqin[i].tianshu;}else if ((emp_kaoqin[i].tianshu>=10)&&(emp_kaoqin[i].tianshu<20)) {kaoqin=5*emp_kaoqin[i].tianshu;}else{kaoqin=0;}yingfagongzi=zhiwugongzi+zhiwubutie+zhufangbutie+kaoqin;yingfagongzi=zhiwugongzi+zhiwubutie+zhufangbutie+kaoqin;yanglaobaoxian=(zhiwugongzi+zhiwubutie)*0.1;zhufang=yingfagongzi*0.05;shifagongzi=yingfagongzi-yanglaobaoxian-zhufang;emp_gongzi[i].zhiwugongzi=zhiwugongzi;emp_gongzi[i].zhiwubutie=zhufangbutie;emp_gongzi[i].zhufangbutie=zhufangbutie;emp_gongzi[i].kaoqin=kaoqin;emp_gongzi[i].yingfagongzi=yingfagongzi;emp_gongzi[i].yanglaobaoxian=yanglaobaoxian;emp_gongzi[i].zhufang=zhufang;emp_gongzi[i].shifagongzi=shifagongzi;}if (strcmp(emp[i].degree,gaojigongchengshi) == 0){zhiwugongzi=1350*(1+(emp[i].nianxian*5)/100);zhiwubutie=zhiwugongzi*25/100;zhufangbutie=(zhiwugongzi+zhiwubutie)*25/100;if (emp_kaoqin[i].tianshu>=20){kaoqin=10*emp_kaoqin[i].tianshu;}else if ((emp_kaoqin[i].tianshu>=10)&&(emp_kaoqin[i].tianshu<20)) {kaoqin=5*emp_kaoqin[i].tianshu;}else{kaoqin=0;}yingfagongzi=zhiwugongzi+zhiwubutie+zhufangbutie+kaoqin;yingfagongzi=zhiwugongzi+zhiwubutie+zhufangbutie+kaoqin;yanglaobaoxian=(zhiwugongzi+zhiwubutie)*0.1;zhufang=yingfagongzi*0.05;shifagongzi=yingfagongzi-yanglaobaoxian-zhufang;emp_gongzi[i].zhiwugongzi=zhiwugongzi;emp_gongzi[i].zhiwubutie=zhufangbutie;emp_gongzi[i].zhufangbutie=zhufangbutie;emp_gongzi[i].kaoqin=kaoqin;emp_gongzi[i].yingfagongzi=yingfagongzi;emp_gongzi[i].yanglaobaoxian=yanglaobaoxian;emp_gongzi[i].zhufang=zhufang;emp_gongzi[i].shifagongzi=shifagongzi;}printf("\n");}fwrite(emp_gongzi, sizeof(struct emp_gong),number, fp3);fclose(fp);fclose(fp2);fclose(fp3);if ((fp = fopen(nian, "rb+")) == NULL){printf("Can't open file\n");exit(0);}printf(" 更新成功!!\n");for (i = 0; fread(&emp_gongzi[i],sizeof(struct emp_gong),1,fp) == 1 ; i++){printf("编号%s 姓名%s 职务工资%f 职务补贴%f 住房补贴%f\n考勤管理奖%f 应发工资%f 养老保险%f 住房公积金%f 实发工资%f\n",emp_gongzi[i].num,emp_gongzi[i].name,emp_gongzi[i].zhiwugongzi,emp_gongzi[i].zhiwubutie,emp_gongzi[i].zhufangbutie,emp_gongzi[i].kaoqin,emp_gongzi[i].yingfagongzi,emp_gongzi[i].yanglaobaoxian, emp_gongzi[i].zhufang,emp_gongzi[i].shifagongzi);printf("\n\n\n");}fclose(fp);}void findnum(){FILE *fp;int i;char num[5];int flag=1;if ((fp = fopen("number.dat", "rb+")) == NULL){printf("Can't open file\n");exit(0);}fread(&number,sizeof(int),1,fp);fclose(fp);if ((fp = fopen("emp_gong.dat", "rb+")) == NULL){printf("Can't open file\n");exit(0);}fread(emp_gongzi,sizeof(struct emp_gong),number,fp);fclose(fp);printf("请您输入编号:\n");scanf("%s",num);for (i=0;i<number;i++){if (strcmp(num, emp_gongzi[i].num) == 0){printf("搜索成功!!\n");printf("编号%s 姓名%s 职务工资%f 职务补贴%f 住房补贴%f\n考勤管理奖%f 应发工资%f 养老保险%f 住房公积金%f 实发工资%f\n",emp_gongzi[i].num,emp_gongzi[i].name,emp_gongzi[i].zhiwugongzi,emp_gongzi[i].zhiwubutie,emp_gongzi[i].zhufangbutie,emp_gongzi[i].kaoqin,emp_gongzi[i].yingfagongzi,emp_gongzi[i].yanglaobaoxian,emp_gongzi[i].zhufang,emp_gongzi[i].shifagongzi);flag=2;}}if (flag==1){printf("该信息不存在\n");}}void findname(){FILE *fp;int i;char name[10];int flag=1;if ((fp = fopen("number.dat", "rb+")) == NULL){printf("Can't open file\n");exit(0);}fread(&number,sizeof(int),1,fp);fclose(fp);if ((fp = fopen("emp_gong.dat", "rb+")) == NULL){printf("Can't open file\n");exit(0);}fread(emp_gongzi,sizeof(struct emp_gong),number,fp);fclose(fp);printf("请您输入姓名:\n");scanf("%s",name);for (i=0;i<number;i++){if (strcmp(name, emp_gongzi[i].name) == 0){printf("搜索成功!!\n");printf("搜索成功!!\n");printf("编号%s 姓名%s 职务工资%f 职务补贴%f 住房补贴%f\n考勤管理奖%f 应发工资%f 养老保险%f 住房公积金%f 实发工资%f\n",emp_gongzi[i].num,emp_gongzi[i].name,emp_gongzi[i].zhiwugongzi,emp_gongzi[i].zhiwubutie,emp_gongzi[i].zhufangbutie,emp_gongzi[i].kaoqin,emp_gongzi[i].yingfagongzi,emp_gongzi[i].yanglaobaoxian, emp_gongzi[i].zhufang,emp_gongzi[i].shifagongzi);flag=2;}}if (flag==1){printf("该信息不存在\n");}}void findname2(){FILE *fp;int i;char name[10];int flag=1;if ((fp = fopen("number.dat", "rb+")) == NULL){printf("Can't open file\n");exit(0);}fread(&number,sizeof(int),1,fp);fclose(fp);if ((fp = fopen("emp_gong.dat", "rb+")) == NULL){printf("Can't open file\n");exit(0);}fread(emp_gongzi,sizeof(struct emp_gong),number,fp);fclose(fp);printf("请您输入姓:\n");scanf("%s",name);for (i=0;i<number;i++){if (name[0]==emp_gongzi[i].name[0]){。

员工工资管理系统代码

员工工资管理系统代码
printf("实发工资:");
scanf("%s",employee.shi);
fseek (fp,0,SEEK_END); /*移动文件内部位置指针*/
fwrite(&employee,sizeof(EmployeeType),1,fp); /*将员工信息存入文件中*/
tag=tolower(tag); /*大写字母转化为小写字母*/
}
} while(tag=='y'); /*肯定回答时循环*/
}
fseek(fp,-sizeof(EmployeeType),SEEK_CUR); /*移动文件内部位置指针*/
fwrite(&employee,sizeof(EmployeeType),1,fp); /*输入数据*/
}break;
case 2: /*按员工姓名查询*/
printf("输入员工的姓名:\n");
scanf("%s",name);
rewind (fp); /*使指针位置返回到文件的开头*/
void ListDate(void); /*显示数据*/
void Pack(void); /*在物理上删除作有标记的记录*/
#endif
FILE *fp;
void AddData(void) /*增添数据*/
&& employee.status==0
)break;
fread (&employee,sizeof(EmployeeType),1,fp);
}
if(!feof(fp))
{ /*查询成功*/

c语言职工工资管理系统代码

c语言职工工资管理系统代码

C语言职工工资管理系统代码简介职工工资管理是一项重要的任务,它涉及到工资计算、薪资发放、绩效评估等方面。

为了提高管理的有效性和准确性,许多公司和组织都开发了各种各样的工资管理系统。

本文将介绍一种基于C语言开发的职工工资管理系统代码。

代码功能及特点1. 基本功能•添加新员工信息•更新员工信息•计算员工工资•发放工资•查询员工信息•统计工资情况2. 特点•简单易懂:代码使用C语言编写,阅读和理解都相对简单。

•高效可靠:代码采用模块化设计,结构清晰,运行效率高,容错性强。

•跨平台支持:C语言是一种具有广泛应用的语言,可以在多个操作系统上运行。

代码实现1. 员工信息结构体定义struct Employee {int id; // 员工编号char name[20]; // 员工姓名float basicSalary; // 员工基本工资float performanceBonus; // 绩效奖金float salary; // 员工工资};2. 添加新员工信息函数void addEmployee(struct Employee *employee, int num) {printf("请输入员工编号:");scanf("%d", &(employee[num].id));// 输入其他员工信息...}3. 更新员工信息函数void updateEmployee(struct Employee *employee, int id) {int i;for (i = 0; i < num; i++) {if (employee[i].id == id) {// 更新员工信息...}}}4. 计算员工工资函数void calculateSalary(struct Employee *employee, int num) {int i;for (i = 0; i < num; i++) {employee[i].salary = employee[i].basicSalary + employee[i].performance Bonus;}}5. 发放工资函数void paySalary(struct Employee *employee, int num) {int i;for (i = 0; i < num; i++) {printf("员工编号:%d,工资:%.2f\n", employee[i].id, employee[i].salar y);}}6. 查询员工信息函数void searchEmployee(struct Employee *employee, int id) {int i;for (i = 0; i < num; i++) {if (employee[i].id == id) {// 输出员工信息...}}}7. 统计工资情况函数void statisticsSalary(struct Employee *employee, int num) { float totalSalary = 0;int i;for (i = 0; i < num; i++) {totalSalary += employee[i].salary;}printf("总工资:%f\n", totalSalary);}使用示例1. 添加员工信息struct Employee employees[100];int num = 0;addEmployee(employees, num);num++;2. 更新员工信息int id = 12345;updateEmployee(employees, id);3. 计算员工工资calculateSalary(employees, num);4. 发放工资paySalary(employees, num);5. 查询员工信息int id = 12345;searchEmployee(employees, id);6. 统计工资情况statisticsSalary(employees, num);总结本文介绍了一个基于C语言的职工工资管理系统代码。

C++职工工资管理系统源代码

C++职工工资管理系统源代码

附录〈源程序〉#include <stdio.h>#include <stdlib.h>#include <string.h>struct worker{char name[30];char ID[10];int salary1,salary2,salary3;};int dq(struct worker wo[]);void show();void bc(struct worker wo[]);void add();void see();void search();void ghcz();void xmcz();void del();void xmsc();void ghsc();void statistics();void modify();void ghxg();void xmxg();void reserve();void back();void author();struct worker wo[100]; //保存所有的职工信息int Number=0; //记录总的职工人数void main(){int choose=0;while(true){show();printf("\t\t====>请选择:");scanf("%d",&choose);system("cls");switch(choose){case 0: exit(0);//退出break;case 1: add();back();//添加职工信息break;case 2: see();back();//查看职工信息break;case 3: search();back();// 查找职工信息break;case 4: del();back();//删除职工信息break;case 5: statistics();back();//统计职工工资break;case 6: modify();back();//修改职工信息break;case 7:reserve();back();//保存数据break;case 8:author();back();//作者信息break;default:break;}fflush(stdin);getchar();system("cls");}}int dq(struct worker wo[]){FILE *fp=NULL;int i=0;fp=fopen("C://worker.dat","rb");while(fread(&wo[i],sizeof(struct worker),1,fp)) i++;fclose(fp);return i;}void show(){printf("\n");printf("\t****************职工工资管理系统****************\n\n"); printf("\t*☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆*\n\n"); printf("\t^^^^^^^^^^^^^^^[1] 添加职工信息^^^^^^^^^^^^^^^^^\n"); printf("\t^^^^^^^^^^^^^^^[2] 查看职工信息^^^^^^^^^^^^^^^^^\n"); printf("\t^^^^^^^^^^^^^^^[3] 查找职工信息^^^^^^^^^^^^^^^^^\n"); printf("\t^^^^^^^^^^^^^^^[4] 删除职工信息^^^^^^^^^^^^^^^^^\n"); printf("\t^^^^^^^^^^^^^^^[5] 统计职工工资^^^^^^^^^^^^^^^^^\n"); printf("\t^^^^^^^^^^^^^^^[6] 修改职工信息^^^^^^^^^^^^^^^^^\n"); printf("\t^^^^^^^^^^^^^^^[7] 保存数据^^^^^^^^^^^^^^^^^\n"); printf("\t^^^^^^^^^^^^^^^[8] 作者信息^^^^^^^^^^^^^^^^^\n"); printf("\t^^^^^^^^^^^^^^^[0] 退出系统^^^^^^^^^^^^^^^^^\n\n"); printf("\t*★★★★★★★★★★★★★★★★★★★★★★★*\n"); }void bc(struct worker *wo){FILE *fp=NULL;fp=fopen("C://worker.dat","ab+");fwrite(wo,sizeof(struct worker),1,fp);fclose(fp);}//添加职工信息void add(){int numberTemp=0;int i=0;struct worker temp;printf("请输入要添加职工个数:");scanf("%d",&numberTemp);for(i=0;i<numberTemp;i++){printf("输入第%d个职工信息\n",i+1);printf("姓名:");scanf("%s",);printf("工号:");scanf("%s",temp.ID);printf("基本工资:");scanf("%d",&temp.salary1);printf("职务工资:");scanf("%d",&temp.salary2);printf("津贴:");scanf("%d",&temp.salary3);wo[Number++]=temp; //写入到数组bc(&temp); //写入到文件}printf("添加成功\n");}//查看职工信息void see(){int i=0;printf("以下是全部职工\n");printf("\t姓名\t工号\t基本工资\t职务工资\t津贴\n");while(i<Number){printf("\t%s\t%s\t%d\t\t%d\t\t%d\n",wo[i].name,wo[i].ID,wo[i].salary1,wo[i].sal ary2,wo[i].salary3);i++;}}//查找职工信息void search(){int n=0;printf("1 按姓名查找\n");printf("2 按工号查找\n");scanf("%d",&n);switch(n){case 1: xmcz();break;case 2: ghcz();break;default: printf("输入错误!\n");break;}}void xmcz()//按姓名查找{char name[30];int i=0;printf("请输入要查找职工姓名:");scanf("%s",name);system("cls");printf("\t姓名\t工号\t基本工资\t职务工资\t津贴\n");for (i=0;i<Number;i++){if (strcmp(name,wo[i].name)==0){printf("\t%s\t%s\t%d\t\t%d\t\t%d\n",wo[i].name,wo[i].ID,wo[i].salary1,wo[i].sal ary2,wo[i].salary3);}}}void ghcz()//按工号查找{char id[10];int i=0;printf("请输入要查找职工工号:");scanf("%s",id);system("cls");printf("\t姓名\t工号\t基本工资\t职务工资\t津贴\n");for (i=0;i<Number;i++){if (strcmp(id,wo[i].ID)==0){printf("\t%s\t%s\t%d\t\t%d\t\t%d\n",wo[i].name,wo[i].ID,wo[i].salary1,wo[i].sal ary2,wo[i].salary3);}}}//删除职工信息void del(){int n=0;printf("1 按姓名删除\n");printf("2 按工号删除\n");scanf("%d",&n);switch(n){case 1: xmsc();break;case 2: ghsc();break;}}void xmsc()//按姓名删除{FILE *fp=NULL;char name[30];int i=0;int j=0;printf("请输入要删除的职工姓名:");scanf("%s",name);for(i=0;i<Number;i++){if (strcmp(name,wo[i].name)==0){for (j=i;j<Number-1;j++){wo[j]=wo[j+1];}Number--;}}//将剩余数据写入文件擦除以前的数据fp=fopen("C://worker.dat","wb");for (i=0;i<Number;i++){fwrite(&wo[i],sizeof(struct worker),1,fp); }fclose(fp);printf("删除成功;\n");}void ghsc()//按工号删除{FILE *fp=NULL;char id[60];int i=0;int j=0;printf("请输入要删除的职工工号:");scanf("%s",id);for(i=0;i<Number;i++){if (strcmp(id,wo[i].ID)==0){for (j=i;j<Number-1;j++){wo[j]=wo[j+1];}Number--;}}//将剩余数据写入文件擦除以前的数据fp=fopen("C://worker.dat","wb");for (i=0;i<Number;i++){fwrite(&wo[i],sizeof(struct worker),1,fp);}fclose(fp);printf("删除成功;\n");}//统计职工工资void statistics(){int i=0;double s=0.0;double sum[100];for(i=0;i<Number;i++){sum[i]=wo[i].salary1+wo[i].salary2+wo[i].salary3; printf("%s的总工资为:%f\n",wo[i].name,sum[i]); }for(i=0;i<Number;i++){s+=sum[i];}printf("平均工资为:%f\n",s/Number);}//修改职工信息void modify(){int mode=0;printf("请选择修改查找方式\n");printf("1 按姓名查找修改\n");printf("2 按工号查找修改\n");scanf("%d",&mode);switch(mode){case 1: xmxg();break;case 2: ghxg();break;default: printf("输入错误!\n");break;}}void xmxg()//按姓名修改{FILE *fp=NULL;char name[30];int i=0;printf("请输入要修改的职工姓名:");scanf("%s",name);for (i=0;i<Number;i++){if (strcmp(name,wo[i].name));elsebreak;}printf("\t姓名\t工号\t基本工资\t职务工资\t津贴\n");printf("\t%s\t%s\t%d\t\t%d\t\t%d\n",wo[i].name,wo[i].ID,wo[i].salary1,wo[i].sal ary2,wo[i].salary3);printf("请重新输入该职工信息");printf("姓名:");scanf("%s",wo[i].name);printf("工号:");scanf("%s",wo[i].ID);printf("基本工资:");scanf("%d",&wo[i].salary1);printf("职务工资:");scanf("%d",&wo[i].salary2);printf("津贴:");scanf("%d",&wo[i].salary3);//信息修改后重新更新文件里面的数据以保持数据一致性fp=fopen("C://worker.dat","wb");for (i=0;i<Number;i++){fwrite(&wo[i],sizeof(struct worker),1,fp);}fclose(fp);}void ghxg()//按工号修改{FILE *fp=NULL;char id[30];int i=0;printf("请输入要修改的职工工号:");scanf("%s",id);for (i=0;i<Number;i++){if (strcmp(id,wo[i].ID));elsebreak;}printf("\t姓名\t工号\t基本工资\t职务工资\t津贴\n");printf("\t%s\t%s\t%d\t\t%d\t\t%d\n",wo[i].name,wo[i].ID,wo[i].salary1,wo[i].sal ary2,wo[i].salary3);printf("请重新输入该职工信息");printf("姓名:");printf("姓名:");scanf("%s",wo[i].name);printf("工号:");scanf("%s",wo[i].ID);printf("基本工资:");scanf("%d",&wo[i].salary1);printf("职务工资:");scanf("%d",&wo[i].salary2);printf("津贴:");scanf("%d",&wo[i].salary3);//信息修改后重新更新文件里面的数据以保持数据一致性fp=fopen("C://worker.dat","wb");for (i=0;i<Number;i++){fwrite(&wo[i],sizeof(struct worker),1,fp);}fclose(fp);printf("\t=======>修改成功\n");}//保存数据void reserve(){printf("\t=====程序在运行时已自动保存.....\n");}void back(){printf("\t===>按Enter键返回主菜单\n");}//作者信息void author(){printf("\t***☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆***\n\n"); printf("\t^^^^^^^^^^^^^^^学校名称^^^^^^^^^^^^^\n\n"); printf("\t^^^^^^^^^^^^^^学院班级^^^^^^^^^^^^^\n\n"); printf("\t^^^^^^^^^^^^^^^XXX制作^^^^^^^^^^^^^\n\n"); printf("\t***★★★★★★★★★★★★★★★★***\n\n");。

C++员工工资管理系统源代码

C++员工工资管理系统源代码

#include <iomanip>#include <iostream>#include <fstream>#include <malloc.h>#include <stdlib.h>#include <string.h>using namespace std;#define NULL 0#define LEN sizeof(struct student)int const N=20;void Menu();void Pass();int n=0; //定义一个全局变量统计职工人数//——--------->定义一个职工信息的结构体struct student{char name[N]; //用来存放姓名char sex[N]; //用来存放性别long id; //用来存放编号float paid[3]; //用来存放工资int total; //用来存放总工资struct student *next;};//-------------->职工类class Information{public:Information() ; //构造函数.~Information() ; //析构函数.student *creat(); //建立链表void output(student *head); //显示职工信息int count(student *head); //定义函数count()统计职工总数student *insert(student*head); //指针函数*insert()用来添加职工信息.student *cancel(student *head,long id); //指针函数*cancel()用来删除职工信息. student *find(student *head,long id); //指针函数*find()用来查找职工信息.student *modify(student *head,long id); //指针函数*modife()用来修改职工的信息.void paixu(student *head); //定义paixu()函数将职工的总额从大到小排列并输出void average(student *head); //定义职工工资平均值的函数void save(student *head); //保存文件信息student *Read(); //读取文件信息private:student *p1,*p2,*p3,*head,st;};Information::Information(){cout<<" ******************************************************************************\n";cout<<" ------------------------<<欢迎您使用员工工资管理系统>>------------------------\n";cout<<" ******************************************************************************\n\n";}Information::~Information(){ cout<<" ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤\n";cout<<" \n"; cout<<" 本系统管理员\n"; cout<<" \n"; cout<<" \n"; cout<<" ------------------------<<谢谢您使用员工工资管理系统>>------------------------\n";cout<<" \n"; cout<<" \n"; cout<<" 欢迎下次使用\n"; cout<<" \n"; cout<<" \n"; cout<<" 再见\n"; cout<<" \n"; cout<<" ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤\n";}//------------>建立链表信息student *Information::creat(void){//定义一个指向struct student的结构体指针函数*creat()用来录入职工信息.char ch[N];n=0; //用来存放职工姓名p1=p2=(student *)malloc(LEN);//调用malloc()函数用来开辟一个新的存储单元cout<<" -------------<<请建立员工信息表,在姓名处键以# 结束输入!>>--------------"<<endl;cout<<" 姓名:";cin>>ch;head=NULL; //给指针head赋初值while (strcmp(ch,"#")!=0){ //调用字符比较函数strcmp()用来判断是否继续输入p1=(student *)malloc(LEN); //调用malloc()函数用来开辟一个新的存储单元strcpy(p1->name,ch); //将循环结构前面输入的姓名复制到结构体名为p1的数组name中cout<<" 性别:";cin>>p1->sex;cout<<" 编号:";cin>>p1->id;while((p1->id)<0||(p1->id)>100000) //判断输入的编号是否有效(100000个){cout<<" 对不起您的输入错误!请重新输入(>0<1000000): ";cin>>p1->id;}cout<<" 基本工资:";cin>>p1->paid[0];while((p1->paid[0])<0||(p1->paid[0])>100000) //判断输入的分数是否有效(>=0 <=100000){cout<<" 对不起您的输入错误!请重新输入(>0<100000): ";cin>>p1->paid[0];}cout<<" 加班工资:";cin>>p1->paid[1];while((p1->paid[1])<0||(p1->paid[1])>100000) //判断输入的分数是否有效(>=0<=100000){cout<<" 对不起您的输入错误!请重新输入(>0<100000): ";cin>>p1->paid[1];}cout<<" 其他奖金:";cin>>p1->paid[2];while((p1->paid[2])<0||(p1->paid[2])>100000) //判断输入的分数是否有效(>=0 <=100000){cout<<" 对不起您的输入错误!请重新输入(>0<100000): ";cin>>p1->paid[2];}p1->total=p1->paid[0]+p1->paid[1]+p1->paid[2]; //计算总额if(n==0)head=p1; //如果是输入第一组职工信息就将指针p1赋给指针headelse p2->next=p1; //否则将p1赋给p2所指结构体的next指针p2=p1; //将指针p1赋给指针p2n++; //将职工人数n的值加1cout<<"\n 姓名:";cin>>ch; //将输入的姓名存放到字符数组ch中}p2->next=NULL; //将p2所指结构体的next指针重新赋空值return (head);//将输入的第一组职工信息返回}//--------------->定义output()函数将职工的信息从头指针所指内容开始输出void Information::output(student *head)system("cls");if(head==NULL) cout<<" 这是一个空表,请先输入员工信息!\n";else{cout<<"-------------------------------------------------------------------------------\n";cout<<" *职工工资信息表*\n";cout<<"-------------------------------------------------------------------------------\n";cout<<"|编号| |姓名| |性别| |基本工资| |加班工资| |其他奖金| |总额|\n"; cout<<"-------------------------------------------------------------------------------\n";p1=head; //将头指针赋给pdo{cout<<setw(6)<<p1->id<<setw(10)<<p1->name<<setw(10)<<p1->sex<<setw(10)<<p1->paid[0]<<setw(10)<<p1->paid[1]<<setw(12)<<p1->paid[2]<<setw(12)<<p1->total<<endl;cout<<"-------------------------------------------------------------------------------\n";p1=p1->next; //将下一组职工信息的next指针赋给p}while(p1!=NULL); //若指针p非空则继续,目的是把所有的职工信息都传给指针p然后输出.}//------------>统计职工人数的函数int Information::count(struct student *head) //定义函数count()统计职工总数{if(head==NULL)return(0); //若指针head为空返回值为0else return(1+count(head->next)); //函数的递归调用}//----------->添加职工的成绩的函数student *Information::insert( student *head)//插入新结点定义一个指向struct student的结构体指针函数*insert()用来添加职工信息. {system("cls");cout<<"\t----------------<<请输入新增员工信息>>----------------\n"<<endl;p1=(student *)malloc(LEN); //使p1指向插入的新结点cout<<" 编号:";cin>>p1->id;while((p1->id)<0||(p1->id)>100000){cout<<" 对不起您的输入错误!请重新输入(>0<100000): ";cin>>p1->id; //将输入的编号存放到p1所指结构体的数组id中}cout<<" 姓名:";cin>>p1->name; //将输入的姓名存放到结构体名为p1的数组name中cout<<" 性别:";cin>>p1->sex;cout<<" 基本工资:";cin>>p1->paid[0];while((p1->paid[0])<0||(p1->paid[0])>100000){cout<<" 对不起您的输入错误!请重新输入(>0<100000): ";cin>>p1->paid[0]; //将输入的基本工资存放到p1所指结构体的数组paid中}cout<<" 加班工资:";cin>>p1->paid[1];while((p1->paid[1])<0||(p1->paid[1])>100000){cout<<" 对不起您的输入错误!请重新输入(>0<100000): ";cin>>p1->paid[1]; //将输入的加班工资存放到p1所指结构体的数组paid中}cout<<" 其他奖金:";cin>>p1->paid[2];while((p1->paid[2])<0||(p1->paid[2])>100000){cout<<" 对不起您的输入错误!请重新输入(>0<100000): ";cin>>p1->paid[2]; //将输入的其他奖金存放到p1所指结构体的数组paid中}p1->total=p1->paid[0]+p1->paid[1]+p1->paid[2];//计算总分p2=head; //将头指针赋给p2if(head==NULL) //若没调用次函数以前的头指针head为空{head=p1;p1->next=NULL;} //则将p1赋给头指针head并将p1所指结构体成员指针next赋空值else{while((p1->id>p2->id)&&(p2->next!=NULL)){p3=p2; //p3指向原p2指向的结点p2=p2->next;} //p2后移一个结点if(p1->id<=p2->id){if(head==p2){p1->next=head;head=p1;} //插入到第一个结点之前else{p3->next=p1;p1->next=p2;} //插入到p3所指结点之后}else{p2->next=p1;p1->next=NULL;} //插入到尾结点之后}n++; //将职工人数加1cout<<"\t----------------<<你输入的员工信息已经成功插入>>----------------"<<endl; return (head);}//------------>删除职工信息student *Information::cancel(student *head,long id) //定义一个指向struct student的结构体指针函数*delete()用来删除考生信息.{system("cls");if(head==NULL) //若调用次函数以前的头指针head为空{return(head);}else{p1=head; //否则将头指针赋给p1while(id!=p1->id&&p1->next!=NULL) //寻找要删除的结点当p1所指的职工编号不是输入的职工编号并且p1所指的next指针不为空{p2=p1;p1=p1->next;} //p2指向原p1指向的结点p1后移一个结点if(id==p1->id) //如果输入的职工编号是p1所指的职工编号//结点找到后删除{if(p1==head) head=p1->next; //如果head指针和p1指针相等则将下一个结点赋给指针head elsep2->next=p1->next; //否则将p1所指结点赋给p2所指结点将要删除的职工信息跳过去cout<<" 删除编号为"<<id<<"的职工\n";n--; //将职工人数减1}return(head); //将头指针返回}}/**************************修改职工数据**************************/student *Information::modify(student *head,long id){system("cls");cout<<"\t----------------<<请输入须修改的员工工资信息>>----------------\n"<<endl;p1=(student *)malloc(LEN); //使p1指向输入的结点p1=head; //否则将头指针赋给p1while(id!=p1->id&&p1->next!=NULL)//寻找结点当p1所指的职工编号不是输入的职工编号并且p1所指的next指针不为空{p1=p1->next; //p2指向原p1指向的结点p1后移一个结点}if(id==p1->id) //如果要查找的职工编号是p1所指的职工编号{cout<<"你需要修改的员工信息如下:\n";cout<<"------------------------------------------------------------------------------\n";cout<<"|编号| |姓名| |性别| |基本工资| |加班工资| |其他奖金| |总额|\n";cout<<"------------------------------------------------------------------------------\n";cout<<setw(6)<<p1->id<<setw(10)<<p1->name<<setw(10)<<p1->sex<<setw(10)<<p1->paid[0]<<setw(10)<<p1->paid[1]<<setw(12)<<p1->paid[2]<<setw(12)<<p1->total<<endl;cout<<"------------------------------------------------------------------------------\n";cout<<" 编号:";cin>>p1->id;while((p1->id)<0||(p1->id)>100000){cout<<" 对不起您的输入错误!请重新输入(>0<100000): ";cin>>p1->id; //将输入的编号存放到p1所指结构体的数组id中}cout<<" 姓名:";cin>>p1->name; //将输入的姓名存放到结构体名为p1的数组name中cout<<" 性别:";cin>>p1->sex;cout<<" 基本工资:";cin>>p1->paid[0];while((p1->paid[0])<0||(p1->paid[0])>100000){cout<<" 对不起您的输入错误!请重新输入(>0<100000): ";cin>>p1->paid[0]; //将输入的基本工资存放到p1所指结构体的数组paid中}cout<<" 加班工资:";cin>>p1->paid[1];while((p1->paid[1])<0||(p1->paid[1])>100000){cout<<" 对不起您的输入错误!请重新输入(>0<100000): ";cin>>p1->paid[1]; //将输入的加班工资存放到p1所指结构体的数组paid中}cout<<" 其他奖金:";cin>>p1->paid[2];while((p1->paid[2])<0||(p1->paid[2])>100000){cout<<" 对不起您的输入错误!请重新输入(>0<100000): ";cin>>p1->paid[2]; //将输入的其他奖金存放到p1所指结构体的数组paid中}p1->total=p1->paid[0]+p1->paid[1]+p1->paid[2]; //计算总分}elsecout<<" 需要修改的信息中没有编号为"<<id<<"的员工.\n\n"; //没有想要修改的结点信息getchar();return(head);}//------------>查找职工信息student *Information::find(student *head,long id)//定义一个指向struct student的结构体指针函数*find()用来查找职工信息.{system("cls");if(head==NULL) //若调用次函数以前的头指针head为空{cout<<" 这是一个空表,请先输入员工信息!\n";return(head);}else{p1=head; //否则将头指针赋给p1while(id!=p1->id&&p1->next!=NULL)//寻找结点当p1所指的职工编号不是输入的职工编号并且p1所指的next指针不为空{p1=p1->next; //p2指向原p1指向的结点p1后移一个结点}if(id==p1->id) //如果要查找的职工编号是p1所指的职工编号{cout<<"------------------------------------------------------------------------------\n";cout<<"|编号| |姓名| |性别| |基本工资| |加班工资| |其他奖金| |总额|\n"; cout<<"------------------------------------------------------------------------------\n";cout<<setw(6)<<p1->id<<setw(10)<<p1->name<<setw(10)<<p1->sex<<setw(10)<<p1->paid[0]<<setw(10)<<p1->paid[1]<<setw(12)<<p1->paid[2]<<setw(12)<<p1->total<<endl;cout<<"------------------------------------------------------------------------------\n";}elsecout<<"信息中没有编号为"<<id<<"的员工.\n"; //结点没找到return(head);}}//------------定义paixu()函数将职工的工资总额从大到小排列并输出void Information::paixu(student *head){system("cls");int i,k,m=0,j;student *p[N];//定义一个指向struct student的结构体指针数组pif(head!=NULL)//如果头指针是空则继续{ m=count(head);cout<<"------------------------------------------------------------------------------\n";cout<<" *员工工资统计表*\n";cout<<"------------------------------------------------------------------------------\n";cout<<"|编号| |姓名| |性别| |基本工资| |加班工资| |其他奖金| |总额| |名次|\n"; cout<<"------------------------------------------------------------------------------\n";p1=head;for(k=0;k<m;k++){p[k]=p1;p1=p1->next;}for(k=0;k<m-1;k++) //选择排序法for(j=k+1;j<m;j++)if(p[k]->total<p[j]->total){p2=p[k];p[k]=p[j];p[j]=p2;} //从大到小排列的指针for(i=0;i<m;i++){cout<<setw(6)<<p[i]->id<<setw(8)<<p[i]->name<<setw(9)<<p[i]->sex<<setw(10)<<p[i]->paid[0]<<setw(10)<<p[i]->paid[1]<<setw(10)<<p[i]->paid[2]<<setw(10)<<p[i]->total<<setw(10)<<i+1<<endl;cout<<"------------------------------------------------------------------------------\n";}}}//------------>求各工资的平均值的函数void Information::average(student *head){int k,m;float arg1=0,arg2=0,arg3=0;if(head==NULL)//如果头指针是空则继续{cout<<" 这是一个空表,请先输入员工信息!\n";}else{m=count(head);p1=head;for(k=0;k<m;k++){arg1+=p1->paid[0];arg2+=p1->paid[1];arg3+=p1->paid[2];p1=p1->next;}arg1/=m;arg2/=m;arg3/=m;cout<<" *各项工资的平均值*\n";cout<<"------------------------------------------------------------------------------\n";cout<<"\t\t基本工资的平均值: "<<setw(4)<<arg1<<"\n"<<"\t\t加班工资的平均值: "<<setw(4)<<arg2<<"\n"<<"\t\t奖金的平均值: "<<setw(4)<<arg3<<"\n";cout<<"------------------------------------------------------------------------------\n";}}//------------------->保存函数.void Information::save(student *head){system("cls");ofstream out("data.txt",ios::out);out<<count(head)<<endl;while(head!=NULL){ out<<head->name<<"\t"<<head->id<<"\t"<<"\t"<<head->sex<<"\t"<<head->paid[0]<<"\t"<<head->paid[1]<<"\t"<<head->paid[2]<<"\t"<<head->total<<endl;head=head->next;}}//———————————>读取文件的信息student *Information::Read(){system("cls");int i=0;p1=p2=( student *)malloc(LEN);head=NULL;ifstream in("data.txt",ios::in);in>>i;if(i==0){cout<<" data 文件中的数据为空,请先输入数据!"<<endl; return 0;}else {cout<<"\n原文件已保存的信息如下:\n";cout<<" ………………………………………………………………………………………………" <<endl;cout<<"|姓名| |编号| |性别| |基本工资| |加班工资| |其他奖金| |总额|\n";cout<<" ………………………………………………………………………………………………" <<endl;for(;i>0;i--){p1=(student *)malloc(LEN);in>>>>st.id>>st.sex>>st.paid[0]>>st.paid[1]>>st.paid[2]>>st.total;strcpy(p1->name,);p1->id=st.id;strcpy(p1->sex,st.sex);p1->paid[0]=st.paid[0];p1->paid[1]=st.paid[1];p1->paid[2]=st.paid[2];p1->total=st.total;if(n==0)head=p1; //如果是输入第一组职工信息就将指针p1赋给指针headelse p2->next=p1; //否则将p1赋给p2所指结构体的next指针p2=p1; //将指针p1赋给指针p2n++; //将n的值加1//显示读入数据cout<<" "<<p1->name<<"\t"<<p1->id<<" \t"<< p1->sex <<" \t"<< p1->paid[0] <<" \t"<< p1->paid[1] <<" \t"<< p1->paid[2] <<" \t"<< p1->total<<endl;cout<<" ………………………………………………………………………………………………" <<endl;}cout<<" 数据已经成功读取完毕!\n\n"<<endl;p2->next=NULL;in.close();return (head);}}//-------------------->菜单void Menu(){Information person;student *head=NULL;int choice;long i;head=person.Read();do{cout<<"\t※※※※※※※※※※※※※※※※※※※※※※※※※"<<endl;cout<<"\t※"<<endl;cout<<"\t※_ _ _ 欢迎进入员工信息统计管理_ _ _ "<<endl;cout<<"\t※"<<endl;cout<<"\t※※※※※※※※※※※※※※※※※※※※※※※※※"<<endl;cout<<"\t "<<endl;cout<<"\t 相关操作选项"<<endl;cout<<"\t "<<endl;cout<<"\t※※※※※※※※※※※※※※※※※※※※※※※※※"<<endl;cout<<"\t※※"<<endl;cout<<"\t※※"<<endl;cout<<"\t※ 1. 员工数据输入※"<<endl;cout<<"\t※※"<<endl;cout<<"\t※ 2. 显示员工工资※"<<endl;cout<<"\t※※"<<endl;cout<<"\t※ 3. 排序统计工资※"<<endl;cout<<"\t※※"<<endl;cout<<"\t※ 4. 查找员工工资※"<<endl;cout<<"\t※※"<<endl;cout<<"\t※ 5. 增加员工工资※"<<endl;cout<<"\t※※"<<endl;cout<<"\t※ 6. 删除员工工资※"<<endl; cout<<"\t※※"<<endl;cout<<"\t※7. 修改员工信息※"<<endl; cout<<"\t※※"<<endl;cout<<"\t※8. 成功保存信息※"<<endl;cout<<"\t※※"<<endl;cout<<"\t※9. 安全退出系统※"<<endl; cout<<"\t※※"<<endl;cout<<"\t※※※※※※※※※※※※※※※※※※※※※※※※※※※\n"<<endl; cout<<" 请输入您的选择(0--9):";cin>>choice;while(choice<0||choice>9){cout<<" 对不起您的输入错误!请输入您的选择(0--9): ";cin>>choice;}//head=person.Read();switch(choice){case 1:head=person.creat();break;case 2://head=person.Read();person.output(head);break;case 3://head=person.Read();person.paixu(head); person.average(head);cout<<" 参加工作的员工人数为:"<<person.count(head)<<"人\n\n";break;case 4://head=person.Read();cout<<" 请输入要查找的编号:";cin>>i;while(i<0||i>100000){cout<<" 对不起您的输入错误!请重新输入: ";cin>>i;}person.find(head,i);break;case 5://head=person.Read();head=person.insert(head);person.output(head);break;case 6://head=person.Read();cout<<" 请输入要删除的编号:";cin>>i;while(i<0||i>100000){cout<<" 对不起您的输入错误!请重新输入: ";cin>>i;}head=person.cancel(head,i);person.output(head);break;case 7://head=person.Read();cout<<" 请输入要修改的编号:";cin>>i;while(i<0||i>100000){cout<<" 对不起您的输入错误!请重新输入: ";cin>>i;}person.modify(head,i);break;case 8:cout<<"信息已经成功保存!"<<endl;person.save(head);break;case 9:system("cls");break;default :cout<<" 对不起您的输入有误!请重新输入:\n";break;}}while(choice!=9);}//----------------->管理员登陆void Pass(){char UserName[30];char Passward[20];int i=0;cout<<"****************************************************************************\n";cout<<"\n\t为保护员工信息,只有管理员才可以进行管理!\n";cout<<"\n\t管理员名和登陆密码都只有4次机会,如果超过将自动退出系统!\n\n";cout<<"****************************************************************************\n";cout<<"\n请输入管理员名:";cin>>UserName;while (strcmp(UserName,"1")!=0){if(i>=3)exit(0); //超过4次则登陆失败,退出系统i++;cout<<"\n管理员名无效!请重新输入:";cin>>UserName;}cout<<"\n请输入密码:";cin>>Passward;while(strcmp(Passward,"1")!=0){if(i>=3)exit(0); //超过4次则登陆失败,退出系统i++;cout<<"\n密码输入错误!请重新输入:"<<endl; cin>>Passward;}cout<<"\n\t\t欢迎管理员的到来!!!!!\n"<<endl;}//------------------------------>主函数.int main(void){//设置背景色和字体颜色system("PAUSE"); //系统暂停system("cls"); //系统清屏Pass();system("PAUSE");system("cls");Menu();return 0; }//。

职工工资管理系统设计与源代码

职工工资管理系统设计与源代码

职工工资管理系统一、设计目标:按照软件工程的规范,以SQL Server或Access为后台数据库,以Delphi 或Visual C++为前端开发工具,设计并实现一个简化的工资管理系统。

二、需求描述该系统存储了某单位全体职工和工资信息。

职工的基本信息包括:职工编号、姓名、性别、出生年月、职称、最后学历、工资和婚否。

每一个职工的工资信息包括:月份、职工编号、职工姓名、基本工资、津贴、岗贴、补贴、房贴、交通补贴、应发数、房租、储蓄、会费、个人所得税、应扣数、实发数、其他收入。

个人所得税计算方法设为:应发数少于800元为0;800~1000元的部分为5%;1000~5000元的部分为10%;5000元以上的部分为20%。

系统功能如下:1.职工信息管理:a.增加职工信息。

增加新职工时输入新职工的基本信息;b.删除某职工的基本信息。

如,职工死亡或离职时;c.修改某职工(指定职工编号)的某些信息(如,加工资、获得新学位、晋升职称、结婚或离婚)。

2.工资管理:a.增加工资信息。

当增加新职工时,添加某职工的工资信息;b.职工离职或死亡时,删除某职工的工资信息;c.修改工资信息。

当月开始增加或减少某些项工资或扣款数变化时,修改某职工的部分工资信息;3.查询与统计:a.查询职工信息,如查询全体职工信息,或按职称、学历、出生年月、出生年月之前/ 之后、已婚/ 未婚等条件或多个条件的组合来查询相应的职工信息。

b.查询指定编号职工的工资信息;c.按时间段统计职工收入或单位的工资支出。

三、概要设计四、详细设计void CWorkerMgr6View::OnExit(){OnExit();}void CWorkerMgr6View::OnRecordFirst(){if(m_pSet->IsBOF()){m_pSet->SetFieldNull(NULL);}else{m_pSet->MoveFirst();UpdateData(FALSE);//更新对话框窗口}}void CWorkerMgr6View::OnRecordLast(){m_pSet->MoveLast();UpdateData(FALSE);//更新对话框窗口}void CWorkerMgr6View::OnRecordNext(){if(m_pSet->IsBOF()){m_pSet->SetFieldNull(NULL);}//判断是否溢出if(m_pSet->IsEOF()){AfxMessageBox("已经到达最后记录");}else{m_pSet->MoveNext();}UpdateData(FALSE);}void CWorkerMgr6View::OnRecordPre(){if(m_pSet->IsBOF()){AfxMessageBox("已经到达第一个记录");m_pSet->MoveFirst();}m_pSet->MovePrev();UpdateData(FALSE);}void CWorkerMgr6View::OnAddWorker(){HRESULT hr;try{hr =m_pConnection.CreateInstance("ADODB.Connection");//创建Connection对象if(SUCCEEDED(hr)){hr=m_pConnection->Open("Provider=Microsoft.Jet.OLEDB.4.0;DataSource=worker.mdb","","",adModeUnknown);//连接数据库//上面一句中连接字串中的Provider是针对ACCESS2000环境的,对于ACCESS97,需要改为:Provider=Microsoft.Jet.OLEDB.3.51;}}catch(_com_error e)///捕捉异常{CString errormessage;errormessage.Format("连接数据库失败!\r\n错误信息:%s",e.ErrorMessage()); AfxMessageBox(errormessage);///显示错误信息}CAddWorker dl;if(dl.DoModal()==IDOK){m_pSet->AddNew();m_pSet->m_name=dl.m_nm;m_pSet->m_id=dl.m_ids;m_pSet->m_sex=dl.m_sx;m_pSet->m_born=dl.m_bn;m_pSet->m_zhichen=dl.m_zhch;m_pSet->m_xueli=dl.m_xli;m_pSet->m_salary=dl.m_sala;m_pSet->m_marry=dl.m_marr;m_pSet->Update();m_pSet->MoveLast();UpdateData(false);}OnAddMoney();}void CWorkerMgr6View::OnDeleteWorker(){HRESULT hr;try{hr =m_pConnection.CreateInstance("ADODB.Connection");//创建Connection对象if(SUCCEEDED(hr)){hr=m_pConnection->Open("Provider=Microsoft.Jet.OLEDB.4.0;DataSource=worker.mdb","","",adModeUnknown);///连接数据库///上面一句中连接字串中的Provider是针对ACCESS2000环境的,对于ACCESS97,需要改为:Provider=Microsoft.Jet.OLEDB.3.51;}}catch(_com_error e)///捕捉异常{CString errormessage;errormessage.Format("连接数据库失败!\r\n错误信息:%s",e.ErrorMessage()); AfxMessageBox(errormessage);///显示错误信息}CDelWorker dl;if(dl.DoModal()==IDOK)UpdateData(true);try{long id=dl.m_idid;CString str;str.Format("DELETE from worker where ID=%d",id);_variant_t RecordsAffected;m_pConnection->Execute((_bstr_t)str,&RecordsAffected,adCmdText); AfxMessageBox("删除成功!");}catch(_com_error*e){AfxMessageBox(e->ErrorMessage());}m_pSet->MoveNext();if(m_pSet->IsEOF())m_pSet->MoveLast();UpdateData(FALSE);}}void CWorkerMgr6View::OnChangWorker(){HRESULT hr;try{hr =m_pConnection.CreateInstance("ADODB.Connection");//创建Connection对象if(SUCCEEDED(hr)){hr=m_pConnection->Open("Provider=Microsoft.Jet.OLEDB.4.0;DataSource=worker.mdb","","",adModeUnknown);///连接数据库///上面一句中连接字串中的Provider是针对ACCESS2000环境的,对于ACCESS97,需要改为:Provider=Microsoft.Jet.OLEDB.3.51;}}catch(_com_error e)///捕捉异常{CString errormessage;errormessage.Format("连接数据库失败!\r\n错误信息:%s",e.ErrorMessage()); AfxMessageBox(errormessage);///显示错误信息}CChangeWork dl2;if(dl2.DoModal()==IDOK){UpdateData(true);long id=dl2.m_wid;m_pSet->MoveFirst();while(m_pSet->m_id!=dl2.m_wid)m_pSet->MoveNext();CChangeOne dl1;dl1.m_name1=m_pSet->m_name;dl1.m_id1=m_pSet->m_id;dl1.m_sex1=m_pSet->m_sex;dl1.m_born1=m_pSet->m_born;dl1.m_zhichen1=m_pSet->m_zhichen;dl1.m_xueli=m_pSet->m_xueli;dl1.m_salary1=m_pSet->m_salary;dl1.m_marry1=m_pSet->m_marry;if(dl1.DoModal()==IDOK){m_pSet->Edit();m_pSet->m_name=dl1.m_name1;m_pSet->m_id=dl1.m_id1;m_pSet->m_sex=dl1.m_sex1;m_pSet->m_born=dl1.m_born1;m_pSet->m_zhichen=dl1.m_zhichen1;m_pSet->m_xueli=dl1.m_xueli;m_pSet->m_salary=dl1.m_salary1;m_pSet->m_marry=dl1.m_marry1;m_pSet->Update();// m_pSet->MoveNext();UpdateData(false);}}}void CWorkerMgr6View::OnMShowDetail() {CMShowDetail dl;long id=m_pSet->m_id;m_pSet->MoveFirst();while(m_pSet->m_id!=id)m_pSet->MoveNext();dl.m_month=m_pSet->m_month;dl.m_id=m_pSet->m_id;dl.m_name=m_pSet->m_name;dl.m_base=m_pSet->m_base;dl.m_jintie=m_pSet->m_jintie;dl.m_gangtie=m_pSet->m_gangtie;dl.m_butie=m_pSet->m_butie;dl.m_fangtie=m_pSet->m_fangtie;dl.m_jiaotong=m_pSet->m_jiaotong;dl.m_yingfa=dl.m_base+dl.m_jintie+dl.m_gangtie+dl.m_butie+dl.m_fangtie+ dl.m_jiaotong;dl.m_fangzu=m_pSet->m_fangzu;dl.m_chuxu=m_pSet->m_chuxu;dl.m_huifei=m_pSet->m_huifei;if(dl.m_yingfa<800){dl.m_gerentax=0;}else if(dl.m_yingfa>=800&&dl.m_yingfa<=1000){dl.m_gerentax=dl.m_yingfa*0.05f;}else if(dl.m_yingfa>1000&&dl.m_yingfa<=5000){dl.m_gerentax=dl.m_yingfa*0.1f;}else if(dl.m_yingfa>5000){dl.m_gerentax=dl.m_yingfa*0.2f;}dl.m_yingkou=dl.m_fangzu+dl.m_chuxu+dl.m_huifei+dl.m_gerentax;dl.m_shifa=dl.m_yingfa-dl.m_yingkou;dl.m_other=m_pSet->m_other;dl.DoModal();}void CWorkerMgr6View::OnAddMoney(){CAddMoney dl;dl.m_id=m_pSet->m_id;dl.m_name=m_pSet->m_name;if(dl.DoModal()==IDOK){m_pSet->Edit();m_pSet->m_base=dl.m_base;m_pSet->m_month=dl.m_month;m_pSet->m_jintie=dl.m_jintie;m_pSet->m_gangtie=dl.m_gangtie;m_pSet->m_butie=dl.m_butie;m_pSet->m_fangtie=dl.m_fangtie;m_pSet->m_jiaotong=dl.m_jiaotong;dl.m_yingfa=dl.m_base+dl.m_jintie+dl.m_gangtie+dl.m_butie+dl.m_fangtie+ dl.m_jiaotong;m_pSet->m_yingfa=dl.m_yingfa;m_pSet->m_fangzu=dl.m_fangzu;m_pSet->m_chuxu=dl.m_chuxu;m_pSet->m_huifei=dl.m_huifei;if(dl.m_yingfa<800){dl.m_gerentax=0;}else if(dl.m_yingfa>=800&&dl.m_yingfa<=1000){dl.m_gerentax=dl.m_yingfa*0.05f;}else if(dl.m_yingfa>1000&&dl.m_yingfa<=5000){dl.m_gerentax=dl.m_yingfa*0.1f;else if(dl.m_yingfa>5000){dl.m_gerentax=dl.m_yingfa*0.2f;}m_pSet->m_gerentax=dl.m_gerentax;dl.m_yingkou=dl.m_fangtie+dl.m_chuxu+dl.m_huifei+dl.m_gerentax;m_pSet->m_yingkou=dl.m_yingkou;dl.m_shifa=dl.m_yingfa-dl.m_yingkou;m_pSet->m_shifa=dl.m_shifa;m_pSet->m_other=dl.m_other;m_pSet->Update();//m_pSet->MoveLast();UpdateData(false);}}void CWorkerMgr6View::OnDeleteMoney(){HRESULT hr;try{hr =m_pConnection.CreateInstance("ADODB.Connection");//创建Connection对象if(SUCCEEDED(hr)){hr=m_pConnection->Open("Provider=Microsoft.Jet.OLEDB.4.0;DataSource=worker.mdb","","",adModeUnknown);///连接数据库///上面一句中连接字串中的Provider是针对ACCESS2000环境的,对于ACCESS97,需要改为:Provider=Microsoft.Jet.OLEDB.3.51;}}catch(_com_error e)///捕捉异常{CString errormessage;errormessage.Format("连接数据库失败!\r\n错误信息:%s",e.ErrorMessage()); AfxMessageBox(errormessage);///显示错误信息}CDeleteMoney dl;if(dl.DoModal()==IDOK)UpdateData(true);try{long id=dl.m_id;CString str;str.Format("DELETE from worker where ID=%d",id);_variant_t RecordsAffected;m_pConnection->Execute((_bstr_t)str,&RecordsAffected,adCmdText); AfxMessageBox("删除成功!");}catch(_com_error*e){AfxMessageBox(e->ErrorMessage());}m_pSet->MoveNext();if(m_pSet->IsEOF())m_pSet->MoveLast();UpdateData(FALSE);}}void CWorkerMgr6View::OnChangeMoney(){HRESULT hr;try{hr =m_pConnection.CreateInstance("ADODB.Connection");//创建Connection对象if(SUCCEEDED(hr)){hr=m_pConnection->Open("Provider=Microsoft.Jet.OLEDB.4.0;DataSource=worker.mdb","","",adModeUnknown);}}catch(_com_error e) //捕捉异常{CString errormessage;errormessage.Format("连接数据库失败!\r\n错误信息:%s",e.ErrorMessage()); AfxMessageBox(errormessage); //显示错误信息}CChangeWork dl2;if(dl2.DoModal()==IDOK){UpdateData(true);long id=dl2.m_wid;m_pSet->MoveFirst();while(m_pSet->m_id!=dl2.m_wid)m_pSet->MoveNext();CChangeMoney dl1;dl1.m_month=m_pSet->m_month;dl1.m_name=m_pSet->m_name;dl1.m_id=m_pSet->m_id;dl1.m_base=m_pSet->m_base;dl1.m_jintie=m_pSet->m_jintie;dl1.m_gangtie=m_pSet->m_gangtie;dl1.m_butie=m_pSet->m_butie;dl1.m_fangtie=m_pSet->m_fangtie;dl1.m_jiaotong=m_pSet->m_jiaotong;dl1.m_yingfa=dl1.m_base+dl1.m_jintie+dl1.m_gangtie+dl1.m_butie+dl1.m_fa ngtie+dl1.m_jiaotong;dl1.m_fangzu=m_pSet->m_fangzu;dl1.m_chuxu=m_pSet->m_chuxu;dl1.m_huifei=m_pSet->m_huifei;if(dl1.m_yingfa<800){dl1.m_gerentax=0;}else if(dl1.m_yingfa>=800&&dl1.m_yingfa<=1000){dl1.m_gerentax=dl1.m_yingfa*0.05f;}else if(dl1.m_yingfa>1000&&dl1.m_yingfa<=5000){dl1.m_gerentax=dl1.m_yingfa*0.1f;}else if(dl1.m_yingfa>5000){dl1.m_gerentax=dl1.m_yingfa*0.2f;}dl1.m_yingkou=dl1.m_gerentax+dl1.m_fangzu+dl1.m_chuxu+dl1.m_huifei;dl1.m_shifa=dl1.m_yingfa-dl1.m_yingkou;dl1.m_other=dl1.m_other;if(dl1.DoModal()==IDOK){m_pSet->Edit();m_pSet->m_name=dl1.m_name;m_pSet->m_id=dl1.m_id;m_pSet->m_month=dl1.m_month;m_pSet->m_base=dl1.m_base;m_pSet->m_jintie=dl1.m_jintie;m_pSet->m_gangtie=dl1.m_gangtie;m_pSet->m_butie=dl1.m_butie;m_pSet->m_fangtie=dl1.m_fangtie;m_pSet->m_jiaotong=dl1.m_jiaotong;m_pSet->m_yingfa=dl1.m_base+dl1.m_jintie+dl1.m_gangtie+dl1.m_butie+dl1. m_fangtie+dl1.m_jiaotong;m_pSet->m_fangzu=dl1.m_fangzu;m_pSet->m_chuxu=dl1.m_chuxu;m_pSet->m_huifei=dl1.m_huifei;if(m_pSet->m_yingfa<800){m_pSet->m_gerentax=0;}else if(m_pSet->m_yingfa>=800&&m_pSet->m_yingfa<=1000){m_pSet->m_gerentax=m_pSet->m_yingfa*0.05f;}else if(m_pSet->m_yingfa>1000&&m_pSet->m_yingfa<=5000){m_pSet->m_gerentax=m_pSet->m_yingfa*0.1f;}else if(m_pSet->m_yingfa>5000){m_pSet->m_gerentax=m_pSet->m_yingfa*0.2f;}m_pSet->m_yingkou=dl1.m_fangzu+dl1.m_chuxu+dl1.m_huifei+m_pSet->m_geren tax;m_pSet->m_shifa=m_pSet->m_yingfa-m_pSet->m_yingkou;m_pSet->m_other=dl1.m_other;m_pSet->Update();// m_pSet->MoveNext();UpdateData(false);}}}void CWorkerMgr6View::OnFindMoney(){HRESULT hr;try{hr =m_pConnection.CreateInstance("ADODB.Connection");//创建Connection对象if(SUCCEEDED(hr)){hr=m_pConnection->Open("Provider=Microsoft.Jet.OLEDB.4.0;DataSource=worker.mdb","","",adModeUnknown);}}catch(_com_error e) //捕捉异常{CString errormessage;errormessage.Format("连接数据库失败!\r\n错误信息:%s",e.ErrorMessage()); AfxMessageBox(errormessage); //显示错误信息}CFindNo dl2;if(dl2.DoModal()==IDOK){UpdateData(true);long id=dl2.m_id;m_pSet->MoveFirst();while(m_pSet->m_id!=dl2.m_id)m_pSet->MoveNext();CMShowDetail dl1;dl1.m_month=m_pSet->m_month;dl1.m_name=m_pSet->m_name;dl1.m_id=m_pSet->m_id;dl1.m_base=m_pSet->m_base;dl1.m_jintie=m_pSet->m_jintie;dl1.m_gangtie=m_pSet->m_gangtie;dl1.m_butie=m_pSet->m_butie;dl1.m_fangtie=m_pSet->m_fangtie;dl1.m_jiaotong=m_pSet->m_jiaotong;dl1.m_yingfa=dl1.m_base+dl1.m_jintie+dl1.m_gangtie+dl1.m_butie+dl1.m_fa ngtie+dl1.m_jiaotong;dl1.m_fangzu=m_pSet->m_fangzu;dl1.m_chuxu=m_pSet->m_chuxu;dl1.m_huifei=m_pSet->m_huifei;if(dl1.m_yingfa<800){dl1.m_gerentax=0;}else if(dl1.m_yingfa>=800&&dl1.m_yingfa<=1000){dl1.m_gerentax=dl1.m_yingfa*0.05f;}else if(dl1.m_yingfa>1000&&dl1.m_yingfa<=5000){dl1.m_gerentax=dl1.m_yingfa*0.1f;}else if(dl1.m_yingfa>5000){dl1.m_gerentax=dl1.m_yingfa*0.2f;}dl1.m_yingkou=dl1.m_gerentax+dl1.m_fangzu+dl1.m_chuxu+dl1.m_huifei;dl1.m_shifa=dl1.m_yingfa-dl1.m_yingkou;dl1.m_other=dl1.m_other;dl1.DoModal();}}void CWorkerMgr6View::OnStaticsMoney(){HRESULT hr;try{hr =m_pConnection.CreateInstance("ADODB.Connection");//创建Connection对象if(SUCCEEDED(hr)){hr=m_pConnection->Open("Provider=Microsoft.Jet.OLEDB.4.0;DataSource=worker.mdb","","",adModeUnknown);}}catch(_com_error e) //捕捉异常{CString errormessage;errormessage.Format("连接数据库失败!\r\n错误信息:%s",e.ErrorMessage()); AfxMessageBox(errormessage); //显示错误信息}m_pSet->MoveFirst();float sum=0;while(!m_pSet->IsEOF()){sum=sum+m_pSet->m_shifa;m_pSet->MoveNext();}CString string;string.Format("%f",sum);MessageBox(string,"统计当月支出",MB_OKCANCEL);}五、测试及结果分析(a)在此前端主界面下查看后台数据库中员工的基本信息。

C++职工工资管理系统代码

C++职工工资管理系统代码

C++职工工资管理系统代码项目简介本项目是一个基于C++语言的职工工资管理系统。

它能够很好地管理公司内部的职工信息和工资发放情况,方便公司管理人员对职工数据进行快速、准确的查询和统计。

技术实现本项目使用C++语言编写,主要用到了以下技术:•面向对象编程:本项目基于面向对象的编程思想,将职工信息和工资管理抽象成对象,方便代码的组织和维护。

•文件操作:本项目使用文件存储职工信息和工资发放情况,利用文件操作实现数据的读写和更新。

•数据结构:本项目用到了数组、链表等数据结构,用来存储和操作职工和工资数据。

功能实现本项目包含以下功能:•添加职工信息:可以添加新的职工信息,包括职工编号、姓名、性别、年龄、职位等。

•显示职工信息:可以输出所有职工的信息,或根据职工编号、姓名等关键字查询职工信息。

•删除职工信息:可以根据职工编号删除职工信息。

•修改职工信息:可以根据职工编号修改职工信息,包括姓名、性别、年龄、职位等。

•计算职工工资:可以根据职工编号计算职工的工资,并输出实发工资。

•按照职工编号排序:可以按照职工编号升序排序输出所有职工信息。

•清空所有职工信息:可以清空文件中所有的职工信息。

使用说明1.安装编译环境:本项目需要使用C++编译器才能运行,请安装相关的编译环境。

2.下载代码:可以直接在Github上下载本项目的源代码,或通过Git命令将代码clone到本地。

3.编译运行:使用编译器将源代码编译成可执行文件,然后在终端运行可执行文件即可使用本系统。

代码实现下面是本项目部分核心代码的实现:// 职工类class Worker {public:// 构造函数Worker(int id, string name, int age, string sex, string position);// 显示职工信息void showInfo();// 获取职工编号int getId();// 修改职工信息void updateInfo();// 计算职工工资virtual int getSalary() = 0;private:int m_id; // 编号string m_name; // 姓名int m_age; // 年龄string m_sex; // 性别string m_position;// 职位};// 公司类class WorkerManager {public:// 构造函数WorkerManager();// 显示菜单void showMenu();// 退出系统void exitSystem();// 添加职工void addWorker();// 显示所有职工void showAllWorkers();// 删除职工void deleteWorker();// 修改职工信息void modifyWorker();// 查找职工void findWorker();// 按编号排序void sortWorker();// 清空所有记录void cleanAllWorkers();// 获取职工数量int getWorkerNum();// 析构函数~WorkerManager();private:int m_workerNum; // 职工人数bool m_fileIsEmpty; // 文件是否为空vector<Worker*> m_workerArray; // 职工数组};技术难点与解决方案在开发本项目的过程中,我遇到了一些技术难点,主要包括:1.文件读写:如何实现数据的读写和更新,避免数据出错和丢失。

C语言课程设计职工工资信息管理系统源代码

C语言课程设计职工工资信息管理系统源代码

#include <stdio.h>#include <string.h>#include <stdlib.h>#include <conio.h>#define N 10000int choice;struct employee{int num;int position;char name[10000];char sex[2];int salary;int i,max,t;}em[N];struct empsalary{char name[10000];int salary;}emps[N];void manage();void query();void input();void display();void change();void del();void add();void paixu();int changeposition();int changesalary();void querysalary();void creat();void main(){do{printf("欢迎进入职工管理系统中文版\n"); printf("请你选择操作类型:\n");printf("1进入管理系统\n");printf("2进入查询系统\n");printf("0退出系统\n");scanf("%d",&choice);switch(choice){case 1:manage();break;case 2:query();break;case 0:{printf("谢谢使用,再见\n");exit(0);}default:{printf("输入有错误请重新输入:\n");return;}}}while(1);}void manage(){int choicemanage;char choice='y';while(choice=='y'||choice=='Y'){printf("欢迎进入管理系统\n");printf("请你选择操作类型:\n");printf("1输入职工信息\n");printf("2显示职工信息\n");printf("3修改职工信息\n");printf("4追加一个职工信息\n");printf("5删除一个职工信息\n");printf("6排序\n");printf("0返回\n");scanf("%d",&choicemanage);switch(choicemanage){case 1:input();break;case 2:display();break;case 3:change();break;case 4:add();break;case 5:del();case 6:paixu();break;case 0:printf("谢谢你的使用再见\n");return;default:printf("你的输入有错请重新输入\n"); }printf("是否继续管理?(y/n)");scanf("%s",&choice);}if(toupper(choice)=='N'||(choice)=='n'){printf("输入完毕,任意键返回\n");getch();return;}}void input(){FILE *fp;int i=0;char choiceinput='y';if((fp=fopen("employee.txt","w"))==NULL) return;while(choiceinput=='y'||choiceinput=='Y'){i++;printf("第%d个职工\n",i);printf("\n");printf("请你输入工号:\n");scanf("%d",&em[i].num);printf("\n");printf("请你输入职位:\n");printf("1董事长2总经理3副总经理\n");printf("4经理5副经理6秘书\n");printf("7技术员8领班9员工\n");scanf("%d",&em[i].position);printf("\n");printf("请你输入姓名:\n");scanf("%s",em[i].name);printf("\n");printf("请你输入性别以m为男f为女:\n");scanf("%s",em[i].sex);printf("\n");printf("请你输入工资:\n");scanf("%d",&em[i].salary);printf("\n");printf("是否继续输入?(y/n)\n");scanf("%s",&choiceinput);fwrite(&em[i],sizeof(struct employee),1,fp);}if(toupper(choiceinput)=='N'){fclose(fp);printf("输入完毕,任意键返回\n");getch();return;}}void display(){FILE *fp;int i;if((fp=fopen("employee.txt","r"))==NULL)return;printf("输出结果:\n");for(i=0;fread(&em[i],sizeof(struct employee),1,fp)!=0;i++) {printf("工号%d\n",em[i].num);printf("职位为%d\n",em[i].position);printf("1董事长2总经理3副总经理\n");printf("4经理5副经理6秘书\n");printf("7技术员8领班9员工\n");printf("姓名为%s\n",em[i].name);printf("性别为%s\n",em[i].sex);printf("其中m为男f为女\n");printf("工资为%d\n",em[i].salary);}printf("完毕按任意键返回\n");getch();fclose(fp);return;}void change(){FILE *fp;int i;char chname[8];int choicechange;printf("请你输入要修改的人的姓名:\n");scanf("%s",&chname);if((fp=fopen("employee.txt","w+"))==NULL){printf("不能够打开这个文件\n");return;}for(i=0;i<N;i++){if(strcmp(chname,em[i].name)==0){printf("这是你要修改的人的信息\n");printf("工号为%d\n 职位为%d\n 姓名为%s\n 性别为%s\n 工资为%d\n",em[i].num,em[i].position,em[i].name,em[i].sex,em[i].salary);printf("请你输入要修改的部分:\n");printf("1修改职位\n");printf("2修改工资\n");printf("0退出系统\n");printf("请选择\n");scanf("%d",&choicechange);switch(choicechange){case 1:em[i].position=changeposition();break;case 2:em[i].salary=changesalary();break;case 0:return;default :printf("输入有错误");}fwrite(&em[i],sizeof(struct employee),1,fp); }}fclose(fp);printf("操作完成按任意键返回\n");getch();return;}int changeposition(){int newposition;printf("请你输入新职位:\n");printf("1董事长2总经理3副总经理\n"); printf("4经理5副经理6秘书\n"); printf("7技术员8领班9员工\n"); scanf("%d",&newposition);return(newposition);}int changesalary(){int newsalary;printf("请你输入新的工资:\n");scanf("%d",&newsalary);return(newsalary);}void add(){struct employee emp;FILE *fp;int i=0;if((fp=fopen("employee.txt","ab+"))==NULL){printf("不能够打开这个文件\n");getch();return;}printf("请你输入新人的内容:\n");printf("请你输入工号:\n");scanf("%d",&em[i].num);printf("请你输入职位:\n");printf("1董事长2总经理3副总经理\n");printf("4经理5副经理6秘书\n");printf("7技术员8领班9员工\n");scanf("%d",&emp.position);printf("请你输入姓名:\n");scanf("%s",);printf("请你输入性别以m为男f为女:\n");scanf("%s",emp.sex);printf("请你输入工资:\n");scanf("%d",&emp.salary);fwrite(&emp,sizeof(struct employee),1,fp);rewind(fp);printf("插入完毕,按任意键返回\n");getch();fclose(fp);return;}void del(){int i=0;char delname[8];FILE *fp;if((fp=fopen("employee.txt","w"))==NULL){printf("文件为空,不能够打开\n");printf("按任意键返回\n");getch();return;}printf("请你输入要删除的人的姓名:\n");scanf("%s",delname);for(i=0;fread(&em[i],sizeof(struct employee),1,fp)!=0;i++) {if(strcmp(em[i].name,delname)!=0)fwrite(&em[i],sizeof(struct employee),1,fp);}fclose(fp);if((fp=fopen("employee.txt","r"))==NULL)return;printf("新的职工的信息为:\n");for(i=0;fread(&em[i],sizeof(struct employee),1,fp)!=0;i++) {printf("工号%d",em[i].num);printf("职位为%d",em[i].position);printf("1董事长2总经理3副总经理\n");printf("4经理5副经理6秘书\n");printf("7技术员8领班9员工\n");printf("姓名为%s\n",em[i].name[8]);printf("性别为%s\n",em[i].sex[2]);printf("其中m为男f为女\n");printf("工资为%d\n",em[i].salary);fclose(fp);}}void query(){FILE *fp;int i=0;char quename[8];if((fp=fopen("employee.txt","r"))==NULL){printf("不能够打开文件,按任意键返回\n");getch();return;}printf("请你输入要查询的人的姓名\n");scanf("%s",quename);for(i=0;fread(&em[i],sizeof(struct employee),1,fp)!=0;i++) {if(strcmp(em[i].name,quename)==0){printf("\t\t\n查询到的职工号或姓名为的信息如下:\n");printf("以下是你要查询的人的信息\n");printf("工号%d",em[i].num);printf("职位为%d",em[i].position);printf("\t 1董事长2总经理3副总经理\n");printf("\t 4经理5副经理6秘书\n");printf("\t 7技术员8领班9员工\n");printf("姓名为%s\n",em[i].name);printf("性别为%s\n",em[i].sex);printf("\t其中m为男f为女\n");printf("工资为%d\n",em[i].salary);printf("\n");printf("查询完毕,按任意键返回\n");getch();fclose(fp);return;}}printf("没有这样的人,按任意键返回\n");getch();fclose(fp);return;}void querysalary(){int i;FILE *fp1,*fp2;creat();if((fp1=fopen("employee.txt","w+"))==NULL)return;for(i=0;fread(&em[i],sizeof(struct employee),1,fp1)!=0;i++) {printf("输出结果为:\n");printf("工号%d",em[i].num);printf("职位为%d",em[i].position);printf(" 1董事长2总经理3副总经理\n");printf(" 4经理5副经理6秘书\n");printf(" 7技术员8领班9员工\n");printf("姓名为%s\n",em[i].name[8]);printf("性别为%s\n",em[i].sex[2]);printf("其中m为男f为女\n");printf("工资为%d\n",em[i].salary);strcpy(emps[i].name,em[i].name);emps[i].salary=em[i].salary;}if((fp2=fopen("empsalary.txt","w"))==NULL)return;for(i=0;i<N;i++)fwrite(&emps[i],sizeof(struct empsalary),1,fp2);fclose(fp1);fclose(fp2);}void creat(){FILE *fp;if((fp=fopen("D:\\employee.txt","w+"))==NULL)return;input();fclose(fp);}void paixu(){int max,i,t,j;for(i=1;i<10;i++){max=em[i].salary;for(j=i;j<10;j++){if(em[j].salary>max){max=em[j].salary;t=em[j].salary;em[j].salary=t;}}}printf("姓名工资工号性别职位\n");for(i=1;i<10;i++)printf(" %s %d %d %s %d\n ",em[i].name,em[i].salary,em[i].num,em[i].sex,em[i].position);}。

c语言课程设计职工工资管理系统源代码word文档

c语言课程设计职工工资管理系统源代码word文档

绝对可以完美运行,下面有运行图片#include<stdio.h> //调用库函数#include<string.h> //字符串处理#include<conio.h> //控制台输入输出#include<stdlib.h> //定义杂项函数及内存分配函数#define N 2 //宏定义以3代替N/******************************************************************************函数声明*******************************************************************************/ void enter();int menu();void input();void output();void search();void search_employeeid();void search_name();void edit();void array();void array_basesalary();void array_postwage();void array_totalwage();void statistics();void save();void load();/******************************************************************************职工类型定义*******************************************************************************/ struct employee{char employeeid[10];char name[10];char sex[10];int age;float basesalary;float postwage;float totalwage;};/******************************************************************************职工变量定义******************************************************************************/ struct employee emp[N];struct employee replace;struct employee *p=emp;/*****************************************************************************系统主函数******************************************************************************/ void main(){int c;while(1){printf(" \n\n\n\n"); printf(" 欢迎进入职工工资管理系统 \n\n\n");printf(" 1 进入管理系统 \n\n");printf(" 0 退出 \n\n");printf(" \n\n\n\n");printf(" 请输入你选择: \n");scanf("%d",&c);switch(c){case 1:enter();break;case 0:printf(" 谢谢使用!\n");exit(0);}}}/*****************************************************************************功能:登陆函数,进行密码验证*****************************************************************************/ void enter(){char q;char key[10],password[10]="china";int k=1,i;printf(" 请输入密码: \n");for(i=0;i<5;i++){q=getch();key[i]=q;printf("*");}while(k<=3){if(strncmp(key,password,5)==0){while(1){int a;//system("cls");a=menu();switch(a){case 1:input();break;case 2:output();break;case 3:search();break;case 4:edit();break;case 5:array();break;case 6:load();statistics();break;case 0:printf("\n\n 谢谢使用!\n\n\n\n");save();exit(0);}}}else{k++;printf(" 输入密码错误!请再次输入:");for(i=0;i<5;i++){q=getch();key[i]=q;printf("*");}if(k>2){if(strncmp(password,key,5)==0)continue;else{printf(" 输入密码错误三次,系统将自动退出!\n");exit(0);}}}}}/************************************************************************功能: 主菜单函数参数:a类型:int说明: 变量返回值: a************************************************************************/int menu(){int a ;printf("\n\n");printf("|*****************欢迎进入职工工资管理系统************************|\n");printf("| |\n");printf("| |\n");printf("| 1 职工信息输入|\n");printf("| |\n");printf("| 2 职工信息输出|\n");printf("| |\n");printf("| 3 职工信息查询|\n");printf("| |\n");printf("| 4 职工信息修改|\n");printf("||\n");printf("| 5 工资排序|\n");printf("||\n");printf("| 6 工资统计|\n");printf("||\n");printf("| 0 退出|\n");printf("||\n");printf("||\n");printf("|*****************************************************************|\n");printf("\n\n");printf(" 请输入你所选择的选项:");scanf("%d",&a);while(a>6||a<0){printf(" error!\n");printf(" 请重新输入你所选择的选项:");scanf("%d",&a);}return a;}/********************************************************************************* ***功能:职工信息输入********************************************************************************** ***/void input(){int c;p=emp;printf(" 进入职工信息输入模块 \n\n\n");for(c=0;c<N;c++,p++){p[c].totalwage=p[c].basesalary+p[c].postwage;printf(" 请输入第%d个职工信息:\n\n",c+1);printf(" 请输入职工号:\n");scanf("%s",p->employeeid);if(strcmp(p->employeeid,"0")!=0){printf(" 请输入职工姓名:\n");scanf("%s",p->name);printf(" 请输入职工性别: \n");scanf("%s",&p->sex);printf(" 请输入职工年龄: \n");scanf("%d",&p->age);printf(" 请输入职工基本工资:\n");scanf("%f",&p->basesalary);printf(" 请输入职工岗位工资:\n");scanf("%f",&p->postwage);printf(" 职工信息输入完成! \n\n");}elsereturn;}save();}/*******************************************************************************功能:职工信息输出********************************************************************************/ void output(){int j;load();p=emp;printf(" 进入职工信息输出模块 \n\n\n");printf("-------------------------------------------------------------------------------\n");printf("| 职工号 |姓名 |性别 |年龄 |基本工资 |岗位工资|总工资 |\n");printf("-------------------------------------------------------------------------------\n");for(j=0;j<N;j++){p[j].totalwage=p[j].postwage+p[j].basesalary;printf("|%10s|%9s|%7s| %5d| %10.2f| %10.2f| %10.2f|\n",p[j].employeeid, p[j].name,p[j].sex,p[j].age,p[j].basesalary,p[j].postwage,p[j].totalwage);printf("-------------------------------------------------------------------------------\n");}printf("\n\n 职工信息输出完成! \n\n");getchar();}/******************************************************************************功能:职工信息查询******************************************************************************/ void search(){int j;while(1){printf("*********************职工信息查询*********************\n\n\n");printf(" 1 按职工号查询 \n");printf(" 2 按职工姓名查询 \n");printf(" 0 退出该项操作 \n");printf("\n\n");while(1){printf(" 请输入你的选择 \n");scanf("%d",&j);if(j>=0&&j<=2){switch(j){case 1:search_employeeid();break;case 2:search_name();break;case 0:return;}}else{printf(" 输入错误! \n\n");printf(" 请再次输入你的选择:\n\n");}}}}/*******************************************************************************功能:按职工号查询函数*******************************************************************************/ void search_employeeid(){char employeeid[10];int k,j;p=emp;printf("*********************按职工号查询职工信息*****************************\n\n\n\n");printf(" 请输入要查询职工的职工号:\n\n");scanf("%s",employeeid);for(k=0;k<N;k++){if(strcmp(employeeid,p->employeeid)==0){j=k;p[j].totalwage=p[j].postwage+p[j].basesalary;printf("-------------------------------------------------------------------------------\n");printf("| 职工号 |姓名 |性别 |年龄 |基本工资 |岗位工资|总工资 |\n");printf("|%10s|%9s|%7s| %5d| %10.2f| %10.2f| %10.2f|\n",p[j].employeeid, p[j].name,p[j].sex,p[j].age,p[j].basesalary,p[j].postwage,p[j].totalwage);printf("-------------------------------------------------------------------------------\n");break;}else{printf(" not found\n");return;}}}/*****************************************************************************功能:按职工姓名查询函数*****************************************************************************/ void search_name(){char name[10];int flog=0;int f,j;p=emp;printf("******************************按职工姓名查询职工信息***********************\n\n\n");printf(" 请输入要查询职工的姓名:\n\n");scanf("%s",name);for(f=0;f<N;f++,p++){if(strcmp(name,p->name)==0){j=f;p[j].totalwage=p[j].postwage+p[j].basesalary;printf("-------------------------------------------------------------------------------\n");printf("| 职工号 |姓名 |性别 |年龄 |基本工资 |岗位工资|总工资 |\n");printf("|%10s|%9s|%7s| %5d| %10.2f| %10.2f| %10.2f|\n",p[j].employeeid, p[j].name,p[j].sex,p[j].age,p[j].basesalary,p[j].postwage,p[j].totalwage);printf("-------------------------------------------------------------------------------\n");break;}else{printf(" not found \n\n");return;}}getchar();}/*******************************************************************************功能:职工信息修改函数*******************************************************************************/ void edit(){char e[10];int g=0,j;char flog;p=emp;printf(" 请输入你要修改职工的职工号: \n");scanf("%s",e);for(g=0;g<N;g++){// if(*e==p[g].employeeid)if(strcmp(e,p->employeeid)==0){j=g;p[j].totalwage=p[j].postwage+p[j].basesalary;printf("-------------------------------------------------------------------------------\n");printf("| 职工号 |姓名 |性别 |年龄 |基本工资 |岗位工资 |总工资 |\n");printf("|%10s|%9s|%7s| %5d| %10.2f| %10.2f| %10.2f|\n",p[j].employeeid,p[j]. name,p[j].sex,p[j].age,p[j].basesalary,p[j].postwage,p[j].totalwage);printf("-------------------------------------------------------------------------------\n");printf(" 是否要修改该职工信息?y(是)or n(否)?\n\n");getchar();scanf("%c",&flog);if(flog == 'y'){printf(" 请输入新姓名:\n");scanf("%s",p->name);printf(" 请输入性别: \n");scanf("%s",&p->sex);printf(" 请输入年龄: \n");scanf("%d",&p->age);printf(" 请输入基本工资:\n");scanf("%f",&p->basesalary);printf(" 请输入岗位工资:\n");scanf("%f",&p->postwage);printf(" 修改职工信息成功! \n\n");}if(flog == 'n'){printf(" 退出该项操作! \n\n");return;}save();}if(g==N){printf(" not found \n\n\n");return;}}}/************************************************************************功能:职工工资排列函数************************************************************************/void array(){int j;while(1){printf("*************************工资排序*********************\n\n"); printf(" 1 按基本工资排序 \n\n");printf(" 2 按岗位工资排序 \n\n");printf(" 3 按总工资排列 \n\n");printf(" 0 退出 \n\n");printf("\n\n\n");while(1){printf(" 请输入你的选择: \n\n");scanf("%d",&j);if(j>=0&&j<=3){switch(j){case 1:array_basesalary();break;case 2:array_postwage();break;case 3:array_totalwage();break;case 0:return;}}else{printf(" 输入错误!\n\n\n");printf(" 请再次输入你的选择:\n\n");}}}}/**************************************************************************功能:按基本工资排列(选择法)***************************************************************************/ void array_basesalary(){int i,j,k;p=emp;for(i=0;i<N-1;i++){k=i;for(j=i+1;j<N;j++){if(p[k].basesalary<p[j].basesalary)k=j;}if(k!=i){replace=emp[k];emp[k]=emp[i];emp[i]=replace;}}for(j=0;j<N;j++){p[j].totalwage=p[j].postwage+p[j].basesalary;printf("-------------------------------------------------------------------------------\n");printf("| 职工号 |姓名 |性别 |年龄 |基本工资 |岗位工资|总工资 |\n");printf("|%10s|%9s|%7s| %5d| %10.2f| %10.2f| %10.2f|\n",p[j].employeeid, p[j].name,p[j].sex,p[j].age,p[j].basesalary,p[j].postwage,p[j].totalwage);}printf("-------------------------------------------------------------------------------\n");}/************************************************************************功能:按岗位工资排列(冒泡法)*************************************************************************/void array_postwage(){int i,j;p=emp;for(i=0;i<N;i++){for(j=0;j<N-i;j++){if(p[j].postwage<p[j+1].postwage){replace=emp[j];emp[j]=emp[j+1];emp[j+1]=replace;}}}for(j=0;j<N;j++){p[j].totalwage=p[j].postwage+p[j].basesalary;printf("------------------------------------------------------------------------------\n");printf("| 职工号 |姓名 |性别 |年龄 |基本工资 |岗位工资|总工资 |\n");printf("|%10s|%9s|%7s| %5d| %10.2f| %10.2f| %10.2f|\n",p[j].employeeid, p[j].name,p[j].sex,p[j].age,p[j].basesalary,p[j].postwage,p[j].totalwage);}printf("-------------------------------------------------------------------------------\n");}/************************************************************************功能:按总工资排列(插入法)************************************************************************/void array_totalwage(){int i,j;p=emp;for(i=1;i<N;i++){replace=emp[i];for(j=i-1;j>=0&&p[i].totalwage>p[i].totalwage;j--){emp[j+1]=emp[j];emp[j+1]=replace;}}for(j=N-1;j>=0;j--){p[j].totalwage=p[j].postwage+p[j].basesalary;printf("-------------------------------------------------------------------------------\n");printf("| 职工号 |姓名 |性别 | 年龄 |基本工资 |岗位工资|总工资 |\n");printf("|%10s|%9s|%7s| %5d| %10.2f| %10.2f| %10.2f|\n",p[j].employeeid, p[j].name,p[j].sex,p[j].age,p[j].basesalary,p[j].postwage,p[j].totalwage);}printf("-------------------------------------------------------------------------------\n");}/*************************************************************************功能:工资统计函数**************************************************************************/void statistics(){int z,a=0,b=0,c=0;p=emp;for(z=0;z<N;z++){if(p[z].totalwage>3000){a++;continue;}if(p[z].totalwage>=2000&&p[z].totalwage<=3000){b++;continue;}if(p[z].totalwage<=2000&&p[z].totalwage>0){c++;continue;}}printf(" 总工资在3000元以上的职工人数有: %d\n\n",a);printf(" 总工资在2000元至3000元的职工人数有:%d\n\n",b);printf(" 总工资在2000元以下的职工人数有: %d\n\n",c);getchar();}/***************************************************************************功能:导出函数***************************************************************************/ void save(){int k;FILE *fp;p=emp;if((fp=fopen("emp_list","wb"))==NULL){printf(" Create file error!\n");return;}for(k=0;k<N;k++,p++){if(fwrite(p,sizeof(struct employee),1,fp)!=1){printf(" file save error!\n\n");break;}elsecontinue;}getchar();fclose(fp);}/***********************************************************************功能:导入函数***********************************************************************/ void load(){int l;FILE *fp;p=emp;if((fp=fopen("emp_list","rb"))==NULL){printf(" Create file error!\n");exit(0);}for(l=0;l<N;l++,p++){if(fread(p,sizeof(struct employee),1,fp)!=1){printf(" file read error!\n\n");break;}elsecontinue;}getchar();fclose(fp);}下面是实验结果(注:素材和资料部分来自网络,供参考。

c语言职工工资管理系统代码

c语言职工工资管理系统代码

C语言职工工资管理系统代码1. 项目简介本项目是一个用C语言编写的职工工资管理系统。

该系统旨在帮助企业或组织更好地管理职工的工资信息,包括薪资计算、数据存储和查询等功能。

通过该系统,可以提高工资管理的效率和准确性,减少人力资源部门的负担。

2. 功能需求本系统需要实现以下功能:•添加新员工:输入员工姓名、基本工资、津贴等信息,并生成唯一的员工ID。

•删除员工:根据员工ID删除指定员工信息。

•修改员工信息:根据员工ID修改指定员工的基本信息。

•计算薪资:根据员工ID计算指定员工的实际薪资,并将结果保存到数据库中。

•查询薪资:根据员工ID查询指定员工的薪资信息。

3. 数据结构设计为了存储职工的基本信息和薪资数据,我们可以使用以下数据结构:3.1 员工结构体定义struct Employee {int id; // 员工IDchar name[50]; // 员工姓名float basicSalary; // 基本工资float allowance; // 津贴float actualSalary; // 实际薪资};3.2 员工数组定义struct Employee employees[100]; // 最多存储100个员工的信息int employeeCount = 0; // 当前员工数量4. 系统实现4.1 添加新员工void addEmployee() {struct Employee employee;printf("请输入员工姓名:");scanf("%s", );printf("请输入基本工资:");scanf("%f", &employee.basicSalary);printf("请输入津贴:");scanf("%f", &employee.allowance);employee.id = employeeCount + 1;employee.actualSalary = employee.basicSalary + employee.allowance;employees[employeeCount] = employee;employeeCount++;printf("添加成功!员工ID为:%d\n", employee.id);}4.2 删除员工void deleteEmployee() {int id;printf("请输入要删除的员工ID:");scanf("%d", &id);int index = findEmployeeIndex(id);if (index == -1) {printf("未找到对应的员工信息。

职工工资管理系统设计与源代码

职工工资管理系统设计与源代码

职工工资管理系统一、设计目标:按照软件工程的规范,以SQL Server 或Access 为后台数据库,以Delphi 或Visual C++ 为前端开发工具,设计并实现一个简化的工资管理系统。

二、需求描述该系统存储了某单位全体职工和工资信息。

职工的基本信息包括:职工编号、姓名、性别、出生年月、职称、最后学历、工资和婚否。

每一个职工的工资信息包括:月份、职工编号、职工姓名、基本工资、津贴、岗贴、补贴、房贴、交通补贴、应发数、房租、储蓄、会费、个人所得税、应扣数、实发数、其他收入。

个人所得税计算方法设为:应发数少于800 元为0;800~1000 元的部分为5%;1000~5000元的部分为10%;5000 元以上的部分为20%。

系统功能如下:1.职工信息管理:a.增加职工信息。

增加新职工时输入新职工的基本信息;b.删除某职工的基本信息。

如,职工死亡或离职时;c.修改某职工(指定职工编号)的某些信息(如,加工资、获得新学位、晋升职称、结婚或离婚)。

2.工资管理:a.增加工资信息。

当增加新职工时,添加某职工的工资信息;b.职工离职或死亡时,删除某职工的工资信息;c.修改工资信息。

当月开始增加或减少某些项工资或扣款数变化时,修改某职工的部分工资信息;3.查询与统计:a.查询职工信息,如查询全体职工信息,或按职称、学历、出生年月、出生年月之前/ 之后、已婚/ 未婚等条件或多个条件的组合来查询相应的职工信息。

b.查询指定编号职工的工资信息;c.按时间段统计职工收入或单位的工资支出三、概要设计四、详细设计void CWorkerMgr6View::OnExit(){OnExit();}void CWorkerMgr6View::OnRecordFirst(){if(m_pSet->IsBOF()){m_pSet->SetFieldNull(NULL);}else{m_pSet->MoveFirst();UpdateData(FALSE);// 更新对话框窗口}}void CWorkerMgr6View::OnRecordLast(){m_pSet->MoveLast();UpdateData(FALSE);// 更新对话框窗口}void CWorkerMgr6View::OnRecordNext(){if(m_pSet->IsBOF()){m_pSet->SetFieldNull(NULL);}// 判断是否溢出if(m_pSet->IsEOF()){AfxMessageBox(" 已经到达最后记录");}else{m_pSet->MoveNext();}UpdateData(FALSE);}void CWorkerMgr6View::OnRecordPre(){ if(m_pSet->IsBOF()){AfxMessageBox(" 已经到达第一个记录"); m_pSet->MoveFirst();}m_pSet->MovePrev();UpdateData(FALSE);}void CWorkerMgr6View::OnAddWorker(){HRESULT hr;try{hr =m_pConnection.CreateInstance("ADODB.Connection");// 创建Connection 对象if(SUCCEEDED(hr)){hr=m_pConnection->Open("Provider=Microsoft.Jet.OLEDB.4.0;DataSource=worker.mdb","","",adModeUnknown);// 连接数据库//上面一句中连接字串中的Provider是针对ACCESS200环境的,对于ACCESS97, 需要改为:Provider=Microsoft.Jet.OLEDB.3.51;}}catch(_com_error e)/// 捕捉异常{CString errormessage;errormessage.Format(" 连接数据库失败!\r\n 错误信息:%s",e.ErrorMessage()); AfxMessageBox(errormessage);/// 显示错误信息}CAddWorker dl;if(dl.DoModal()==IDOK){m_pSet->AddNew(); m_pSet->m_name=dl.m_nm;m_pSet->m_id=dl.m_ids;m_pSet->m_sex=dl.m_sx;m_pSet->m_born=dl.m_bn;m_pSet->m_zhichen=dl.m_zhch;m_pSet->m_xueli=dl.m_xli;m_pSet->m_salary=dl.m_sala;m_pSet->m_marry=dl.m_marr;m_pSet->Update();m_pSet->MoveLast();UpdateData(false);}OnAddMoney();}void CWorkerMgr6View::OnDeleteWorker(){HRESULT hr;try{hr =m_pConnection.CreateInstance("ADODB.Connection");// 创建Connection 对象if(SUCCEEDED(hr)){hr=m_pConnection->Open("Provider=Microsoft.Jet.OLEDB.4.0;DataSource=worker.mdb","","",adModeUnknown);/// 连接数据库///上面一句中连接字串中的Provider是针对ACCESS200环境的,对于ACCESS97,需要改为:Provider=Microsoft.Jet.OLEDB.3.51;}}catch(_com_error e)/// 捕捉异常{CString errormessage;errormessage.Format(" 连接数据库失败!\r\n 错误信息:%s",e.ErrorMessage()); AfxMessageBox(errormessage);/// 显示错误信息}CDelWorker dl;if(dl.DoModal()==IDOK){UpdateData(true);try{long id=dl.m_idid;CString str;str.Format("DELETE from worker where ID=%d",id);_variant_t RecordsAffected;m_pConnection->Execute((_bstr_t)str,&RecordsAffected,adCmdText); AfxMessageBox(" 删除成功!");} catch(_com_error*e){AfxMessageBox(e->ErrorMessage());}m_pSet->MoveNext(); if(m_pSet->IsEOF()) m_pSet->MoveLast();UpdateData(FALSE);}}void CWorkerMgr6View::OnChangWorker(){HRESULT hr;try{hr =m_pConnection.CreateInstance("ADODB.Connection");// 创建Connection 对象if(SUCCEEDED(hr)){ hr=m_pConnection->Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=worker.mdb","","",adModeUnknown);/// 连接数据库///上面一句中连接字串中的Provider是针对ACCESS200环境的,对于ACCESS97,需要改为:Provider=Microsoft.Jet.OLEDB.3.51;}} catch(_com_error e)/// 捕捉异常{CString errormessage;errormessage.Format(" 连接数据库失败!\r\n 错误信息:%s",e.ErrorMessage()); AfxMessageBox(errormessage);/// 显示错误信息}CChangeWork dl2;if(dl2.DoModal()==IDOK){UpdateData(true);long id=dl2.m_wid;m_pSet->MoveFirst(); while(m_pSet->m_id!=dl2.m_wid) m_pSet->MoveNext(); CChangeOne dl1;dl1.m_name1=m_pSet->m_name; dl1.m_id1=m_pSet->m_id; dl1.m_sex1=m_pSet->m_sex; dl1.m_born1=m_pSet->m_born; dl1.m_zhichen1=m_pSet->m_zhichen;dl1.m_xueli=m_pSet->m_xueli; dl1.m_salary1=m_pSet->m_salary;dl1.m_marry1=m_pSet->m_marry;if(dl1.DoModal()==IDOK){m_pSet->Edit();m_pSet->m_name=dl1.m_name1; m_pSet->m_id=dl1.m_id1; m_pSet->m_sex=dl1.m_sex1; m_pSet->m_born=dl1.m_born1; m_pSet->m_zhichen=dl1.m_zhichen1;m_pSet->m_xueli=dl1.m_xueli; m_pSet->m_salary=dl1.m_salary1;m_pSet->m_marry=dl1.m_marry1;m_pSet->Update();// m_pSet->MoveNext();UpdateData(false);}}}void CWorkerMgr6View::OnMShowDetail(){CMShowDetail dl;long id=m_pSet->m_id;m_pSet->MoveFirst(); while(m_pSet->m_id!=id) m_pSet->MoveNext();dl.m_month=m_pSet->m_month;dl.m_id=m_pSet->m_id;dl.m_name=m_pSet->m_name;dl.m_base=m_pSet->m_base;dl.m_jintie=m_pSet->m_jintie; dl.m_gangtie=m_pSet->m_gangtie;dl.m_butie=m_pSet->m_butie;dl.m_fangtie=m_pSet->m_fangtie;dl.m_jiaotong=m_pSet->m_jiaotong;dl.m_yingfa=dl.m_base+dl.m_jintie+dl.m_gangtie+dl.m_butie+dl.m_fangtie+ dl.m_jiaotong; dl.m_fangzu=m_pSet->m_fangzu; dl.m_chuxu=m_pSet->m_chuxu;dl.m_huifei=m_pSet->m_huifei;if(dl.m_yingfa<800){dl.m_gerentax=0;}else if(dl.m_yingfa>=800&&dl.m_yingfa<=1000){dl.m_gerentax=dl.m_yingfa*0.05f;}else if(dl.m_yingfa>1000&&dl.m_yingfa<=5000){dl.m_gerentax=dl.m_yingfa*0.1f;}else if(dl.m_yingfa>5000){dl.m_gerentax=dl.m_yingfa*0.2f;}dl.m_yingkou=dl.m_fangzu+dl.m_chuxu+dl.m_huifei+dl.m_gerentax;dl.m_shifa=dl.m_yingfa-dl.m_yingkou;dl.m_other=m_pSet->m_other;dl.DoModal();}void CWorkerMgr6View::OnAddMoney(){CAddMoney dl;dl.m_id=m_pSet->m_id;dl.m_name=m_pSet->m_name;if(dl.DoModal()==IDOK){m_pSet->Edit();m_pSet->m_base=dl.m_base;m_pSet->m_month=dl.m_month;m_pSet->m_jintie=dl.m_jintie;m_pSet->m_gangtie=dl.m_gangtie;m_pSet->m_butie=dl.m_butie;m_pSet->m_fangtie=dl.m_fangtie;m_pSet->m_jiaotong=dl.m_jiaotong;dl.m_yingfa=dl.m_base+dl.m_jintie+dl.m_gangtie+dl.m_butie+dl.m_fangtie+ dl.m_jiaotong; m_pSet->m_yingfa=dl.m_yingfa;m_pSet->m_fangzu=dl.m_fangzu;m_pSet->m_chuxu=dl.m_chuxu;m_pSet->m_huifei=dl.m_huifei;if(dl.m_yingfa<800){dl.m_gerentax=0;}else if(dl.m_yingfa>=800&&dl.m_yingfa<=1000){dl.m_gerentax=dl.m_yingfa*0.05f;}else if(dl.m_yingfa>1000&&dl.m_yingfa<=5000){dl.m_gerentax=dl.m_yingfa*0.1f;}else if(dl.m_yingfa>5000){dl.m_gerentax=dl.m_yingfa*0.2f;}m_pSet->m_gerentax=dl.m_gerentax;dl.m_yingkou=dl.m_fangtie+dl.m_chuxu+dl.m_huifei+dl.m_gerentax;m_pSet->m_yingkou=dl.m_yingkou;dl.m_shifa=dl.m_yingfa-dl.m_yingkou;m_pSet->m_shifa=dl.m_shifa;m_pSet->m_other=dl.m_other;m_pSet->Update();//m_pSet->MoveLast();UpdateData(false);}}void CWorkerMgr6View::OnDeleteMoney(){HRESULT hr;try{hr =m_pConnection.CreateInstance("ADODB.Connection");// 创建Connection 对象if(SUCCEEDED(hr)){hr=m_pConnection->Open("Provider=Microsoft.Jet.OLEDB.4.0;DataSource=worker.mdb","","",adModeUnknown);/// 连接数据库///上面一句中连接字串中的Provider是针对ACCESS200环境的,对于ACCESS97,需要改为:Provider=Microsoft.Jet.OLEDB.3.51;}}catch(_com_error e)/// 捕捉异常{CString errormessage;errormessage.Format(" 连接数据库失败!\r\n 错误信息:%s",e.ErrorMessage()); AfxMessageBox(errormessage);/// 显示错误信息}CDeleteMoney dl;if(dl.DoModal()==IDOK){UpdateData(true);try{long id=dl.m_id;CString str;str.Format("DELETE from worker where ID=%d",id);_variant_t RecordsAffected;m_pConnection->Execute((_bstr_t)str,&RecordsAffected,adCmdText); AfxMessageBox(" 删除成功!");} catch(_com_error*e){AfxMessageBox(e->ErrorMessage());} m_pSet->MoveNext();if(m_pSet->IsEOF()) m_pSet->MoveLast();UpdateData(FALSE);}}void CWorkerMgr6View::OnChangeMoney(){HRESULT hr;try{hr =m_pConnection.CreateInstance("ADODB.Connection");// 创建Connection 对象if(SUCCEEDED(hr)){ hr=m_pConnection->Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=worker.mdb","","",adModeUnknown);}} catch(_com_error e) // 捕捉异常{CString errormessage;errormessage.Format(" 连接数据库失败!\r\n 错误信息:%s",e.ErrorMessage()); AfxMessageBox(errormessage); // 显示错误信息}CChangeWork dl2; if(dl2.DoModal()==IDOK){UpdateData(true);long id=dl2.m_wid;m_pSet->MoveFirst(); while(m_pSet->m_id!=dl2.m_wid) m_pSet->MoveNext(); CChangeMoney dl1; dl1.m_month=m_pSet->m_month; dl1.m_name=m_pSet->m_name;dl1.m_id=m_pSet->m_id; dl1.m_base=m_pSet->m_base; dl1.m_jintie=m_pSet->m_jintie;dl1.m_gangtie=m_pSet->m_gangtie; dl1.m_butie=m_pSet->m_butie;dl1.m_fangtie=m_pSet->m_fangtie; dl1.m_jiaotong=m_pSet->m_jiaotong;dl1.m_yingfa=dl1.m_base+dl1.m_jintie+dl1.m_gangtie+dl1.m_butie+dl1.m_fangtie+dl1.m_jiaotong;dl1.m_fangzu=m_pSet->m_fangzu; dl1.m_chuxu=m_pSet->m_chuxu;dl1.m_huifei=m_pSet->m_huifei;if(dl1.m_yingfa<800){dl1.m_gerentax=0;}else if(dl1.m_yingfa>=800&&dl1.m_yingfa<=1000){dl1.m_gerentax=dl1.m_yingfa*0.05f;}else if(dl1.m_yingfa>1000&&dl1.m_yingfa<=5000){dl1.m_gerentax=dl1.m_yingfa*0.1f;}else if(dl1.m_yingfa>5000){dl1.m_gerentax=dl1.m_yingfa*0.2f;}dl1.m_yingkou=dl1.m_gerentax+dl1.m_fangzu+dl1.m_chuxu+dl1.m_huifei;dl1.m_shifa=dl1.m_yingfa-dl1.m_yingkou;dl1.m_other=dl1.m_other;if(dl1.DoModal()==IDOK){m_pSet->Edit();m_pSet->m_name=dl1.m_name;m_pSet->m_id=dl1.m_id;m_pSet->m_month=dl1.m_month;m_pSet->m_base=dl1.m_base;m_pSet->m_jintie=dl1.m_jintie;m_pSet->m_gangtie=dl1.m_gangtie;m_pSet->m_butie=dl1.m_butie;m_pSet->m_fangtie=dl1.m_fangtie;m_pSet->m_jiaotong=dl1.m_jiaotong;m_pSet->m_yingfa=dl1.m_base+dl1.m_jintie+dl1.m_gangtie+dl1.m_butie+dl1.m_fangtie+dl1.m_jiaotong;m_pSet->m_fangzu=dl1.m_fangzu;m_pSet->m_chuxu=dl1.m_chuxu;m_pSet->m_huifei=dl1.m_huifei; if(m_pSet->m_yingfa<800){m_pSet->m_gerentax=0;}else if(m_pSet->m_yingfa>=800&&m_pSet->m_yingfa<=1000){m_pSet->m_gerentax=m_pSet->m_yingfa*0.05f;}else if(m_pSet->m_yingfa>1000&&m_pSet->m_yingfa<=5000){m_pSet->m_gerentax=m_pSet->m_yingfa*0.1f;}else if(m_pSet->m_yingfa>5000){m_pSet->m_gerentax=m_pSet->m_yingfa*0.2f;}m_pSet->m_yingkou=dl1.m_fangzu+dl1.m_chuxu+dl1.m_huifei+m_pSet->m_geren tax; m_pSet->m_shifa=m_pSet->m_yingfa-m_pSet->m_yingkou;m_pSet->m_other=dl1.m_other;m_pSet->Update();// m_pSet->MoveNext();UpdateData(false);}}}void CWorkerMgr6View::OnFindMoney(){HRESULT hr;try{hr =m_pConnection.CreateInstance("ADODB.Connection");// 创建Connection 对象if(SUCCEEDED(hr)){ hr=m_pConnection->Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=worker.mdb","","",adModeUnknown);}}catch(_com_error e) // 捕捉异常{CString errormessage;errormessage.Format(" 连接数据库失败!\r\n 错误信息:%s",e.ErrorMessage()); AfxMessageBox(errormessage); // 显示错误信息}CFindNo dl2; if(dl2.DoModal()==IDOK){UpdateData(true);long id=dl2.m_id;m_pSet->MoveFirst(); while(m_pSet->m_id!=dl2.m_id)m_pSet->MoveNext();CMShowDetail dl1; dl1.m_month=m_pSet->m_month;dl1.m_name=m_pSet->m_name; dl1.m_id=m_pSet->m_id;dl1.m_base=m_pSet->m_base; dl1.m_jintie=m_pSet->m_jintie;dl1.m_gangtie=m_pSet->m_gangtie; dl1.m_butie=m_pSet->m_butie;dl1.m_fangtie=m_pSet->m_fangtie;dl1.m_jiaotong=m_pSet->m_jiaotong;dl1.m_yingfa=dl1.m_base+dl1.m_jintie+dl1.m_gangtie+dl1.m_butie+dl1.m_fangtie+dl1.m_jiaotong;dl1.m_fangzu=m_pSet->m_fangzu; dl1.m_chuxu=m_pSet->m_chuxu;dl1.m_huifei=m_pSet->m_huifei;if(dl1.m_yingfa<800){dl1.m_gerentax=0;}else if(dl1.m_yingfa>=800&&dl1.m_yingfa<=1000){dl1.m_gerentax=dl1.m_yingfa*0.05f;}else if(dl1.m_yingfa>1000&&dl1.m_yingfa<=5000){dl1.m_gerentax=dl1.m_yingfa*0.1f;}else if(dl1.m_yingfa>5000){dl1.m_gerentax=dl1.m_yingfa*0.2f;}dl1.m_yingkou=dl1.m_gerentax+dl1.m_fangzu+dl1.m_chuxu+dl1.m_huifei;dl1.m_shifa=dl1.m_yingfa-dl1.m_yingkou;dl1.m_other=dl1.m_other;dl1.DoModal();void CWorkerMgr6View::OnStaticsMoney(){HRESULT hr;try{创建Connection 对hr =m_pConnection.CreateInstance("ADODB.Connection");// 象if(SUCCEEDED(hr)){hr=m_pConnection->Open("Provider=Microsoft.Jet.OLEDB.4.0;DataSource=worker.mdb","","",adModeU nkn ow n);}}catch(_com_error e) // 捕捉异常{ _CStri ng errormessage;errormessage.Format(” 连接数据库失败!\r\n 错误信息:%s",e.ErrorMessage()); AfxMessageBox(errormessage); // 显示错误信息}m_pSet->MoveFirst();float sum=0;while(!m_pSet->lsEOF()){ _sum=sum+m_pSet->m_shifa; m_pSet->MoveNext();}CStri ng stri ng;stri ng.Format("%f",sum);MessageBox(string,"统计当月支出",MB_OKCANCEL); }五、测试及结果分析(a)在此前端主界面下查看后台数据库中员工的基本信息。

员工工资管理系统源代码样本

员工工资管理系统源代码样本

#include<stdio.h> #include<string.h> typedef struct{int basic;// 基本工资岗位工资int position;//津贴int subsidy;//奖金int wages;//int sum;// 总工资}money;typedef struct{char num[20];// 职工号char name[20];// 姓名int age;// 年龄char sex[20];// 性别money salary;// 工资}employee;int Print_jinru();// 账号密码输入void Fscan_information();// ”职工信息.txt ”文件写入void Print_staff();// 全体员工void Print_empl1(char x[51]);// 按职工号查询按姓名查询void Print_empl2(char s[51]);//主界面void Print_MainInterface();//职工信息录入界面void Print_Interface_1();//职工信息查询界面void Print_Interface_2();//职工工资排序界面void Print_Interface_3();//职工总工资void Print_Interface_4();//文件读出void Print_Interface_5();//快速排序void qsort(int l,int r);//void Print_delete(int t);// 删除职工信息void Print_Interface_2_1(int t);// 职工信息修改界面int fyanzheng(char s1[],char s2[]);// 密码验证函数employee st[500];// 记录职工信息的函数int n;// 职工总数void main(){int x;employee em;printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ @@\n");printf("@@@@ 欢迎使用员工工资管理系统@@@@\n");printf("@@@@ 制作人: 刘爽@@@@\n");printf("@@@@在使用中产生的任何问题,欢迎进行批评指正@@@@\n");printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ @@\n");printf("\n");printf("\n");printf("\n");if (Print_jinru()){Fscan_information();Print_MainInterface();}else return;}void Fscan_information(){FILE *fp;int i;if ((fp=fopen(" 职工信息.txt","r"))==NULL){printf("cannot open this file\n"); return ;}fscanf(fp,"%d",&n);for (i=1;i<=n;i++)fscanf(fp,"%s%s%d%s%d%d%d",st[i].num,st[i].name,&st[i] .age,st[i].sex,&st[i].salar y.basic,&st[i].salary.subsidy, &st[i].salary.wages);st[i].salary.sum=st[i].salary.basic+st[i].salary.subsi dy+st[i].salary.wages;}fclose(fp);}int fyanzheng(char s1[],char s2[]){FILE *fp1,*fp2;char str1[40]="",str2[40]="",st;int t;if ((fp1=fopen(" 账号验证.in","r"))==NULL){printf("cannot open this file\n");return 0;}t=0;st=fgetc(fp1);while (st!='#'){str1[t]=st;t++;st=fgetc(fp1);if ((fp2=fopen(" 密码验证.in","r"))==NULL) {printf("cannot open this file\n");return 0;}t=0;st=fgetc(fp2);while (st!='#')。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
{
cout<<" ******************************************************************************\n";
cout<<" ------------------------<<欢迎您使用职工薪酬管理系统>>------------------------\n";
{
//system("cls");
if(head==NULL) cout<<" 这是一个空表,请先输入职工信息!\n";
else{
cout<<"-------------------------------------------------------------------------------\n";
{
public:
Information() ; //构造函数.
~Information() ; //析构函数.
employee *creat(); //建立链表
void output(employee *head); //显示职工信息
int count(employee *head); //定义函数count()统计职工总数
#define LEN sizeof(struct employee)
using namespace std;
int n=0; //定义一个全局变量统计职工人数
//定义一个职工信息的结构体
struct employee
{
char name[N]; //用来存放姓名
{
if(head==NULL)return(0); //若指针head为空返回值为0
else return(1+count(head->next)); //函数的递归调用
}
//添加职工的薪酬的函数
employee *Information::insert( employee *head)
{
cout<<" 对不起,您的输入错误!请重新输入(0~100000): ";
cin>>p1->paid[2];
}
p1->total=p1->paid[0]+p1->paid[1]+p1->paid[2]; //计算总额
if(n==0)head=p1; //如果是输入第一组职工信息就将指针p1赋给指针head
strcpy(p1->name,ch); //将循环结构前面输入的姓名复制到结构体名为p1的数组name中
cout<<" 性别:";
cin>>p1->sex;
cout<<" 编号:";
cin>>p1->id;
}
p2->next=NULL; //将p2所指结构体的next指针重新赋空值
return (head);//将输入的第一组职工信息返回
}
//定义output()函数将职工的信息从头指针所指内容开始输出
void Information::output(employee *head)
cout<<" *பைடு நூலகம்工工资信息表*\n";
cout<<"-------------------------------------------------------------------------------\n";
cout<<"|编 号| |姓 名| |性别| |基本工资| |加班工资| |其他奖金| |总额|\n";
cin>>p1->paid[0];
while((p1->paid[0])<0||(p1->paid[0])>100000) //判断输入的基本工资是否有效(0~100000)
{
cout<<" 对不起,您的输入错误!请重新输入(0~100000): ";
<<setw(9)<<p1->sex
<<setw(12)<<p1->paid[0]
<<setw(12)<<p1->paid[1]
<<setw(12)<<p1->paid[2]
<<setw(14)<<p1->total<<endl;
cout<<"-------------------------------------------------------------------------------\n";
cout<<" ******************************************************************************\n\n";
}
//作者的信息和提示
void editor()
{
cout<<"\n\t\t\t本程序制作者:\n\n\t\t\t黄志勤 王颖洁 霍梦娇";
employee *insert(employee*head); //指针函数*insert()用来添加职工信息.
employee *cancel(employee *head,long id); //指针函数*cancel()用来删除职工信息.
employee *find(employee *head,long id); //指针函数*find()用来查找职工信息.
p1=p1->next; //将下一组职工信息的next指针赋给p1
}while(p1!=NULL); //若指针p非空则继续,目的是把所有的职工信息都传给指针p然后输出.
}
}
//统计职工人数的函数
int Information::count(struct employee *head) //定义函数count()统计职工总数
void save(employee *head); //保存文件信息
employee *Read(); //读取文件信息
private:
employee *p1,*p2,*p3,*head,st;
};
Information::Information()
employee *modify(employee *head,long id); //指针函数*modife()用来修改职工的信息.
void sort(employee *head); //定义sort()函数将职工的总额从大到小排列并输出
void average(employee *head); //定义职工工资平均值的函数
{
cout<<" 对不起,您的输入错误!请重新输入(0~100000): ";
cin>>p1->paid[1];
}
cout<<" 其他奖金:";
cin>>p1->paid[2];
while((p1->paid[2])<0||(p1->paid[2])>100000) //判断输入的其他奖金是否有效(0~100000)
//插入新结点定义一个指向struct employee的结构体指针函数*insert()用来添加职工信息.
cout<<" ******************************************************************************\n";
}
//建立链表信息
employee *Information::creat(void)
{//定义一个指向struct employee的结构体指针函数*creat()用来录入职工信息.
else p2->next=p1; //否则将p1赋给p2所指结构体的next指针
p2=p1; //将指针p1赋给指针p2
n++; //将职工人数n的值加1
cout<<"\n 姓名:";
cin>>ch; //将输入的姓名存放到字符数组ch中
char sex[N]; //用来存放性别
long id; //用来存放编号
float paid[3]; //用来存放工资
int total; //用来存放总工资
struct employee *next;
};
//职工类
class Information
//职工薪酬管理系统
#include <iomanip>
#include <iostream>
#include <fstream>
#include <malloc.h>
#include <stdlib.h>
#include <string.h>
#define NULL 0
int const N=20;
while((p1->id)<0||(p1->id)>100000) //判断输入的编号是否有效(100000个)
相关文档
最新文档