管理系統(tǒng)C課程設(shè)計_第1頁
管理系統(tǒng)C課程設(shè)計_第2頁
管理系統(tǒng)C課程設(shè)計_第3頁
管理系統(tǒng)C課程設(shè)計_第4頁
管理系統(tǒng)C課程設(shè)計_第5頁
已閱讀5頁,還剩39頁未讀 繼續(xù)免費閱讀

下載本文檔

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

文檔簡介

管理系統(tǒng)c

課程設(shè)計

一、需求與功能分析

二、系統(tǒng)總體框架

三、模塊設(shè)計與分析

四、類的設(shè)計與分析

五、特色算法分析

六、功能測試

七、存在的不足與對策

八、程序源代碼

一.需求與功能分析

一、程序的需求

隨著科學(xué)技術(shù)的不斷提高,計算機(jī)科學(xué)日漸成熟,其強(qiáng)大的功能已為人

們深刻認(rèn)識,它已進(jìn)入人類社會的各個領(lǐng)域并發(fā)揮著越來越重要的作用。作

為計算機(jī)應(yīng)用的一部分,使用計算機(jī)對人事信息進(jìn)行管理,具有著手工管理

所無法比擬的優(yōu)點.例如:檢索迅速、查找方便、可靠性高、存儲量大、保

密性好、壽命長、成本低等。這些優(yōu)點能夠極大地提高人事理的效率,也是

企業(yè)的科學(xué)化、正規(guī)化管理,與世界接軌的重要條件。因此,開發(fā)這樣一套

管理軟件成為很有必要的事情。

目前,無論是機(jī)關(guān)、事業(yè)單位、還是企業(yè)單位,人事管理對于組織生

存與長遠(yuǎn)發(fā)展所具備的重要性都已經(jīng)有了明確的認(rèn)識,而人事管理水平的

提升不僅需要高素質(zhì)的管理人員,而且也需要信息化工具進(jìn)行輔助

在現(xiàn)代化的企業(yè)管理中,人事管理系統(tǒng)有著十分重要的作用,然而,

用大型軟件系統(tǒng)來于小型的企事業(yè)單位,不啻于“殺雞用牛刀”,因此小

型的的軟件對于這種單位自然有十分重要作用。

二、程序的主要功能

1、添加功能:

添加一個職員的基本信息,包括姓名,工作證號,身份證號碼,生日,

家庭住址,家庭電話號碼,部門,薪水,性別,職務(wù)。

2、刪除功能:

能夠?qū)σ粋€職員的信息進(jìn)行刪除按姓名進(jìn)行刪除。

1錄133-44-99-1111-171818-33

3、刪除全部職員信息:

能夠?qū)τ谌柯殕T的信息進(jìn)行刪除!4、顯示功能:

顯示所有職員的主要信息包括姓名,身份證號碼,工作證號,生日等。

5、查找功能:

根據(jù)你鍵入的職員姓名,顯示其詳細(xì)信息!6、修改功能:

對職員的信息進(jìn)行修改。7、保存信息

對全部信息進(jìn)行保存。8、退出程序

能夠退出程序。

二.系統(tǒng)總體框架

系統(tǒng)

錄入員工信息

顯示員工信息查找員工信息刪除員工信息修改員工信息清空員工信

息保存員工信息

退出程序

三.模塊設(shè)計與分析

1.錄入員工信息

