杂货店管理系统_第1页
杂货店管理系统_第2页
杂货店管理系统_第3页
杂货店管理系统_第4页
杂货店管理系统_第5页
已阅读5页,还剩44页未读 继续免费阅读

下载本文档

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

文档简介

1、 电子科技大学成都学院微电子技术系C语言课程设计实验报告册题 目:杂货店库存销售管理系统 指导教师: 设 计 者(组长): 赵同学 设 计 者(组员1): 李同学 所属院系:微电子技术系 微电子技术系制2016年 6月1日一、课程设计的目的1、进一步掌握和利用C语言进行程设计的能力;2、进一步理解和运用结构化程序设计的思想和方法;3、初步掌握开发一个小型实用系统的基本方法;4、学会调试一个较长程序的基本方法;5、学会利用流程图或N-S图表示算法;6、掌握书写程序设计开发文档的能力。二、课程设计的任务内容(一)系统需求分析1. 输入记录:将每一个商品的商品名称、商品ID 号以及商品类型、商品单价

2、、商品数量的数据作为一个记录。该软件能建立一个新的数据文件或给已建立好的数据文件增加记录。2. 显示记录:根据用户提供的记录或者根据商品名称显示一个或几个商品的各项详细记录。3. 修改记录:可以对数据文件的任意记录的数据进行修改并在修改前后对记录内容进行显示。4查找记录:可以对数据文件的任意记录的数据进行查找并在查找前后对记录内容进行显示。5. 删除记录:可删除数据文件中的任一记录。6排序:按货号排序。7. 统计: (A)统计有多少种商品类型,并计算各项商品类型下的商品数量和总金额,。(B) 统计符合指定条件(如商品单价在50元以下、50100 元、100元以上) 以内的商品数量以及占总商品数

3、量的百分比。(C)按货号或者单价排序形式打印全部商品信息表。8保存数据文件以及打开数据文件功能。经过逐层逐块、不断细化、求精过程,编写程序并进行测试、验证,可以逐个模块地分开调试,并通过文件包含或用工程文件的形式进行逐步联合调试。三模块设计分析(一)系统功能模块图欢迎画面登陆界面主菜单保存与读取按商品ID号查找修改商品ID号修改商品名称修改商品数量修改商品价格修改商品类型找零查询库存查询销量排行名称顾客消费排行统计某月生日顾客(二)各个模块详细功能描述1.欢迎界面:有背景音乐和配图,配图颜色会随机变化。2.登陆界面:可以进行背景色的设置,浏览关于我们的技术支持信息,可以修改登陆密码等。3.客户

4、管理:实现客户信息的增删查改。4.商品管理:实现了商品基本信息录入的增删查改,还能查看库存量,此处的库存量会由于销售系统部分售出商品而及时更改库存信息。5.购物结算:可帮助售货员进行销售,具有结算功能,可实现收银台的作用。6.销售结算:对销售量,库存量,客户购买需求等进行统计排名,帮助店家进货时能选择热销商品,同时可以查询各个月份生日的顾客。(三)功能函数的调用关系图主函数欢迎程序登陆程序客户管理退出程序购物结算销售结算商品管理客户贡献排行程序修改客户程序添加客户程序删除客户程序查询客户程序查询商品程序删除商品程序修改商品程序添加商品程序查询某月客户生日程序销量排行程序四系统详细设计(请按照功

5、能模块的划分,抓图并搭配相应的实现代码来描述具体的实现。代码中可以添加必要的注释)1.欢迎界面:有背景轻音乐,有动态动画展示,动画颜色随机变化。#ifndef _user_def_H /用户自定义头文件user-defined#define _user_def_H#include <windows.h> /支持Sleep函数 #include <stdio.h> #include <time.h> /用于随机函数初始化time()void color_back() /设置文本字符的颜色 int i; srand(unsigned)time(NULL); /初

