C语言程序课程设计商品进销存管理程序_第1页
C语言程序课程设计商品进销存管理程序_第2页
C语言程序课程设计商品进销存管理程序_第3页
C语言程序课程设计商品进销存管理程序_第4页
C语言程序课程设计商品进销存管理程序_第5页
免费预览已结束,剩余48页可下载查看

下载本文档

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

文档简介

1、题目及运行说明商品进销存管理程序1、题目描述设计一个商品进销管理程序,该程序具有以下功能:(1)录入商品信息;给定商品编号,修改该商品信息;给定商品编号,删除该商品信息;录入商品的进货和销售信息;(5)给定商品编号或商品名,查看该商品及库存信息(6)统计功能:提供一些统计各类信息的功能。2、题目要求(1)按照分析、设计、编码、调试和测试过程完成应用程序学习并使用流程图等工具,并在撰写报告中使用程序的各项功能在程序运行时,以菜单形式选择并执行要求用户输入数据时,要给出清晰、明确的提示,包括:输入数 据的内容、格式及其结束方式等(5)所有的信息存储在一个文件或多个中,并实现文件读写操作。(6)程序

2、中用链表存放商品及进销存信息并实现增删减功能。3、提示(1) 提醒事件信息可以设计一个结构体类型自己构思并增加的除规定功能之外的新功能,酌情加分。(1)程序中主要变量Struct goods *head 结构体指针Int n,kstruct goodsint nu mber;char n ame20;int shumu;float jiage;struct goods *n ext;int n,k;struct goods *head;等一些变量。(2) 数据输入的形式和输入值的范围字符不超过20位整型变量输入大于0浮点型变量也大于0商品编号为四位整数(3) 数据输入的形式按程序运行的提示操作

3、(4) 程序所能达到的功能及出错处理该程序具有以下功能:(1)录入商品信息;给定商品编号,修改该商品信息;给定商品编号,删除该商品信息;录入商品的进货和销售信息;(5)给定商品编号或商品名,查看该商品及库存信息(6)统计功能:提供一些统计各类信息的功能。程序设计思路根据要求首先设计一个结构体类型,设计好界面,设计好主函数。程序各功能通过调用子函数来实现用switch来实现菜单的选择 一切数据信息通通存在文件中,并实现文件读写操作。设计子函数来实现查询,保存,读取数据,删除等操作。【总体设计】图1系统功能模块图【详细设计】1.主函数主函数设计要求简洁,只提供部分提示语和函数的调用【程序】具体设计