voidinsert?!ㄤ浫霐?shù)據(jù){intn;while(l){

cout<<"請輸入部門的代碼:1-人事部cin>>n;

if(n==l||n==21|n==3){

if(n==l){do{

Staff<Personnel>*p;p=newStaff<Personnel>;

2

2-維修部3—銷售部"<<endl;

p->bumen,show();p->input();p->bumen.input();intq;do{for(inti=0;i<

;N;i++){q=0;if(P[i]==NULL){break;}elseif(P[i]->No==p->No){cout<<"

此工作號已存在!請修改

~!"<<endl;p->input();p->bumen.input();q++;break;}}}while(q!=0);fo

r(intj=0;j<N;j++){if(P[j]==NULL){P[j]=p;cout<<"輸入成

功!”<<endl;break;}}

你還要繼續(xù)執(zhí)行其操作嗎?是'1',否

'0':";cin>>n;}while(n==l);P申請新的Staff<Personnel>

空間,輸入數(shù)據(jù),檢查所輸入的信息是否已經(jīng)存在,存在顯示數(shù)據(jù)已經(jīng)存

在,重新輸入新的數(shù)據(jù),再檢查,直到輸入沒有錯誤。進(jìn)入保存該正確的

數(shù)據(jù),空間要有足夠的空間才能保存數(shù)據(jù),不足就保存失敗。

2.顯示員工信息

voidshow()〃顯示數(shù)據(jù)

Staff<Personnel>*p;cout<<out<<endl;for(intj=0;j<N;j++){if(P

U]!=NULL){

3

)

只要P的空間內(nèi)不為空就輸出數(shù)據(jù)。

3.查找員工信息p=P[j];p->output();p->bumen.output();

voidfind()〃查找數(shù)據(jù)stringn;cout<<"輸入你要查找姓名

"<<endl;cin>>n;for(intj=0;j<N;j++){

if(P[j]!=NULL&&(P[j]->Name)==n){P[j]->bumen.show();cout<

;<out<<endl;P[j]->output();P[j]->bumen.output();break;}

輸入要查找的名字,循環(huán)空間,空間不為空,而且空間里的名字與輸

入的名字對比,

符合就輸出該數(shù)據(jù),不符合下一條數(shù)據(jù),直到符合為止。如果全部空

間掃描完都沒有找到該信息,就輸出不存在該信息。

4.刪除員工信息

voidDelete()〃刪除數(shù)據(jù)stringn;intm;cout<<"輸入你要查找姓名

"<<endl;cin>>n;cout<<''請輸入該員工所在的部門的代碼:1-

人事部"<<endl;cin>>m;if(m==l){for(intj=0;j<N;j++){

if(P[j]!=NULL&&(P[j]->Name)==n){cout<<out<<endl;PD]

->output();P[j]->bumen.output();P[j]=NULL;

42-維修部3—銷售部

)

輸入要查找的名字,循環(huán)空間,空間不為空,而且空間里的名字與輸

入的名字對比,符合就把該項的數(shù)據(jù)賦為空值,不符合下一條數(shù)據(jù),直到

符合為止。如果全部空間掃描完都沒有找到該信息,沒有信息輸出。

5.修改員工信息}}cout<<”該員工已被刪除!l,<<endl;break;

voidrevise()〃修改數(shù)據(jù)stringn;intm;cout<<"輸入你要查找姓名

"<<endl;cin>>n;cout<<"請輸入該員工所在的部門的代碼:1-

人事部2-維修部3—銷售部

"<<endl;cin>>m;if(m==l){for(intj=0;j<N;j++){if(P[j]l=NULL&

&(P[j]->Name)==n){cout<<out<<endl;P[j]->output();P[j]-

>bumen.output();P[j]->input();P[j]->bumen.input();cout<<"該員

工修改成功!";break;}}}

輸入要查找的名字,循環(huán)空間,空間不為空,而且空間里的名字與輸

入的名字對比,符合就重新輸入數(shù)據(jù),不符合下一條數(shù)據(jù),直到符合為止。

如果全部空間掃描完都沒有找到該信息,就沒有信息輸出。

6.清空員工信息

voidclear?!ㄇ蹇諗?shù)據(jù){intn,a=l;do{cout<<"請輸入密碼

"<<"cin>>n;if(n==a){'0'返回界面"<<endl;

5

}for{inti=0;i<N;i++){P[i]=NULL;M[i]=NULL;S[i]=NULL;}cout<<"^TW

員工的資料已被刪除!"<<endl;break;}elsecout<<"輸入密碼失

敗!"<<endl;}while(n!=O);

首先清空全部員工數(shù)據(jù)是要慎重考慮的,所以要設(shè)置密碼,且密碼定

義為1,沒有密碼不能清空全部員工。密碼正確,然后把所有的空間都賦

為空值。

7.保存員工信息

voidsave()〃保存數(shù)據(jù)

{ofstreamoutput_file;ofstreamoutput_filel;ofstreamoutput_file2;ofstreamout

put_file3;cout<<"正在保存

中..."<<endl;output_file.open("Personnel.txt");if(!output_file){cout<

保存Personnel文件失

^!"<<endl;}for(inti=0;i<N;i++){if(P[i]!=NULL){output_file<<P[i]-&g

t;No<<""<<P[i]->Sex<<""<<P[i]->Name<<""<

<R[i]->ID<<""<<R[i]->Birthday<<""<<P[i]->Addr

ess<<""<<P[i]->Phone<<""<<P[i]->bumen.Job<<

""<<P[i]->bumen.Pay<<endl;bl++;}}output_file2.open("Maintain.

txt");if(!output_file2){cout<<廠保存Maintain文件失

敗!"<<endl;}for(i=0;i<N;i++){if(M[i]!=NULL){

output_file2<<M[i]->No<<""<<M[i]->Sex<<""<<

M[i]->Name<<""<<M[i]->ID<<""<<M[i]->Birthday

<<""<<M[i]->Address<<""<<M[i]->Phone<<""&l

t;<M[i]->bumen.Job<<""<<M[i]->bumen.Pay<<endl;

6

}}b2++;

output_file3.open("Sell.txt");if(!output_file3){cout<<"保存Sell文件

敗!"<<endl;}for(i=0;i<N;i++){if⑸i]!=NULL){output_file3<<S[i]->

t;S[i]->ID<<""<<S[i]->Birthday<<""<<S[i]->Address

<<S[i]->bumen.Pay<<endl;b3++;}}

因為我用了3個數(shù)組來保存3個不同的部門信息,所以就用了3個不

同的文件來保存。然后再用一個文件來保存各個部門的數(shù)據(jù)的條數(shù),這樣

是用來控制讀出文件的條數(shù),防止讀出錯誤的信息。

8.退出程序

四.類的設(shè)計與分析

為了界面簡潔些,用了幾個類。一個類包含員工的基本信息,一個類

包含部門的信息,一個類繼承了基本信息和部門信息。

1.Base類

classBase{public:intNo;intlD;stringName;stringSex;intBirthday;stringAddress;in

tPhone;voidinput(){cout<<”輸入員工的工作

號:"<<endl;cin>>No;cout<<"輸入員工的姓

名:"<<endl;cin>>Name;cout<<"輸入員工的性

別:"<<endl;cin>>Sex;

7

輸入員工的身分

證:"<<endl;cin>>ID;cout<<"輸入員工的生

日:"<<endl;cin>>Birthday;cout<<"輸入員工的家庭住

址:"<<endl;cin>>Address;cout<<"輸入員工的家庭電話號

M:"<<endl;cin>>Phone;}voidoutput(){cout<<setiosflags(ios::le

ft)<<setw(8)<<No

<<setw(8)<<Name<<setw(6)<<Sex<<setw(8)<<l

D<<setw(10)<<Birthday<<setw(8)<<Address<<setw(l

0)<<Phone;}};

2.Personnel類

classPersonnel〃人事部

{public:

virtualvoidshow()

{cout<<"人事部"<<endl;

)

stringjob;

intPay;

voidinput()

{

cout<<"請輸入該員工的職務(wù)"<<endl;

cin>>Job;

請輸入該員工的薪水"<<endl;

cin>>Pay;

8

)

voidoutput(){

cout<<setiosflags(ios::left)<</職務(wù):"<<setw⑹

薪水:"<<setw⑹<<Pay<<endl;}};

3.繼承類

classMaintain:publicPersonnel{public:

virtualvoidshowO{cout<<"維修部"<<endl;}};

〃維修部

classStaff:publicBase,publicBranch<Type>{};

9

Birthday

Address

Phone

voidinput()

voidoutputO數(shù)據(jù)成員數(shù)據(jù)成員數(shù)據(jù)成員記錄員工對象的生日記錄員

工對象的家庭住址記錄員工對象的電話成員方法數(shù)據(jù)成員

數(shù)據(jù)成員JobPay

virtualvoid

show()

voidinput()

voidoutputO成員方法成員方法成員方法成員函數(shù),輸入數(shù)據(jù)記錄員工

對象的職務(wù)記錄員工對象的薪水虛函數(shù),顯示所在的部門成員函數(shù),輸入

數(shù)據(jù)成員函數(shù),輸出數(shù)據(jù)

五.特色算法分析

1.隨機(jī)生成字符串

功能:能夠隨機(jī)生成字符串。

算法思路:在一個保存了字母的數(shù)組里隨機(jī)抽取字母,而控制抽取字

母的就是數(shù)組的下標(biāo)位置。只要隨機(jī)生成下標(biāo)的數(shù)字,再用另外的一個數(shù)

組來保存所抽取出來的字母,這樣就成功生成隨機(jī)字符串。

代碼:

constintSIZE_CHAR=5;

constcharCCH[]="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVW

XYZ";stringm()〃隨機(jī)生字母

charch[SIZE_CHAR+l]={0};

for(inti=0;i<SIZE_CHAR;++i)

(

intx=rand()%(sizeof(CCH)-l);

ch[i]=CCH[x];

)

returnch;

)

2.查找員工的信息

功能:查找相應(yīng)的員工信息

算法思路:輸入想要查找的信息,循環(huán)空間,空間不為空,而且空間

里的名字與輸入的名字對比,符合就顯示相對應(yīng)的數(shù)據(jù),不符合下一條數(shù)

據(jù),直到符合為止。如果全部空間掃描完都沒有找到該信息,就沒有信息

輸出。

流程圖:

n

j=0

10P[j]!=NULL&&(P[j]->Name)==n

243

1輸出

數(shù)據(jù)j+=lnull

j<N

結(jié)束

代碼:

voidfindQ〃查找數(shù)據(jù){stringn;cout<<「輸入你要查找姓名

"<<endl;cin>>n;for(intj=0;j<N;j++){

if(P[j]!=NULL&&(P[j]->Name)==n){P[j]->bumen.show();cout<

;<out<<endl;ll

}}for(j=0;j<N;j++){if(M[j]!=NULL&&(M[j]->Name)==n){M[j]

->bumen.show();cout<<out<<endl;M[j]->output();M[j]->bu

men.output();break;}}for(j=0;j<N;j++){if(S[j]!=NULL&&(S[j]->Na

me)==n){S[j]->bumen.show();cout<<out<<endl;S[j]->output();

S[j]->bumen.output();break;}}}P[j]->output();P[j]->bumen.output();br

eak;

六.功能測試1

.界面

圖6-1

2.界面選擇“1”界面測試圖

12

圖6-2

3.再選擇"1

”選擇1的測試圖

圖6-3選擇1的測試圖

如果輸入的工作號原先已存在就會輸出

6—3a.圖6-3a選擇1的測試圖

13

4.界面選擇"2

圖6-4選擇2的測試圖

5.界面選擇"3

圖6-5選擇3的測試圖

6.界面選擇"4

圖6-6選擇4的測試圖

7.界面選擇“5"

14

圖6-7選擇5的測試圖

8.界面選擇"6

圖6-8選擇6的測試圖

密碼錯誤的時候

圖6-8a選擇6的測試圖

9.界面選擇"7

圖6-9選擇7的測試圖

10.界面選擇"8

15

圖6-10選擇8的測試圖

七.存在的不足與對策

由于設(shè)計者水平有限及時間等方面的原因,該系統(tǒng)的功能比較簡單,

查錯能力也不強(qiáng),對于一些不正確的輸入可能會造成一些難以預(yù)料的結(jié)果,

因此,請不要故意輸入錯誤信息。這些不足請老師多多諒解。今后設(shè)計者

會更多的學(xué)習(xí)編程技巧,不斷的提高程序設(shè)計水平。

1.在使用讀取功能時,運(yùn)行程序出現(xiàn)錯誤,發(fā)現(xiàn)原來沒有申請新的

空間,導(dǎo)致運(yùn)行出錯。

2.在使用錄入功能時,如果輸入與已經(jīng)存在的數(shù)據(jù)時不會出現(xiàn)提示,

最后要用到循環(huán)來檢查數(shù)據(jù)是否相同。開始的時候用到全局變量來控制循

環(huán),然后再用到局部變量來覆蓋全部變量,導(dǎo)致不能判斷數(shù)據(jù)是否相同。

經(jīng)過修改。在循環(huán)那里在重新賦值就可以成功判斷!

3.在使用讀取功能時,讀出數(shù)據(jù)成功,可是讀出一些空值,因此在

保存數(shù)據(jù)的時候增加了保存多少條數(shù)據(jù),這樣用來控制讀出數(shù)據(jù)的條數(shù),

以免讀出空值!

八.程序源代碼

//basic.h

#include"string"

#include"iostream"

#include"iomanip"

usingnamespacestd;

classBase

(

public:

intNo;

intID;

stringName;

stringSex;

intBirthday;

stringAddress;

intPhone;

voidinput()

(

cout<<”輸入員工的工作號:"<<endl;

cin>>No;

輸入員工的姓名:"<<endl;

cin>>Name;

cout<<”輸入員工的性別:"<<endl;

cin>>Sex;

cout<<”輸入員工的身分證:"<<endl;

cin>>ID;

cout<<"輸入員工的生H:"<<endl;

cin>>Birthday;

cout<<“輸入員工的家庭住址:"<<endl;

16

cin>>Address;

輸入員工的家庭電話號碼:"<<endl;

cin>>Phone;

)

voidoutput()

(

cout<<setiosflags(ios::left)<<setw(8)<<No

<<setw(8)<<Name<<setw(6)<<Sex<<setw(8)<<l

D<<setw(10)<<Birthday

<<setw(8)<<Address<<setw(10)<<Phone;

)

);

//branch.h

#include"iostream"

#include"string"

#include"iomanip"

usingnamespacestd;

classPersonnel〃人事部

{public:

virtualvoidshow()

{cout<<"人事部"<<endl;

)

stringjob;

intPay;

voidinput()

(

cout<<「請輸入該員工的職務(wù)"<<endl;

cin>>Job;

cout<<”請輸入該員工的薪水l,<<endl;

cin>>Pay;

)

voidoutput()

(

cout<<setiosflags(ios::left)<<"職務(wù):"<<setw⑹<<Job

薪水:"<<setw⑹<<Pay<<endl;

)

);

classMaintain:publicPersonnel

{public:

virtualvoidshow()

{cout<<"維修部"<<endl;〃維修部

17

)

);

classSell:publicPersonnel〃銷售部{public:

virtualvoidshow()

{cout<<"銷售部"<<endl;

)

);

template<classType>

classBranch

(

public:

Typebumen;

);

//staff.h

#include"basic.h"

#include"branch.h"

#include"iostream"

usingnamespacestd;

template<classType>

classStaff:publicBase,

(

);

〃頭文件

#include"string"

#include<string>

#include"staff.h"

#include"cstdio"

#include"conio.h"

#include"fstream"

#include"iostream"

#include"stdlib.h"

#defineN100

usingnamespacestd;

Staff<Personnel>*P[N];

Staff<Maintain>*M[N];

Staff<Sell>*S[N];

constintSIZE_CHAR=5;publicBranch<Type>

18

constcharCCH[]

"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";intbl=Ozb2

=0,b3=0;〃導(dǎo)入數(shù)據(jù)條數(shù)

stringm()〃隨機(jī)生字母

(

charch[SIZE_CHAR+l]={0};

for(inti=0;i<SIZE_CHAR;++i)

(

intx=rand()%(sizeof(CCH)-l);

ch[i]=CCH[x];

)

returnch;

)

ostream&out(ostream&stream)〃操縱符

(

returnstream<<setiosflags(ios::left)

<<setw⑻也工作號"<<setw⑻姓名"

<<setw⑹也性別性lt;<setw⑻身分

"<<setw(12)<<"生日"<<setw⑻地址"

<<setw(10)<<"電話"

<<>部門";

)

voidinsert()〃錄入數(shù)據(jù)

intn;

while(l)

{

請輸入部門的代碼:1-人事部2-維修部3—銷售部

"<<endl;cin>>n;

if(n==l||n==21|n==3)

(

if(n==l)

(

do

{

Staff<Personnel>*p;

p=newStaff<Personnel>;

p->bumen.show();

p->input();

p->bumen.input();

19=證

intq;

do

for(inti=0;i<N;i++)

q=0;

if(P[i]==NULL)

{break;}

elseif(P[i]->No==p->No)

{cout<<”此工作號已存在!請修改~!"<<endl;

p->input();

p->bumen.input();

q++;

break;

}

)

}while(q!=O);

for(intj=0;j<N;j++)

(

if(P[j]==NULL)

(

P[j]=P;

cout<<"輸入成功!

break;

)

)

cout<<"你還要繼續(xù)執(zhí)行其操作嗎?是'1',否

'0':";cin>>n;}while(n==l);

}

elseif(n==2)

(

do

(

Staff<Maintain>*a;

a=newStaff<Maintain>;

a->bumen.show();

a->input();

a->bumen.input();

intq;

do{

for(inti=0;i<N;i++)

{q=o;

if(M[i]==NULL)

20

{break;}

elseif(M[i]->No==a->No)

{cout<<''此工作號已存在!請修改~!”<<endl;

a->input();

a->bumen.input();

q++;

break;

)

)

}while(q!=O);

for(intj=0;j<N;j++)

(

if(M[j]==NULL)

(

M[j]=a;

輸入成功!"<<endl;

break;

)

)

你還要繼續(xù)執(zhí)行其操作嗎?是'2',否

'0':";cin>>n;}while(n==2);

)

elseif(n==3)

do

Staff<Sell>*s;

s=newStaff<Sell>;

s->bumen.show();

s->input();

s->bumen.input();

intq;

do{

for(inti=0;i<N;i++)

{q=o;

if(S[i]==NULL)

{break;}

elseif(S[i]->No==s->No)

{cout<<''此工作號已存在!請修改~!''<<endl;

s->input();

s->bumen.input();

q++;

break;

21

}

)

}while(q!=O);

for(intj=0;j<N;j++)

if(S[j]==NULL)

(

S[j]=s;

cout<<"輸入成功!"<<endl;

break;

)

)

cout<<"你還要繼續(xù)執(zhí)行其操作嗎?是'3',}while(n==3);

)

}

break;

)

)

