C語言課程設計報告—服裝銷售系統(tǒng)_第1頁
C語言課程設計報告—服裝銷售系統(tǒng)_第2頁
C語言課程設計報告—服裝銷售系統(tǒng)_第3頁
C語言課程設計報告—服裝銷售系統(tǒng)_第4頁
C語言課程設計報告—服裝銷售系統(tǒng)_第5頁
已閱讀5頁,還剩15頁未讀, 繼續(xù)免費閱讀

下載本文檔

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

文檔簡介

1、 C語言課程設計報告05205218 : 王德富1:題目: 20:要求 系統(tǒng)設計要求: 1:包含三類用戶:管理員、店長、銷售員。 2: 向管理員提供以下功能:自身密碼的修改,其他用戶的添加刪除,用戶信息修改、統(tǒng)計。商品信息添加、修改、刪除、查找、統(tǒng)計。 3:向店長提供以下功能:登陸、注銷、自身密碼修改、自身信息修改。商品信息修改、商品信息統(tǒng)計。查看日報表、月報表、商品銷售量報表、營業(yè)員業(yè)績報表、查找瀏覽修改商品儲藏信息。4:向銷售員提供以下功能:商品瀏覽、查找、出售商品、查看自己本日報表、本月報表。提示 1:總體設計 整個效勞銷售系統(tǒng)可設計為管理員模塊、店長模塊、銷售員模塊、商品模塊等。 2:

2、數(shù)據(jù)結構采用結構體。2:設計思路:服裝銷售系統(tǒng)商品瀏覽商品刪除商品出售商品查找 商品修改商品添加商品模塊用戶刪除用戶修改用戶添加管理員模塊銷售員模塊店長模塊 3:模塊介紹: 管理員模塊:先建立文本文件Admin.txt其中存放管理員的ID和密碼及其它的信息;文本文件shopkeeper.txt,其中存放店主的用戶名和密碼及其它信息;文本文件Sell.txt,其中存放銷售員的ID和密碼及其它的信息。 登陸系統(tǒng)時,通過菜單項選擇擇登陸身份,然后提示輸入用戶ID和密碼。 如果以管理員的身份登陸,那么在Admin.txt文件中查找輸入的用戶的ID和密碼是否存在,如果存在,那么允許進入,顯示菜單:修改密

3、碼、添加用戶、用戶信息、商品信息;否那么,顯示“輸入的用戶名或密碼錯誤!,返回上級菜單。 管理員添加用戶,就是執(zhí)行文件寫操作,采用追加的方式把用戶信息寫入用戶信息文件。刪除用戶操作,讀取用戶的信息文件,如果讀取的用戶不是要刪除的用戶,那么直接重新寫入文件,否那么放棄。 管理員選擇用戶的信息,將進入用戶信息的修改和用戶信息統(tǒng)計的選擇。用戶信息修改操作,即查找要修改的用戶信息文件,找到要修改的用戶,寫入修改后的信息覆蓋掉原始信息。用戶信息的統(tǒng)計操作,讀用戶信息文件,比較統(tǒng)計信息字段,符合統(tǒng)計要求那么計數(shù)加1,最后輸出符合條件的記錄數(shù)。 管理員選擇商品信息,那么可以選擇商品信息添加、修改、刪除、查找

4、、統(tǒng)計,商品信息的添加、修改、刪除、統(tǒng)計操作與用戶信息的相應操作類似。查找操作只需采用根本的查找算法查找商品信息文件就行了。 店長模塊:店長修改密碼和修改個人信息操作與管理員相應操作與管理員模塊類似。 店長的商品信息可以選擇商品信息修改和商品信息統(tǒng)計,此類操作與管理員的相應操作相同。 店長選擇查看報表,那么顯示選擇菜單:日報表、月報表、商品銷售量報表、營業(yè)員業(yè)績報表。查看日報表、根據(jù)輸入的日期在商品報表文件中查找,把出售日期與輸入日期符合的記錄輸出。查看月報表操作類似,查找商品報表文件中商品出售日期在輸入月份之間的記錄輸出。商品銷售量報表,這是一個統(tǒng)計的過程,查找商品報表,統(tǒng)計同一商品的銷售量

