公司人員管理系統(tǒng)程序_第1頁
公司人員管理系統(tǒng)程序_第2頁
公司人員管理系統(tǒng)程序_第3頁
公司人員管理系統(tǒng)程序_第4頁
公司人員管理系統(tǒng)程序_第5頁
已閱讀5頁,還剩7頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

1、#include <iostream.h>#include <fstream.h>#include <ctype.h>#include <string.h>/全局?jǐn)?shù)據(jù),對(duì)象double ManagerSalary=5000; /經(jīng)理固定月薪double SalesManagerSalary=2000; /銷售經(jīng)理固定月薪double SalesManagerPercent=0.5; /銷售經(jīng)理提成double SalesPercent=5; /銷售人員提成double WagePerHour=20; /技術(shù)人員小時(shí)工資int ID; /員工標(biāo)識(shí)(

2、要保證唯一)class Person /員工類protected: int No; /編號(hào) char Name20; /姓名 int Duty; /崗位 double Earning; /收入 Person *next;public: Person(char ID,char *Name,int Duty) this->Duty=Duty; strcpy(this->Name,Name); this->No=ID; virtual void CalcSalary()=0; virtual void Output()=0; friend class Company;class M

3、anager:public Person /經(jīng)理類public: Manager(char ID,char *Name,int Duty):Person(ID,Name,Duty) void CalcSalary()Earning=ManagerSalary; void Output() CalcSalary(); cout<<No<<"t"<<Name<<"t經(jīng)理t"<<Earning<<endl;class SalesManager:public Person /銷售經(jīng)理類pri

4、vate: double Amounts;public: SalesManager(char ID,char *Name,int Duty,double Amounts):Person(ID,Name,Duty)this->Amounts=Amounts; void SetAmounts(double s) Amounts=s; void CalcSalary() Earning=SalesManagerSalary+Amounts*SalesManagerPercent/100; void Output() CalcSalary(); cout<<No<<&qu

5、ot;t"<<Name<<"t銷售經(jīng)理t"<<Earning<<endl;class Technician:public Person /技術(shù)員類private: double t;public: Technician(char ID,char *Name,int Duty,double T):Person(ID,Name,Duty) this->t=T; double GetT() return t; void SetT(double T) this->t=T; void CalcSalary() Ea

6、rning=WagePerHour*t; void Output() CalcSalary(); cout<<No<<"t"<<Name<<"t技術(shù)員t"<<t<<"t"<<Earning<<endl;class Sales:public Person /銷售員類private: double Amount;public: Sales(char ID,char *Name,int Duty,double Amount):Person(ID,

7、Name,Duty) this->Amount=Amount; double GetAmount() return Amount; void SetAmount(double Amount) this->Amount=Amount; void CalcSalary() Earning=SalesPercent/100*Amount; void Output() CalcSalary(); cout<<No<<"t"<<Name<<"t銷售員t"<<Amount<<&quo

8、t;t"<<Earning<<endl;class Company /公司類private: Person *Worker; /員工表public: Company() Worker=0; Company() Person *p; p=Worker; while(p) p=p->next; delete Worker; Worker=p; Worker=0; void Add(); /增加人員 void Delete(); /刪除人員 void Modify(); /修改人員 void Query(); /查詢?nèi)藛T void Set();/設(shè)置基本數(shù)據(jù)

9、void Save(); /數(shù)據(jù)存盤(包括基礎(chǔ)數(shù)據(jù),人員數(shù)據(jù));void Company:Add() Person *p; /新結(jié)點(diǎn)指針 int Duty; char Name20; double Amount,Amounts,T; cout<<"n* 新增員工 *n" /輸入員工信息 ID+; cout<<"輸入崗位(1-經(jīng)理2-銷售經(jīng)理3-銷售員4-技術(shù)員):" cin>>Duty; cout<<"輸入姓名:" cin>>Name;if(Duty=2)cout<&l

10、t;"本月銷售額:" cin>>Amounts;if(Duty=3) cout<<"本月銷售額:" cin>>Amount;else if(Duty=4) cout<<"本月工作小時(shí)數(shù)(0-168):" cin>>T;/創(chuàng)建新員工結(jié)點(diǎn)switch(Duty)case 1:p=new Manager(ID,Name,Duty); break;case 2:p=new SalesManager(ID,Name,Duty,Amounts); break;case 3:p=new S

11、ales(ID,Name,Duty,Amount); break;case 4:p=new Technician(ID,Name,Duty,T); break;p->next=0;/員工結(jié)點(diǎn)加入鏈表if(Worker) /若已經(jīng)存在結(jié)點(diǎn)Person *p2;p2=Worker;while(p2->next) /查找尾結(jié)點(diǎn)p2=p2->next;p2->next=p; /連接else /若不存在結(jié)點(diǎn)(表空)Worker=p; /連接 void Company:Delete() /刪除人員 int No; cout<<"n* 刪除員工 *n"

12、 cout<<"ID:" cin>>No;/查找要?jiǎng)h除的結(jié)點(diǎn) Person *p1,*p2; p1=Worker; while(p1) if(p1->No=No) break; else p2=p1; p1=p1->next;/刪除結(jié)點(diǎn) if(p1!=NULL)/若找到結(jié)點(diǎn),則刪除 if(p1=Worker) /若要?jiǎng)h除的結(jié)點(diǎn)是第一個(gè)結(jié)點(diǎn) Worker=p1->next; delete p1; else /若要?jiǎng)h除的結(jié)點(diǎn)是后續(xù)結(jié)點(diǎn) p2->next=p1->next; delete p1; cout<<&qu