voidshow?!@示數(shù)據(jù)

(

intn;

while(l)

(

請輸入部門的代碼:1-人事部"<<endl;

cin>>n;

if(n==l||n==21|n==3)

if(n==l)

(

Staff<Personnel>*p;

cout<<out<<endl;

for(intj=0;j<N;j++)

(

if(P[j]!=NULL){

P=P[j];

p->output();

p->bumen.output();

)

)

break;

)

22否'0':";cin>>n;2-維修部3—銷售部

elseif(n==2)

(

Staff<Maintain>*a;

cout<<out<<endl;

for(inti=0;i<N;i++)

if(M[i]!=NULL)

a=M[i];

a->output();

a->bumen.output();

)

)

break;

)

elseif(n==3)

(

Staff<Sell>*s;

cout<<out<<endl;

for(inti=0;i<N;i++)

(

if(S[i]!=NULL)

(

s=S[i];

s->output();

s->bumen.output();

)

)

break;

)

}

elseif(n=O)break;

)

)

丫01€|甘11€|()〃查找數(shù)據(jù){

stringn;

cout<</輸入你要查找姓名"<<endl;cin>>n;

for(intj=0;j<N;j++)

(

23

if(P[j]!=NULL&&(P[j]->Name)==n)

(

P[j]->bumen.show();

cout<<out<<endl;

P[j]->output();P[j]->bumen.output();break;

)

}

for(j=0;j<N;j++)

if(M[j]!=NULL&&(M[j]->Name)==n)

M[j]->bumen.show();

cout<<out<<endl;

M[j]->output();M[j]->bumen.output();break;

)

)

