商品銷售管理系統(tǒng)設計_第1頁
商品銷售管理系統(tǒng)設計_第2頁
商品銷售管理系統(tǒng)設計_第3頁
商品銷售管理系統(tǒng)設計_第4頁
商品銷售管理系統(tǒng)設計_第5頁
已閱讀5頁,還剩35頁未讀, 繼續(xù)免費閱讀

下載本文檔

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

文檔簡介

1、.:.;、商品銷售管理問題描畫:知一公司有10種產(chǎn)品產(chǎn)品編號,產(chǎn)品稱號,產(chǎn)品價錢,產(chǎn)品產(chǎn)地,庫存數(shù)量最開場為1000個,設計一程序,完成以下功能:1)銷售:從鍵盤輸入顧客姓名,銷售數(shù)量、銷售日期,實現(xiàn)銷售功能。需求判別產(chǎn)品能否存在,銷售數(shù)量能否小于庫存數(shù)量,銷售日期格式能否合法格式為:YYYY-MM-DD,如2021-01-022)能根據(jù)產(chǎn)品編號查詢產(chǎn)品的銷售歷史3)計算時間段內(nèi)各個產(chǎn)品的銷售總額4)能根據(jù)顧客姓名,查詢購買歷史5)能顯示一切顧客的姓名提示:定義一個日期構(gòu)造體保管日期,詳細信息為:年、月、日判別存款日期和取款日期的格式能否合法時,需求判別長度能否為10,第5位和第8位能否為-,

2、字符,將1-4位表示的年份,6-7位表示的月份,9-10位表示的日期分別轉(zhuǎn)換成整數(shù)。判別能否滿足構(gòu)成日期的條件閏年月份只能是1-12之間的數(shù),假設是閏年,二月可以是29天否那么不能大于28,1,3,5,7,8,10,12月可以是31天,其他只能小于等于30建議寫成函數(shù)。定義一個構(gòu)造體數(shù)組保管10種產(chǎn)品信息,詳細信息為:產(chǎn)品編號,產(chǎn)品稱號,產(chǎn)品價錢,產(chǎn)品產(chǎn)地,庫存數(shù)量最開場為1000個定義一個鏈表,保管銷售信息,詳細為:顧客代碼,銷售數(shù)量、銷售日期。定義一個鏈表保管顧客信息,詳細為:顧客代碼,顧客姓名當輸入銷售信息時查詢顧客鏈表,假設在鏈表中存在該姓名的顧客記錄,那么將其代碼在該銷售鏈表中插入一

3、條記錄,假設不存在,那么在顧客鏈表中插入一條記錄,顧客代碼需求自動生成。 #include stdio.h /*I/O函數(shù)*/#include stdlib.h /*規(guī)范庫函數(shù)*/#include string.h/*字符串函數(shù)*/#include ctype.h /*字符操作函數(shù)*/#include time.h /*時鐘函數(shù)*/#include cstdlib#include conio.hint x,k;/*定義全局變量用于保管當前商品種類*/struct product /*定義商品數(shù)據(jù)構(gòu)造*/ int num; /*商品編號*/ char name20; /*商品稱號*/ float

4、 price; /*商品售價*/ char place10; /*商品稱號*/ int storage; /*商品庫存*/_product10,product110;/定義主構(gòu)造體數(shù)組和備用構(gòu)造體數(shù)組struct data/定義日期構(gòu)造體 int year,month,day;struct sell /*定義銷售數(shù)據(jù)構(gòu)造*/ int cus; /*顧客代碼*/ int num; /*商品編號*/ float sells;/*銷售數(shù)量*/ char data112;/*日期*/ struct sell * next;*head_s,*pp,*tail_s;/定義頭指針操、作指針以及尾指針 str

5、uct customer /*定義銷售數(shù)據(jù)構(gòu)造*/ int cus; /*顧客代碼*/ char name10; /*顧客姓名*/ struct customer * next;*head_c,*,*tail_c;/定義頭指針操、作指針以及尾指針void load();/讀取文件函數(shù)void add();/添加銷售信息函數(shù)int search_num();/根據(jù)商品編號查詢商品的銷售歷史void cal();/計算時間段內(nèi)各個商品的銷售總額int search_name();/根據(jù)顧客姓名,查詢購買歷史void list_name();/顯示一切顧客的姓名void main();/主函數(shù)int

