《C++职工工资管理系统代码(7页).doc》由会员分享,可在线阅读,更多相关《C++职工工资管理系统代码(7页).doc(7页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、-C+职工工资管理系统代码-第 7 页#include#include#includeusing namespace std;class zhigongpublic:void setnumber(int n) number=n;void setname(char *na) strcpy(name,na); void setbumen(char *bu) strcpy(bumen,bu);int getnumber() return number; char *getname() return name; char *getbumen() return bumen; void setzhigon
2、g() coutbumen; coutnumber; coutname; private: int number;char name20;char bumen20;class gongzipublic: void setgangwei(double g) gangwei=g;void setjintie(double j) jintie=j;void setyiliao(double y) yiliao=y;void setshuidian(double s) shuidian=s;double getgangwei() return gangwei;double getjintie() re
3、turn jintie;double getyilao() return yiliao;double getshuidian() return shuidian;double getyingfa() return (gangwei+jintie); double getshifa() return (gangwei+jintie-shuidian-yiliao); void setgongzi()coutgangwei; coutjintie; coutshuidian; coutyiliao; private: double gangwei;double jintie;double yili
4、ao;double shuidian;class zhigongzi:public zhigong,public gongzi public: void setzhigongzi() setzhigong(); setgongzi();void menu() cout*endl;cout-职工工资管理系统(小蛇制作)-endl;cout*endl;cout* 1. 输入职工信息 *endl;cout* 2. 修改职工工资 *endl;cout* 3. 添加职工信息 *endl; cout* 4. 删除职工信息 *endl; cout* 5. 查询职工工资 *endl;cout* 6. 显示职工
5、信息 *endl;cout* 7. 退出系统 *endl;cout*endl;int i=-1;int shuru(zhigongzi z) ofstream ofile(D:zhigong.dat,ios:binary);if(!ofile)cout文件夹不能打开.endl;return 0;while(1) int p=1; while(p=1) i+; zi.setzhigongzi(); ofile.write(char*)&zi,sizeof(zhigongzi); cout输入成功!endl; coutp; return i+1;ofile.close();int t,number
6、;double gangwei;double jintie;double yiliao;double shuidian;char name20;int xiugai(zhigongzi z,int m)ofstream ofile(D:zhigong.dat,ios:binary);int flag;int n=1;while(n=1)coutnumber;flag=0;int a; for(int i=0;im;i+) if(number=zi.getnumber()docout请选择要修改的信息:endl;cout*endl; cout* 1.修改岗位工资 *endl;cout* 2.修改
7、岗位津贴 *endl;cout* 3.修改应交纳水电费 *endl;cout* 4.修改应交纳医疗保险费用 *endl;cout*endl; couta;if(a=1)coutgangwei; zi.setgangwei(gangwei); if(a=2)coutjintie;zi.setjintie(jintie); if(a=3)coutshuidian;zi.setshuidian(shuidian); if(a=4)coutyiliao;zi.setyiliao(yiliao);ofile.write(char*)&zi,sizeof(zhigongzi);flag=1; while(
8、a4);if(flag=0)cout查询不到该工号的职工,按0退出n;elsecoutn; coutendl;ofile.close();return 0;int tianjia(zhigongzi z,int m) int n=1; while(n=1) cout请输入要添加的新职工信息endl; zt.setzhigongzi(); cout添加成功!;t+; cout是否继续添加,继续请按1 / 退出请按0:n; return t;void shanchu(zhigongzi z,int m) int flag;int n=1;while(n=1) coutnumber; flag=0;
9、 for(int i=0;it;i+) if(number=zi.getnumber() int k;k=i; for(k;kt;k+) zk=zk+1;t=t-1; flag=1; cout*删除成功*endl; if(flag=0) cout查询不到该工号的职工,无法删除按0退出n; else coutn;void chaxun(zhigongzi z,int m) cout-1 按姓名查询-endl;cout-2 按工号查询-endl;coutk;if(k=1) int u10; int n=1; while(n=1) coutname;int j=0; for(int i=0;it;i
10、+) if(strcmp(name,zi.getname()=0) uj=i;j+; if(j=0) cout没有你要查询的职工名字endl; cout是否继续查询,继续请按1 / 退出按0:n; for(int b=0;bj;b+) if(j2) i=ub; cout职工号 姓名 所属部门 岗位工资 岗位津贴 水电费 医疗保险 应发工资 实发工资endl; coutzi.getnumber()tzi.getname()tzi.getbumen()t zi.getgangwei()tzi.getjintie()tzi.getshuidian()t zi.getyilao()tzi.getyin
11、gfa()tzi.getshifa()endl; else i=ub; if(k=2) int flag; int n=1;while(n=1) coutnumber;flag=0; for(int i=0;it;i+) if(number=zi.getnumber() cout职工号 姓名 所属部门 岗位工资 岗位津贴 水电费 医疗保险 应发工资 实发工资endl; coutzi.getnumber()tzi.getname()tzi.getbumen()t zi.getgangwei()tzi.getjintie()tzi.getshuidian()t zi.getyilao()tzi.g
12、etyingfa()tzi.getshifa()endl; flag=1; if(flag=0) cout查询不到,按0退出n; else cout是否继续查询,继续请按1 / 退出按0:n;int xianshi(zhigongzi z,int m) cout职工工资信息: endl; cout职工号 姓名 所属部门 岗位工资 岗位津贴 水电费 医疗保险 应发工资 实发工资endl; for(int i=0;im;i+) coutzi.getnumber()tzi.getname()tzi.getbumen()t zi.getgangwei()tzi.getjintie()tzi.getsh
13、uidian()t zi.getyilao()tzi.getyingfa()tzi.getshifa()endl; return 0;int main()zhigongzi z20;int a;while(1) menu() ; coutendl; cout-请输入序号选择对应功能-endl; coutendl; couta; switch(a) case 1:system(cls);t=shuru(z);break; case 2:system(cls);xiugai(z,t);break; case 3:system(cls);tianjia(z,t);break; case 4:system(cls);shanchu(z,t);break; case 5:system(cls);chaxun(z,t);break; case 6:system(cls);xianshi(z,t);break; case 7:exit(0);system(pause);system(cls); return 0;
限制150内