for(j=0;j<N;j++)

(

if(S[j]!=NULL&&(S[j]->Name)==n)

(

S[j]->bumen.show();

cout<<out<<endl;

S[j]->output();S[j]->bumen.output();break;

)

)

)

voidDelete()〃刪除數(shù)據(jù)

(

stringn;intm;

輸入你要查找姓名"<<endl;

cin>>n;

cout<<"請輸入該員工所在的部門的代碼:1-人事部部"<<endl;

cin>>m;

if(m==l)

(

for(intj=0;j<N;j++)

(

242-維修部3—銷售

if(P[j]!=NULL&&(P[j]->Name)==n){

cout<<out<<endl;

P[j]->output();P[j]->bumen.output();P[j]=NULL;

cout<<"該員工已被刪除!"<<endl;break;

}

)

)

if(m==2)

(

for(intj=0;j<N;j++)

(

if(M[j]!=NULL&&(M[j]->Name)==n){

cout<<out<<endl;

M[j]->output();M[j]->bumen.output();M[j]=NULL;

cout<<”該員工已被刪除!”<<endl;break;

)

)

)

if(m==3)

{

for(intj=0;j<N;j++)

(

if(S[j]!=NULL&&(S[j]->Name)==n){

cout<<out<<endl;

S[j]->output();S[j]->bumen.output();S[j]=NULL;

cout<<"該員工已被刪除!"<<endl;break;

}

)

)

)

