C语言课程设计《商品销售管理系统》_第1页
C语言课程设计《商品销售管理系统》_第2页
C语言课程设计《商品销售管理系统》_第3页
免费预览已结束,剩余15页可下载查看

下载本文档

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

文档简介

1、商品销售管理系统目录一、需求分析 2二、概要设计 2三、详细设计 4四、调试分析 14五、用户手册 14六、测试数据 15七、附录 18一、需求分析商品销售管理程序商品信息:商品编号、商品名称、商品类别普通电视机、DVD带DVD的电视机,带DVD的电视机的售价为普通电视机和 DVD单价之和的80%、商品 进货价格、商品销售价格、商品数量、供应商名称等。记录每一次销售商品的数量和价格,并提供对已售出商品的价格、数量进 行统计、排序功能,但允许用户退商品。要求: 1. 源文件采用多文件的工程结构 2. 数据存储采用文件形式 3. 标准的 C 输入输出 4. 功能完善,适当的注释, 5. 关于文件的

2、内容需要自学、二、概要设计( 一)按系统分析的功能要求将系统划分为以下几个主要功能模块:1 、文件管理 文件翻开、关闭:对于刚输入或进行操作后的商品信息,在建立新的商 品库存量后,可以把其保存在一个文件中,并对该文件可进行翻开和关闭操 作。2、进出货管理(1) 商品进货 : 输入数据后商品信息能自动更新进行添加(2) 商品销售 : 输入数据后商品信息能自动更新进行减少3、商品数据管理(1) 增加/ 删除商品 : 添加或删除某条商品的信息(2) 修改商品信息 : 对某条商品的信息进行修改4、浏览商品信息管理(1) 查询商品信息:可分别按商品编号、名称、类别或需要进货商品查询(2) 排序商品信息

3、: 可按商品编号、名称、类别分别排排序(3) 浏览商品信息:可浏览输入、查询或排序后的数据。 二、本程序结构 1、结构体设计struct goods long int num;char name20;char sort20;long int count;long int price; goods200;(2) 各功能函数设计:void input() /* 功能 1:输入商品信息 */2void sequence() /*功能 2:排序商品信息 */void purchase() /*功能 3:进货商品信息 */void sell() /* void edit() /* void correc

4、t() /* void search() /*void scan() /* void reserve() /* void quit() /* (3) 主函数设计:功能 4:销售商品信息 */功能 5:添加或删除商品信息 */ 功能 6:修改商品信息 */ 功能 7:查询商品信息 */ 功能 8:浏览商品信息 */ 功能 9:保存文件 */ 退出系统 */void main ()void input(); void sequence(); void purchase(); void sell(); void edit(); void correct(); void search(); void

5、scan(); void reserve();lp: for(i=0;i<1;i+)scanf("%d",&k);system("cls");switch(k) /* 用 switch 语句实现功能选择 */ system("cls"); /* 清屏 */ goto lp; /* 返回主界面 */三、详细设计(1) 各功能函数:void input() /*功能 1 :输入商品信息 */printf("n 请输入需要建立新库存的商品种类数量 :");scanf("%d",&

6、n);system("cls");prin tf("n n");for(i=0;i<n;i+) /*用循环实现输入 n 个商品 */printf("nt*请输入商品的编号 :");scanf("%ld",&goodsi.num);printf("nt请输入商品的名称 :");scanf("%s",);printf("nt 请输入商品的种类 :"); scanf("%s",goodsi.sort);pr

7、intf("nt 请输入商品的数量 :"); scanf("%d",&goodsi.count);printf("nt 请输入商品的单价 :");scanf("%d",&goodsi.price);prin tf("n n"); printf("tPlease press any key to continue:"); getch();return; /* 返回主界面 */void sequence() /*功能 2:排序商品信息 */long temp;ch

8、ar p130,p230;for(k=0;k<n-1;k+) /*(1):按编号排序 */for(i=0;i<n-k-1;i+) /*用起泡法排序 */if(goodsi.num>goodsi+1.num) /*按编号由小到大排序 */temp=goodsi.num; goodsi.num=goodsi+1.num;goodsi+1.num=temp; strcpy(p1,); strcpy(,goodsi+1.name);strcpy(goodsi+1.name,p1); strcpy(p2,goodsi.sort);strcpy

