C語言課設之人事管理系統.doc_第1頁
C語言課設之人事管理系統.doc_第2頁
C語言課設之人事管理系統.doc_第3頁
C語言課設之人事管理系統.doc_第4頁
C語言課設之人事管理系統.doc_第5頁
已閱讀5頁,還剩31頁未讀 繼續免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

學習資料收集于網絡,僅供參考C語言課程設計人事管理系統 題目要求:人事管理管理系統要求某高校主要人員有:在職人員(行政人員、教師、一般員工)、退休人員和臨時工。現在,需要存儲這些人員的人事檔案信息:編號、姓名、性別、年齡、職務、職稱、政治面貌、最高學歷、任職時間、來院時間、人員類別。其中,人員編號唯一,不能重復。(1) 添加刪除功能:能根據學院人事的變動情況,添加刪除記錄;(2) 查詢功能:能根據編號和姓名進行查詢;(3) 編輯功能(高級):根據查詢對相應的記錄進行修改,并存儲;(4) 統計功能:能根據多種參數進行人員的統計(在職人數、黨員人數、女工人數、高學歷高職稱人數(碩士學位以上或者副教授以上),統計要求同時顯示被統計者的信息;(5) 排序功能:按照年齡、來院時間進行排序;(6) 保存功能:能對輸入的數據進行相應的存儲;一、 需求分析:根據題目要求,職工信息是存放在文件中的,所以應該提供相應的文件的輸入輸出的功能,在程序中應該有添加刪除,查詢,編輯,統計,排序,保存等程序實現相應的操作,另外菜單式的選擇方式選擇程序的功能也是必須需的。另外程序中要求存儲的模塊,采用的方式均為將原文件中的所有數據讀入內存,在內存中處理之后以覆蓋的方式寫入文件存貯,這樣的方法在一定程度上提高了對數據處理的靈活性,較容易理解,但存在處理中遇到以外情況而丟失數據的風險,另外當文件中的數據量很大時,這種方法也存在一定的難度,在本程序中將N定為100,基本上能滿足要求;二、 總體設計:根據以上需求分析,將程序分成以下幾個模塊:1、 新建數據文件(build new data);2、 添加記錄(add data);3、 刪除記錄(delete data);4、 按工號搜索(search by number);5、 按姓名搜索(search by name);6、 瀏覽全部數據(browse all);7、 修改數據(modify the data);8、 排序功能(order the volume);9、 統計功能(data a volume);系統功能模塊圖如下:三、 詳細設計;1、 主函數:1需求分析:為使系統執行完每部分功能后能夠方便的回到系統主界面,main()函數設計的較簡單,只包含一個menu()函數,其余的全部功能都通過menu()函數調用來實現,并通過menu()函數的遞歸調用實現返回主界面的功能。main()函數定義如下:main() menu();而menu()定義如下:2流程圖:menu() int n,w1;doprintf(nttttMENUn);printf(tt0tbuild new datann);printf(tt1tdelete datann);printf(tt2tadd datann);printf(tt3tsearch by numbernn);printf(tt4tsearch by namenn);printf(tt5tbrowse allnn);printf(tt6tmodify the datann);printf(tt7torder the volumenn);printf(tt8tdata a volumenn);printf(tt9texitnn);printf(tplease choice and enter a number bb);scanf(%d,&n);if(n8)w1=1; getchar(); else w1=0;while(w1=1);switch(n)case 0:build();break; /*調用新建數據文件函數*/case 1:del();break; /*調用刪除數據函數*/case 2:add();break; /*調用添加數據函數*/case 3:snum();break; /*調用按工號搜索函數*/case 4:sname();break; /*調用按姓名搜索函數*/case 5:browse();break; /*調用瀏覽數據函數*/case 6:modify();break; /*調用修改數據函數*/case 7:order();break; /*調用排序函數函數*/case 8:data();break; /*調用統計函數*/case 9:exit(0); /*退出*/default:printf(input error! please input a number between 0 and 8);menu();2、各功能模塊設計:(1)、新建數據文件模塊:、數據結構;看各個數據信息,編號、姓名、性別、年齡、職務、職稱、政治面貌、最高學歷、任職時間、來院時間、人員類別,均為字符串類型,在文件中以文本形式存放,每條記錄對應一個人員的信息,可以方便信息的管理;而數據讀進內存中時,可以以結構體的形式,每一個結構體包含了一個人員的全部信息,多的人員的信息組成了一個結構體數組。定義如下:struct worker char num11; char name10; char sex2; char age3; char zhiwu15; char zhicheng15; char zhengzhi15; char xueli15; char renzhisj8; char laiyansj8; char leibie15; wkN,s;其中N是宏定義形式定義的字符,臨時定義為100,wkN,為存放人員信息的結構體數組,而S為臨時的結構體,用來保存信息處理過程中的臨時數據。2、流程圖如下:3、程序:build() int i,m,k,p;FILE *fp;if(fp=fopen(worker00.txt,w)=NULL)printf(can not build filen);printf_back();printf(how many workers do you want to input(0-%d)?:,N);scanf(%d,&m);k=m;for(i=0;ik;i+)printf(nInput %dth worker record.n,i+1);input(i);for(p=0;p=i;p+)if(fprintf(fp,%st%st%1st%st%st%st%st%st%st%st%sn,wkp.num,,wkp.sex,wkp.age,wkp.zhiwu,wkp. zhicheng,wkp.zhengzhi,wkp.xueli,wkp.renzhisj,wkp.laiyansj,wkp.leibie)!=1)printf(cannot write the datann);fclose(fp);printf_back();(2)、追加模塊:1需求分析該模塊的功能是擁護需要增加新的員工記錄,從鍵盤輸入并逐條寫入到原來的文件中去,其中輸入號碼是要防止號碼重復,重復時報告錯誤,重新輸入。為方便用戶管理和查看,該模塊采用的方式是用先把原來文件中的數據讀入內存,保存在內存中,然后在內存中的數據后面增加新的數據,操作完成后用寫的方式打開文件,用覆蓋的方式寫入。2流程圖:3程序:add() int i,m,n,k,p;FILE *fp;n=load();if(n=-1)menu();printf(how many workers do you want to add(0-%d)?: bbb,N-n);scanf(%d,&m);k=m+n;for(i=n+1;i=k;i+)printf(nInput %dth worker record.n,i-n+1);input(i);if(fp=fopen(worker00.txt,w)=NULL) /*將數據保存到文件*/printf(can not open filen); printf_back();for(p=0;pk;p+)fprintf(fp,%st%st%1st%st%st%st%st%st%st%st%sn,wkp.num,,wkp.sex,wkp.age,wkp.zhiwu,wkp. zhicheng,wkp.zhengzhi,wkp.xueli,wkp.renzhisj,wkp.laiyansj,wkp.leibie);fclose(fp);printf_back();(3)修改模塊:1 需求分析:該模塊的功能是顯示所有信息,考慮到記錄較多,采用分屏顯示,顯示完所有的記錄后,由用戶輸入需要修改的人員的號碼,查找成功后,顯示查找結果,并詢問擁護修改人員的哪部分記錄,根據用戶選擇修改相應的信息,然后保存修改后的結果;2 流程圖3 程序;modify() int i,n,k,p,w0=1,w1,w2=0;FILE *fp;n=load();dok=-1;printf_face();for(i=0;i=n;i+) if(i!=0)&(i%10=0) printf(nnRemember the No.which need modify.npress any key to continue.);getch();puts(nn); printf_one(i);doprintf(nnEnter NO. that you want to modify!nttNO. bb);scanf(%s,s.num);for(i=0;in;i+) if(strcmp(s.num,wki.num)=0); k=i; s=wki; if(k=-1) printf(nnNO exit ! please again); while(k=-1);printf_face();printf_one(k);w1=modify_data(k); if(w1=1) printf(nsuccessful!nnDo yuo want to modify another?nntt1tYesnntt2tBack with savent bb); scanf(%d,&w0); w2=1; else w0=0; if(w2=1) wkk=s; wkk=s; if(w0!=1&w2=1) fp=fopen(worker00.txt,w); for(p=0;pnntt1tNO.ntt2tnamentt3tsexntt4tagentt5tzhiwuntt6tzhichengntt7tzhengzhimianmaontt8txuelintt9trenzhishijianntt10tlaiyuanshijianntt11trenyuanleibiennttt bb);scanf(%d,&c);if(c11|c11|c1);doswitch(c)case 1:printf(the old number is %s,wki.num);input_num(i,i-1);break;case 2:printf(the old name is %s,enter the new name:,);scanf(%s,);break;case 3:printf(the old sex is %s,enter the new sex:,wki.sex);scanf(%1s,wki.sex);break;case 4:printf(the old age is %s,enter the new age:,wki.age);scanf(%s,wki.age);break;case 5:printf(the old zhiwu is %s,enter the new zhiwu:,wki.zhiwu);scanf(%s,wki.zhiwu);break;case 6:printf(the old zhicheng is %s,enter the new zhicheng:,wki.zhicheng);scanf(%s,wki.zhicheng);break;case 7:printf(the old zhengzhimianmao is %s,enter the new zhengzhimiainmao:,wki.zhengzhi);scanf(%s,wki.zhengzhi);break;case 8:printf(the old zuigaoxueli is %s,enter the new zuigaoxueli:,wki.xueli);scanf(%s,wki.xueli);break;case 9:printf(the old renzhishijian is %s,enter the new renzhishijian:,wki.renzhisj);scanf(%s,wki.renzhisj);break;case 10:printf(the old laiyuanshijian is %s,enter the new laiyuanshijian:,wki.laiyansj);scanf(%s,wki.laiyansj);break;case 11:printf(the old renyuanleibie is %s,enter the new renyuanleibie:,wki.leibie);scanf(%s,wki.leibie);break;printf(now:nn);printf_face();printf_one(i);printf(nare you sure?nntt1tsurentt2tNo and remodifyntt3tback without save in this timenttt bbb);scanf(%d,&w1);while(w1=2);return(w1);(4)刪除模塊:1需求分析:該模塊的運行方式與修改模塊類似,首先分屏顯示所有人員的記錄,顯示完所有的記錄后,由用戶輸入要刪除的人員的號碼,根據號碼查找相應的記錄并將結果顯示出來,經用戶確認后刪除,刪除的方法是將文件中的數據讀入內存,賦給相應的結構體,并將結構體數組中將刪除的后面的數據賦給前一個結構體,然后將相應數據寫入文件并保存;2流程圖:Y3程序;del() char c;int i,j,n,k,m,w0=1,w1=0,w2=0;FILE *fpt;n=load();dok=-1;printf_face();for(i=0;i=n;i+) if(i!=0)&(i%10=0) printf(nnRemember the No.which need delete.npress any key to continue.);getch();printf(nn); printf_one(i);do printf(nnEnter NO. that you want to delete!nttNO. bb);scanf(%s,s.num);for(i=0;i=n;i+) if(strcmp(s.num,wki.num)=0); k=i; s=wki; if(k=-1) printf(nnNO exit ! please again); while(k=-1);printf_face();printf_one(k);printf(are you sure to delete the data? ty/nntt bb);scanf(%1s,&c); if(c=y) for(j=i;j=n;j+) wkj=wkj+1; w1=1; else menu(); if(w1=1) printf(nsuccessful!nnDo yuo want to delete another?nntt1tYesnntt2tBack with saventbb); scanf(%d,&w0); w2=1; if(w0!=1&w2=1) fpt=fopen(worker00.txt,w); for(m=0;mn;m+)fprintf(fpt,%st%st%1st%st%st%st%st%st%st%st%sn,wkm.num,,wkm.sex,wkm.age,wkm.zhiwu,wkm. zhicheng,wkm.zhengzhi,wkm.xueli,wkm.renzhisj,wkm.laiyansj,wkm.leibie);fclose(fpt); while(w0=1);menu();(5)、按號碼搜索:1需求分析:該模塊的功能是按照輸入的人員的號碼查找對應的記錄,并將其顯示,查找成功以后,增加刪除和修改等功能,其中刪除和修改功能可以通過調用相應的函數來實現。2流程圖;3、程序;snum() FILE *fp;int i,n,k,p,w1=1,w2,w3,w4;n=load();do do k=-1; printf(nnEnter the number that you want to search!nttnumber: bbbbb); scanf(%s,s.num);for(i=0;i=n;i+)if(strcmp(s.num,wki.num)=0) k=i; printf_one(k);break; if(k=-1) printf(nnNO exist!please);printf(nnAre you again?ntt1tagainntt2tNO and backntt bb);scanf(%d,&w1);if(w1=1)snum();break;if(w1=2) menu();break; while(k=-1&w1=1);w4=0;w3=0;if(k!=-1); printf(nnWhat do you want to do ?ntt1tsearch anotherntt2tmodifyntt3tDeletentt4tback menuntt bb); scanf(%d,&w2); switch(w2) case 1:snum();break;case 2:w3=modify_data(k);break;/*調用修改數據函數*/case 3:printf(nAre you sure?ntt1tsurentt2tno and backntt bb); scanf(%d,&w4); if(w4=1) for(p=i;p=n;p+) wkp=wkp+1; break;case 4:menu();break; if(w3=1|w4=1) fp=fopen(worker00.txt,w);for(p=0;p=n;p+)fprintf(fp,%st%st%1st%st%st%st%st%st%st%st%sn,wkp.num,,wkp.sex,wkp.age,wkp.zhiwu,wkp. zhicheng,wkp.zhengzhi,wkp.xueli,wkp.renzhisj,wkp.laiyansj,wkp.leibie); fclose(fp);printf(nnttsuccessful!n);printf(nnWhat do you want to do?ntt1tSearch anotherntt2tBackntt bb);scanf(%d,&w2);while(w2=1);menu();(7) 按姓名搜索。該模塊的結構與按號碼查詢的結構基本相同;(8) 瀏覽模塊;1 需求分析:該模塊的功能是顯示所有保存在文件中的記錄,考慮到記錄較多,采用分屏顯示的方式;2、流程圖;3程序:browse() int i,j,n; n=load(); printf_face();for(i=0;i=n;i+) if(i!=0)&(i%10=0) printf(nnRemember the No.which need delete.npress any key to continue.);getch();printf(nn); printf_one(i); printf(tThere are %d record.n,n+1);printf(press any key to continue.);getch();menu();(9)、排序模塊;1、需求分析;該模塊的功能是要求將記錄按照年齡或者來院時間進行排序,總體結構是先用n=load()函數將文件中的數據調入內存,然后按照選擇法排序,并將結果顯示出來,然后將排序后的結果保存。2 流程圖;3 程序;order() int i,j,k,n,p,m;FILE *fp;n=load();printf(which do you like to follow?ntt1tagentt2tlaiyuanshijiannn);scanf(%d,&p);if(p=1) for(i=0;i=n-1;i+)for(j=i+1;j=n;j+) if(strcmp(wki.age,wkj.age)0) s=wki; wki=wkj; wkj=s; if(p=2) for(i=0;i=n-1;i+) for(j=i+1;j=n;j+) if(strcmp(wki.laiyansj,wkj.laiyansj)0) s=wki; wki=wkj; wkj=s; fp=fopen(worker00.txt,w+);for(m=0;m=n;m+)if(fprintf(fp,%st%st%1st%st%st%st%st%st%st%st%sn,wkm.num,,wkm.sex,wkm.age,wkm.zhiwu,wkm. zhicheng,wkm.zhengzhi,wkm.xueli,wkm.renzhisj,wkm.laiyansj,wkm.leibie)=NULL)printf(cannot open the file,press any key to continue.);getchar();menu(); fclose(fp);printf(nn);printf_back();(10)、統計模塊1、需求分析;該模塊的功能是按照用戶的要求統計出滿足符合條件的所有記錄的個數,并將滿足條件的記錄顯示出來。該模塊沒有涉及到文件的保存,所以將文件用只讀的方式打開,可以防止操作過程中數據的丟失。2流程圖;3、程序data() int p;printf(what kind do you want to data?ntt1tthe number on dutyntt2tthe number of Party memberntt3tthe number of womenntt4tthe number of high educationntt5texitnntt bb);scanf(%d,&p); switch(p) case 1:numduty();break;case 2:numpm();break;case 3:numwm();break;case 4:hiedcation();break;case 5:menu();break;dafault:printf(the number must be between 1 and 4,please choose again!); data(); 該過程中調用了四個函數,numduty()(統計在職人員人數),numpm()(統計黨員人數),numwm()(統計女工人數),hieduction()(統計高學歷高職稱人數),函數的具體定義見后面附錄源程序。并通過在四個函數中調用menu()函數返回到主菜單。上機操作:1:數據源2:編譯,連接和運行下面是各個模塊的運行結果的界面圖:1、 主菜單函數界面:2、輸入模塊:新建文件和 添加模塊的輸入界面基本相同:3、刪除模塊:4、瀏覽模塊;5、編輯模塊:6、統計模塊:7、排序模塊:附所有源程序:#define N 100#include struct worker char num11; char name10; char sex2; char age3; char zhiwu15; char zhicheng15; char zhengzhi15; char xueli15; char renzhisj8; char laiyansj8; char leibie15; wkN,s,h; menu() /*菜單函數*/int n,w1;doprintf(nttttMENUn);printf(tt0tbuild new datann);printf(tt1tdelete datann);printf(tt2tadd datann);printf(tt3tsearch by numbernn);printf(tt4tsearch by namenn);printf(tt5tbrowse allnn);printf(tt6tmodify the datann);printf(tt7torder the volumenn);printf(tt8tdata a volumenn);printf(tt9texitnn);printf(tplease choice and enter a number bb);scanf(%d,&n);if(n8) w1=1; getchar(); else w1=0;while(w1=1);switch(n)case 0:build();break;case 1:del();break;case 2:add();break;case 3:snum();break;case 4:sname();break;case 5:browse();break;case 6:modify();break;case 7:order();break;case 8:data();break;case 9:exit(0);default:printf(input error! please input a number between 0 and 8);menu();build() /*新建文件*/int i,m,k,p;FILE *fp;if(fp=fopen(worker00.txt,w)=NULL)printf(can not build filen);printf_back();printf(how many workers do you want to input(0-%d)?:,N);scanf(%d,&m);k=m;for(i=0;ik;i+)printf(nInput %dth worker record.n,i+1);input(i);for(p=0;p=i;p+)if(fprintf(fp,%st%st%1st%st%st%st%st%st%st%st%sn,wkp.num,,wkp.sex,wkp.age,wkp.zhiwu,wkp. zhicheng,wkp.zhengzhi,wkp.xueli,wkp.renzhisj,wkp.laiyansj,wkp.leibie)!=1)printf(cannot write the datann);fclose(fp);printf_back(); add() /*add*/int i,m,n,k,p;FILE *fp;n=load();if(n=-1)menu();printf(how many workers do you want to add(0-%d)?: bbb,N-n);scanf(%d,&m);k=m+n;for(i=n+1;i=k;i+)printf(nInput %dth worker record.n,i-n+1);input(i);if(fp=fopen(worker00.txt,a+)=NULL)printf(can not open filen); printf_back();for(p=0;pk;p+)fprintf(fp,%st%st%1st%st%st%st%st%st%st%st%sn,wkp.num,,wkp.sex,wkp.age,wkp.zhiwu,wkp. zhicheng,wkp.zhengzhi,wkp.xueli,wkp.renzhisj,wkp.laiyansj,wkp.leibie);fclose(fp);printf_back();input(int i) /*輸入一個記錄*/input_num(i,i-1);printf(nenter the name:t bbbbbbbbbbb);scanf(%s,);printf(nenter the age:t bbbb);scanf(%s,wki.age);printf(nenter the sexM for man and W for woman:t bb);scanf(%1s,wki.sex);printf(nenter the zhiwu:t bbbbbbbbbbbbbbbb);scanf(%s,wki.zhiwu);printf(nenter the zhicheng:t bbbbbbbbbbbbbbbb);scanf(%s,wki.zhicheng);printf(nenter the zhengzhimiannao:t bbbbbbbbbbbbbbbb);scanf(%s,wki.zhengzhi);printf(nenter the xueli:t bbbbbbbbbbbbbbbb);scanf(%s,wki.xueli);printf(nenter the renzhishijian:t bbbbbbbbb);scanf(%s,wki.renzhisj);printf(nenter the laiyanshijian:t bbbbbbbbb);scanf(%s,wki.laiyansj);printf(nenter the leibie:t bbbbbbbbbbbbbbbb);scanf(%s,wki.leibie);load() /*加載函數*/FILE *fp;int i;if(fp=fopen(worker00.txt,r)=NULL)printf(cannot open filen);return NULL;elsefor(i=0;!feof(fp);i+)fscanf(fp,%st%st%1st%st%st%st%st%st%st%st%sn,wki.num,,wki.sex,wki.age,wki.zhiwu,wki. zhicheng,wki.zhengzhi,wki.xueli,wki.renzhisj,wki.laiyansj,wki.leibie);return(i-1);input_num(int i,int n) /*輸入號碼*/ int j,k,w1; do w1=0; printf(enter the number: bbb

溫馨提示

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

評論

0/150

提交評論