voidrevise()〃修改數(shù)據(jù)

(

stringn;intm;

cout<<"輸入你要查找姓名"<<endl;

25

cin>>n;

請輸入該員工所在的部門的代碼:1-人事部部"<<endl;

cin>>m;

if(m==l)

(

for(intj=0;j<N;j++)

{

if(P[j]!=NULL&&(P[j]->Name)==n)

(

cout<<out<<endl;

P[j]->output();P[j]->bumen.output();P[j]->input();P[j]->bumen.inp

ut();

cout<<”該員工修改成功!”;

break;

)

)

)

if(m==2)

(

for(intj=0;j<N;j++)

if(M[j]!=NULL&&(M[j]->Name)==n)

cout<<out<<endl;

M[j]->output();M[j]->bumen.output();M[j]->input();M[j]->bumen.i

nput();

cout<<“該員工修改成功!

break;

)

)

)

if(m==3)

(

for(intj=0;j<N;j++)

{

if(S[j]!=NULL&&(S[j]->Name)==n)

(

cout<<out<<endl;

S[j]->output();S[j]->bumen.output();S[j]->input();S[j]->bumen.inpu

t();

cout<<”該員工修改成功!";

break;

)

262-維修部3—銷售

)

)

}

voidclear()〃清空數(shù)據(jù)