4、如下:结构体设计struct goodsint nu mber;char n ame20;int shumu;float jiage;struct goods *n ext;主函数设计void mai n()void jiema n();void luru();struct goods *shuju();void sha nchu(struct goods *head);void jin ghuo(struct goods *head);void xiaoshu(struct goods *head);void xiugai(struct goods *head);void chax un(

5、struct goods *head);struct goods *head二NULL;int k=0;system("cls");jiema n();printf(”请选择你要的功能键:”);sca nf("%d",&k);getchar();while(k!=0)head=shuju();switch(k)case 1:luru();break;case 2:xiugai(head);break;case 3:chax un( head);break;case 4:xiaoshu(head);break;case 5:jin ghuo(hea

6、d);break;case 6:sha nchu(head);break;case O:exit(O);default: pnntf("pl ease try aga in !n");jiema n();printf("请选择你要的功能键:”);sca nf("%d",&k);界面设计void jiema n()printf("*n");printf(” 欢迎进入商品管理系统n");n");printf("*1 * 录入信息 *printf("*2 * 修改信息承 * n&qu

7、ot;);printf("*3 * 查询信息承 * n");printf("*4 * 销售信息承 * n");printf("*5 * 进货信息承 * n");printf("*6 * 删除信息承 * n");printf("*0 * 退出系统承 * n");printf(” 欢迎进入商品管理系统n");printf("*n");文件保存函数设计struct goods *baoc un( struct goods *head) struct goods *shuj

8、u();struct goods *p=NULL;FILE *fp二NULL;char ch='0'getcharO;printf(”是否保存到文件?(y/n):");ch=getchar();putchar(IO);if(ch='y'|ch二二'Y')fp=fo pen ("goods.txt","wb");p 二head;if(fp=NULL )&&(p二二 NULL)printf("读取数据失败!");exit(0);while( p!二NULL)fpri

9、n tf(fp,"%dn%s n %dn%ft", p->nu mber, p->n ame, p->shumu, p->jiage)p二p->n ext;printf("保存成功!n");fclose(fp);retu rn( head);else if(ch=' n'|ch='N')printf("信息未保存到文件!n");head二shuju();retu rn( head);elseprin tf("sorry, please try aga in(y/n

10、):");ch=getchar();putchar(10);retu rn( head);数据读取函数设计struct goods *shuju()int n=0;FILE *fp;struct goods *head二NULL,* p1,* p2;fp二fopen ("goods.txt","rb");if(fp=NULL)printf("nsorry,读取数据失败!n");exit(0);elsep1= p2=(struct goods *)malloc(LEN);fsca nf(fp,"%d%s%d%f&qu

11、ot;,&p 1-> nu mber, p1-> name,&p 1->shumu,&p 1->jia ge);while(!feof(fp)n+;if(n二=1)head 二p1;else p2->n ext 二p1;p2=p1;p 1=(struct goods *)malloc(LEN);fsca nf(fp,"%d%s%d%f",&p 1-> nu mber, p1-> name,&p 1->shumu,&p 1->jiage);p2-> next二NULL;

12、fclose(fp);retur n( head);录入函数设计void luru() struct goods *shuju();struct goods *baoc un( struct goods *head);struct goods *p 1,* p2,* p3;head=shuju();p 1=head;p2=(struct goods *)malloc(LEN);printf("请输入四位编号:");sca nf("%d",&p 2-> nu mber);printf("请输入商品名:");sea nf(&

13、quot;%s", p2-> name);printf("请输入商品数量:");sea nf("%d",&p 2->shumu);printf("请输入商品价格:");sea nf("%f",&p 2->jiage);if(p 仁二NULL)p仁p2; p2-> next二NULL;baoc un(p 2);return;while( p1!=NULL) p3=p 1; p1=p 1-> next; p3->n ext 二p2;p2-> next二

14、NULL;baoc un( head);进货函数设计void jin ghuo(struct goods *head) struct goods *baoc un( struct goods *head);int c;int p;struct goods *p 1,* p2;system("cls");printf(”请输入四位编号:");sca nf("%d",&p);p仁head;while( p!二 p1-> number&&p 1-> next!二NULL)p2=p1;p1二p1->n ext;

15、if(p=p 1- >nu mber)printf("n商品编号t商品名t数量t价格n");prin tf("%dtt%stt%dtt%fn", p1-> nu mber, p1-> name ,p 1->shumu, p1->ji age);printf("请输入该商品经货个数:");sea nf("%d", &c);p 1->shum u=p 1->shumu+c;printf("该商品经货个数:%dn",p1->shumu);baoc

16、 un( head);删除函数设计void sha nchu(struct goods *head) struct goods *p 1,* p2;struct goods *baoc un( struct goods *head);int p;system("cls");printf("请输入四位编号:");sca nf("%d",&p);p 仁head;while( p!二 p1-> number&&p 1-> next!二NULL) p2=p 1; p1=p 1-> next;if(p=

17、p 1- >nu mber)printf("n商品编号t商品名t数量t价格n");printf("%dtt%stt%dtt%.2fn", p1-> number, p1-> name, p1->shumu, p 1->jiage);if(p 1=head) head 二p1->n ext;else p2->n ext=p 1- >n ext; n=n-1;printf("删除成功!n");baoc un( head);查询函数设计void chax un( struct goods *h

18、ead)int a,c,i=0;struct goods *p 1,* p2;char t20;printf(" 1*商品编号查询n");printf(”2*商品名字查询n");printf(”请选择你需要的功能键n”);sca nf("%d",&a);getchar();if(a=1)printf("请输入四位编号:");sca nf("%d", &c);getchar();while(c!=0&&i=0)p仁head;while(c!=p1-> number&am

19、p;&p 1-> next!二NULL)p2=p 1; p1=p 1-> next;if(c=p 1- >nu mber)printf("n商品编号t名字t数目t价格:n");prin tf("%dt%st %dt %.2fn", p1-> number, p1-> name, p1->shumu, p1->jiage);i=1;else printf(" 系统中无该商 品记录 !press enter retum!n");getchar();system("cls"

20、;);retum;if(a=2&&i=0)system("cls");printf("请输入商品名字:");sca nf("%s",& t);getchar();while(strc mp (t,"0")!=0&&i=0)p仁head;if(strc mp (t ,p 1-> name)!=0&&p 1-> next!二NULL)p2二p1;p1二p1->n ext;if(strc mp (t ,p 1- >n ame)=0)print

21、f("n商品编号t名字t数目t价格:n");prin tf("%dt%st %dt %fn",p1->number,p1->name,p1->shumu, p1->jiage);i=1;elseprin tf("系统中无该商品记录 !p ressen terretum!n");getchar();system("cls");retum;修改函数设计void xiugai(struct goods *head) struct goods *baoc un( struct goods *head

22、);int p,i=0;struct goods *p 1,* p2;system("cls");printf(”请输入四位编号:");sca nf("%d",&p);getchar();if(p 匸0)p仁head;while( p!二 p1-> number&&p 1-> next!二NULL)p2=p1;p1二p1->n ext;if(p=p 1- >nu mber)prin tf("%dt%st %dt %fn",p1->number,p1->name,p1

23、->shumu, p1->jiage);printf("请输入要修改的新商品编号");sca nf("%d",&p 1-> nu mber);i=1;if(i=1)printf("修改后新商品编号名字数目 价格:n");prin tf("%d%s%d%f", p1->nu mber, p1->n ame ,p1->shum u,p 1->jiage);printf("修改成功!n");baoc un( head);销售函数设计void xiaos

24、hu(struct goods *head)struct goods *baoc un( struct goods *head);int c;int p;struct goods *p 1,* p2;system("cls");printf(”请输入四位编号:");sca nf("%d",&p);getchar();p仁head;while( p!二 p1-> number&&p 1-> next!二NULL)p2=p1; p1二p1->n ext;if(p=p 1- >nu mber)print

25、f("n商品编号t商品名t数量t价格n");prin tf("%dtt%stt%dtt%fn", p1-> nu mber, p1-> name ,p 1->shumu, p1->ji age);printf("请输入该商品售货个数:");sca nf("%d", &c);p 1->shum u=p 1->shumu-c;printf("该商品经货个数:%dn",p1->shumu);baoc un( head);三程序清单#in clude&l

26、t;stdio.h>#in cludevstri ng.h> #in cludevstdlib.h> #i ncludevmalloc.h> #defi ne LEN sizeof(struct goods) struct goods 结构体int number; 商品编号char name20;商品名 int shumu; 商品数目float jiage;商品价格 struct goods *n ext;int n,k;全局变量struct goods *head; 全局变量void main ()主函数void jiema n();界面函数声明void luru()

27、;录入函数声明struct goods *shuju();数据读取函数声明void shanchu(struct goods *head);删除函数声明void jin ghuo(struct goods *head);进货函数声明void xiaoshu(struct goods *head);销售函数声明void xiugai(struct goods *head);修改函数声明void chax un( struct goods *head);查询函数声明struct goods *head二NULL;int k=0;system("cls");jiema n();p

28、rintf(”请选择你要的功能键:");sca nf("%d",&k);getchar();while(k!=0)head二shuju();switch(k)case 1:luru();break;case 2:xiugai(head);break;case 3:chax un( head);break;case 4:xiaoshu(head);break;case 5:jin ghuo(head);break;case 6:sha nchu(head);break;case 0:exit(0);default: pnntf("pl ease t

29、ry aga in !n");jiema n();printf("请选择你要的功能键:");sea nf("%d",&k);struct goods *baoe un( struct goods *head) 保存函数struct goods *shuju();struct goods *p=NULL;FILE *fp=NULL;char ch='0'getcharO;printf(”是否保存到文件?(y/n):");判断是否保存 ch=getchar();putchar(10);if(ch='y

30、9;|ch=' Y')fp=fo pen ("goods.txt","wb");p 二head;if(fp=NULL )&&(p二二 NULL)printf("读取数据失败!");exit(O);while( p!二NULL)fprin tf(fp,"%dn%s n %dn%ft", p->nu mber, p->n ame, p->shumu, p->jiage)p二p->n ext;printf("保存成功!n");fclose(

31、fp);retu rn( head);else if(ch=' n'|ch='N')printf("信息未保存到文件!n");head=shuju();retu rn( head);elseprin tf("sorry, please try aga in(y/n):");ch二getcharO;putchar(IO);retu rn( head);void chaxun(struct goods *head) 查询函数int a,c,i=0;struct goods *p 1,* p2;char t20;printf(”

32、1*商品编号查询n");printf(”2*商品名字查询n");printf(”请选择你需要的功能键n");sca nf("%d",&a);getchar();if(a=1)printf("请输入四位编号:");sea nf("%d", &c);getchar();while(c!=O&&i=0)p仁head;while(c!=p1-> number&&p 1-> next!二NULL)查找商品p2=p 1; p1=p 1-> next;i

33、f(c=二p 1- >nu mber)printf("n商品编号t名字t数目t价格:n");prin tf("%dt%st %dt %.2fn", p1-> number, p1-> name, p1->shumu, p1->jiage);i=1;else printf(" 系统中无该商 品记录 !press enter return!n");getchar();system("cls");return;if(a=2&&i=0)system("cls"

34、;);printf("请输入商品名字:");sea nf("%s",& t);getchar();while(strc mp (t,"0")!=0&&i=0)p仁head;if(strcmp(t,p 1->name)!=0&&p 1->next!二NULL)查找商品p2二p1;p1二p1->n ext;if(strc mp (t ,p 1- >n ame)=0)printf("n商品编号t名字t数目t价格:n");prin tf("%dt%s

35、t %dt %fn",p1->number,p1->name,p1->shumu, p1->jiage);i=1;else prin tf(" 系统 中 无该商 品记录!p ressen ter return!n");getchar();system("cls");return;void jin ghuo(struct goods *head)进货函数struct goods *baoc un( struct goods *head);int c;int p;struct goods *p 1,* p2;system(&

36、quot;cls");printf(”请输入四位编号:");sca nf("%d",&p);p仁head;while( p!二 p1-> number&&p 1-> next!二NULL)查找商品p2=p1;p1二p1->n ext;if(p=p 1- >nu mber)printf("n商品编号t商品名t数量t价格n");prin tf("%dtt%stt%dtt%fn", p1-> number, p1-> name ,p 1->shumu, p

37、1->ji age);printf("请输入该商品经货个数:");sca nf("%d", &c);p 1->shum u=p 1->shumu+c;printf("该商品经货个数:dn",p1->shumu);baocu n( head);保存数据 void luru()struct goods *shuju();调用函数struct goods *baoc un( struct goods *head);struct goods *p 1,* p2,* p3;head二shuju();p 1=hea

38、d;p2=(struct goods *)malloc(LEN);printf("请输入四位编号:");sca nf("%d",&p 2-> nu mber);printf("请输入商品名:");sca nf("%s", p2-> name);printf("请输入商品数量:");sea nf("%d",&p 2->shumu);printf("请输入商品价格:");sea nf("%f",&p

39、 2->jiage);if(p 仁二NULL)p仁p2; p2-> next二NULL;baoe un(p 2);return;while( p1!=NULL) p3=p 1; p1=p 1-> next; p3->n ext 二p2;p2-> next二NULL;baoeun(head);保存数据 void shanchu(struct goods *head) 删除函数struct goods *p 1,* p2;struct goods *baoe un( struct goods *head);int p;system("cls");p

40、rintf("请输入四位编号:");sea nf("%d",&p);p 仁head;while( p!二 p1-> nu mber&&p 1-> next!二NULL)查找商品p2=p 1; p1=p 1-> next;if(p=p 1- >nu mber)printf("n商品编号t商品名t数量t价格n");prin tf("%dtt%stt%dtt%.2fn", p1-> number, p1-> name ,p 1->shumu, p 1-&g

41、t;jiage);if(p 1=head) head 二p1->n ext;else p2->n ext 二p 1- >n ext; n=n-1;printf("删除成功!n");baoc un( head);struct goods *shuju()数据读取函数int n=0;FILE *fp;struct goods *head二NULL,* p1,* p2;fp二fopen ("goods.txt","rb");if(fp=NULL)printf("nsorry,读取数据失败!n");exi

42、t(0);elsep1= p2=(struct goods *)malloc(LEN);fsca nf(fp,"%d%s%d%f",&p 1-> nu mber, p1-> name,&p 1->shumu,&p 1->jia ge);while(!feof(fp)n+;if(n二=1)head 二p1;else p2->n ext 二p1;p2=p1;p 1=(struct goods *)malloc(LEN);fsca nf(fp,"%d%s%d%f",&p 1-> nu mber

43、, p1-> name,&p 1->shumu,&p 1->jiage);p2-> next二NULL;fclose(fp);retur n( head);void jiema n()界面函数printf("*n");printf(” 欢迎进入商品管理系统n");prin tf("*1 *n");pri ntf("*2 * n");pri ntf("*3 * n");pri ntf("*4 * n");pri ntf("*5 * n&q

44、uot;);pri ntf("*6 * n");pri ntf("*O * n");printf(” 欢迎进入商品管理系统n");printf("*n");void xiaoshu(struct goods *head) 销售函数struct goods *baoc un( struct goods *head);int c;int p;struct goods *p 1,* p2;system("cls");printf(”请输入四位编号:");sca nf("%d",&a

45、mp;p);getchar();p仁head;while( p!二 p1-> number&&p 1-> next!二NULL)查找商品p2=p1;p1二p1->n ext;if(p=p 1- >nu mber)printf("n商品编号t商品名t数量t价格n");prin tf("%dtt%stt%dtt%fn", p1-> number, p1-> name ,p 1->shumu, p1->jiage);printf("请输入该商品售货个数:”);sca nf("%

46、d", &c);p 1->shum u=p 1->shumu-c;printf("该商品经货个数:%dn",p1->shumu);baocu n( head);保存数据void xiugai(struct goods *head) 修改函数struct goods *baoc un( struct goods *head);int p,i=0;struct goods *p 1,* p2;system("cls");printf(”请输入四位编号:");sca nf("%d",&p

47、);getcharO;if(p 匸0)p仁head;while( p!二 p1-> number&&p 1-> next!二NULL)查找商品p2=p1;p1二p1->n ext;if(p=p 1- >nu mber)printf("n商品编号t名字t数目t价格:n");prin tf("%dt%st %dt %fn",p1->number,p1->name,p1->shum u,p 1->jiage);printf("请输入要修改的新商品编号");sca nf(&quo

48、t;%d",&p 1-> nu mber);i=1;if(i=1)printf("修改后新商品编号名字数目 价格:n");prin tf("%d%s%d%f", p1->nu mber, p1->n ame ,p1->shum u,p 1->jiage);printf("修改成功!n");baoc un( head);四.系统运行请按要求操作界面!, r I 置 r I 叮口 - , ,|I,_ :r X!2 I1HSgjgfgggjiggjglgggjigfjgigfjiglggigg

49、iggljgigWggjjWBIPQ|HrH 息xHmxHun*券凸 t息KMWMMMKMKMMMMM M* * 虽冬悬 心 刑1界信屁*負*一* T 丑退 由累髡'无*'5齐亓召爲為 茨迎逬入商品管理系统 情选择你要的功能键=录入苓翠辱竽*瞬翌sa兽犁ST®呱灌早早罕竽翠竽:e : tn即T T E工口窗T I e “ 瞪T- 33T tr丢 SjBSSS比iBS &YYYY aas s; d 口肛翠翠翠*SE易習 MVBiO*W VVV*¥*印罠 XMAMM 字HKKLKMUKMr gL 加酣 尊巧翠*护一*讣厝 fffi Wy¥»¥-WgSBL VVVV*WiBfelS* £节 ¥卑¥¥¥&#

温馨提示

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

评论

0/150

提交评论