5、。查看營業(yè)員的業(yè)績報表,那么讀銷售員信息文件,把信息打印輸出即可。 店長查找瀏覽修改商品儲藏信息,查找與修改操作可以參考管理員對商品的查找與修改操作,瀏覽操作就是把商品儲藏信息分屏輸出,每屏10條記錄,按任意鍵繼續(xù)。這些操作在該店長對應的商品儲藏信息文件中執(zhí)行。 銷售員模塊:銷售員可以選擇商品瀏覽、查找、出售商品、查看自己本日報表、本月報表。商品瀏覽、查找以及查看自己本日報表、本月報表。 商品模塊:出售商品操作執(zhí)行的動作是:在本店的商品儲藏文件中查找要出售的商品,如果存在,那么出售,在商品報表文件和銷售員銷售文件中添加該商品信息,并把該商品信息從商品儲藏文件中刪除。4:測試數(shù)據(jù)及運行結果: 當

6、你輸入1可以添加一用戶,2是刪除一個用戶,3可以修改一個用戶的信息,4是顯示用戶的數(shù)量,5添加一個商品,6為刪除商品的信息,7修改商品的信息,8為查看商品的具體信息,9為展示商品的信息,10為退出系統(tǒng)。 在指定位置輸入1后,按Enter,顯示如下:/*第一次默認添加的是管理員帳號*/管理員可以完成110的內容。輸入administrator :wang/ Enrer/輸入password:123Enter/Enter后如下:輸入1后可以添加1administrator代表管理員wang,2shopkeeoer代表店長yan,3seller代表營業(yè)員fei*/管理員完成后注銷完,店長yan可以登

7、陸店長系統(tǒng)店長yan可以完成如下功能:代表營業(yè)員fei的登陸系統(tǒng)如下:營業(yè)員登陸后可以完成如下功能:4:原代碼:#include "stdio.h"#include "dos.h"#include "string.h"/*帳戶結構*/struct Account char name15; char password10; int type;/*1代表管理員,2代表店長,3代表營業(yè)員*/ struct Account *next; head1;/*服裝商品結構*/struct Dress int amount;/*商品數(shù)量*/ char

8、 ID5;/*商品編號*/ int type; struct Dress *next; head2;/*營業(yè)員結構*/struct Seller char account 15; int SelledAmount;/*營業(yè)員銷售量*/ long money; struct Seller *next; head3;char buffer4000,buffer14000,buffer24000,buffer34000; /*保存屏幕的緩存*/char menu2buf15; /*用于店主菜單中找自己帳號的緩存*/char menu3buf15;load()/*加載文件中的數(shù)據(jù)*/ FILE *fp

