C++實(shí)現(xiàn)職工工資管理系統(tǒng)_第1頁(yè)
C++實(shí)現(xiàn)職工工資管理系統(tǒng)_第2頁(yè)
C++實(shí)現(xiàn)職工工資管理系統(tǒng)_第3頁(yè)
C++實(shí)現(xiàn)職工工資管理系統(tǒng)_第4頁(yè)
C++實(shí)現(xiàn)職工工資管理系統(tǒng)_第5頁(yè)
已閱讀5頁(yè),還剩20頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

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

文檔簡(jiǎn)介

第C++實(shí)現(xiàn)職工工資管理系統(tǒng)本文實(shí)例為大家分享了C++實(shí)現(xiàn)職工工資管理系統(tǒng)的具體代碼,供大家參考,具體內(nèi)容如下

main.cpp

#includeiostream

#includevector

#includemap

#includealgorithm

#includestring

#includewindows.h

#include"data.h"

#include"user.h"

#include"fuction1-9.h"

#include"fuction10.h"

#include"menu.h"

usingnamespacestd;

intmain()

system("color3f");

if(login()==false)

return0;

load_inf();

while(show_menu());

save_inf();

return0;

}

data.h

#pragmaonce

constintmaxn=100;

usingnamespacestd;

structdepartment

intcode;

intnumber;

stringdepartment_name;

voidshow_inf(){printf("%50s部門(mén)號(hào):%-6d部門(mén)名稱(chēng):%-12s部門(mén)人數(shù):%-6d\n","",code,department_name.c_str(),number);}

mapint,departmentdep;//部門(mén)表的映射

structemployee

intcode;

stringname;

stringgender;

intworking_age;

intdepartment_code;//部門(mén)編碼

voidshow_inf(){printf("%50s編號(hào):%-6d姓名:%-12s性別:%-9s工齡(年):%-6d部門(mén):%-12s\n","",code,name.c_str(),gender.c_str(),working_age,dep[department_code].department_name.c_str());}

mapint,employeeemp;///存儲(chǔ)數(shù)據(jù)的容器

structwage

intcode;

intbase_wage;//基本工資

intovertime;//加班工資

intbonus;//津貼

intgross_pay;//應(yīng)發(fā)工資

intwithholding;//代扣款

intpayment;//實(shí)發(fā)工資

voidshow_inf(){printf("%30s員工號(hào):%-6d員工姓名:%-12s基本工資:%-6d\t加班工資:%-6d\t津貼:%-6d\t應(yīng)發(fā)工資:%-6d\t代扣款:%6d\t實(shí)發(fā)工資:%6d\n","",code,emp[code].name.c_str(),base_wage,overtime,bonus,gross_pay,withholding,payment);}

voidcalculate(){gross_pay=base_wage+overtime+bonus,payment=gross_pay-withholding;}

mapint,wagewag;

fuciton1-9.h

#pragmaonce

usingnamespacestd;

voidload_inf()

FILE*p;

chars[maxn];

system("cls");

if((p=fopen("employee.txt","r"))==NULL)

{

printf("%70s數(shù)據(jù)異常,無(wú)法訪問(wèn)!\n","");

system("pause");

exit(0);

}

while(fgets(s,100,p))

{

intcode;

charname[maxn];

chargender[maxn];

intworking_age;

intdepartment_code;

sscanf(s,"%d%s%s%d%d",code,name,gender,working_age,department_code);

emp[code]=(employee{code,name,gender,working_age,department_code});

}

printf("%70s","");

for(inti=0;ii++){cout".";Sleep(200);}

printf("員工信息導(dǎo)入成功!\n");

coutendl;

fclose(p);

if((p=fopen("department.txt","r"))==NULL)

{

printf("%70s數(shù)據(jù)異常,無(wú)法訪問(wèn)!\n","");

system("pause");

exit(0);

}

while(fgets(s,100,p))

{

intcode;

intnumber;

chardepartment_name[maxn];

sscanf(s,"%d%d%s",code,number,department_name);

dep[code]={code,number,department_name};

}

printf("%70s","");

for(inti=0;ii++){cout".";Sleep(200);}

printf("部門(mén)信息導(dǎo)入成功!\n");