6、 judge();/主體判別函數(shù)int judge_data(char *data1);/細節(jié)判別函數(shù),用于判別日期能否合法void download_s();/寫入銷售信息(顧客代碼,銷售數(shù)量、銷售日期)文件void download_c();/導出顧客購買記錄void display();/顯示如今的商品信息/主函數(shù)void main() int choice; struct customer * head;/定義構(gòu)造指針 head=malloc(sizeof(struct customer);/懇求動態(tài)存儲空間 head-next=NULL;do printf(*歡迎運用商品銷售管理系統(tǒng)

7、!*nn); printf( 1. 導入商品信息n); printf( 2. 顯示商品信息n); printf( 3. 輸入銷售記錄記錄n); printf( 4. 按編號查尋商品銷售歷史n); printf( 5. 計算時間段內(nèi)各個銷售總額n); printf( 6. 按顧客姓名查找購買歷史n); printf( 7. 顯示顧客姓名n); printf( 8. 導出銷售信息(顧客代碼,銷售數(shù)量、銷售日期)文件n); printf( 9. 導出顧客信息文件n); printf( 0. 退出n); printf(*n); printf(請選擇不同功能 輸入0-9的數(shù)字n 假設輸入其它值會提早退出

8、n); scanf(%d,&choice); system(cls); switch(choice) case 1: load(); system(cls); break; case 2: display(); break; case 3: add(); break; case 4: search_num(); break; case 5: cal(); break; case 6: search_name(); break; case 7: list_name(head); break; case 8: download_s(); break; case 9: download_c(); b

9、reak; case 0: printf(nnnn); printf(*謝謝運用*nnnn); break; while(choice0&choicenext=NULL; -next=NULL; system(cls); /*清屏*/ printf(*商品信息*nnn); printf( 商品編號 商品稱號 商品價錢 商品產(chǎn)地 庫存數(shù)量n); while(i10) /輸出商品記錄 printf(%8d%12s %12.2f%10s%14dn,_producti.num,_,_producti.price, _producti.place,_producti.stora

10、ge); i+; printf(nn查詢終了,請按恣意鍵繼續(xù).); getch(); system(cls);void load()/讀取文件函數(shù) int i=0,n=0,a,b,j; FILE *fp; /指向文件的指針 do printf(請選擇導入商品信息的方法n1:經(jīng)過鍵盤輸入n2:經(jīng)過文件導入n); scanf(%d,&a); if(a=2) if(fp=fopen(商品信息.txt,rb)=NULL)/翻開文件 printf(不能翻開文件,請檢查文件途徑n); /不能翻開 exit(0); /退出*/ printf(*88商品信息88*n); printf(編號 稱號 價錢 產(chǎn)地

11、庫存數(shù)量n); while(!feof(fp) /讀入文件 fscanf(fp,%d%s%f%s%d,&_producti.num,_,&_producti.price,_producti.place,&_producti.storage); printf(%-10d%-10s %-10.2f%-12s%-12dn,_producti.num,_,_producti.price,_producti.place,_producti.storage); i+; for(i=0;i10;i+) product1i=_producti; /對備用構(gòu)造

12、體數(shù)組賦值 fclose(fp); /封鎖文件 printf(tt數(shù)據(jù)讀入勝利!按恣意鍵繼續(xù).n); if(a=1) if(fp=fopen(商品信息1.txt,w)=NULL)/翻開文件 printf(不能翻開文件,請檢查文件途徑n); /不能翻開 exit(0); /退出*/ printf(請輸入商種類數(shù)); scanf(%d,&b); printf(*商品信息*n); printf(編號 稱號 價錢 產(chǎn)地 庫存數(shù)量n); for(j=1;j10000|year12|month31|day30) n=0; if(month=2&day=29) n=0; if(month=4|month=6

13、|month=9|month=11) if(day30) n=0; return n;/判別函數(shù) int judge()/判別商品編號 數(shù)量 日期能否正確 int i,j=0,k,temp; for(i=0;inum=_producti.num) j+; x=k=i; temp=_productk.storage; if(_productk.storage-(int)pp-sells)=0) _productk.storage-=(int)pp-sells;/判別計算剩余量 break; if(j=0) return 3;/判別能否存在輸入編號的商品 else if(temp-(int)pp-

14、sellssells-(int)pp-sells=1e-6) return 4;/商品量 else if(judge_data(pp-data1)=0) return 0;/判別日期 else return 1;/完全正確/添加銷售信息函數(shù)void add() int code,i=0,n,m; pp=(struct sell *)malloc(sizeof(struct sell);/懇求動態(tài)存儲空間并將指針轉(zhuǎn)變?yōu)闃?gòu)造類型 =(struct customer *)malloc(sizeof(struct customer);/懇求動態(tài)存儲空間并將指針轉(zhuǎn)變?yōu)闃?gòu)造類型 srand(time(0)

15、; code=rand(); pp-next=NULL; -next=NULL; system(cls); /*清屏*/ printf(請輸入銷售記錄nnn); /*提示輸入記錄*/ printf(顧客姓名 商品編號 銷售數(shù)量 銷售日期n); printf(-n); scanf(%s%d%f%s,-name,&pp-num,&pp-sells,pp-data1); /*輸入記錄*/ n=(int)pp-sells; if(nsells); while(1) m=judge();/判別商品編號 數(shù)量 日期能否正確 if(m=1) / pp=(struct sell *)malloc(sizeof

16、(struct sell);/懇求動態(tài)存儲空間并將指針轉(zhuǎn)變?yōu)闃?gòu)造類型 / =(struct customer *)malloc(sizeof(struct customer); pp-cus=-cus=code;/隨機數(shù) if(head_s=NULL) head_s=pp; else tail_s-next=pp; tail_s=pp; if(head_c=NULL) head_c=; else tail_c-next=; tail_c=; printf(tt銷售信息輸入勝利!按恣意鍵繼續(xù).n); getch(); system(cls); break; else if(m=2) system

17、(cls); printf(銷售數(shù)量已大于庫存數(shù)量,請重新輸入:nnn); printf(請輸入銷售數(shù)量nnn); /*提示輸入記錄*/ printf(銷售數(shù)量 n); scanf(%f,&pp-sells); /*輸入記錄*/ continue; else if(m=3) system(cls); printf(無此商品,請重新輸入:nnn); printf(請輸入銷售記錄nnn); /*提示輸入記錄*/ printf( 商品編號 n); scanf(%d,&pp-num); /*輸入記錄*/ continue; else if(m=4) system(cls); printf(商品數(shù)量輸入

18、錯誤,請重新輸入商品數(shù)量:nnn); printf(請輸入銷售記錄nnn); /*提示輸入記錄*/ printf(銷售數(shù)量:n); scanf(%f,&pp-sells); /*輸入記錄*/ continue; else if(m=0) system(cls); printf(銷售日期不合法,請重新輸入銷售日期:nnn);/*提示輸入記錄*/ printf(銷售日期n); scanf(%s,pp-data1); /*輸入記錄*/ continue; k+; /根據(jù)商品編號查詢商品的銷售歷史search_num() int i,num,k=0,flag=1,n=0; struct sell *

19、ptr; system(cls); printf(請輸入商品編號:n); scanf(%d,&num); for(i=0;inext) if(num=ptr-num) if(k=0) printf(商品編號 銷售數(shù)量 銷售總額 銷售日期n); printf(-n); k+; printf(%5d%20d%20.2f%15sn,ptr-num,(int)ptr-sells, (int)ptr-sells*_producti.price,ptr-data1); if(k=0) printf(該商品記錄為空!按恣意鍵繼續(xù).); getch(); system(cls); return 0; else

20、 printf(nn查詢終了,請按恣意鍵繼續(xù).); getch(); system(cls); return 0; /計算時間段內(nèi)各個商品的銷售總額void cal() int i,n=0; struct sell s1,s2,*p=&s1,*q=&s2,*ptr; system(cls); printf(請輸入開場日期:); scanf(%s,p-data1); system(cls); do if(judge_data(pp-data1)!=1) printf(輸入日期不合法,請重新輸入:); scanf(%s,p-data1); system(cls); n=1; else n=0;wh

21、ile(n=1); printf(請輸入終了日期:); scanf(%s,q-data1); system(cls);do if(judge_data(q-data1)!=1) printf(輸入日期不合法,請重新輸入:); scanf(%s,q-data1); system(cls); n=1; else n=0;while(n=1); printf(銷售記錄如下:tt時間:%s至%sn,p-data1,q-data1); printf(nntt商品編號 銷售總額n); printf(tt-nn);for(ptr=head_s;ptr;ptr=ptr-next) for(i=0;inum)

22、break; product1i.storage-=(int)ptr-sells; for(i=0;inext) for(ptr2=head_s;ptr2;ptr2=ptr2-next) if(ptr1-cus=ptr2-cus) break; for(i=0;inum=_producti.num) break; if(strcmp(name,ptr1-name)=0) / if(k=0|k%8=0) printf(顧客姓名 顧客代碼 商品編號 購買數(shù)量 購買總額 購買日期n); printf(-n); printf(%2s%15d%15d%10d%15.2f%15sn,ptr1-name,p

23、tr1-cus,ptr2-num,(int)ptr2-sells,(int)ptr2-sells)*product1i.price,ptr2-data1); /k+; k=0; if(k=0) printf(不存在此顧客!按恣意鍵繼續(xù).); getch(); system(cls); return 0; else printf(nn查詢終了,請按恣意鍵繼續(xù).); getch(); system(cls); return 0; /顯示一切顧客的姓名void list_name() int n=1; struct customer * ptr; system(cls); if(head_c!=NU

24、LL)/判別鏈表能否為空 printf(顧客姓名如下:n);/用來顯示一切顧客的姓名 for(ptr=head_c;ptr;ptr=ptr-next) printf(tt%sn,ptr-name); n+; printf(nn顧客姓名查詢終了,請按恣意鍵繼續(xù).); getch(); system(cls); else printf(顧客鏈表為空!請按恣意鍵繼續(xù).); getch(); system(cls); void download_s()/寫入銷售信息(顧客代碼,銷售數(shù)量、銷售日期)文件int i=0; FILE *fp; struct customer *ptr1; struct sell *ptr2; system(cls); if(fp=fopen(銷售信息文件.txt,w)=NULL) printf(銷售信息文件無法生成!n); exit(0); if(!=NULL) fprintf(fp, 顧客代碼 銷售數(shù)量 購買日期n); for(ptr1=head_c;ptr1;ptr1=ptr1-n

溫馨提示

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

評論

0/150

提交評論