6、始化时钟 i=rand()%15; /随机一个0到14的整数 switch(i) case 0: system("color 07");break; case 1: system("color 08");break; case 2: system("color 09");break; case 3: system("color 0A");break; case 4: system("color 0B");break; case 5: system("color 0C");br

7、eak; case 6: system("color 0D");break; case 7: system("color 0E");break; case 8: system("color 0F");break; case 9: system("color 01");break; case 10:system("color 02");break; case 11:system("color 03");break; case 12:system("color 04&q

8、uot;);break; case 13:system("color 05");break; case 14:system("color 06");break; void display_picture() /显示动画程序 system("cls"); printf("nn"); color_back(); /随机一个文本颜色 Sleep(300); /让系统暂停300毫秒,1秒 = 1 000 毫秒 printf("tt -n"); color_back(); Sleep(300); prin

9、tf("tt |-|n"); color_back(); Sleep(600); printf("tt * * * * * * *n"); color_back(); Sleep(600); printf("tt * * * * *n"); color_back(); Sleep(900); printf("tt <= *= *=<<<<<<n"); color_back(); Sleep(900);printf("tt * * *n"); color_

10、back(); Sleep(1000);printf("tt * * * *n"); color_back(); Sleep(1000);printf("tt * *n"); color_back(); Sleep(1200); printf("tt - n"); color_back(); Sleep(1300);printf("tt 李&赵 杂货商店 n"); color_back(); Sleep(1300); printf("tt - - n"); color_back(); S

11、leep(600); printf("tt * * * * n"); color_back(); Sleep(600); printf("tt * * n"); color_back(); Sleep(600); printf("tt * * * *n"); color_back(); Sleep(600); printf("tt * * * * n");#endif2.登陆界面:登陆账号,改变背景色,修改密码,查看关于我们的技术支持,退出系统void main() char choice='5'

12、/存储判断的选项 int i; PlaySound (TEXT("C:Users15878Desktopsupermarket洋葱.wav"), NULL, SND_ASYNC | SND_NODEFAULT);/音乐播放 printf("杂货店管理程序n"); system("pause"); for(i=0;i<1;i+) display_picture(); /打印动画效果 printf("nttt 亲,欢迎光临本系统!(00)/n"); system("pause"); /暂停 d

13、o system("cls"); system("color EE"); printf("nn*欢迎进入赵&李超市管理系统*nn"); printf("n请您选择操作选项:nn"); printf("tt 1.登录账号n"); printf("tt 2.修改密码n"); printf("tt 3.更改系统颜色n"); printf("tt 4.关于我们n"); printf("tt 5.退出系统n"); pr