coutendl;

fclose(p);

if((p=fopen("wage.txt","r"))==NULL)

{

printf("%70s數(shù)據(jù)異常,無(wú)法訪問(wèn)!","");

system("pause");

exit(0);

}

while(fgets(s,100,p))

{

intcode;//員工號(hào)

intbase_wage;//基本工資

intovertime;//加班工資

intbonus;//津貼

intgross_pay;

intwithholding;//代扣款

intpayment;

sscanf(s,"%d%d%d%d%d%d%d",code,base_wage,overtime,bonus,gross_pay,withholding,payment);

wag[code]=(wage{code,base_wage,overtime,bonus,gross_pay,withholding,payment});

}

printf("%70s","");

for(inti=0;ii++){cout".";Sleep(200);}

printf("工資信息導(dǎo)入成功!\n");

coutendl;

fclose(p);

return;

voidsave_inf()

FILE*p=fopen("employee.txt","w");

charinf[maxn];

for(autoit=emp.begin();it!=emp.end();it++)

{

sprintf(inf,"%d%s%s%d%d\n",it-second.code,it-.c_str(),it-second.gender.c_str(),it-second.working_age,it-second.department_code);

fputs(inf,p);

}

printf("%70s","");

for(inti=0;ii++){cout".";Sleep(200);}

printf("員工信息保存成功!\n");

fclose(p);

p=fopen("department.txt","w");

for(autoit=dep.begin();it!=dep.end();it++)

{

sprintf(inf,"%d%d%s\n",it-second.code,it-second.number,it-second.department_name.c_str());

fputs(inf,p);

}

printf("%70s","");

for(inti=0;ii++){cout".";Sleep(200);}

printf("部門(mén)信息保存成功!\n");

fclose(p);

p=fopen("wage.txt","w");

for(autoit=wag.begin();it!=wag.end();it++)

{

sprintf(inf,"%d%d%d%d%d%d%d\n",it-second.code,it-second.base_wage,it-second.overtime,it-second.bonus,it-second.gross_pay,it-second.withholding,it-second.payment);

fputs(inf,p);

}

printf("%70s","");

for(inti=0;ii++){cout".";Sleep(200);}

printf("工資信息保存成功!\n");

fclose(p);

return;

/以下為部門(mén)表的操作

voidadd_dep()

printf("%70s請(qǐng)輸入要添加的部門(mén)號(hào):","");

intcode;cincode;

stringdepartment_name;

if(!dep.count(code))

{

printf("%70s請(qǐng)輸入部門(mén)名稱(chēng):","");

while(1)

{

intflag=0;

cindepartment_name;

for(autoit=dep.begin();it!=dep.end();it++)

if(it-second.department_name==department_name)

{

printf("%70s該部門(mén)已存在,請(qǐng)重新輸入!\n","");

flag=1;

}

if(!flag)break;

}

dep[code]={code,0,department_name};

printf("%70s部門(mén)添加成功!該部門(mén)信息如下:\n","");

dep[code].show_inf();

}

else

printf("%70s該部門(mén)已存在!\n","");

return;

voidchange_dep()

printf("%70s請(qǐng)輸入要修改的部門(mén)編號(hào):","");

intcode;cincode;

if(!dep.count(code))

printf("%70s該部門(mén)不存在!\n","");

else

{

printf("%70s該部門(mén)當(dāng)前信息如下:\n","");

dep[code].show_inf();

printf("%70s請(qǐng)輸入部門(mén)的新名字:","");

while(1)

{

stringname;cinname;

intflag=0;

for(autoit=dep.begin();it!=dep.end();it++)

if(it-second.department_name==name)

{

flag=1;

break;

}

if(flag)

printf("%70s部門(mén)名字重復(fù)!請(qǐng)重新輸入\n","");

else

{

dep[code].department_name=name;

printf("%70s修改成功!\n","");

printf("%70s修改后的部門(mén)信息如下:\n","");

dep[code].show_inf();

break;

}

}

}

return;

voiddelete_dep()

printf("%70s請(qǐng)輸入要?jiǎng)h除的部門(mén)編號(hào):","");

intcode;cincode;

if(!dep.count(code))

