小型公司工資管理系統(tǒng)(C++)源代碼.doc
#include<iomanip.h>#include<iostream.h>#include<fstream.h>#include<stdlib.h>class Employ/基類-雇員類protected: int num; char name10; char sex; int age; int wage;public:virtual void set()=0;virtual void print()=0;virtual void reserved()=0;class Manager:public Employ/經(jīng)理類public: void set(); void print();void reserved();class Salesman:public Employ/銷售員類protected:int salesvolume;int snum;public: void set(); void print();void reserved();void printinfor();int getsales()return salesvolume;int getsnum()return snum;class MarketMan:public Manager/銷售經(jīng)理類protected:int salesvolume;public: void set(); void print();void reserved(); int resetwage();int getnum()return num;char*getname()return name;int getamount(Salesman s,int n)salesvolume=0;for(int i=0;i<n;i+)if(si.getsnum()=num)salesvolume+=si.getsales();return salesvolume;class Technician:public Employ/技術(shù)員類protected:int worktime;public: void set(); void print();void reserved();void Manager:set()wage=8000;cout<<"經(jīng)理的編號(hào):"cin>>num;cout<<"其姓名:"cin>>name;cout<<"性別(m/w):"cin>>sex;cout<<"年齡:"cin>>age;void Manager:print()/經(jīng)理類成員函數(shù)cout<<""<<endl;cout<<""<<setw(12)<<num<<""<<setw(12)<<name<<""<<setw(12)<<sex;cout<<""<<setw(12)<<age<<""<<setw(12)<<wage<<""<<endl;void Manager:reserved()ofstream employf("E:05-29gzglxt.txt",ios:app);employf<<"經(jīng)理的編號(hào):"<<num<<endl <<"其姓名:"<<name<<endl <<"性別(m/w):"<<sex<<endl <<"年齡:"<<age<<endl;void MarketMan:set()wage=resetwage();cout<<"銷售經(jīng)理的編號(hào):"cin>>num;cout<<"其姓名:"cin>>name;cout<<"性別(m/w):"cin>>sex;cout<<"年齡:"cin>>age; void MarketMan:print() resetwage();cout<<""<<endl;cout<<""<<setw(12)<<num<<""<<setw(12)<<name<<""<<setw(12)<<sex;cout<<""<<setw(12)<<age<<""<<setw(12)<<wage<<""<<endl;void MarketMan:reserved() ofstream employf("E:05-29gzglxt.txt",ios:app);employf<<"銷售經(jīng)理的編號(hào):"<<num<<endl <<"其姓名:"<<name<<endl <<"性別(m/w):"<<sex<<endl <<"年齡:"<<age<<endl;int MarketMan:resetwage()wage=5000+int(salesvolume*0.005);return wage;void Salesman:set()/銷售員類定義cout<<"銷售員的編號(hào):"cin>>num;cout<<"其姓名:"cin>>name;cout<<"性別(m/w):"cin>>sex;cout<<"年齡:"cin>>age;cout<<"銷售額:"cin>>salesvolume;cout<<"所屬銷售經(jīng)理的編號(hào):"cin>>snum; wage=int(salesvolume*0.04);void Salesman:printinfor()cout<<""<<endl;cout<<""<<setw(14)<<num<<""<<setw(14)<<name<<""<<setw(14)<<salesvolume<<""<<endl;void Salesman:print()cout<<""<<endl;cout<<""<<setw(8)<<num<<""<<setw(10)<<name<<""<<setw(10)<<sex;cout<<""<<setw(10)<<age<<""<<setw(10)<<wage<<""<<setw(16)<<getsnum()<<""<<endl; void Salesman:reserved()ofstream employf("E:05-29gzglxt.txt",ios:app);employf<<"銷售員的編號(hào):"<<num<<endl <<"其姓名:"<<name<<endl <<"性別(m/w):"<<sex<<endl <<"年齡:"<<age<<endl <<"銷售額:"<<salesvolume<<endl <<"所屬銷售經(jīng)理的編號(hào)"<<snum<<endl;void Technician:set()/技術(shù)員類定義cout<<"技術(shù)員的編號(hào):"cin>>num;cout<<"其姓名:"cin>>name;cout<<"性別(m/w):"cin>>sex;cout<<"年齡:"cin>>age;cout<<"工作時(shí)間:"cin>>worktime;wage=worktime*100; void Technician:print()cout<<""<<endl;cout<<""<<setw(12)<<num<<""<<setw(12)<<name<<""<<setw(12)<<sex;cout<<""<<setw(12)<<age<<""<<setw(12)<<wage<<""<<endl; void Technician:reserved() ofstream employf("E:05-29gzglxt.txt",ios:app);employf<<"技術(shù)員的編號(hào):"<<num<<endl <<"其姓名:"<<name<<endl <<"性別(m/w):"<<sex<<endl <<"年齡:"<<age<<endl <<"工作時(shí)間:"<<worktime<<endl;/主函數(shù)int t,m,s,mm;Technician*pt;Manager*pm;Salesman*ps;MarketMan*pmm;void setin();void count();void printdata();void reservedall();void single();void main()cout<<"請(qǐng)分別輸入技術(shù)員,經(jīng)理,銷售員,銷售經(jīng)理人數(shù):"<<endl;cin>>t>>m>>s>>mm;pt=new Techniciant;pm=new Managerm;ps=new Salesmans;pmm=new MarketManmm;if(!pt)|(!pm)|(!ps)|(!pmm)cout<<"堆內(nèi)存分配失敗!"<<endl;exit(1);single();void single() cout<<"小型公司工資管理系統(tǒng)"<<endl;cout<<""<<endl;cout<<" 請(qǐng)選擇所需的操作 "<<endl;cout<<" "<<endl;cout<<" 數(shù)據(jù)輸入:1,并按回車鍵 "<<endl;cout<<" "<<endl;cout<<" 數(shù)據(jù)統(tǒng)計(jì):2,并按回車鍵 "<<endl;cout<<" "<<endl;cout<<" 數(shù)據(jù)打印:3,并按回車鍵 "<<endl;cout<<" "<<endl;cout<<" 數(shù)據(jù)備份:4,并按回車鍵 "<<endl;cout<<" "<<endl;cout<<" 退出系統(tǒng):5,并按回車鍵 "<<endl;cout<<" "<<endl;cout<<""<<endl;cout<<"請(qǐng)選擇一個(gè)操作:"<<endl;int choice;cin>>choice;switch(choice)case 1:setin();case 2:count(); case 3:printdata();case 4:reservedall();case 5:exit(0);void setin()Menu1:cout<<"小型公司工資管理系統(tǒng)"<<endl;cout<<""<<endl;cout<<" 請(qǐng)選擇所需的操作 "<<endl;cout<<" "<<endl;cout<<"技術(shù)員數(shù)據(jù)輸入 : 1,并按回車鍵 "<<endl;cout<<" "<<endl;cout<<"經(jīng)理數(shù)據(jù)輸入 : 2,并按回車鍵 "<<endl;cout<<" "<<endl;cout<<"銷售員數(shù)據(jù)輸入 : 3,并按回車鍵 "<<endl;cout<<" "<<endl;cout<<"銷售經(jīng)理數(shù)據(jù)輸入 : 4,并按回車鍵 "<<endl;cout<<" "<<endl;cout<<"返回上一級(jí)菜單 : 5,并按回車鍵 "<<endl;cout<<""<<endl;cout<<"請(qǐng)選擇一個(gè)操作"int ch1,i;cin>>ch1;switch(ch1)case 1:for(i=0;i<t;i+) pti.set(); cout<<"-"<<endl; goto Menu1;case 2:for(i=0;i<m;i+) pmi.set(); cout<<"-"<<endl; goto Menu1;case 3:for(i=0;i<s;i+) psi.set(); cout<<"-"<<endl; goto Menu1; case 4:for(i=0;i<mm;i+) pmmi.set(); cout<<"-"<<endl; goto Menu1; case 5:single();void count()Menu2:cout<<"小型公司工資管理系統(tǒng)"<<endl;cout<<""<<endl;cout<<" 請(qǐng)選擇所需的操作 "<<endl;cout<<" "<<endl;cout<<"各銷售經(jīng)理下屬銷售員業(yè)績統(tǒng)計(jì) : 1,并按回車鍵 "<<endl;cout<<" "<<endl;cout<<"銷售經(jīng)理按工資排序 : 2,并按回車鍵 "<<endl;cout<<" "<<endl;cout<<"返回上一級(jí)菜單 : 3,并按回車鍵 "<<endl;cout<<""<<endl;cout<<"請(qǐng)選擇一個(gè)操作"int ch2,i,j;cin>>ch2;switch(ch2)case 1:for(i=0;i<mm;i+) cout<<"職工號(hào)為:"<<pmmi.getnum()<<"銷售經(jīng)理:"<<pmmi.getname()<<"下屬銷售員的業(yè)績?yōu)?"<<endl; cout<<""<<endl; cout<<"職工號(hào) 姓名 銷售額 "<<endl; for(j=0;j<s;j+) if(pmmi.getnum()=psj.getsnum() psj.printinfor(); cout<<""<<endl; cout<<"銷售額總計(jì): "<<setw(22)<<pmmi.getamount(ps,s)<<""<<endl; cout<<""<<endl; goto Menu2; case 2:cout<<"銷售經(jīng)理按工資排序?yàn)?"<<endl; MarketMan pmmm; for(i=1;i<mm;i+) for(j=0;j<mm-i;j+) if(pmmj.getamount(ps,s)<pmmj+1.getamount(ps,s) pmmm=pmmj; pmmj=pmmj+1; pmmj+1=pmmm; cout<<""<<endl; cout<<" 職工號(hào) 姓名 性別 年齡 工資 "<<endl; for(i=0;i<mm;i+) pmmi.print(); cout<<""<<endl; cout<<" -"<<endl; goto Menu2;case 3:single();void printdata()Menu3:cout<<"小型公司工資管理系統(tǒng)"<<endl;cout<<""<<endl;cout<<" 請(qǐng)選擇所需的操作 "<<endl;cout<<" "<<endl;cout<<"技術(shù)員數(shù)據(jù)輸出 : 1,并按回車鍵 "<<endl;cout<<" "<<endl;cout<<"經(jīng)理數(shù)據(jù)輸出 : 2,并按回車鍵 "<<endl;cout<<" "<<endl;cout<<"銷售員數(shù)據(jù)輸出 : 3,并按回車鍵 "<<endl;cout<<" "<<endl;cout<<"銷售經(jīng)理數(shù)據(jù)輸出 : 4,并按回車鍵 "<<endl;cout<<" "<<endl;cout<<"返回上一級(jí) : 5,并按回車鍵 "<<endl;cout<<""<<endl;cout<<"請(qǐng)選擇一個(gè)操作"int ch3,i;cin>>ch3;switch(ch3)case 1: cout<<"技術(shù)員"<<endl<<endl; cout<<""<<endl; cout<<" 職工號(hào) 姓名 性別 年齡 工資 "<<endl; for(i=0;i<t;i+) pti.print(); cout<<""<<endl; cout<<"-"<<endl; goto Menu3;case 2: cout<<"經(jīng)理"<<endl<<endl; cout<<""<<endl; cout<<" 職工號(hào) 姓名 性別 年齡 工資 "<<endl; for(i=0;i<m;i+) pmi.print(); cout<<""<<endl; cout<<"-"<<endl; goto Menu3;case 4:cout<<"銷售經(jīng)理"<<endl<<endl; cout<<""<<endl; cout<<" 職工號(hào) 姓名 性別 年齡 工資 "<<endl; for(i=0;i<mm;i+) pmmi.print(); cout<<""<<endl; cout<<"-"<<endl; goto Menu3;case 3:cout<<"銷售員"<<endl<<endl; cout<<""<<endl; cout<<" 職工號(hào) 姓名 性別 年齡 工資 所屬部門經(jīng)理編號(hào)"<<endl; for(i=0;i<s;i+) psi.print(); cout<<""<<endl; cout<<"-"<<endl; goto Menu3;case 5:single();void reservedall()Menu4:cout<<"小型公司工資管理系統(tǒng)"<<endl;cout<<""<<endl;cout<<" 請(qǐng)選擇所需的操作 "<<endl;cout<<" "<<endl;cout<<"技術(shù)員數(shù)據(jù)備份 : 1,并按回車鍵 "<<endl;cout<<" "<<endl;cout<<"經(jīng)理數(shù)據(jù)備份 : 2,并按回車鍵 "<<endl;cout<<" "<<endl;cout<<"銷售員數(shù)據(jù)備份 : 3,并按回車鍵 "<<endl;cout<<" "<<endl;cout<<"銷售經(jīng)理數(shù)據(jù)備份 : 4,并按回車鍵 "<<endl;cout<<" "<<endl;cout<<"返回上一級(jí) : 5,并按回車鍵 "<<endl;cout<<""<<endl;cout<<"請(qǐng)選擇一個(gè)操作"int ch4,i;cin>>ch4;switch(ch4)case 1:for(i=0;i<t;i+) pti.reserved(); goto Menu4; case 2:for(i=0;i<m;i+) pmi.reserved(); goto Menu4; case 3:for(i=0;i<s;i+) psi.reserved(); goto Menu4; case 4:for(i=0;i<mm;i+) pmmi.reserved(); goto Menu4; case 5:single();