员工管理系统c语言源代码.doc_第1页
员工管理系统c语言源代码.doc_第2页
员工管理系统c语言源代码.doc_第3页
员工管理系统c语言源代码.doc_第4页
员工管理系统c语言源代码.doc_第5页
已阅读5页,还剩14页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

#include#include#define N 10000 /*员工的最大数*/typedef struct wagefloat wage1; /*员工的基本工资*/float Bonus; /*员工的奖金*/float tax; /*员工的税金*/float S_fee; /*员工的水费*/float D_fee; /*员工的电费*/float T_fee; /*员工的有线电视费*/float Q_fee; /*员工的清洁费*/float S_wage; /*员工的实发工资*/WAGE;typedef struct worker char name10; /*员工的姓名*/char ID10; /*员工的工号*/ int ID_P; /*员工的职务代号 1-高级工程师 2-中级工程师 3-初级工程师 */char ID_Wage10; /*员工的工资卡号*/char depart10; /*员工的部门*/ int age; /*员工的年龄*/char sex; /*员工的性别*/char m_phone10; /*员工的手机*/char H_phone10; /*员工的住宅电话*/ WAGE salary;WORK;WORK woN;int n;/*员工的总数*/void menu();/*员工管理操作主菜单函数声明*/void menu1();/*员工管理操作子菜单函数声明*/*Author : GTCopyRight : function name : saveComments : 保存文件函数input : 无output : 无CreatedDate : 2007/06/01*/save() /*保存函数,保存n个记录*/int w=1;FILE *fp;int i;system( cls );if(fp=fopen(work.txt,wb)=NULL) /*以输出打开方式,在此前的记录被覆盖*/ printf(nCannot open filen); return NULL; for(i=0;in;i+)if(fwrite(&woi,sizeof(struct worker),1,fp)!=1) printf(file write errorn); w=0;if(w=1) printf(file save ok!n);fclose(fp);getch();menu();/*Author : GTCopyRight : function name : loadComments : 载入文件函数input : 无output : 无CreatedDate : 2007/06/01*/load() /*加载记录或可以计算记录个数的函数*/FILE *fp;int i,w;w=1;system( cls );if(fp=fopen(work.txt,rb)=NULL) /*以输出打开方式,在此前的记录被覆盖*/ printf(nCannot open filen); w=0; return NULL;n=0;for(i=0;!feof(fp);i+) fread(&woi,sizeof(struct worker),1,fp); n+;n=n-1;fclose(fp);if(w=1) printf(Load file ok!);getch();menu();return(i-1); /*返回记录个数*/*Author : GTCopyRight : function name : no_inputComments : 输入不能重复的员工编号input : i:表示第i个的员工编号信息 n:表示比较到第n个员工编号信息output : 无CreatedDate : 2007/06/01*/void no_input(int i,int n) /*i表示第i个的员工编号信息,n表示比较到第n个员工编号*/int j,k,w1;do w1=0; printf(NO.:); scanf(%s,woi.ID); for(j=0;woi.IDj!=0;j+) /*员工编号输入函数,作了严格规定*/ if(woi.IDj9) /*判断员工编号是否为数字*/ puts(Input error! Only be made up of (0-9).Please reinput!n); w1=1; break; if(w1!=1) for(k=0;kn;k+) /*比较到第n个员工编号*/ /*排除第i个员工编号即你要修改的*/ if(k!=i&strcmp(wok.IDj,woi.IDj)=0) /*判断员工编号是否有雷同*/ puts(This record is exist. please reinput!n); w1=1; break; while(w1=1);/*Author : GTCopyRight : function name : taxComments : 工资税金input : s: 表示员工工资信息output : 员工的税金CreatedDate : 2007/06/01*/float tax(float s)float tax;if(s800&s1400) tax=(s-1400)*0.1+600*0.05; return tax;/*Author : GTCopyRight : function name : inputComments : 输入一条员工记录input : i: 表示第i个的员工信息output : 无CreatedDate : 2007/06/01*/void input(int i) /*输入一个记录函数*/ int j,sum; no_input(i,i); /*调用员工编号输入函数*/ printf(name:);fflush(stdin);gets();printf(Bank ID:);fflush(stdin);gets(woi.ID_Wage);printf(grade);scanf(%d,&woi.ID_P);printf(Department:);fflush(stdin);gets(woi.depart); printf(age:);scanf(%d,&woi.age); printf(sex:);fflush(stdin);scanf(%c,&woi.sex); printf(mobile phone);fflush(stdin);gets(woi.m_phone); printf(home phone);fflush(stdin);gets(woi.H_phone);printf(basic salary);scanf(%f,&woi.salary.wage1);woi.salary.tax=tax(woi.salary.wage1);printf(Bonus:);scanf(%f,&woi.salary.Bonus);printf(water fee:);scanf(%f,&woi.salary.S_fee);printf(dian fee:);scanf(%f,&woi.salary.D_fee);printf(QingJie fee:);scanf(%f,&woi.salary.Q_fee);printf(TV fee:);scanf(%f,&woi.salary.T_fee); woi.salary.S_wage=woi.salary.wage1+woi.salary.Bonus-woi.salary.tax-woi.salary.D_fee-woi.salary.Q_fee-woi.salary.S_fee-woi.salary.T_fee;/*Author : GTCopyRight : function name : enterComments : 输入员工管理系统信息记录input : 无output : 无CreatedDate : 2007/06/01*/void enter()/*输入模块*/int i;system( cls );printf(How many record(0-%d)?:,N);scanf(%d,&n); /*要输入的记录个数*/printf(nEnter data nownn);for(i=0;in;i+) printf(nInput %dth record.n,i+1); input(i); /*调用输入函数*/ getch();menu();/*Author : GTCopyRight : function name : printf_oneComments : 输出一条员工信息记录input : i:表示第i个的员工信息output : 无CreatedDate : 2007/06/01*/void printf_one(int i) /*显示一个记录的函数*/int j;printf(%11s %-6s %-6s %d %d %c %6.2f %s %s,woi.ID,,woi.ID_Wage,woi.ID_P,woi.age,woi.sex,woi.salary.S_wage,woi.m_phone,woi.H_phone);/*Author : GTCopyRight : function name : printf_one_sComments : 输出一条员工工资记录input : i:表示第i个的工资信息output : 无CreatedDate : 2007/06/01*/void printf_one_s(int i) /*显示一个记录的函数*/int j;printf( %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f,woi.salary.wage1,woi.salary.S_wage,woi.salary.Bonus,woi.salary.D_fee,woi.salary.Q_fee,woi.salary.S_fee,woi.salary.T_fee,woi.salary.tax);/*Author : GTCopyRight : function name : browseComments : 输出员工管理系统信息记录input : 无output : 无CreatedDate : 2007/06/01*/void browse() /*浏览(全部)模块*/int i,j;system( cls );puts(n-);printf(nt工号 姓名 银行卡号 职称 年龄 性别 实发工资 手机 住宅电话n);for(i=0;in;i+) if(i!=0)&(i%10=0) /*目的是分屏显示*/ printf(nnPass any key to contiune . . .); getch(); puts(nn); printf_one(i); /*调用显示一个记录的函数*/ printf(n);puts(n-);printf(tThere are %d record.n,n);getch(); /*按任意健*/menu();/*Author : GTCopyRight : function name : search_by_IDComments : 按工号查找所有员工信息记录input : 无output : 输出查找员工编号CreatedDate : 2007/06/01*/int search_by_ID() /*查找模块*/int i,k;struct worker s;k=-1;system( cls );printf(nnEnter the ID:);scanf(%s,s.ID); /*输入要到达的地方*/for(i=0;in;i+) /*查找要修改的数据*/ if(strcmp(s.ID,woi.ID)=0) k=i; /*找到要修改的记录*/ printf(nt工号 姓名 银行卡号 职称 年龄 性别 实发工资 手机 住宅电话n); printf_one(k); printf(工资信息:n); printf(nt基本工资 实发工资 奖金 电费 清洁费 水费 电视费 税金n); printf_one_s(k); break; /*调用显示一个记录的函数*/ if(k=-1) printf(nnNO exist!); getch(); menu1(); return -1;else getch(); menu1(); return k;/*Author : GTCopyRight : function name : search_by_ageComments : 按年龄查找所有员工信息记录input : 无output : 输出查找员工编号CreatedDate : 2007/06/01*/int search_by_age() /*查找模块*/int i,k,t_age,b_age;struct worker s;k=-1;system( cls );printf(nnEnter the top age:);scanf(%d,&t_age);printf(nnEnter the bottom age:);scanf(%d,&b_age);printf(nt工号 姓名 银行卡号 职称 年龄 性别 实发工资 手机 住宅电话n);for(i=0;i=b_age&woi.age=t_age) k=i; /*找到要修改的记录*/ printf_one(k); break; /*调用显示一个记录的函数*/ if(k=-1) printf(nnNO exist!); getch(); menu1(); return -1;else getch(); menu1(); return k;/*Author : GTCopyRight : function name : search_by_PComments : 按职称统计所有员工的工资信息input : 无output : 无CreatedDate : 2007/06/01*/void count_by_P() /*查找模块*/int i,k;float S_sal3=0,0,0,sal3=0,0,0,bon3=0,0,0,tax3=0,0,0; system( cls );for(i=0;in;i+) /*查找要修改的数据*/ if(woi.ID_P=1) S_sal0=S_sal0+woi.salary.S_wage; sal0=sal0+woi.salary.wage1; bon0=bon0+woi.salary.Bonus; tax0=tax0+woi.salary.tax; else if(woi.ID_P=2) S_sal1=S_sal1+woi.salary.S_wage; sal1=sal1+woi.salary.wage1; bon1=bon1+woi.salary.Bonus; tax1=tax1+woi.salary.tax; else if(woi.ID_P=3) S_sal2=S_sal2+woi.salary.S_wage; sal2=sal2+woi.salary.wage1; bon2=bon2+woi.salary.Bonus; tax2=tax2+woi.salary.tax; printf(n级别为高级工程师的工资统计为:n);printf(实发工资:%f,基本工资:%f,奖金:%f,税金:%fn,S_sal0,sal0,bon0,tax0);printf(n级别为中级工程师的工资统计为:n);printf(实发工资:%f,基本工资:%f,奖金:%f,税金:%fn,S_sal1,sal1,bon1,tax1);printf(n级别为初级工程师的工资统计为:n);printf(实发工资:%f,基本工资:%f,奖金:%f,税金:%fn,S_sal2,sal2,bon2,tax2);printf(n公司所有人员的工资统计为:n);printf(实发工资:%f,基本工资:%f,奖金:%f,税金:%fn,S_sal2,sal2,bon2,tax2);getch();menu1();/*Author : GTCopyRight : function name : orderComments : 按照实发工资的高低排序input : 无output : 无CreatedDate : 2007/06/01*/void order() /*排序模块(按平均成绩)*/int i,j,k;struct worker s;system( cls );for(i=0;in-1;i+) /*选择法排序*/ k=i; for(j=i+1;jwok.salary.S_wage) k=j; s=woi; woi=wok; wok=s; printf(The ordered data is:n);browse();getch();menu1();/*Author : GTCopyRight : function name : menu1Comments : 员工管理操作的子菜单input : 无output : 无CreatedDate : 2007/06/01*/void menu1()int n,w1; do system( cls ); /*清屏*/ puts(tttt 员工管理操作!nn); puts(tt*MENU*nn); puts(tttt1.search by ID); puts(tttt2.search by age); puts(tttt3.count salary); puts(tttt4.order by salary); puts(tttt5.return to menu); puts(nntt*n); printf(Choice your number(1-5): bb); scanf(%d,&n); if(n5) /*对选择的数字作判断*/ w1=1; printf(your choice is not between 1 and 4,Please input again:); getchar(); else w1=0; while(w1=1);/*选择功能*/switch(n) case 1:search_by_ID();break; /*输入模块*/ case 2:search_by_age();break; /*浏览模块*/ case 3:count_by_P();break; /*查找模块*/ case 4:order();break; /*

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论