printf("%70s該部門(mén)不存在,無(wú)法刪除!\n","");

elseif(!dep[code].number)//如果該部門(mén)沒(méi)有人,則可刪除

{

for(autoit=dep.begin();it!=dep.end();it++)

if(it-first==code)

{

printf("%70s您刪除了%s\n","",it-second.department_name.c_str());

dep.erase(it);

break;

}

}

else

printf("%70s該部門(mén)有員工,不可刪除!\n","");

return;

/以下為員工表的操作

voidadd_emp()

printf("%70s請(qǐng)輸入要添加的員工號(hào):","");

intcode;cincode;

if(!emp.count(code))

{

emp[code].code=code;

printf("%70s請(qǐng)輸入員工的姓名:","");cinemp[code].name;

printf("%70s請(qǐng)輸入員工的性別:","");cinemp[code].gender;

printf("%70s請(qǐng)輸入員工的工齡:","");cinemp[code].working_age;

printf("%70s請(qǐng)輸入員工的部門(mén)號(hào):","");

intdepartment_code;

while(cindepartment_code!dep.count(department_code))

printf("%70s該部門(mén)不存在,請(qǐng)重新輸入:","");

emp[code].department_code=department_code;

dep[department_code].number++;

printf("%70s員工信息添加成功!員工信息如下:\n","");

emp[code].show_inf();

}

else

printf("%70s該員工號(hào)已存在\n","");

return;

voidchange_emp()

intcode;

printf("%70s請(qǐng)輸入要修改的員工號(hào):","");

while(cincode!emp.count(code))

printf("%70s該員工不存在!請(qǐng)重新輸入:","");

printf("%70s該員工當(dāng)前信息如下:\n","");

emp[code].show_inf();

printf("%70s請(qǐng)輸入修改后的工齡:","");cinemp[code].working_age;

printf("%70s請(qǐng)輸入修改后的部門(mén)編碼:","");

dep[emp[code].department_code].number--;///原部門(mén)人數(shù)減一

cinemp[code].department_code;

dep[emp[code].department_code].number++;//現(xiàn)部門(mén)人數(shù)加一

printf("%70s修改成功!修改之后的信息如下:\n","");

emp[code].show_inf();

return;

voiddelete_emp()

printf("%70s請(qǐng)輸入要?jiǎng)h除的員工號(hào):","");

intcode;cincode;

if(!emp.count(code))

printf("%70s該員工不存在!無(wú)法刪除\n","");

else

{

dep[emp[code].department_code].number--;//原部門(mén)人數(shù)減一

for(autoit=emp.begin();it!=emp.end();it++)

if(it-first==code)

{

printf("%70s您刪除的員工信息如下:\n","");

emp[it-second.code].show_inf();

emp.erase(it);

break;

}

for(autoit=wag.begin();it!=wag.end();it++)

if(it-first==code)

{

wag.erase(it);

break;

}

}

return;

voidadd_wag()

printf("%70s請(qǐng)輸入錄入工資的員工編號(hào):","");

intcode;cincode;

if(!emp.count(code))

printf("%70s該員工不存在!\n","");

elseif(wag.count(code))

printf("%70s該員工信息已錄入!\n","");

else

{

wag[code].code=code;

printf("%70s請(qǐng)輸入員工的基本工資:","");cinwag[code].base_wage;

printf("%70s請(qǐng)輸入員工的加班工資:","");cinwag[code].overtime;

printf("%70s請(qǐng)輸入員工的津貼:","");cinwag[code].bonus;

printf("%70s請(qǐng)輸入員工的代扣款:","");cinwag[code].withholding;

printf("%70s員工工資信息添加成功!\n","");

printf("%70s工資信息如下:\n","");

wag[code].calculate();

wag[code].show_inf();

}

return;

voidchange_wag()

intcode;

printf("%70s要修改者的編號(hào):","");

while(cincode!wag.count(code))

printf("%70s該員工不存在!請(qǐng)重新輸入\n","");

printf("%70s該員工當(dāng)前的工資信息如下\n","");

wag[code].show_inf();

printf("%70s請(qǐng)輸入基本工資:","");cinwag[code].base_wage;

printf("%70s請(qǐng)輸入加班工資:","");cinwag[code].overtime;