{intn,a=l;

do

(

請輸入密碼"<<"'0'返回界面"<<endl;

cin>>n;

if(n==a)

(

for(inti=0;i<N;i++)

(

P[i]=NULL;

M[i]=NULL;

S[i]=NULL;

)

cout<<"所有員工的資料已被刪除!”<<endl;break;

}

elsecout<<"輸入密碼失敗!

}while(n!=0);

)

voidsave()〃保存數(shù)據(jù)

(

ofstreamoutput_file;

ofstreamoutput_filel;

ofstreamoutput_file2;

ofstreamoutput_file3;

正在保存中..."<<endl;

output_file.openCPersonnel.txt");

if(!output_file)

{cout<<"保存Personnel文件失敗!"<<endl;}

for(inti=0;i<N;i++){

if(P[i]!=NULL)

(

output_file<<P[i]->No<<""<<P[i]->Sex<<""<<P[i

]->Name<<""<<P[i]->ID<<""<<P[i]->Birthday<&

lt;""<<P[i]->Address<<""<<P[i]->Phone<<""<<P[

i]->bumen.Job<<""<<P[i]->bumen.Pay<<endl;

bl++;

)

27

)

output_file2.open("Maintain.txt");

if(!output_file2)

{cout<<"保存Maintain文件失敗!"<<endl;}

for(i=0;i<N;i++){

if(M[i]!=NULL)

(

output_file2<<M[i]->No<<""<<M[i]->Sex<<""<<

M[i]->Name<<""<<M[i]->ID<<""<<M[i]->Birthday

<<""<<M[i]->Address<<""<<M[i]->Phone<<""&l

t;<M[i]->bumen.Job<<""<<M[i]->bumen.Pay<<endl;

b2++;

)

)

output_file3.open("Sell.txt");

if(!output_file3)

{cout<<"保存Sell文件失敗!"<<endl;}

for(i=0;i<N;i++){

if(S[i]!=NULL)

output_file3<<S[i]->No<<""<<S[i]->Sex<<""<<S[

i]->Name<<""<<S[i]->ID<<""<<S[i]->Birthday<&

lt;""<<S[i]->Address<<""<<S[i]->Phone<<""<<S[i

]->bumen.Job<<""<<S[i]->bumen.Pay<<endl;b3++;

)

)