9、(goodsi.sort,goodsi+1.sort); strcpy(goodsi+1.sort,p2);printf("n");printf("ntt按商品编号排序后的商品信息 nn");printf("t 商品编号 商品名称 商品类别商品数量商品单价 n"); /* 输出排序后商品信息 */for(i=0;i<n;i+)printf("t %5ld %5s%5s %5ld %5ldn",goodsi.num,,goodsi.sort,goodsi.count,goodsi.pric

10、e)4for(k=0;k<n-1;k+) /*(2): 按商品名称排序 */ for(i=0;i<n-k-1;i+) if(strcmp(,goodsi+1.name)>0)strcpy(p1,); strcpy(,goodsi+1.name); strcpy(goodsi+1.name,p1);temp=goodsi.num; goodsi.num=goodsi+1.num; goodsi+1.num=temp;strcpy(p2,goodsi.sort); strcpy(goodsi.sort,goodsi

11、+1.sort); strcpy(goodsi+1.sort,p2);printf("n");商品数量printf("ntt 按商品名称排序后的商品信息 n"); printf("nt 商品名称 商品编号 商品类别 商品单价 n"); /* 输出排序后商品信息 */for(i=0;i<n;i+)printf("t %5s %5ld %5s %5ld %5ldn",goods ,goodsi.num,goodsi.sort,goodsi.count,goodsi.price);for(k=0;k&l

12、t;n-1;k+) /*(3): 按商品类别排序 */ for(i=0;i<n-k-1;i+) /* 用起泡法排序 */ if(strcmp(goodsi.sort,goodsi+1.sort)>0)strcpy(p2,goodsi.sort); strcpy(goodsi.sort,goodsi+1.sort); strcpy(goodsi+1.sort,p2);temp=goodsi.num; goodsi.num=goodsi+1.num;goodsi+1.num=temp;strcpy(p1,); strcpy(,goodsi+1

13、.name); strcpy(goodsi+1.name,p1);printf("");商品数量printf"ntt 按商品类别排序后的商品信息 nn" printf"t 商品类别 商品编号 商品名称 商品单价 n" /* 输出排序后商品信息 */fori=0;i<n;i+printf("t %5s %5ld %5s %5ld %5ldn",goodsi.sort,goodsi.num,,goodsi.count,goodsi.price)printf("");pri

14、ntf("please press any key to continue:");getch();void purchase() /* long temp; /* int j; printf("nt5return; /* 返回主界面 */功能 3:进货商品信息 */*/定义临时变量表示刚进货的商品编号请输入刚进货的商品编号 :"scanf("%ld",&temp);printf("nt5 请输入刚进货的商品数量 :");scanf("%d",&j);printf("nn

15、ntpress any key to contiue:"); getch();system("cls");*/商品价printf("nt 输出进货后的商品信息: "); for(i=0;i<n;i+) /* 循环,寻找与进货相同的商品信息 */ if(temp=goodsi.num)goodsi.count=goodsi.count+j; /* 自动更改商品数量 printf("nt 商品编号 商品名 商品类别 商品数量 格");for(i=0;i<n;i+) /* 循环,输出进货后的商品信息 */ printf

16、("nt %4ld %4s %4s %ld %4ld",goodsi .num,,goodsi.sort,goodsi.count,goodsi.price);printf("nnttPress any key to enter menu:"); getch(); /* 返回功能选择界面 */ return; 6void sell() /*功能4:销售商品信息 */long temp; /* 定义临时变量 temp 表示刚销售的商品编号 */ int j;printf("nt5请输入刚销售的商品编号 :");sc

17、anf("%ld",&temp);printf("nt5请输入刚销售的商品数量 :");scanf("%d",&j);for(i=0;i<n;i+) /* 循环,找到刚销售的商品信息 */if(temp=goodsi.num)for(;j>goodsi.count;) /* 如果销售额大于库存量,那么出现错误 提示 */printf("nt 售出数量大于商品原有数量,出现错误,请重新输 入:");scanf("%d",&j);goodsi.count=good