printf("%70s請(qǐng)輸入津貼:","");cinwag[code].bonus;

printf("%70s請(qǐng)輸入代扣款:","");cinwag[code].withholding;

wag[code].calculate();

printf("%70s修改成功!修改之后的工資信息如下\n","");

wag[code].show_inf();

return;

voiddelete_wag()

printf("%70s請(qǐng)輸入要?jiǎng)h除工資信息的員工編號(hào):","");

intcode;cincode;

if(!wag.count(code))

printf("%70s不存在該員工的工資信息\n","");

else

{

for(autoit=wag.begin();it!=wag.end();it++)

if(it-first==code)

{

wag.erase(it);

printf("%70s刪除成功!\n","");

break;

}

}

return;

}

fuction10.h

#pragmaonce

boolcomp1(constinta,constintb)//升序

returnwag[a].paymentwag[b].payment;

boolcomp2(constinta,constintb)

returnwag[a].paymentwag[b].payment;

boolsearch_inf()

system("cls");

printf("%70s0.返回\n","");

printf("%70s1.查詢(xún)?nèi)繂T工的工資\n","");

printf("%70s2.按員工號(hào)查詢(xún)員工工資\n","");

printf("%70s3.按部門(mén)查詢(xún)員工工資\n","");

printf("%70s4.按指定實(shí)發(fā)工資區(qū)間查詢(xún)員工工資\n","");

printf("%70s5.按員工姓名查詢(xún)員工工資\n","");

printf("%70s6.查詢(xún)?nèi)坎块T(mén)信息\n","");

printf("%70s7.按編號(hào)查詢(xún)單個(gè)員工的基本信息\n","");

printf("%70s8.按姓名查詢(xún)單個(gè)員工的基本信息\n","");

printf("%70s9.顯示所有員工的基本信息\n","");

printf("%70s請(qǐng)輸入操作編號(hào)[0-9]:","");

intope;

intcode;

stringname;

intdir;

intflag=0;

longlongsum=0;

vectorinttemp;//存儲(chǔ)滿(mǎn)足查詢(xún)要求的人員編號(hào)

while(cinope!(ope=0ope=9))

printf("%70s輸入非法,請(qǐng)重新輸入:","");

if(!ope)

returnfalse;

switch(ope)

