![商品銷售管理系統(tǒng)設(shè)計_第1頁](http://file4.renrendoc.com/view/c8e60c3bb26bb150cf9aca1fdb756c7b/c8e60c3bb26bb150cf9aca1fdb756c7b1.gif)
![商品銷售管理系統(tǒng)設(shè)計_第2頁](http://file4.renrendoc.com/view/c8e60c3bb26bb150cf9aca1fdb756c7b/c8e60c3bb26bb150cf9aca1fdb756c7b2.gif)
![商品銷售管理系統(tǒng)設(shè)計_第3頁](http://file4.renrendoc.com/view/c8e60c3bb26bb150cf9aca1fdb756c7b/c8e60c3bb26bb150cf9aca1fdb756c7b3.gif)
![商品銷售管理系統(tǒng)設(shè)計_第4頁](http://file4.renrendoc.com/view/c8e60c3bb26bb150cf9aca1fdb756c7b/c8e60c3bb26bb150cf9aca1fdb756c7b4.gif)
![商品銷售管理系統(tǒng)設(shè)計_第5頁](http://file4.renrendoc.com/view/c8e60c3bb26bb150cf9aca1fdb756c7b/c8e60c3bb26bb150cf9aca1fdb756c7b5.gif)
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
年4月19日商品銷售管理系統(tǒng)設(shè)計文檔僅供參考、商品銷售管理問題描述:已知一公司有10種產(chǎn)品(產(chǎn)品編號,產(chǎn)品名稱,產(chǎn)品價格,產(chǎn)品產(chǎn)地,庫存數(shù)量(最開始為1000個)),設(shè)計一程序,完成以下功能:1)銷售:從鍵盤輸入顧客姓名,銷售數(shù)量、銷售日期,實現(xiàn)銷售功能。需要判斷產(chǎn)品是否存在,銷售數(shù)量是否小于庫存數(shù)量,銷售日期格式是否合法(格式為:YYYY-MM-DD,如-01-02))2)能根據(jù)產(chǎn)品編號查詢產(chǎn)品的銷售歷史3)計算時間段內(nèi)各個產(chǎn)品的銷售總額4)能根據(jù)顧客姓名,查詢購買歷史5)能顯示所有顧客的姓名提示:定義一個日期結(jié)構(gòu)體保存日期,具體信息為:年、月、日判斷存款日期和取款日期的格式是否合法時,需要判斷長度是否為10,第5位和第8位是否為’-’,字符,將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ù))。定義一個結(jié)構(gòu)體數(shù)組保存10種產(chǎn)品信息,具體信息為:產(chǎn)品編號,產(chǎn)品名稱,產(chǎn)品價格,產(chǎn)品產(chǎn)地,庫存數(shù)量(最開始為1000個)定義一個鏈表,保存銷售信息,具體為:顧客代碼,銷售數(shù)量、銷售日期。定義一個鏈表保存顧客信息,具體為:顧客代碼,顧客姓名當(dāng)輸入銷售信息時查詢顧客鏈表,如果在鏈表中存在該姓名的顧客記錄,則將其代碼在該銷售鏈表中插入一條記錄,如果不存在,則在顧客鏈表中插入一條記錄,(顧客代碼需要自動生成)。
#include"stdio.h"
/*I/O函數(shù)*/
#include"stdlib.h"/*標(biāo)準(zhǔn)庫函數(shù)*/
#include"string.h"/*字符串函數(shù)*/
#include"ctype.h"/*字符操作函數(shù)*/
#include"time.h"/*時鐘函數(shù)*/
#include"cstdlib"
#include"conio.h"
intx,k;/*定義全局變量用于保存當(dāng)前商品種類*/
structproduct/*定義商品數(shù)據(jù)結(jié)構(gòu)*/
{
intnum;/*商品編號*/
charname[20];/*商品名稱*/
floatprice;
/*商品售價*/
charplace[10];/*商品名稱*/
intstorage;
/*商品庫存*/
}_product[10],product1[10];//定義主結(jié)構(gòu)體數(shù)組和備用結(jié)構(gòu)體數(shù)組
structdata//定義日期結(jié)構(gòu)體
{intyear,month,day;
};
structsell/*定義銷售數(shù)據(jù)結(jié)構(gòu)*/
{
intcus;/*顧客代碼*/
intnum;/*商品編號*/
floatsells;/*銷售數(shù)量*/
chardata1[12];/*日期*/
structsell*next;
}*head_s,*pp,*tail_s;//定義頭指針操、作指針以及尾指針
structcustomer/*定義銷售數(shù)據(jù)結(jié)構(gòu)*/
{
intcus;/*顧客代碼*/
charname[10];/*顧客姓名*/
structcustomer*next;
}*head_c,*qq,*tail_c;//定義頭指針操、作指針以及尾指針
voidload();//讀取文件函數(shù)
voidadd();//添加銷售信息函數(shù)
intsearch_num();//根據(jù)商品編號查詢商品的銷售歷史
voidcal();//計算時間段內(nèi)各個商品的銷售總額
intsearch_name();//根據(jù)顧客姓名,查詢購買歷史
voidlist_name();//顯示所有顧客的姓名
voidmain();//主函數(shù)
intjudge();//主體判斷函數(shù)
intjudge_data(char*data1);//細(xì)節(jié)判斷函數(shù),用于判斷日期是否合法
voiddownload_s();//寫入銷售信息(顧客代碼,銷售數(shù)量、銷售日期)文件
voiddownload_c();//導(dǎo)出顧客購買記錄
voiddisplay();//顯示現(xiàn)在的商品信息
//主函數(shù)
voidmain()
{
intchoice;
structcustomer*head;//定義結(jié)構(gòu)指針
head=malloc(sizeof(structcustomer));//申請動態(tài)存儲空間
head->next=NULL;
do
{
printf("***********************歡迎使用商品銷售管理系統(tǒng)!!!*******************\n\n");
printf("
1.導(dǎo)入商品信息\n");
printf("
2.顯示商品信息\n");
printf("
3.輸入銷售記錄記錄\n");
printf("
4.按編號查尋商品銷售歷史\n");
printf("
5.計算時間段內(nèi)各個銷售總額\n");
printf("
6.按顧客姓名查找購買歷史\n");
printf("
7.顯示顧客姓名\n");
printf("
8.導(dǎo)出銷售信息(顧客代碼,銷售數(shù)量、銷售日期)文件\n");
printf("
9.導(dǎo)出顧客信息文件\n");
printf("
0.退出\n");
printf("***********************************************************************\n");
printf("請選擇不同功能輸入09的數(shù)字\n若輸入其它值會提前退出\n");
scanf("%d",&choice);
system("cls");
switch(choice)
{
case1:
load();
system("cls");
break;
case2:
display();
break;
case3:
add();
break;
case4:
search_num();
break;
case5:
cal();
break;
case6:
search_name();
break;
case7:
list_name(head);
break;
case8:
download_s();
break;
case9:
download_c();
break;
case0:
printf("\n\n\n\n");
printf("*************謝謝使用************\n\n\n\n");
break;
}
}while(choice>0&&choice<=9);
}
voiddisplay()
{
intcode,i=0;
pp=(structsell*)malloc(sizeof(structsell));//申請動態(tài)存儲空間并將指針轉(zhuǎn)變?yōu)榻Y(jié)構(gòu)類型
qq=(structcustomer*)malloc(sizeof(structcustomer));//申請動態(tài)存儲空間并將指針轉(zhuǎn)變?yōu)榻Y(jié)構(gòu)類型
pp->next=NULL;
qq->next=NULL;
system("cls");
/*清屏*/
printf("**************************商品信息**************************\n\n\n");
printf("
商品編號
商品名稱
商品價格
商品產(chǎn)地
庫存數(shù)量\n");
while(i<10)
{
//輸出商品記錄
printf("%8d%12s
%12.2f%10s%14d\n",_product[i].num,_product[i].name,_product[i].price,
_product[i].place,_product[i].storage);
i++;
}
printf("\n\n查詢完畢,請按任意鍵繼續(xù)");
getch();
system("cls");
}
voidload(){//讀取文件函數(shù)
inti=0,n=0,a,b,j;
FILE*fp;//指向文件的指針
do{
printf("請選擇導(dǎo)入商品信息的方法\n1:經(jīng)過鍵盤輸入\n2:經(jīng)過文件導(dǎo)入\n");
scanf("%d",&a);
if(a==2){
if((fp=fopen("商品信息.txt","rb"))==NULL)//打開文件
{
printf("不能打開文件,請檢查文件路徑\n");
//不能打開
exit(0);
//退出*/
}printf("*****************88商品信息88*******************\n");
printf("編號
名稱
價格
產(chǎn)地
庫存數(shù)量\n");
while(!feof(fp))
{
//讀入文件
fscanf(fp,"%d%s%f%s%d",&_product[i].num,_product[i].name,&_product[i].price,_product[i].place,&_product[i].storage);
printf("%-10d%-10s%-10.2f%-12s%-12d\n",_product[i].num,_product[i].name,_product[i].price,_product[i].place,_product[i].storage);
i++;
}
for(i=0;i<10;i++)
product1[i]=_product[i];
//對備用結(jié)構(gòu)體數(shù)組賦值
fclose(fp);//關(guān)閉文件
printf("\t\t數(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;j<=b;j++){
scanf("%d%s%f%s%d",&_product[i].num,_product[i].name,&_product[i].price,_product[i].place,&_product[i].storage);
fprintf(fp,"%-6d%-6s%-6.2f%-6s%-6d\n",_product[i].num,_product[i].name,_product[i].price,_product[i].place,_product[i].storage);
}
fclose(fp);//關(guān)閉文件
printf("\t\t數(shù)據(jù)讀入成功!按任意鍵繼續(xù)\n");
}
}while(a!=1&&a!=2);}
//細(xì)節(jié)判斷函數(shù),用于判斷日期是否合法
intjudge_data(char*data1)
{
intn=1,m,year=(data1[0]-48)*1000+(data1[1]-48)*100+(data1[2]-48)*10+(data1[3]-48),
month=(data1[5]-48)*10+(data1[6]-48),day=(data1[8]-48)*10+(data1[9]-48);
m=strlen(data1);
if(m!=10)
n=0;
if(data1[4]!='-'||data1[7]!='-')
n=0;
if(year>10000||year<1000||month>12||month<1||day>31||day<1)n=0;
if(((year%4==0&&year%100!=0)||(year%400==0))&&month==2)
if(day>30)n=0;
if(month==2&&day>=29)n=0;
if(month==4||month==6||month==9||month==11)
if(day>30)n=0;
returnn;
}
//判斷函數(shù)
intjudge()//判斷商品編號數(shù)量日期是否正確
{
inti,j=0,k,temp;
for(i=0;i<10;i++)
if(pp->num==_product[i].num)
{
j++;
x=k=i;
temp=_product[k].storage;
if((_product[k].storage-(int)pp->sells)>=0)
_product[k].storage-=(int)pp->sells;//判斷計算剩余量
break;
}
if(j==0)return3;//判斷是否存在輸入編號的商品
elseif(temp-(int)pp->sells<0)return2;//判斷輸入量是否大于剩余庫存量
elseif(pp->sells-(int)pp->sells>=1e-6)return4;//商品量
elseif(judge_data(pp->data1)==0)return0;//判斷日期
elsereturn1;//完全正確
}
//添加銷售信息函數(shù)
voidadd()
{
intcode,i=0,n,m;
pp=(structsell*)malloc(sizeof(structsell));//申請動態(tài)存儲空間并將指針轉(zhuǎn)變?yōu)榻Y(jié)構(gòu)類型
qq=(structcustomer*)malloc(sizeof(structcustomer));//申請動態(tài)存儲空間并將指針轉(zhuǎn)變?yōu)榻Y(jié)構(gòu)類型
srand(time(0));
code=rand();
pp->next=NULL;
qq->next=NULL;
system("cls");
/*清屏*/
printf("請輸入銷售記錄\n\n\n");/*提示輸入記錄*/
printf("顧客姓名
商品編號
銷售數(shù)量
銷售日期\n");
printf("\n");
scanf("%s%d%f%s",qq->name,&pp->num,&pp->sells,pp->data1);
/*輸入記錄*/
n=(int)pp->sells;
if(n<=0)
{
printf("商品數(shù)量有誤!!!請從新輸入");
scanf("%f",&pp->sells);
}
while(1)
{
m=judge();//判斷商品編號數(shù)量日期是否正確
if(m==1){
//pp=(structsell*)malloc(sizeof(structsell));//申請動態(tài)存儲空間并將指針轉(zhuǎn)變?yōu)榻Y(jié)構(gòu)類型
//qq=(structcustomer*)malloc(sizeof(structcustomer));
pp->cus=qq->cus=code;//隨機數(shù)
if(head_s==NULL)
head_s=pp;
else
tail_s->next=pp;
tail_s=pp;
if(head_c==NULL)head_c=qq;
elsetail_c->next=qq;
tail_c=qq;
printf("\t\t銷售信息輸入成功!按任意鍵繼續(xù)\n");
getch();
system("cls");
break;
}
elseif(m==2)
{
system("cls");
printf("銷售數(shù)量已大于庫存數(shù)量,請重新輸入:\n\n\n");
printf("請輸入銷售數(shù)量\n\n\n");/*提示輸入記錄*/
printf("銷售數(shù)量\n");
scanf("%f",&pp->sells);
/*輸入記錄*/
continue;
}
elseif(m==3){
system("cls");
printf("無此商品,請重新輸入:\n\n\n");
printf("請輸入銷售記錄\n\n\n");/*提示輸入記錄*/
printf("商品編號
\n");
scanf("%d",&pp->num);
/*輸入記錄*/
continue;
}
elseif(m==4){
system("cls");
printf("商品數(shù)量輸入錯誤,請重新輸入商品數(shù)量:\n\n\n");
printf("請輸入銷售記錄\n\n\n");/*提示輸入記錄*/
printf("銷售數(shù)量:\n");
scanf("%f",&pp->sells);
/*輸入記錄*/
continue;
}
elseif(m==0){
system("cls");
printf("銷售日期不合法,請重新輸入銷售日期:\n\n\n");/*提示輸入記錄*/
printf("銷售日期\n");
scanf("%s",pp->data1);
/*輸入記錄*/
continue;}
k++;}
}
//根據(jù)商品編號查詢商品的銷售歷史
search_num()
{
inti,num,k=0,flag=1,n=0;
structsell*ptr;
system("cls");
printf("請輸入商品編號:\n");
scanf("%d",&num);
for(i=0;i<10;i++)
if(num==_product[i].num){flag=0;break;}
if(flag==1)
{
system("cls");
printf("無此商品,請查實商品編號后按任意鍵準(zhǔn)備重新輸入!!!");
getch();
system("cls");
return0;
}
for(ptr=head_s;ptr;ptr=ptr->next)
if(num==ptr->num)
{
if(k==0)
{
printf("商品編號
銷售數(shù)量
銷售總額
銷售日期\n");
printf("\n");
k++;
}
printf("%5d%20d%20.2f%15s\n",ptr->num,(int)ptr->sells,
(int)ptr->sells*_product[i].price,ptr->data1);
}
if(k==0)
{
printf("該商品記錄為空!!!按任意鍵繼續(xù)");
getch();
system("cls");
return0;
}
else
{
printf("\n\n查詢完畢,請按任意鍵繼續(xù)");
getch();
system("cls");
return0;
}
}
//計算時間段內(nèi)各個商品的銷售總額
voidcal()
{
inti,n=0;
structsells1,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;
}while(n==1);
printf("請輸入結(jié)束日期:");
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("銷售記錄如下:\t\t時間:%s至%s\n",p->data1,q->data1);
printf("\n\n\t\t商品編號
銷售總額\n");
printf("\t\t\n\n");
for(ptr=head_s;ptr;ptr=ptr->next)
{
for(i=0;i<10;i++)
if(product1[i].num==ptr->num)break;
product1[i].storage-=(int)ptr->sells;
}
for(i=0;i<10;i++)
printf("\t\t%2d\t\t%.2f\n",product1[i].num,product1[i].price*(1000-product1[i].storage));
printf("\n\n查詢完畢,請按任意鍵繼續(xù)");
getch();
system("cls");
}
//根據(jù)顧客姓名,查詢購買歷史
intsearch_name()
{
inti,k=1;
charname[10];
structcustomer*ptr1;
structsell*ptr2;
system("cls");
printf("請輸入顧客姓名:\n");
scanf("%s",name);
for(ptr1=head_c;ptr1;ptr1=ptr1->next)
{
for(ptr2=head_s;ptr2;ptr2=ptr2->next)
if(ptr1->cus==ptr2->cus)break;
for(i=0;i<10;i++)
if(ptr2->num==_product[i].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%15s\n",ptr1->name,ptr1->cus,ptr2->num,(int)ptr2->sells,((int)ptr2->sells)*product1[i].price,ptr2->data1);
//k++;
}
k=0;
}
if(k==0)
{
printf("不存在此顧客!!!按任意鍵繼續(xù)");
getch();
system("cls");
return0;
}
else{
printf("\n\n查詢完畢,請按任意鍵繼續(xù)");
getch();
system("cls");
return0;
}
}
//顯示所有顧客的姓名
voidlist_name()
{
intn=1;
structcustomer*ptr;
system("cls");
if(head_c!=NULL)//判斷鏈表是否為空
{
printf("顧客姓名如下:\n");//用來顯示所有顧客的姓名
for(ptr=head_c;ptr;ptr=ptr->next)
{
printf("\t\t%s\n",ptr->name);
n++;
}
printf("\n\n顧客姓名查詢完畢,請按任意鍵繼續(xù)");
getch();
system("cls");
}
else
{
printf("顧客鏈表為空!!!請按任意鍵繼續(xù)");
getch();
system("cls");
}
}
voiddownload_s()//寫入銷售信息(顧客代碼,銷售數(shù)量、銷售日期)文件
{
inti=0;
FILE*fp;
structcustomer*ptr1;
structsell*ptr2;
system("cls");
if((fp=fopen("銷售信息文件.txt","w"))==NULL)
{
printf("銷售信息文件無法生成!\n");
exit(0);
}
if(qq!=NULL)
{
fprintf(fp,"
顧客代碼
銷售數(shù)量
購買日期\n");
for(ptr1=head_c;ptr1;ptr1=ptr1->next)
{
for(ptr2=head_s;ptr2;ptr2=ptr2->next)
if(ptr1->cus==ptr2->cus)
{
fo
溫馨提示
- 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)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2024-2025學(xué)年第8課中國古代的法治與教化-勤徑學(xué)升高中歷史選擇性必修1同步練測(統(tǒng)編版2019)
- 高利貸借款合同在2025年的法律地位分析
- 2025年居民共同租賃居住環(huán)境協(xié)議
- 2025年甲氨蝶呤項目提案報告模板
- 2025年數(shù)字電視有條件接收設(shè)備項目申請報告模式
- 2025年全屋定制用品合同樣本
- 2025年專利共有權(quán)策劃協(xié)議樣本
- 2025年中學(xué)生實驗操作安全協(xié)議
- 2025年碳酸丙烯酯項目提案報告模板
- 2025年會議中心使用協(xié)議
- 外科手術(shù)及護(hù)理常規(guī)
- 北師大版五年級數(shù)學(xué)下冊教材分析解讀課件完整版
- 學(xué)校開學(xué)教師安全培訓(xùn)
- 出口潛力分析報告
- 晉升的述職報告
- 檔案盒(文件盒)標(biāo)簽?zāi)0?正面、側(cè)面)
- 消防工程施工進(jìn)度計劃橫道圖+進(jìn)度網(wǎng)絡(luò)圖
- 微信視頻號運營技巧攻略詳解全套
- 2023CSCO非小細(xì)胞肺癌診療指南解讀
- 人教版九年級英語全冊期末復(fù)習(xí)完成句子專項練習(xí)
- 干部選拔任用程序
評論
0/150
提交評論