9、1,*fp2,*fp3; /*分別為帳號文件,商品文件和營業(yè)員文件*/ struct Account *p,*q; struct Dress *p1,*q1; struct Seller *p0,*q0; p=(struct Account *)malloc(sizeof(struct Account); head1.next=p; if(fp1=fopen("account","rb")!=NULL) for(;fread(p,sizeof(struct Account),1,fp1);) q=p; p=(struct Account *)malloc

10、(sizeof(struct Account); q->next=p; head1.type+; fclose(fp1); p1=(struct Dress *)malloc(sizeof(struct Dress); head2.next=p1; if(fp2=fopen("dress","rb")!=NULL) for(;fread(p1,sizeof(struct Dress),1,fp2);) head2.type=head2.type+p1->amount; q1=p1; p1=(struct Dress *)malloc(size

11、of(struct Dress); q1->next=p1; fclose(fp2); p0=(struct Seller *)malloc(sizeof(struct Seller); head3.next=p0; if(fp3=fopen("seller","rb")!=NULL) for(;fread(p0,sizeof(struct Seller),1,fp3);) q0=p0; p0=(struct Seller *)malloc(sizeof(struct Seller); q0->next=p0; head3.money+; f

12、close(fp3); struct Account *Research(char array) /*在帳戶表中查找?guī)?,有那么返回其地址,否那么返回?/ struct Account *p; for(p=head1.next;(strcmp(p->name,array)!=0)&&p->next!=NULL;p=p->next); if(strcmp(p->name,array)!=0) p=NULL; gotoxy(15,8); printf("nnsorry,this account doesn't exist!");

13、 return p; struct Dress *Research1(char array) /*在商品鏈表中其ID號查找商品,有就返回其地址,否那么返回空*/ struct Dress *p; for(p=head2.next;(strcmp(p->ID,array)!=0)&&p->next!=NULL;p=p->next); if(strcmp(p->ID,array)!=0) p=NULL; gotoxy(15,8); printf("nnsorry,this dress doesn't exist!"); retur

14、n p; AddAccount() /*增加帳戶函數(shù)*/ struct Account *new1,*p,*q; struct Seller *p0; int i; new1=(struct Account *)malloc(sizeof(struct Account); clrscr(); if(head1.type=0) /*第一次默認添加的是管理員帳號*/ gotoxy(10,5); printf("You must add an administrator for the first time!n"); printf("nplease input the

15、administrator's acccount:"); scanf("%s",new1->name); printf("nplease input the account's password:"); scanf("%s",new1->password); new1->type=1; new1->next=NULL; for(p=&head1,i=1;i<=head1.type;p=p->next,i+); p->next=new1; head1.type+

16、; gotoxy(20,15); printf("Add successfully"); else printf("please input the account's name:"); scanf("%s",new1->name); if(Research(new1->name)=NULL) /*檢測帳戶是否已經存在,是NULL就表示不存在,可以添加*/ clrscr(); printf("account's name:%s",new1->name); printf("

17、nplease input the account's password:"); scanf("%s",new1->password); printf("naccount's type (you need input 1 or 2 or 3 /1:administrator,2:shopkeeper,3:seller):");/*1,2,3分別代表管理員,店主和售貨員*/ scanf("%d",&new1->type); new1->next=NULL; for(p=&hea

18、d1,i=1;i<=head1.type;p=p->next,i+); p->next=new1; head1.type+; if(new1->type=3) /*如果是營業(yè)員帳戶,責需要在營業(yè)員鏈表中添加數(shù)據(jù)*/ for(p0=&head3,i=1;i<=head3.money;p0=p0->next,i+); p0->next=(struct Seller *)malloc(sizeof(struct Seller); strcpy(p0->next->account,new1->name); p0->next-&g

19、t;SelledAmount=0; p0->next->money=0; p0->next->next=NULL; head3.money+; gotoxy(20,10); printf("Add successfully"); else gotoxy(15,15);printf("Sorry,this account has been exsisted."); DelAccount() /*刪除帳戶函數(shù)*/ char name15; struct Account *p,*q; clrscr(); printf("npl

20、ease input account:"); scanf("%s",name); p=Research(name); if(p!=NULL) for(q=&head1;q->next!=p;q=q->next); q->next=p->next; head1.type-; free(p); gotoxy(20,10); printf("Delete successfully!"); AmdAccount() /*修改帳戶信息函數(shù)*/ char name15,namebuf15; struct Account *p

21、; struct Seller *p0; int i; clrscr(); printf("nplease input account:"); scanf("%s",name); p=Research(name); if(p!=NULL) printf("nthe old information:n"); printf("nname:%snpassword:%sntype:%dn",p->name,p->password,p->type); printf("nnNow input thi

22、s account's new information:"); printf("nnname:"); scanf("%s",namebuf); if(Research(namebuf)=NULL) clrscr(); printf("nnname:%s",namebuf); strcpy(p->name,namebuf); printf("npassword:"); scanf("%s",p->password); printf("ntype:"

23、); scanf("%d",&p->type); if(p->type=3) /*如果是營業(yè)員帳戶,責需要在營業(yè)員鏈表中添加數(shù)據(jù)*/ for(p0=&head3,i=1;i<=head3.money;p0=p0->next,i+); p0->next=(struct Seller *)malloc(sizeof(struct Seller); strcpy(p0->next->account,p->name); p0->next->SelledAmount=0; p0->next->mo

24、ney=0; p0->next->next=NULL; head3.money+; gotoxy(20,15); printf("Amend successfully!"); else clrscr();gotoxy(20,10);printf("sorry,this account has been exsisted."); AddCommodity() /*添加商品函數(shù)*/ struct Dress *new1,*p; int i; new1=(struct Dress *)malloc(sizeof(struct Dress); clr

25、scr(); printf("please input the dress's ID:"); /*ID長度不能大于5個字符,如需增加可自行修改*/ scanf("%s",new1->ID); printf("nplease input the dress's amount:"); scanf("%d",&new1->amount); printf("nplease input the dress's type (input 1 or 2 /1:trousers,

26、2:cloth):");/*1,2分別代表褲子和衣服*/ scanf("%d",&new1->type); new1->next=NULL; for(p=&head2,i=1;i<=head2.type;p=p->next,i+); p->next=new1; head2.amount=head2.amount+new1->amount; head2.type=head2.type+new1->amount; gotoxy(20,10); printf("Add successfully"

27、;); DelCommodity() /*刪除商品函數(shù)*/ char ID5; struct Dress *p,*q; clrscr(); printf("nplease input ID:"); scanf("%s",ID); p=Research1(ID); if(p!=NULL) for(q=&head2;q->next!=p;q=q->next); q->next=p->next; head2.type-; free(p); gotoxy(20,15); printf("Delete successful

28、ly!"); AmdCommodity() /*修改商品信息函數(shù)*/ char ID5; struct Dress *p; clrscr(); printf("nplease input ID:"); scanf("%s",ID); p=Research1(ID); if(p!=NULL) printf("nthe old information:n"); printf("nID:%sntype:%dnamount:%dn",p->ID,p->type,p->amount); print

29、f("nnNow input this account's new information:"); printf("nnID:"); scanf("%s",p->ID); printf("namount:"); scanf("%d",&p->amount); printf("ntype:"); scanf("%d",&p->type); gotoxy(20,20); printf("Amend succe

30、ssfully!"); RscCommodity() /*按商品ID查找商品*/ char ID5; struct Dress *p; clrscr(); printf("nplease input ID:"); scanf("%s",ID); p=Research1(ID); if(p!=NULL) printf("nID:%sntype:%dnamount:%dn",p->ID,p->type,p->amount); ScanCommodity() /*輸出所有商品信息*/ struct Dress *

31、p; int i; clrscr(); if(head2.type!=0) printf("There amount of commoditis is %dn",head2.type); printf("nIDtamountttype"); for(i=1,p=head2.next;i<=head2.type;i+,p=p->next) printf("n%st%dt%d",p->ID,p->amount,p->type); else printf("There is no commoditiy

32、!"); SellCommodity() /*銷售服裝*/ struct Seller *p; struct Dress *q; char ID5; int amount; long totalMoney; clrscr(); printf("Commoditiy's ID:"); scanf("%s",ID); /*輸入要賣出商品的ID號*/ printf("nCommoditiy's amount:"); scanf("%d",&amount); /*輸入要賣出商品的數(shù)量*/

33、printf("nCommoditiy's totalMoney:"); scanf("%ld",&totalMoney); /*輸入賣出總價*/ q=Research1(ID); if(q!=NULL) q->amount=q->amount-amount; /*服裝要減少賣掉的數(shù)量*/ for(p=head3.next;strcmp(p->account,menu3buf)!=0;p=p->next); p->SelledAmount=p->SelledAmount+amount; /*營業(yè)員的銷售

34、量加上剛賣的數(shù)量*/ p->money=p->money+totalMoney; /*營業(yè)員的銷售金額加上剛賣的錢*/ printf("nsell successfully!"); else printf("nnYou input a wrong Commoditiy's ID"); SrcSellor()/*查詢員工業(yè)績*/ struct Seller *p; char account15; clrscr(); printf("please input the seller's account"); /*

35、提示輸入營業(yè)員的帳號,以便查找他的業(yè)績*/ scanf("%s",account); for(p=head3.next;(strcmp(p->account,account)!=0)&&p->next!=NULL;p=p->next); if(strcmp(p->account,account)!=0) gotoxy(15,8); printf("nnsorry,this account doesn't exist!"); else printf("naccount: %snsold-amount

36、: %dnsold-money: %ld",p->account,p->SelledAmount,p->money); menu1() /*管理員菜單*/ int choice,key,i; struct Dress *p; clrscr(); printf("1.Add a new account.n"); /*添加新帳戶*/ printf("2.Delete an account.n"); /*刪除帳戶*/ printf("3.Modify an account's information.n"

37、); /*修改帳戶信息*/ printf("4.Show the amount of accounts.n"); /*顯示帳戶數(shù)量*/ printf("5.Add a new commodity.n"); /*增加新商品*/ printf("6.Delete a commodity.n"); /*刪除商品*/ printf("7.Modify a commodity's information.n"); /*修改商品信息*/ printf("8.Research commodity.n"

38、); /*查找商品*/ printf("9.Show the information of commodities.n"); /*顯示商品數(shù)量*/ printf("10.Exit this system.n"); printf("nplease input your option:"); gettext(1,1,80,25,buffer1); lable1:scanf("%d",&choice); switch(choice) case 1:AddAccount();break; case 2:DelAcc

39、ount();break; case 3:AmdAccount();break; case 4:clrscr(); gotoxy(20,15); printf("The amount of account is %d",head1.type); break; case 5:AddCommodity();break; case 6:DelCommodity();break; case 7:AmdCommodity();break; case 8:RscCommodity();break; case 9:ScanCommodity();break; case 10:save()

40、; default:printf("error!n"); key=bioskey(0); /*按任意健返回主菜單*/ if(key!=NULL) puttext(1,1,80,25,buffer1); gotoxy(26,12); goto lable1; menu2()/*店主菜單*/ int choice,key,i; struct Account *p; char namebuf15; clrscr(); gotoxy(10,5);printf("1.Change my password."); /*修改自身密碼*/ gotoxy(10,6);pr

41、intf("2.Change my information."); /*修改個人信息*/ gotoxy(10,7);printf("3.Change commodities's information."); /*修改商品信息*/ gotoxy(10,8);printf("4.Search commodities's information."); /*查詢商品信息*/ gotoxy(10,9);printf("5.Show the information of commodities."); /*

42、顯示所有商品信息,即統(tǒng)計*/ gotoxy(10,10);printf("6.Search seller's achivement."); /*查詢銷售員的業(yè)績*/ gotoxy(10,111);printf("7.Logoff."); /*注銷登陸*/ gotoxy(10,12);printf("please input your option:"); gettext(1,1,80,25,buffer2); lable2:scanf("%d",&choice); switch(choice) ca

43、se 1:clrscr(); p=Research(menu2buf); gotoxy(10,10);printf("please inout your new password:"); scanf("%s",p->password); gotoxy(10,12);printf("Your password is changed."); break; case 2:clrscr(); p=Research(menu2buf); if(p!=NULL) clrscr(); printf("nthe old informa

44、tion:n"); printf("nname:%snpassword:%sn",p->name,p->password); printf("nnNow input this account's new information:"); printf("nnname:"); scanf("%s",namebuf); if(Research(namebuf)=NULL) strcpy(p->name,namebuf); printf("npassword:");

45、scanf("%s",p->password); gotoxy(20,15); printf("Amend successfully!"); else clrscr();gotoxy(20,10);printf("sorry,this account has been exsisted."); break; case 3:AmdCommodity();break; case 4:RscCommodity();break; case 5:ScanCommodity();break; case 6:SrcSellor();break

46、; case 7:save(); default:printf("error!n"); key=bioskey(0); /*按任意健返回店主主菜單*/ if(key!=NULL) puttext(1,1,80,25,buffer2); gotoxy(36,12); goto lable2; menu3()/*營業(yè)員主菜單*/ int choice,key,i; struct Seller *p; clrscr(); gotoxy(10,5);printf("1.Scan the commodities's information");/*瀏覽商品

47、信息*/ gotoxy(10,6);printf("2.Search commodities's information"); /*按ID查找商品信息*/ gotoxy(10,7);printf("3.Sell things"); gotoxy(10,8);printf("4.See my own selling-infomation."); gotoxy(10,9);printf("5.Exit."); gotoxy(10,12);printf("please input your option

48、:"); gettext(1,1,80,25,buffer3); lable3:scanf("%d",&choice); switch(choice) case 1:ScanCommodity();break; case 2:RscCommodity();break; case 3:SellCommodity();break; case 4:clrscr(); for(p=head3.next;strcmp(p->account,menu3buf)!=0;p=p->next); printf("naccount:%snsold-amo

49、unt%dnsold-money:%ld",p->account,p->SelledAmount,p->money); break; case 5:save();break; default:printf("error!n"); key=bioskey(0); /*按任意健返回營業(yè)員主菜單*/ if(key!=NULL) puttext(1,1,80,25,buffer3); gotoxy(36,12); goto lable3; save()/*保存函數(shù)*/ FILE *fp1,*fp2,*fp3; /*分別為帳號文件,商品文件和營業(yè)員文件*/

50、 int i=1,j=1; char ch; struct Account *p; struct Dress *p1; struct Seller *p0; clrscr(); gotoxy(15,5); printf("Do you want to save?(y/n)"); getchar(); ch=getchar(); if(ch='y'|ch='Y') if(fp1=fopen("account","wb")=NULL|(fp2=fopen("dress","wb

51、")=NULL|(fp3=fopen("seller","wb")=NULL) printf("error!"); else for(p=head1.next;i<=head1.type;i+,p=p->next) fwrite(p,sizeof(struct Account),1,fp1); for(p1=head2.next;j<=head2.type;j+,p1=p1->next) fwrite(p1,sizeof(struct Dress),1,fp2); for(p0=head3.next,i=1

溫馨提示

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

評論

0/150

提交評論