13、ot;找到并刪除n" else /未找到結(jié)點(diǎn) cout<<"未找到!n"char ch; cout<<"按任意鍵返回菜單:" cin>>ch; if(ch!='0') return ; void Company:Modify() int No,Duty; char Name20; double Amount,Amounts,T; cout<<"n* 修改員工 *n"cout<<"ID:" cin>>No;/查找要修改的

14、結(jié)點(diǎn) Person *p1,*p2; p1=Worker; while(p1) if(p1->No=No) break; else p2=p1; p1=p1->next;/修改結(jié)點(diǎn) if(p1!=NULL)/若找到結(jié)點(diǎn) p1->Output(); cout<<"調(diào)整崗位(1-經(jīng)理2-銷售經(jīng)理3-銷售員4-技術(shù)員):" cin>>Duty; if(p1->Duty!=Duty) /若崗位發(fā)生變動(dòng) /修改其它數(shù)據(jù) cout<<"輸入姓名:" cin>>Name; if(Duty=2) c

15、out<<"本月銷售額:" cin>>Amounts; if(Duty=3) cout<<"本月銷售額:" cin>>Amount; else if(Duty=4) cout<<"本月工作小時(shí)數(shù)(0-168):" cin>>T;/創(chuàng)建新員工結(jié)點(diǎn) Person *p3; switch(Duty) case 1:p3=new Manager(p1->No,Name,Duty); break; case 2:p3=new SalesManager(p1->N

16、o,Name,Duty,Amounts); break; case 3:p3=new Sales(p1->No,Name,Duty,Amount); break; case 4:p3=new Technician(p1->No,Name,Duty,T); break;/員工結(jié)點(diǎn)替換到鏈表 p3->next=p1->next; if(p1=Worker) /若要替換的結(jié)點(diǎn)是第一個(gè)結(jié)點(diǎn) Worker=p3; else /若要?jiǎng)h除的結(jié)點(diǎn)是后續(xù)結(jié)點(diǎn) p2->next=p3;/刪除原來的員工結(jié)點(diǎn) delete p1; else /若崗位沒有變動(dòng) cout<<&q

17、uot;輸入姓名:" cin>>p1->Name; if(Duty=3) cout<<"本月銷售額:"cin>>Amount; (Sales *)p1)->SetAmount(Amount); else if(Duty=4) cout<<"本月工作小時(shí)數(shù)(0-168):"cin>>T; (Technician *)p1)->SetT(T); cout<<"修改成功!n"else /未找到結(jié)點(diǎn)cout<<"未找到要查

18、詢的人員!n" char ch;cout<<"按任意鍵返回菜單:"cin>>ch;if(ch!='0')return ;void Company:Query()int i;Person *p1,*p2;p1=Worker;if(p1)cout<<"請(qǐng)輸入要查找的人的編號(hào):"cin>>i;while(p1)if(p1->No=i)break;elsep2=p1;p1=p1->next;if(p1!=NULL)p1->Output();elsechar ch;cout

19、<<"查無此人,按任意鍵返回菜單:"cin>>ch;if(ch!='0')return ;elsecout<<"系統(tǒng)還未存入人員"<<endl;return ;void Company:Set() cout<<"n* 設(shè)置基礎(chǔ)數(shù)據(jù) *n" cout<<"經(jīng)理固定月薪"<<ManagerSalary<<"元:" cin>>ManagerSalary; cout<<

20、"銷售經(jīng)理固定月薪"<<SalesManagerSalary<<"元:" cin>>SalesManagerSalary; cout<<"銷售經(jīng)理提成"<<SalesManagerPercent<<":" cin>>SalesManagerPercent; cout<<"銷售人員提成"<<SalesPercent<<":" cin>>SalesP

21、ercent; cout<<"技術(shù)人員小時(shí)工資"<<WagePerHour<<"(元/小時(shí)):" cin>>WagePerHour; cout<<"員工標(biāo)識(shí)>="<<ID<<":" cin>>ID;void Company:Save() /數(shù)據(jù)存盤(包括基礎(chǔ)數(shù)據(jù),人員數(shù)據(jù)),均采用文本文件 ofstream fPerson,fBase; char c; cout<<"n保存人員和基礎(chǔ)數(shù)據(jù),是否

22、繼續(xù)?Y/N:" cin>>c; if(toupper(c)!='Y')return;/保存人員編號(hào)、姓名、崗位 fPerson.open("person.txt",ios:out); Person *p=Worker; while(p) fPerson<<p->No<<"t"<<p->Name<<"t"<<p->Duty<<"t" if(p->Duty=3) fPerson<

23、<(Sales*)p)->GetAmount()<<"t" else if(p->Duty=4) fPerson<<(Technician *)p)->GetT()<<"t" fPerson<<endl; p=p->next; fPerson.close();/保存基礎(chǔ)數(shù)據(jù) fBase.open("base.txt",ios:out); fBase<<"經(jīng)理固定月薪t"<<ManagerSalary<<

24、endl; fBase<<"銷售經(jīng)理固定月薪t"<<SalesManagerSalary<<endl; fBase<<"銷售經(jīng)理提成t"<<SalesManagerPercent<<endl; fBase<<"銷售人員提成t"<<SalesPercent<<endl; fBase<<"技術(shù)人員小時(shí)工資t"<<WagePerHour<<endl; fBase<<"IDt"<<ID<<endl; fPerson.close(); cout<<"n保存人員和基礎(chǔ)數(shù)據(jù)已經(jīng)完成.n"void main()int c;Company a;docout<<" * "<<endl;cout<<" * * "<<en

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論