




已閱讀5頁,還剩15頁未讀, 繼續(xù)免費閱讀
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)
文檔簡介
倉庫貨品管理系統(tǒng)程序設(shè)計書一、程序設(shè)計目標(biāo)1 問題描述一個庫存貨品信息管理系統(tǒng)軟件,要求能實現(xiàn)庫存貨品信息的輸入、插入、刪除、查找等功能,并能建立和更新的庫存信息保存于文件供輸出或打印。對于查找、刪除等功能要求能按貨品名、貨品號分別進行。每個貨品的相關(guān)信息包括:貨品號、貨品名、貨品庫存量、進貨日期、貨品生產(chǎn)廠家及供應(yīng)商等。2 問題分析實際上要完成的是一個簡單數(shù)據(jù)庫管理信息系統(tǒng)的設(shè)計,同時要掌握數(shù)據(jù)結(jié)構(gòu)方面的知識。二、概要設(shè)計1方案確定庫存貨品信息管理系統(tǒng)要求實現(xiàn)許多功能,可遵循結(jié)構(gòu)化程序設(shè)計思想來進行本系統(tǒng)的設(shè)計自頂向下,逐步細化,也就是將軟件設(shè)計任務(wù)劃分成許多容易解決的小的子任務(wù),即分解出許多子功能模塊進行設(shè)計。本程序經(jīng)過分析可劃分出6個子任務(wù):輸入、輸出、插入、刪除、查找和保存。2 程序設(shè)計模塊連接圖庫存貨品信息管理系統(tǒng)的模塊連接結(jié)構(gòu)如下圖:倉庫貨品信息管理系統(tǒng) 主程序模塊 載入模塊刪除模塊保存模塊 查找模塊插入模塊 輸出模塊輸入模塊3 模塊功能說明對本系統(tǒng)的功能進行分析后可作如下的模塊化設(shè)計:輸入模塊實現(xiàn)功能:按順序?qū)⒇浳锞幪?、貨物名稱、貨物數(shù)量依次輸入,并建立鏈表將其連接。當(dāng)輸入的貨品編號為0時,輸入結(jié)束。插入模塊實現(xiàn)功能:向已經(jīng)存盤的文件中再輸入貨品的信息,包括貨品編號、貨品名稱、貨品數(shù)量等等。刪除模塊實現(xiàn)功能:在已經(jīng)存儲的文件中刪除指定的貨品信息,并釋放內(nèi)存空間。刪除可以按照貨品編號和貨品名稱兩中方法進行。查找模塊實現(xiàn)功能:在已經(jīng)存儲的文件中查找指定的貨品信息??梢园凑詹檎邑浧肪幪柡拓浧访Q兩種方法進行。輸出模塊實現(xiàn)功能:在輸入特定的文件名之后,輸出該文件中所包含的全部貨品信息。保存模塊實現(xiàn)功能:進行上述操作后,都要進行保存操作,鏈表中的信息以文件形式被長期。保存。載入模塊實現(xiàn)功能:將磁盤上的數(shù)據(jù)文件載入鏈表。主序模塊實現(xiàn)功能:完成系統(tǒng)的界面處理,包括開始界面和主菜單界面。三、詳細設(shè)計1數(shù)據(jù)設(shè)計(1)數(shù)據(jù)結(jié)構(gòu)的選擇選取動態(tài)數(shù)據(jù)結(jié)構(gòu),本系統(tǒng)是通過雙向鏈表來完成的。動態(tài)存儲分配與釋放: 申請存儲空間函數(shù)malloc( )函數(shù)首部原型為void * malloc(unsigned int size) 釋放存儲空間函數(shù)free( )函數(shù)首部原型為void free(void*p)動態(tài)數(shù)據(jù)結(jié)構(gòu)雙向鏈表head 2030 2036 2025 20422030head2030 20362025D NULL C 2042B 2025A2036(2) 數(shù)據(jù)類型的選擇struct commodity /*定義雙向鏈表結(jié)構(gòu)體*/int number; /*貨物編號*/ char namemax; /*貨物名稱*/ int counter; /*貨物數(shù)量*/ struct commodity *piror, *next; /*定義兩指針,分別指向其前驅(qū)和后繼*/;(3)變量函數(shù)說明:COM *input( )操作結(jié)果:輸入貨品信息COM *insert_perf( )操作結(jié)果:插入某貨品COM *del_perf( )操作結(jié)果:刪除某貨品serch( )操作結(jié)果:查找某貨品print_perf( )操作結(jié)果:輸出某貨品save(COM*head)操作結(jié)果:保存COM *openfile( )操作結(jié)果:載入2 流程框圖查找模塊和載入模塊的算法框圖在此略。開始(1)輸入模塊NULL=ptr1ptr1!=NULL將ptr1指向結(jié)點輸入貨品的信息申請一個結(jié)點空間,使ptr1指向它ptr1-num!=0NY NY是否為第一個數(shù)據(jù)(n=0)NPtr1=ptr2-next;ptr2=ptr1-prior Yptr1=headn+1=n, ptr1=ptr2NULL=ptr2-next 返回head結(jié)束 開始(2)插入模塊調(diào)入載入模塊Head=NULL“yes”or “no” Head=ptr1ptr3=ptr2-next;ptr2=ptr3-priorNULL=ptr3-nextptr1=ptr2;ptr1-next=ptr1ptr2=ptr1-priorptr1!=NULL申請一個結(jié)點空間,使ptr3指向它給ptr3指向結(jié)點輸入預(yù)插入貨品的信息YNY返回NULLNY返回head結(jié)束開始(3)刪除模塊調(diào)用載入模塊head= =NULL Y N從鍵盤讀入sel值Sel!=1且sel!=2 Y 1 2輸入預(yù)刪除的貨品號num輸入預(yù)刪除的貨品號namehead=ptr1ptr1-num= =num orptr1-name= =name Y Nptr1!=NULL且未找到要刪除項Ptr1-next=head N返回NULL Yptr1=ptr2ptr1-next=ptr2-nextptr2=ptr1-priorPtr1-num= =num orPtr1-name= =nameY N Yptr1-next=ptr2-nextptr1-prior=ptr1-next-prior未找到“yes” OR “no” Y N返回head結(jié)束開始(4)保存模塊輸入預(yù)保存文件的文件名創(chuàng)建文件成功 N YHead=ptr1Ptr1!=NULL N Y將ptr1指向結(jié)點的數(shù)據(jù)寫入文件Ptr1-next=ptr1結(jié)束開始(5)輸出模塊調(diào)用載入模塊Head= =NULL Y NHead=ptr1輸出ptr1指向結(jié)點的貨品信息Ptr1-next=ptr1Ptr1!=NULL Y N結(jié)束對以上各模塊的文字解釋說明:(1)輸入模塊:其實就是一個建立鏈表的操作模塊。建立鏈表的具體操作就是逐一輸入各結(jié)點數(shù)據(jù),并建立其前后相鏈的關(guān)系。首先設(shè)三個指針變量:head,ptr1,ptr2。它們都是指向結(jié)構(gòu)體類型數(shù)據(jù)的。先使head的值為NULL,這是鏈表為空的情況。用malloc函數(shù)開辟一個結(jié)點,并使ptr1,ptr2都指向它,之后從鍵盤讀入一個貨品的數(shù)據(jù)給ptr1所指向的結(jié)點。當(dāng)輸入的ptr1-num不為0時,令headptr1;ptr2=ptr1,即把ptr1的值賦給head,使ptr2,ptr1,head都指向這一新開辟的結(jié)點,此結(jié)點就成為鏈表中的第一個結(jié)點。再開辟一個新結(jié)點并使ptr1指向它,讀入該結(jié)點的數(shù)據(jù),如果輸入的ptr1-num不為0,則應(yīng)鏈入這第二個結(jié)點,這時和上一個結(jié)點的處理不同,是將ptr1的值賦給ptr2-next,也就是使第一個結(jié)點的next成員指向第二個結(jié)點,接著將ptr2也指向結(jié)點2。再開辟一個新結(jié)點并使ptr1指向它,讀入該結(jié)點的數(shù)據(jù),同樣將ptr1的值賦給ptr2-next,也就是使第三個結(jié)點鏈接到第二個結(jié)點之后,并接著將ptr1的值賦給ptr2,使ptr2指向結(jié)點3。再開辟一個新結(jié)點,并使ptr1指向它,輸入該結(jié)點的數(shù)據(jù),如果輸入ptr1-num為0,則是輸入結(jié)束標(biāo)志,此結(jié)點不被鏈接到鏈表中,就將NULL賦給ptr2-next。建立鏈表過程至此結(jié)束,ptr1最后所指結(jié)點并未鏈入鏈表中。(2)插入模塊:要完成的是鏈表的插入操作,即將一個新結(jié)點插入到一個已有的鏈表中,對剛剛建立的鏈表,首先新設(shè)一個指針變量ptr0,并開辟一個結(jié)點使ptr3指向它,輸入該結(jié)點的數(shù)據(jù),即新貨的有關(guān)數(shù)據(jù),接下來查找要插入位置結(jié)點,找到后只需修改此結(jié)點和ptr0指向結(jié)點指針域的值即可,鏈表中所有元素位置均不需移動,這就體現(xiàn)了鏈表的優(yōu)點。(3)刪除模塊:要完成的是鏈表的刪除操作,只需修改鏈表中要刪除結(jié)點的前一個結(jié)點的鏈指針。使之指向被刪除結(jié)點的后面一個結(jié)點即可。(4)保存模塊:將最終想要保留的數(shù)據(jù)信息保存于文件中。(5)輸出模塊:要完成的是依次輸出鏈表中各結(jié)點的數(shù)據(jù)的操作。首先找到鏈表頭結(jié)點的地址,也就是head的值,然后設(shè)一個指針變量ptr1,先指向第一個結(jié)點,輸出ptr1所指的結(jié)點,然后使ptr1后移一個結(jié)點,再輸入直至鏈表的尾結(jié)點結(jié)束。四、C源程序清單#include /*標(biāo)準(zhǔn)輸入/輸出頭文件*/#include /*包含繪制圖形函數(shù)等頭文件*/#include /*包含字符串處理函數(shù)頭文件*/#include /*包含動態(tài)存儲與釋放函數(shù)頭文件*/#include#define LEN sizeof(COM)#define PRINT % -15ld% -15s% -15dn,ptr1-num,ptr1-name,ptr1-count#define CHECK_COUNT ptr1-countcountnum);flushall(); if(ptr1-num=0) printf(Please press any key to back to last Menu:); getch( ); free(ptr1); return(0); printf(Please input the No.%d goods%s:n,n,string2);scanf(%s,&ptr1-name); flushall( ); /*刷新緩沖區(qū)函數(shù)*/ printf(Please input the No.%d goods%s:n,n,string3);scanf(%d,&ptr1-count); flushall( ); if(CHECK_COUNT) printf(Please input the right goodscount!n); while(CHECK_COUNT); while(ptr1-num!=NULL) if(n=1) head=ptr1; else ptr2-next=ptr1; ptr1-prior=ptr2; n=n+1; ptr2=ptr1; if(ptr1=(COM* )malloc(LEN)=NULL) printf(No enough memory,fail to creat linklist!); getch( ); do printf(Please input the No.%d goods%s:n,n,string1); scanf(%ld,&ptr1-num); flushall( ); if(ptr1-num=0) ptr1-num=NULL; break; printf(Please input the No.%d goods%s:n,n,string2);scanf(%s,&ptr1-name); flushall( ); printf(Please input the No.%d goods%s:n,n,string3);scanf(%d,&ptr1-count); flushall( ); if(CHECK_COUNT) printf(Please input the right goodscount!n); while(CHECK_COUNT); ptr2-next=NULL; gotoxy(1,24); printf(Finish the inputting of goodsmessage,press any key to back to last Menu,please save:); getch(); return(head);/*插入模塊*/COM * insert( ) COM * ptr3; char string1 =goodsnumber; char string2 =goodsname; char string3 =goodscount; char judge10; clrscr( ); gotoxy(18,10); printf(Please input inserted goodsfliename:); head=openfile( ); if(head=NULL) return(NULL); else do clrscr( ); printf(Please input inserted goodsgoodsmessage:n); if(ptr3=(COM*)malloc(LEN)=NULL) printf(No enough memory,fail to creat node!); getch(); do printf(Please input goods%s(0):n,string1);scanf(%ld,&ptr3-num); flushall( ); if(ptr3-numname);flushall( ); printf(Please input goods%s:n,string3);scanf(%d,&(ptr3-count); flushall( ); if(CHECK_COUNT2) printf(Please input the right goodscount(0)!n); while(CHECK_COUNT2); ptr1=head; while(ptr1!=NULL) ptr2=ptr1; ptr1=ptr1-next; ptr1-prior=ptr2; ptr2-next=ptr3;ptr3-prior=ptr2; ptr3-next=NULL; printf(nInserting success!Cotinue to insert?(yes or no):); scanf(%s,judge); clrscr( ); while(! strcmp(judge,yes); gotoxy(20,10); printf(Inserting success!n); gotoxy(18,11); printf(Press any key to back to last Menun); gotoxy(16,12); printf(And make sure to Save(6) them or you will lose them!n); getch( ); return(head);/*刪除模塊*/COM *delet( ) char name10; char judge10; int sel; int del_num; clrscr( ); gotoxy(20,10); printf(Please input delected goodsfliename:); head=openfile( ); clrscr( ); if(head=NULL) return(NULL); else do do clrscr( ); gotoxy(3,4); printf(Please input delected goodsmessage:); gotoxy(1,9); printf( *1.Del depend on goodsnumbern); gotoxy(1,10); printf( *2.Del depend on goodsnamen); gotoxy(10,22); printf(please choose a number between 1 and 2:); scanf(%d,&sel); switch(sel) case 1:clrscr( ); gotoxy(6,6); printf(Please input goodsnumber:); scanf(%d,&del_num); break; case 2:clrscr( ); gotoxy(6,6); printf(Please input goodsname:); scanf(%s,&name); break; while(sel!=1&sel!=2); ptr1=head; if(ptr1-num=del_num|(strcmp(ptr1-name,name)=0) head=ptr1-next; printf(Success to delect goodsmessage!n); else /*判斷是否是目標(biāo)結(jié)點*/ while(ptr1!=NULL&ptr1-num!=del_num&strcmp(ptr1-name,name)!=0) ptr2=ptr1; ptr1=ptr1-next;ptr1-prior=ptr2; if(ptr1-num=del_num|(strcmp(ptr1-name,name)=0) ptr2-next=ptr1-next; ptr1-next-prior=ptr1-prior; free(ptr1); printf(nSuccess to delect goodsmessage!nn); else printf(nCant find this goodsmessage!nn); printf(Cotinue to delect?(yes or no):); scanf(%s,judge); while(!strcmp(judge,yes); clrscr( ); gotoxy(20,10); printf(Delecting success!n); gotoxy(18,11); printf(Press any key to back to last Menun); gotoxy(16,12); printf(And make sure to Save(6) them or you will lose them!n); getch( ); return(head); /*查找模塊*/void search( )char name10; char judge10; int sel; long int sel_num; clrscr( ); gotoxy(18,10); printf(Please press searched goodsfliename:); head=openfile( ); if(head=NULL) return; else do do clrscr( ); gotoxy(5,4); printf(Please choose the way to search:); gotoxy(1,9); printf( *1.Search depend on goodsnumbern); printf( *1.Search depend on goodsnamen); gotoxy(10,22); printf(please choose a number between 1 and 2:); scanf(%d,&sel); switch(sel) case 1:clrscr( ); printf(Please input goodsnumber:); scanf(%ld,&sel_num); break; case 2:clrscr( ); printf(Please input goodsname:); scanf(%s,name); break; while(sel!=1&sel!=2); ptr1=head; while(ptr1!=NULL&ptr1-num!=sel_num&strcmp(ptr1-name,name)!=0) ptr1=ptr1-next; if (ptr1-num=sel_num)|(strcmp(ptr1-name,name)=0) printf(n Success to search goodsmessage!n); printf(goodsnumber goodsname goodscountnn); printf(PRINT); else printf(nCant find this goodsmessage!nn); printf(Cotinue to search?(yes or no):); scanf(%s,judge); while(!strcmp(judge,yes); gotoxy(10,24); printf(Please press any key to back to last Menu:); getch( ); /*輸出模塊*/void print( ) int i=1; clrscr( ); gotoxy(18,10); printf(Please input printed goodsfilename:); head=openfile( ); if(head=NULL) return; else clrscr( ); printf( The printed result as follows:n); printf(goodsnumber goodsname goodscountnn); ptr1=head; do printf(PRINT); ptr1=ptr1-next; if(i/10=1) /*超過十行換頁*/ i=0; printf(Press any key to change page:); getch( ); clrscr( ); gotoxy(0,6); printf(goodsnumber goodsname goodscountnn); i=i+1; while(ptr1!=NULL); gotoxy(10,24); printf(Please press any key to back to last Menu:); getch( ); /*保存模塊*/void save(COM *head) clrscr(); gotoxy(8,13); printf(Please input saved goodsfilename(limit to letter or number):); scanf(%s,filename1); if(fp=fopen(strcat(filename1,filename2),wb)=NULL) /*以二進制只寫方式打開一個流*/ printf(Fail to creat FILE!); getch( ); return; ptr1=ptr2=head; while(ptr1!=NULL) if(fwrite(ptr1,sizeof(COM),1,fp)!=1) printf(Fail to print message to FILE!); getch( ); return; ptr1=ptr1-next; fclose(fp); gotoxy(10,24); printf(Saving success!Press any key to back to last Menu:); getch();/*載入模塊*/COM * openfile( )int n=1; scanf(%s,filename1); if(fp=fopen(strcat(filename1,filename2),rb)=NULL) gotoxy(15,13); printf(This filename isnt exist,please check if exist.npress any key back to Menu); getch( ); return(NULL); if(ptr1=ptr2=(COM*)malloc(LEN)=NULL) printf(No enough memory,fail to creat linklist!nPlease press any key back to Menun); getch( ); return(NULL); if(fread(ptr1,sizeof(COM),1,fp)!=1) /*從fp指向的流中讀取1個字段,每個字段為COM的字符長,并把它們放到ptr1指向的字符數(shù)組中,文件的位置指示器隨著所讀取的字符數(shù)而下移*/ printf(Fail to print message from FILE!nPlease press any key back to Menun); getch( ); return(NULL); if(ptr1-next=NULL) head=ptr1; else do if(n=1) head=ptr1; else ptr2-next=ptr1; n=n+1; ptr2=ptr1; if(ptr1=(COM*)malloc(LEN)=NULL) printf(No enough memory,fail to creat linklist!nPlease press any key to back to Menun); getch( );return(NULL); if(fread(ptr1,sizeof(COM),1,fp)!=1) printf(Fail to print message from FILE!nPlease press any key to back to Menun); getch( );return(NULL); while(ptr1-next!=NULL); ptr2-next=ptr1; return(head);fclose(fp); /*關(guān)閉文件函數(shù)*/void main( )char message = -*The instruction of GOODS SYSTEM*- nn You can input many kinds of messages,and you can use n goodname as FILEname n This SYSTEM can do operation like insert or delect to the n goodsmessage that have saved,then saved again.while you n can search message depend on the goodsnub or goodsname. nnn -*Welcome to enter the GOODS SYSTEM!*- n ;char menu = *MENU* nnn *1.Input n *2.Output n *3.Insert n *4.Delete n *5.Search n *6.Save n *0.Exit n;int sel;delay(10);textbackground(LIGHTGRAY);textcolor(BLUE); /*背景為銀灰色,字為藍色*/clrscr( );gotoxy(4,8);printf(%s,message);gotoxy(10,22);printf( Please press any key into the Menu!);getch( );doclrscr( );gotoxy(1,7);printf(%s,menu);gotoxy(10,20);printf(please choose a number from 0 to 6:);scanf(%d,&sel);switch(sel)case 1:head=input( ); /*輸入模塊*/ break; case 2:print( ); /*輸出模塊*/ break; case 3:head=insert( ); /*插入模塊*/ break; case 4:head=delet( ); /*刪除模塊*/ break; case 5:search( ); /*查找模塊*/ break; case 6:save(head); /*保存模塊*/ break; case 0:break;while(sel!=0);五、調(diào)試分析和測試結(jié)果各模塊功能測試:1. COM *input( )輸入模塊功能測試用戶逐一輸入的數(shù)據(jù)不斷添加就形成了一個列表。前面已經(jīng)表明本系統(tǒng)的數(shù)據(jù)結(jié)構(gòu)選取動態(tài)數(shù)據(jù)結(jié)構(gòu)雙向鏈表,因此此列表在內(nèi)存中是以鏈表的形式存儲的。那么輸入模塊實際上就是一個建立鏈表的操作模塊。通過模塊save( )將內(nèi)存中的已輸入的數(shù)據(jù)存入到指定路徑的某*.dat文件中去.特別指出: * 為用戶自己
溫馨提示
- 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)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 等保檢測機構(gòu)管理辦法
- 葡萄酒消費稅管理辦法
- 宜賓小區(qū)管理辦法細則
- 規(guī)劃建設(shè)條件管理辦法
- 西安擔(dān)保借貸管理辦法
- 育人故事課件視頻
- 股癬護理課件視頻教學(xué)
- 壓瘡培訓(xùn)課件5
- 培訓(xùn)課件首頁布局
- 高質(zhì)量高考數(shù)學(xué)試卷
- 4.2攜手促發(fā)展 (教學(xué)課件)2024-2025道德與法治九年級下冊 統(tǒng)編版
- 《聽力診斷與評估》課件
- 2025年下半年吉林省白城洮北區(qū)面向應(yīng)征入伍高校畢業(yè)生招聘事業(yè)單位人員18人歷年高頻重點提升(共500題)附帶答案詳解
- 2025年貴州茅臺酒廠集團招聘筆試參考題庫含答案解析
- 臨床技能培訓(xùn)中心建設(shè)方案
- 倉儲式物流產(chǎn)業(yè)園建設(shè)項目可行性研究報告
- 國開電大《親子關(guān)系與親子溝通》形考+大作業(yè)
- 勞務(wù)派遣服務(wù)投標(biāo)文件(技術(shù)方案)
- 2024年變電設(shè)備檢修工(高級)技能鑒定理論考試題庫-上(選擇題)
- 酒店前臺案例分析
- 消防應(yīng)急通信培訓(xùn)
評論
0/150
提交評論