{

case1:

for(autoit=wag.begin();it!=wag.end();it++)

{

temp.push_back(it-first);

sum+=it-second.payment;

}

printf("%70s1.按實(shí)發(fā)工資升序\n","");

printf("%70s2.按實(shí)發(fā)工資降序\n","");

printf("%70s請(qǐng)輸入操作類(lèi)型:","");

while(cindirdir!=1dir!=2)

printf("%70s輸入非法,請(qǐng)重新輸入!\n","");

if(dir==1)

sort(temp.begin(),temp.end(),comp1);

else

sort(temp.begin(),temp.end(),comp2);

for(inti=0;i(int)temp.size();i++)

wag[temp[i]].show_inf();

printf("%144s合計(jì):%10lld\n","",sum);

break;

case2:

printf("%70s請(qǐng)輸入要查詢(xún)的員工號(hào):","");

cincode;

if(!emp.count(code))

printf("%70s該員工不存在!\n","");

elseif(!wag.count(code))

printf("%70s該員工的工資信息未錄入!\n","");

else

wag[code].show_inf();

break;

case3:

printf("%70s請(qǐng)輸入所要查詢(xún)員工的部門(mén):","");

cincode;

if(!dep.count(code))

printf("%70s該部門(mén)不存在!\n","");

else

{

for(autoit=wag.begin();it!=wag.end();it++)

if(emp[it-first].department_code==code)

{

temp.push_back(it-first);

sum+=it-second.payment;

}

printf("%70s1.按實(shí)發(fā)工資升序\n","");

printf("%70s2.按實(shí)發(fā)工資降序\n","");

printf("%70s請(qǐng)輸入操作類(lèi)型:","");

while(cindirdir!=1dir!=2)

printf("%70s輸入非法,請(qǐng)重新輸入!\n","");

if(dir==1)

sort(temp.begin(),temp.end(),comp1);

else

sort(temp.begin(),temp.end(),comp2);

for(inti=0;i(int)temp.size();i++)

wag[temp[i]].show_inf();

printf("%144s合計(jì):%10lld\n","",sum);

}

break;

case4:

intup,down;

printf("%70s請(qǐng)輸入實(shí)發(fā)工資區(qū)間的上限:","");

cinup;

printf("%70s請(qǐng)輸入實(shí)發(fā)工資區(qū)間的下限:","");

cindown;

if(updown)

printf("%70s非法的輸入!\n","");

else

{

for(autoit=wag.begin();it!=wag.end();it++)

if(it-second.payment=downit-second.payment=up)

{

temp.push_back(it-first);

sum+=it-second.payment;

}

if(!temp.size())

{

printf("%70s查詢(xún)不到符合條件的員工!\n","");

cout""endl;

break;

}

printf("%70s1.按實(shí)發(fā)工資升序\n","");

printf("%70s2.按實(shí)發(fā)工資降序\n","");

printf("%70s請(qǐng)輸入操作類(lèi)型:","");

intdir;cindir;

if(dir==1)

sort(temp.begin(),temp.end(),comp1);

else

sort(temp.begin(),temp.end(),comp2);

for(inti=0;i(int)temp.size();i++)

wag[temp[i]].show_inf();

printf("%144s合計(jì):%10lld\n","",sum);

}

break;

case5:

printf("%70s請(qǐng)輸入員工姓名:","");

cinname;

for(autoit=emp.begin();it!=emp.end();it++)

if(it-==name)

{

wag[it-first].show_inf();

flag=1;

}

if(!flag)

printf("%70s查詢(xún)不到此人!\n","");

break;/這個(gè)不需要排序,考慮到會(huì)有重名

case6:

for(autoit=dep.begin();it!=dep.end();it++)

dep[it-first].show_inf();

break;

case7:

printf("%70s請(qǐng)輸入員工編號(hào):","");

cincode;

if(!emp.count(code))

printf("%70s該員工不存在!\n","");

else

emp[code].show_inf();

break;

case8:

printf("%70s請(qǐng)輸入員工姓名:","");

cinname;

for(autoit=emp.begin();it!=emp.end();it++)

if(it-==name)

{

flag=1;

emp[it-second.code].show_inf();

}

if(!flag)

printf("%70s查詢(xún)不到此人!\n","");

break;

case9:

for(autoit=emp.begin();it!=emp.end();it++)

emp[it-second.code].show_inf();

break;

default:

returnfalse;

}

system("pause");

returntrue;

}

menu.h

#pragmaonce

usingnamespacestd;

boolshow_menu()

intdir;

system("cls");//清屏

printf("%70s*************************\n","");

printf("%70s歡迎進(jìn)入職工工資管理系統(tǒng)!\n","");

printf("%70s*************************\n","");

printf("%70s0.退出系統(tǒng)\n","");

printf("%70s1.部門(mén)信息錄入\n","");

printf("%70s2.部門(mén)信息修改\n","");

printf("%70s3.部門(mén)信息刪除\n","");

printf("%70s4.員工信息錄入\n","");

printf("%70s5.員工信息修改\n","");

printf("%70s6.員工信息刪除\n","");

printf("%70s7.員工工資錄入\n","");

printf("%70s8.員工工資修改\n","");

printf("%70s9.員工工資刪除\n","");

printf("%70s10.信息查詢(xún)\n","");

printf("%70s11.修改登錄密碼\n","");

printf("%70s請(qǐng)輸入操作選項(xiàng)[0-11]:","");

while(cindir(dir0||dir11))printf("%70s非法指令,請(qǐng)重新輸入:\n","");

switch(dir)

{

case0:

returnfalse;

case1:

system("cls");

add_dep();

system("pause");

break;

case2:

system("cls");

change_dep();

system("pause");

break;

case3:

system("cls");

delete_dep();

system("pause");

break;

case4:

system("cls");

add_emp();

system("pause");

break;

case5:

system("cls");

change_emp();

system("pause");

break;

case6:

system("cls");

delete_emp();

system("pause");

break;

case7:

溫馨提示

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

評(píng)論

0/150

提交評(píng)論