output_filel.open("kongzhi.txt");

output_filel<<bl<<""<<b2<<""<<b3<<endl;〃保

存數(shù)據(jù)條數(shù)

output_filel.close();

output_file.close();

output_file2.close();

output_file3,close();

cout<<"保存完畢!"<<endl;

)

voidmain()

{ifstreaminput_file;

ifstreaminput_filel;

ifstreaminput_file2;

ifstreaminput_file3;

input_filel.open("kongzhi.txt");

28

input_filel>>bl>>b2>>b3;

input_file.open("Personnel.txt");

input_file2.open("Maintain.txt");

input_file3.open("Sell.txt");

if(!input_file||!input_file21|!input_file3)

{cout<<”打開文件失敗!”<<endl;

建立新的數(shù)據(jù)!"<<endl;

for(inti=0;i<N;i++)

(

P[i]=NULL;

M[i]=NULL;

S[i]=NULL;

)

for(i=0;i<32;i++)

(

〃隨機(jī)生成數(shù)據(jù)

P[i]=newStaff<Personnel>;

P[i]->No=100+i;P[i]->Sex='m';P[i]->Name=m();P[i]->ID=

1000+rand()%100;

P[i]->Birthday=1988000+rand()%100;P[i]->Address=m();P[i]->Phone=

13567+rand()%100;

P[i]->bumenJob=m();P[i]->bumen.Pay=2000+rand()%101;

M[i]=newStaff&11;Maintain>;

M[i]->No=100+i;M[i]->Sex='m';M[i]->Name=m();M[i]->l

D=1000+rand()%100;

M[i]->Birthday=1988000+rand()%100;M[i]->Address=m();M[i]->Phon

e=13567+rand()%100;

M[i]->bumen.Job=m();M[i]->bumen.Pay=2000+rand()%101;

S[i]=newStaff<Sell>;

S[i]->No=100+i;S[i]->Sex='m';S[i]->Name=m();S[i]->ID=l

000+rand()%100;

S[i]->Birthday=1988000+rand()%100;S[i]->Address=m();S[i]->Phone=

13567+ran

溫馨提示

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

最新文檔

評論

0/150

提交評論