C语言课程设计报告—服装销售系统_第1页
C语言课程设计报告—服装销售系统_第2页
C语言课程设计报告—服装销售系统_第3页
C语言课程设计报告—服装销售系统_第4页
C语言课程设计报告—服装销售系统_第5页
已阅读5页,还剩15页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、 C语言课程设计报告05205218 : 王德富1:题目: 20:要求 系统设计要求: 1:包含三类用户:管理员、店长、销售员。 2: 向管理员提供以下功能:自身密码的修改,其他用户的添加删除,用户信息修改、统计。商品信息添加、修改、删除、查找、统计。 3:向店长提供以下功能:登陆、注销、自身密码修改、自身信息修改。商品信息修改、商品信息统计。查看日报表、月报表、商品销售量报表、营业员业绩报表、查找浏览修改商品储藏信息。4:向销售员提供以下功能:商品浏览、查找、出售商品、查看自己本日报表、本月报表。提示 1:总体设计 整个效劳销售系统可设计为管理员模块、店长模块、销售员模块、商品模块等。 2:

2、数据结构采用结构体。2:设计思路:服装销售系统商品浏览商品删除商品出售商品查找 商品修改商品添加商品模块用户删除用户修改用户添加管理员模块销售员模块店长模块 3:模块介绍: 管理员模块:先建立文本文件Admin.txt其中存放管理员的ID和密码及其它的信息;文本文件shopkeeper.txt,其中存放店主的用户名和密码及其它信息;文本文件Sell.txt,其中存放销售员的ID和密码及其它的信息。 登陆系统时,通过菜单项选择择登陆身份,然后提示输入用户ID和密码。 如果以管理员的身份登陆,那么在Admin.txt文件中查找输入的用户的ID和密码是否存在,如果存在,那么允许进入,显示菜单:修改密

3、码、添加用户、用户信息、商品信息;否那么,显示“输入的用户名或密码错误!,返回上级菜单。 管理员添加用户,就是执行文件写操作,采用追加的方式把用户信息写入用户信息文件。删除用户操作,读取用户的信息文件,如果读取的用户不是要删除的用户,那么直接重新写入文件,否那么放弃。 管理员选择用户的信息,将进入用户信息的修改和用户信息统计的选择。用户信息修改操作,即查找要修改的用户信息文件,找到要修改的用户,写入修改后的信息覆盖掉原始信息。用户信息的统计操作,读用户信息文件,比较统计信息字段,符合统计要求那么计数加1,最后输出符合条件的记录数。 管理员选择商品信息,那么可以选择商品信息添加、修改、删除、查找

4、、统计,商品信息的添加、修改、删除、统计操作与用户信息的相应操作类似。查找操作只需采用根本的查找算法查找商品信息文件就行了。 店长模块:店长修改密码和修改个人信息操作与管理员相应操作与管理员模块类似。 店长的商品信息可以选择商品信息修改和商品信息统计,此类操作与管理员的相应操作相同。 店长选择查看报表,那么显示选择菜单:日报表、月报表、商品销售量报表、营业员业绩报表。查看日报表、根据输入的日期在商品报表文件中查找,把出售日期与输入日期符合的记录输出。查看月报表操作类似,查找商品报表文件中商品出售日期在输入月份之间的记录输出。商品销售量报表,这是一个统计的过程,查找商品报表,统计同一商品的销售量

5、。查看营业员的业绩报表,那么读销售员信息文件,把信息打印输出即可。 店长查找浏览修改商品储藏信息,查找与修改操作可以参考管理员对商品的查找与修改操作,浏览操作就是把商品储藏信息分屏输出,每屏10条记录,按任意键继续。这些操作在该店长对应的商品储藏信息文件中执行。 销售员模块:销售员可以选择商品浏览、查找、出售商品、查看自己本日报表、本月报表。商品浏览、查找以及查看自己本日报表、本月报表。 商品模块:出售商品操作执行的动作是:在本店的商品储藏文件中查找要出售的商品,如果存在,那么出售,在商品报表文件和销售员销售文件中添加该商品信息,并把该商品信息从商品储藏文件中删除。4:测试数据及运行结果: 当

6、你输入1可以添加一用户,2是删除一个用户,3可以修改一个用户的信息,4是显示用户的数量,5添加一个商品,6为删除商品的信息,7修改商品的信息,8为查看商品的具体信息,9为展示商品的信息,10为退出系统。 在指定位置输入1后,按Enter,显示如下:/*第一次默认添加的是管理员帐号*/管理员可以完成110的内容。输入administrator :wang/ Enrer/输入password:123Enter/Enter后如下:输入1后可以添加1administrator代表管理员wang,2shopkeeoer代表店长yan,3seller代表营业员fei*/管理员完成后注销完,店长yan可以登

7、陆店长系统店长yan可以完成如下功能:代表营业员fei的登陆系统如下:营业员登陆后可以完成如下功能:4:原代码:#include "stdio.h"#include "dos.h"#include "string.h"/*帐户结构*/struct Account char name15; char password10; int type;/*1代表管理员,2代表店长,3代表营业员*/ struct Account *next; head1;/*服装商品结构*/struct Dress int amount;/*商品数量*/ char

8、 ID5;/*商品编号*/ int type; struct Dress *next; head2;/*营业员结构*/struct Seller char account 15; int SelledAmount;/*营业员销售量*/ long money; struct Seller *next; head3;char buffer4000,buffer14000,buffer24000,buffer34000; /*保存屏幕的缓存*/char menu2buf15; /*用于店主菜单中找自己帐号的缓存*/char menu3buf15;load()/*加载文件中的数据*/ FILE *fp

9、1,*fp2,*fp3; /*分别为帐号文件,商品文件和营业员文件*/ 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) /*在帐户表中查找帐户,有那么返回其地址,否那么返回空*/ 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() /*增加帐户函数*/ 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) /*如果是营业员帐户,责需要在营业员链表中添加数据*/ 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() /*删除帐户函数*/ 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() /*修改帐户信息函数*/ 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) /*如果是营业员帐户,责需要在营业员链表中添加数据*/ 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() /*添加商品函数*/ 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() /*删除商品函数*/ 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() /*修改商品信息函数*/ 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); /*输入要卖出商品的数量*/

33、printf("nCommoditiy's totalMoney:"); scanf("%ld",&totalMoney); /*输入卖出总价*/ q=Research1(ID); if(q!=NULL) q->amount=q->amount-amount; /*服装要减少卖掉的数量*/ for(p=head3.next;strcmp(p->account,menu3buf)!=0;p=p->next); p->SelledAmount=p->SelledAmount+amount; /*营业员的销售

34、量加上刚卖的数量*/ p->money=p->money+totalMoney; /*营业员的销售金额加上刚卖的钱*/ printf("nsell successfully!"); else printf("nnYou input a wrong Commoditiy's ID"); SrcSellor()/*查询员工业绩*/ struct Seller *p; char account15; clrscr(); printf("please input the seller's account"); /*

35、提示输入营业员的帐号,以便查找他的业绩*/ 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"); /*显示帐户数量*/ 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"); /*显示商品数量*/ 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、显示所有商品信息,即统计*/ gotoxy(10,10);printf("6.Search seller's achivement."); /*查询销售员的业绩*/ 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()/*营业员主菜单*/ 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); /*按任意健返回营业员主菜单*/ if(key!=NULL) puttext(1,1,80,25,buffer3); gotoxy(36,12); goto lable3; save()/*保存函数*/ FILE *fp1,*fp2,*fp3; /*分别为帐号文件,商品文件和营业员文件*/

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. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论