14、intf("nn*nn"); printf("n 请输入您的选项(1,2,3,4,5):"); choice=getch(); switch(choice)case '1': if(userlogin()=1)showMymenue();break;case '2': changepw();break;case '3': Color();break;case '4': aboutUs();break;case '5': printf("nn系统安全退出nn"

15、;);exit(0);break; while(1);void Color()system("cls");printf("1.蓝白色n");printf("2.紫白色n");printf("3.黑绿色n");switch(getch()case '1': system("color 1f");break;case '2': system("color 5f");break;case '3': system("color

16、 02");break;void aboutUs() system("cls"); printf("nn*欢迎进入赵&李超市管理系统*|nn"); printf("tttttttt|n"); printf("-|n"); printf("tt版权所有电子科技大学成都学院电科一班tt|nn"); printf("ttt赵&李专属,翻版必究ttt|nn"); printf("*技术扶持*|n"); printf("tt赵先生

17、:TellQQ:1587810964t|n"); printf("-n"); printf("tt李先生:TellQQ:1297579452t|n"); printf("-n"); pcontinue();int userlogin()struct user info;char pw100=0, pw_confirm100=0;int wt = 0;memset(&info, 0, sizeof info);read_data(&info);system(&

18、quot;cls");printf("welcome! please loginn");while(1)printf("请输入用户名:");scanf("%s", pw);if(strcmp(pw,) != 0) printf("无用户名n");continue;printf("请输入密码:");scanf("%s", pw);if(strcmp(pw, info.pw) != 0) printf("密码错误*");printf

19、("您还有%d次输入机会!nn",2-wt);elsebreak;wt +;if(wt >= 3)printf("3次密码错误!n");printf("请稍后再次登录nn");printf("请按任意键退出");getch();return -1;return 1;void changepw()struct user info;char pw100=0, pw_confirm100=0;read_data(&info);system("cls");while(1)int i;pri

20、ntf("按1改密码n按0退出n");scanf("%d", &i);if(i = 0)break;if(i = 1)while(1)printf("请输入原始密码n");scanf("%s", pw);if(strcmp(pw, info.pw) != 0)printf("原始密码错误n");continue;printf("请输入新密码n");scanf("%s", pw);printf("请再输一次n");scanf(&q

21、uot;%s", pw_confirm);if(strcmp(pw, pw_confirm) != 0) int j;printf("两次密码不一致!n");while(1)printf("按1再一次改密码n按2返回上一步n按0退出n");scanf("%d", &j);if(j = 0) return -2;if(j = 1 | j = 2) break;printf("unknown inputn");if(j = 2) break;continue;strcpy(info.pw, pw);w

22、rite_data(&info);break;elseprintf("unknown input, should be 0/1n");3.主菜单void showMymenue() char choice='5' while(1) system("cls"); BreakLine; printf("tt1. 商品管理n"); printf("tt2. 客户管理n"); printf("tt3. 购物预算n"); printf("tt4. 销售预算n")

23、; printf("tt5. 退出系统n"); BreakLine; printf("nn请输入您的选择(1,2,3,4,5):"); choice=getch(); switch (choice) case'1': showGoodsmenue(); break; case'2': showCustmenue(); break;case'3': showSell(); break;case'4': showSales(); break;case'5':printf(&quo

24、t;nn系统安全退出nn");exit(0);break;default: printf("n您的输入有误,请检查后重新输入n"); pcontinue(); 4.商品管理:包括添加商品,修改商品,删除商品,查询商品#include <stdio.h>#include <string.h> #include <conio.h>#include <stdlib.h>#include "MyParams.h"#include "common.h"#include "Mym

25、enu.h"#include "Goodsman.h"struct dateint year;int month;int day;struct goods int no; /编码:char name20; /名称:struct date scday; /生产期 struct date:表示结构体类型date型 scday变量名 生日:-> struct datefloat expenda; /原价:float expendb; /单价:int save; /库存量int sell; /出售量goods100000; /定义一个全局的结构体数组 100000i

26、nt total;int read_Message()FILE *fp;int i=0;if(fp=fopen("goods.dat","rb")=NULL)printf("n*暂无任何可读信息,按任意键继续*");getch();return 0;while(feof(fp)!=1)fread(&goodsi,sizeof(struct goods),1,fp);if(goodsi.no=0)break;elsei+;fclose(fp);return i;void saveall() FILE*fp; int i; if(

27、fp=fopen("goods.dat","wb")=NULL) printf("n无法打开文件n"); return; for(i=0;i<total;i+) fwrite(&goodsi,sizeof(struct goods),1,fp); fclose(fp);void addgoods()struct goods newgoods; /新加入的结构体数组char choice='y' /是否继续录入信息FILE *fp; /文件指针,用它指向一个文件int i=0; /i是一个计数器,因为文件中

28、最多存1000个数据 dosystem("cls");printf("n*添加商品信息*n");printf("请输入商品编码:");scanf("%d",&newgoods.no); /取地址因为它是一个基本类型的数据BreakLine;printf("请输入商品名称:");scanf("%s",&); BreakLine;printf("请输入商品生产期:(格式如下:1999-9-9):");scanf(&qu

29、ot;%d-%d-%d",&newgoods.scday.year,&newgoods.scday.month,&newgoods.scday.day);printf("请输入商品原价:");scanf("%f",&newgoods.expenda); printf("请输入商品单价:");scanf("%f",&newgoods.expendb);printf("请输入商品出售量:");scanf("%d",&new

30、goods.sell);printf("请输入商品库存量:");scanf("%d",&newgoods.save);/以上完成了输入客户信息的操作; /将newcust结构体中的数据保存到一个磁盘文件中if(fp=fopen("goods.dat","ab")=NULL)printf("无法打开文件"); return; /如果打得开文件 /要保存数据的地址 这个数据类型的长度 几个数组文件指针fwrite(&newgoods,sizeof(struct goods),1,fp

31、);fclose(fp); /重新确认是否继续录入printf("n还要继续;录入商品信息吗?(y/n)");choice=getch();while(choice='y');void delgoods()int i,j;int todelno;char choice='n'system("cls");total=read_Message();printf("n请输入你要删除的商品的编码:");scanf("%d",&todelno);for(i=0;i<total;i

32、+)if(todelno=goodsi.no)break; /如果,没有找到要删除的商品if(i=total)printf("n没有找到您想删除的商品n");printf("n按任意键继续n");getch();return; printf("亲爱的管理员,删除后无法恢复,您确定要删除吗?(y/n)");choice=getch();if(choice='n')printf("n放弃删除,返回上一级n");printf("n按任意键继续n");getch();return;for

33、(j=i;j<total;j+)goodsj=goodsj+1;total-=1;saveall();printf("n删除商品数据成功n");pcontinue();getch();void updategoods()int i,r;int todelno;/struct goods gx; char choice='n'system("cls");total=read_Message();printf("n请输入你要更新的商品的编号:");scanf("%d",&todelno);

34、for(i=0;i<total;i+)if(todelno=goodsi.no)break;/如果,没有找到要删除的商品if(i=total)printf("n没有找到您想更新的商品n");pcontinue();getch();return; printf("n*更新商品信息*n"); printf("n*请选择更新项目*n"); printf(" 1.商品编码n"); printf(" 2.商品名称n"); printf(" 3.商品生产期n"); printf(&

35、quot; 4.商品原价n"); printf(" 5.商品单价n"); /printf(" 6.商品出售量n"); printf(" 6.商品库存量n"); printf(" 7.返回上级n"); BreakLine; while(1) printf("请输入选择项目:"); scanf("%d",&r); switch(r) case 1:printf("n请输入商品编码:");scanf("%d",&go

36、odsi.no);break; case 2:printf("n请输入商品名称:");scanf("%s",&);break; case 3:printf("n请输入商品生产期:(格式如下:1999-9-9):");scanf("%d-%d-%d",&goodsi.scday.year,&goodsi.scday.month,&goodsi.scday.day); break; case 4:printf("n请输入商品原价:");scanf

37、("%f",&goodsi.expenda);break; case 5:printf("n请输入商品单价:");scanf("%f",&goodsi.expendb);break;/ case 6:printf("n请输入商品出售量:");/scanf("%d",&goodsi.sell);/break; case 6:printf("n请输入商品库存量:");scanf("%d",&goodsi.save);break;

38、 default:showGoodsmenue();BreakLine; printf("亲爱的管理员,您确定要修改吗?(y/n)"); choice=getch(); if(choice='n') printf("n放弃修改,返回上一级n"); printf("n按任意键继续n"); getch(); return; / goodsi=gx; total-=1; saveall(); printf("n修改商品数据成功n"); pcontinue(); getch(); void findgood

39、s()int i;struct goods c;total=read_Message();system("cls");printf("n*商品信息*n");printf("n商品总数:%d",total);if(total>0)printf("n*显示所有商品信息*n");printf("n编号t名称t生产期tt原价t单价t出售量t库存量n");for(i=0;i<total;i+)c=goodsi;printf("n%dt%st%d-%d-%dt%.2ft%.2ft%dt

40、%dtn",c.no,,c.scday.year,c.scday.month,c.scday.day,c.expenda,c.expendb,c.sell,c.save);BreakLine;else printf("n*系统中暂无任何商品信息*n");printf("n按任意键继续n");getch();5.客户管理:包括客户信息的增添,删除,修改,与查询#include <stdio.h>#include <string.h> #include <conio.h>#include <st

41、dlib.h>#include "MyParams.h"#include "common.h"#include "Mymenu.h"#include "CustMan.h"int read_message(); struct dataint year;int month;int day; ;struct custint no; /编号char name20; /名字double expenditure; /总花费char tel20; /电话号码struct data birthday; /生日cust100

42、0; /最多存1000个客户信息int total; /现在cust.dat文件中总的纪录条数void saveAll() FILE*fp;int i;if(fp=fopen("cust.dat","wb")=NULL)printf("n无法打开文件n");return;for(i=0;i<total;i+)fwrite(&custi,sizeof(struct cust),1,fp);fclose(fp);/ 获取现有文件中客户的总人数int read_message()FILE*fp;int i=0;/记数 /打开文

43、件if(fp=fopen("cust.dat","rb")=NULL)printf("n*暂无任何可读消息,按任意键继续*n");getch();return 0; while(!feof(fp) fread(&custi,sizeof(struct cust), 1, fp); if(custi.no=0) break; else i+; /循环读取文件中的每一条记录 fclose(fp); return i; /存到cust结构中void addcust() /定义增加的struct cust newcust;char c

44、hoice='y'FILE *fp;int i=0;dosystem("cls");BreakLine;printf("请输入客户的编号:");scanf("%d",&newcust.no);printf("n");printf("请输入客户的名字:");scanf("%s",);printf("n");printf("请输入客户消费:"); scanf("%lf",&

45、amp;newcust.expenditure);printf("n");printf("请输入客户的电话号码:");scanf("%s",newcust.tel);printf("n");printf("请输入客户的生日:(格式:1999-9-9)");scanf("%d-%d-%d",&newcust.birthday.year,&newcust.birthday.month,&newcust.birthday.day);printf("

46、n");BreakLine;if(fp=fopen("cust.dat","ab")=NULL)printf("n对不起,不能打开指定的文件n");return ;fwrite(&newcust,sizeof(struct cust),1,fp);fclose(fp);printf("您还要继续输入新客户信息吗?(y/n)");choice=getch();while(choice='y');void findall() /定义查询所有的 int i; struct cust c;

47、 total= read_message(); system("cls"); printf("n*客户信息*n"); printf("n客户总数:%dn",total); if(total>0) printf("n*显示所有客户信息*n"); printf("n 编号 tt 姓名 tt消费 tt 电话 ttt 生日"); for(i=0;i<total;i+) c=custi; printf("n%dtt%stt%.2ftt%stt%d-%d-%dttn",c.n

48、o,,c.expenditure,c.tel,c.birthday); printf("n"); else printf("n*系统中暂无任何客户信息*"); pcontinue();void updatecust() int i,q; int toupdateno; /要更新的编号 int j; system("cls"); total=read_message(); / 读出信息 printf("n请输入您要更新的客户编号:"); scanf("%d",&toupdate

49、no); /查找 for(i=0;i<total;i+) if(toupdateno=custi.no) break; /i里面记录了要更新的客户的索引 if(i=total) printf("n没有找到要更新的客户n");printf("按任意键继续n");getch();return; printf("n*请更新用户信息*n"); printf("n*请选择更新项目*n"); printf(" 1.客户姓名n"); printf(" 2.客户电话n"); printf(" 3.客户生日n"); printf("

温馨提示

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

评论

0/150

提交评论