18、si.count-j; /* 完成自动更改商品数量的 功能*/printf("ntpress any key to contiue:"); getch();system("cls"); /*清屏 */printf("nn * 销售后商品信息: "); printf("nt 商品类别 商品编号 商品名称 商品数量 商品单价 n");for(i=0;i<n;i+) /* 循环,输出销售后商品信息 */ printf("t %4s %4ld %4s %4ld %4ldn",goodsi.sort

19、,goodsi.num,,goodsi.count,goodsi.price );printf("ntPress any key to enter menu:");getch();return; /* 返回功能选择界面 */void edit() /*功能 5:添加或删除商品信息 */void add(); /* 声明子函数 */void dele();7printf("nt请选择: 1.添加商品信息; 2. 删除商品信息; ");printf("t* 请输入 1 或 2 继续: ");scanf("%

20、d",&k);switch(k) /* 用 switch 语句实现功能选择 */case 1: add();break;case 2: dele();break;getch();return; /* 返回主菜单 */void add() /* 添加商品信息 */ /* 定义子函数 */ printf("t* 请输入所添加商品的商品编号 :");scanf("%ld",&goodsn.num);printf("nt请输入所添加商品的名称 :");scanf("%s",)

21、;printf("nt请输入所添加商品的类别 :");scanf("%s",goodsn.sort);printf("nt请输入所添加商品的数量 :");scanf("%d",&goodsn.count);printf("nt请输入所添加商品的价格 :");scanf("%d",&goodsn.price);n=n+1;printf("n");void dele() /*删除商品信息 */ /*定义子函数 */int temp; /* 定义

22、局部变量 */int j;for(i=0;i<n;i+)商品printf("nt 商品编号 商品名 商品类别 商品数量 价格");printf("nt %5ld %5s %5s %5ld %5ld",good si.num,,goodsi.sort,goodsi.count,goodsi.price);printf("n");printf("n");printf("n* 请输入要删除的商品编号 :");scanf("%ld",&temp);

23、printf("nn");8for(i=0;i<n;i+)if(temp=goodsi.num)for(j=i;j<n;j+)goodsj.num=goodsj+1.num; strcpy(,goodsj+1.name); strcpy(goodsj.sort,goodsj+1.sort); goodsj.count=goodsj+1.count; goodsj.price=goodsj+1.price;n=n-1; /* 商品总库存量减少 */ for(i=0;i<n;i+)商品价printf("nt 商品编号 商品名 商

24、品类别 商品数量 格 "); /* 输出删除后的商品信息 */ printf("nt %5ld %5s %5s %5ld %5ld",good si.num,,goodsi.sort,goodsi.count,goodsi.price);printf("n");printf("Please press any key to continue:");getch();void correct() /* long temp; /*printf("ntreturn; /* 返回主界面 */功能 6:修

25、改商品信息 */定义局部变量 */ 请输入要修改的商品的编号 :");scanf("%ld",&temp); /* 输入新的商品信息 */printf("n");for(i=0;i<n;i+) /* 保存新的商品信息 */ if(temp=goodsi.num)printf("t请输入一个新的的商品编号 :");scanf("%ld",&goodsi.num);printf("nt 请输入新的商品的名称 :");scanf("%s",goods

26、);printf("nt 请输入新的商品的类别 :");9 scanf("%s",goodsi.sort);printf("nt请输入新的商品的数量 :");scanf("%d",&goodsi.count);printf("nt请输入新的商品价格 :");scanf("%d",&goodsi.price);printf("n"); for(i=0;i<n;i+)printf("nt 新的商品名称 商品编号 商品

27、类别 商品数量 商品单价 n");printf("t %4s %4ld %4s %4ld %4ld",,goodsi.num,goodsi.sort,goodsi.count,goods i.price);printf("n");printf("Please press any key to continue:"); /*返回功能选择界面 */getch();return; /* 返回主菜单 */void search() /*功能 7 :查询商品信息 */int k; /* 定义局部变量 */long

28、 temp1;char temp230,temp320;printf("nt5 按商品编号查询 , 请按 1ttt5 按商品名查询 , 请按 2nt5 按商品类别查询 , 请按 3ttt5 查需要进货的商品 , 请按 4n");printf("nnnttt 请输入数字确定查询方式 :"); scanf("%d",&k);printf("n");printf("Press any key to continue:"); getch();system("cls");swi

29、tch(k) /* 实现查询方式的选择 */case 1: printf("nnnnntt 请输入要查询的商品的编号 :"); /* 按商品编 号查询 */scanf("%ld",&temp1);system("cls"); /*清屏 */for(i=0;i<n;i+) 10 if(temp1=goodsi.num)printf("n");printf("nt 商品编号 商品名 商品类别 商品数量 商品价格 ");printf("nt %5ld %5s %5s %5ld

30、%5ld",goodsi .num,,goodsi.sort,goodsi.count,goodsi.price);break; /* 跳出 switch 语句 */case 2: printf("nnnnntt 请输入要查询的商品名 :"); /* 按商品名查 询数据 */scanf("%s",temp2);system("cls");for(i=0;i<n;i+)if(strcmp(temp2,)=0)printf("n");printf("

31、nt 商品编号 商品名 商品类别 商品数量 商品价格 ");printf("nt %5ld %5s %5s %5ld %5ld",goodsi .num,,goodsi.sort,goodsi.count,goodsi.price);break; /* 跳出 switch 语句 */case 3: printf("nnnnntt 请输入要查询的商品类别 :"); /* 按商品 类别查询数据 */scanf("%s",temp3);system("cls"); for(i=0;i<

32、;n;i+)if(strcmp(temp3,goodsi.sort)=0) printf("n"); printf("nt 商品编号 商品名 商品类别 商品数量商品价格 ");printf("nt %5ld %5s %5s %5ld %5ld",goodsi.num,,goodsi.sort,goodsi.count,goodsi 11 .price); int a=50;for(i=0;i<n;i+) /*if(goodsi.count<a) printf("ntt4break; /* 跳

33、出 switch 语句 */ case 4:查询需要进货的商品名 */需要进货的商品名 :%s 现有库存 量: %ldn",,goodsi.count);跳出 switch 语句 */ break; /* printf("nnttPress any key to enter menu:");getch(); return; /* void scan() /*返回主界面 */功能 8:浏览商品信息 */printf("nt 浏览输入的商品信息 ,请按 1nnt 浏览查询的商品信息 , 请 按 2nnt 浏览排序后商品信息 , 请按 3

34、n");printf(" 请选择: ");scanf("%d",&k);switch(k)case 1: printf("ttt printf("t浏览输入的商品信息 n");商品编号 商品名 商品类别 商品数量 商品价格 n");/* 输出浏览商品信息 */ for(i=0;i<n;i+) printf("t%5ld %5s %5s %5ld %ld",goodsi.num ,,goodsi.sort,goodsi.count,goodsi.pri

35、ce);printf("n"); printf("Press any key to enter menu:"); getch();return; break; /* 跳出 switch 语句 */case 2: printf("ttt浏览查询的商品信息 n");12printf("t 商品编号 商品名 商品类别 商品数量 商品价 格 n");/* 输出浏览商品信息 */for(i=0;i<n;i+)printf("t%5ld %5s %5s %5ld %ld",goodsi .num,go

36、,goodsi.sort,goodsi.count,goodsi.price);printf("n");printf("nPress any key to enter menu:");getch();return; break; /* 跳出 switch 语句 */case 3: printf("ttt浏览按商品编号排序的商品信息 n");printf("t 商品编号 商品名 商品类别 商品数量 商品价 格 n");/* 输出浏览商品信息 */for(i=0;i<n;i+)%ld"

37、,goodsi.numprintf("t%5ld %5s %5s %5ld ,,goodsi.sort,goodsi.count,goodsi.price);printf("n");printf("nPress any key to enter menu:");返回主界面 */ 跳出 switch 语句 */功能 9:保存文件 */getch(); return; /* break; /* void reserve() /*FILE *fp;char file15; /*用来存放文件保存路径以及文件名 */system(&

38、quot;cls"); /*清屏 */printf"nt* 请输入文件路径及文件名 :"*/scanf("%s",file);fp=fopen("file","w+"); /*创立并翻开一个文件,并得到该文件的地址fprintf(fp," 商品编号 t 商品名 t 商品类别 t 商品数量 t 商品价格 n"); printf(" 商品编号 t 商品名 t 商品类别 t 商品数量 t 商品价格 n");for(i=0;i<n;i+)13 fprintf(fp,&

39、quot;%ldtt%stt%stt%dtt%dn",goodsi.num,,goodsi.sort,goodsi.count,goodsi.price);printf("%ldtt%stt%stt%dtt%dn",goodsi.num,,goodsi.sort,goodsi.count,goodsi.price);fclose(fp); /* 关闭文件 */printf(" 文件已经保存 !n");getch();system("cls"); /*清屏 */void quit()

40、 /* 退出系统 */exit(0);四、调试手册(1) 、sp.c(225) : warning C4013: 'add' undefined; assuming extern returning int add() 函数声明错误。(2) 、 sp.c(265) : error C2143: syntax error : missing '' before ')'。(3) 、 sp.c(78) : warning C4013: 'getch' undefined; assuming extern returning int 。五

41、、用户手册1、本程序的运行环境为 windows XP 操作系统,执行文件为 sp.exe ; 2、进入演示程序后,即显示对话形式的提示操作过程:如:第一项:1输入商品信息 在选择一栏输入: 1即显示商品编号、商品名、商品种类、数量、单价的商品信息,依次输入所需添加的数据。添加商品完毕,选择:2排序商品信息。选择:3输入进货信息。选择:4输入销售信息。选择:5增加或删除商品选择:6修改商品信息。选择:7查询商品信息。选择:8浏览商品信息。选择:9保存商品信息。选择:0退出系统。Enter 退出添加。六、测试数据进入演示程序后,即显示对话形式的提示操作过程:商品销售管理系统输入商品信息f排序商品信息j修改商品信息一输入进货信息-输入销售信息増加卅餘商品f查询商品信息一浏觅商品信息f保存商品信息选择:1输入相应提示的商品信息珀M输入商品的编号=1001请输入商品的名称;FTU请输入商品的种类:putongdi*nshiji请输入商品的数量 请输入商品的单价二圏邮选择:2对商品信息进行排序商品编可100110021003商品名称PTUDUDGTU商品类别商品数量putongdianshiji dud££dvd+pti>90商品单价26 2888 19996499按商品名称

温馨提示

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

评论

0/150

提交评论