C语言课程设计商品库存管理系统.docx
- 文档编号:1605274
- 上传时间:2023-05-01
- 格式:DOCX
- 页数:41
- 大小:400.30KB
C语言课程设计商品库存管理系统.docx
《C语言课程设计商品库存管理系统.docx》由会员分享,可在线阅读,更多相关《C语言课程设计商品库存管理系统.docx(41页珍藏版)》请在冰点文库上搜索。
C语言课程设计商品库存管理系统
第1章系统分析与设计
1.1系统分析
1解决问题
运用现代信息化和智能化的管理方式,解决商品库存信息在日常生活中易于丢失、遗忘,不易保存、管理的问题,从而使企业和商家能够更全面,更直观地了解到商品库存信息。
1软件功能
将商品库存信息进行入库、出库、查询、修改、盘点、排序等操作,更直观反映商品库存信息。
1.2系统设计
1系统设计思路
以简便快捷和人性化为最终目标,力求最简单有效地管理商品库存信息。
1系统功能划分
通过对数据的不同处理方式,将系统分成了商品入库、商品出库、查询商品、修改商品、日盘点、出库排序六大类,在查询商品中又包含了关键字(选项)查询,在出库排序中又包含升降排序等功能。
1功能结构图
图0
第2章详细设计与编码
2.1详细设计
2主要函数算法设计
Voidsave();
创建text.txt,并对其添加内容
voidread();
读取text.txt内容,将其赋给数组
voidinput();
添加商品入库记录
voidoutput();
添加商品出库记录
voidfind_1()
通过名称查询商品信息
voidfind_2();
通过代码查询商品信息
voidfind_3();
通过生产商查询商品信息
voidfind();
查询商品信息
voidchange();
修改商品信息
voiddisplay();
商品信息的盘点
voidshun();
商品出库按升序排序
voiddao();
商品出库按降序排序
voidquit();
退出系统
图1
1.主函数:
main函数
函数原型:
voidmain()
功能是输出一个欢迎界面,并调用函数,提供1-7个功能选项。
图2
(1)商品入库:
input
函数原型:
voidinput()
功能是录入商品信息
图3
2)商品出库:
output
函数原型:
voidoutput()
功能是商品出库(减少库存商品数量)
图4
(3)查询商品find
函数原型:
voidfind()
voidfind_1()
voidfind_2()
voidfind_3()
三种方式查询
图5
1,.按名称查询
Y
图6
2.按代码查询
图7
图8
4.修改商品change()函数原型:
voidchange()
图9
6,出库排序
图10
2.2系统编码
#include"stdio.h"
#include"string.h"
#include
#defineN80/*最大容量限定*/
structa/*商品库内结构体*/
{
charname[10];
intnumb;
charboss[6];
intdate;
intcount;
intprice;
intchu;
intru;
}goods[1];
structaproduct[N]={{"ac",1,"AC",1,15,5,0,0},{"bd",2,"BD",2,10,20,0,0}};
intnum=2;
voidread()
{
FILE*fp;
inti;
system("cls");
fp=fopen("text.txt","r+");
if(fp==NULL)
{
printf("不能打开文件!
\n");
exit(0);
}
i=0;
while(!
feof(fp))
{if(fread(&product[i],sizeof(structa),1,fp)==1)
i++;
}num=i;
fclose(fp);
}
voidsave()/*保存商品的信息*/
{
FILE*fp;
inti;
if((fp=fopen("text.txt","w"))==NULL)
{
printf("cannotopenfile");
return;
}
for(i=0;i { if(fwrite(&product[i],sizeof(structa),1,fp)! =1) printf("filewriteerror\n"); } system("cls");/*清屏*/ //printf("商品已保存! \n"); //getch(); fclose(fp); } voidinput() {chara[10],g; intm,i; printf("输入商品名称: "); scanf("%s",a); for(i=0;i {if(strcmp(product[i].name,a)==0) {printf("请输入商品数量: "); scanf("%d",&m); product[i].count=product[i].count+m; printf("入库后该商品的数量: "); printf("%d",product[i].count); printf("该商品入库量: "); product[i].ru=m; printf("%d",product[i].ru); getch(); break; } } if(i>=num) { printf("库存中无此商品! \n"); printf("请输入商品名称: "); scanf("%s",product[num].name); printf("请输入商品代码: "); scanf("%d",&product[num].numb); printf("请输入商品生产商: "); scanf("%s",product[num].boss); printf("请输入商品生产日期: "); scanf("%d",&product[num].date); printf("请输入商品数量: "); scanf("%d",&product[num].count); printf("请输入商品价格: "); scanf("%d",&product[num].price); printf("请输入商品入库: "); scanf("%d",&product[num].ru); printf("请输入商品出库: "); scanf("%d",&product[num].chu); num++; save(); } printf("是否还想入库商品? ? \n"); printf("按y为继续添加,按n为不添加"); scanf("\n%c",&g); if(g=='y') {input(); getch(); } } voidoutput() { intk,i; charstr[10],l; system("cls");/*清屏*/ printf("\n请输入要出库的商品名称: "); scanf("%s",str); getchar(); for(i=0;i { if(strcmp(str,product[i].name)==0) { printf("\n请输入出库商品数量: "); scanf("%d",&k); if(k<=product[i].count) { printf("\n剩余的库存商品数量: %d",product[i].count-k); product[i].count=product[i].count-k; printf("显示该库存商品的出库量: "); product[i].chu=product[i].chu+k; printf("%d\n",product[i].chu); } elseprintf("库存数量不足\n"); break; } } if(i>=num) { printf("没有该商品! \r\n"); } printf("是否还想出库商品? ? \n"); printf("按y为继续出库,按n为不出库\n"); l=getche(); if(l=='y') { output(); getch();} save(); } voidfind_1() { charstr[10]; inti; system("cls");/*清屏*/ printf("输入要找的商品的名称\n"); scanf("%s",str); printf("名称\t代码\t生产商\t生产日期\t数量\t价格\t出库\t入库\n"); for(i=0;i if((strcmp(str,product[i].name))==0) {printf("%s\t%d\t%s\t%d%d\t%d\t%d\t%d\n",product[i].name,product[i].numb, product[i].boss,product[i].date,product[i].count,product[i].price,product[i].chu, product[i].ru); break; getch(); } while(i>=num) printf("没有该商品"); printf("按回车键返回! "); getch(); } voidfind_2() { inti; intx; system("cls");/*清屏*/ printf("输入要找的商品的代码\n"); scanf("%d",&x); printf("名称\t代码\t生产商\t生产日期\t数量\t价格\t出库\t入库\n"); for(i=0;i if(x==product[i].numb) {printf("%s\t%d\t%s\t%d%d\t%d\t%d\t%d\n",product[i].name,product[i].numb, product[i].boss,product[i].date,product[i].count,product[i].price,product[i].chu, product[i].ru); break; getch(); } while(i>=num) printf("没有该商品"); printf("按回车键返回! "); getch(); } voidfind_3() { chara[6]; inti; system("cls");/*清屏*/ printf("输入要找的商品的生产商\n"); scanf("%s",a); printf("名称\t代码\t生产商\t生产日期\t数量\t价格\t出库\t入库\n"); for(i=0;i if((strcmp(a,product[i].boss))==0) {printf("%s\t%d\t%s\t%d%d\t%d\t%d\t%d\n",product[i].name,product[i].numb, product[i].boss,product[i].date,product[i].count,product[i].price,product[i].chu, product[i].ru); break; getch(); } while(i>=num) printf("没有该商品"); printf("按回车键返回! "); getch(); } voidfind() { intj; getch(); printf("查询商品,用商品名称查询请按1,用代码查询请按2,用商品生产商查询请按3"); scanf("%d",&j); switch(j) {case1: printf("按商品名称查询\n");find_1();break; case2: printf("按代码查询\n");find_2();break; case3: printf("按生产商查询\n");find_3();break; default: break; } } voidchange() { inti,k; charstr[10]; system("cls");/*清屏*/ printf("输入准备修改的商品名称: "); scanf("%s",str); for(i=0;i if((strcmp(str,product[i].name))==0) { printf("名称\t代码\t生产商\t生产日期\t数量\t价格\t出库\t入库\n"); printf("%s\t%d\t%s\t%d\t%d\t%d\t%d\t%d\n\n",product[i].name,product[i].numb, product[i].boss,product[i].date,product[i].count,product[i].price,product[i].chu, product[i].ru); printf("是否修改名称 \n"); k=getche(); if(k=='y') { printf("请输入新的名称: \n"); scanf("%s",product[i].name);} printf("是否修改代码 \n"); k=getche(); if(k=='y') { printf("请输入新的代码: \n"); scanf("%d",&product[i].numb);} printf("是否修改生产商 \n"); k=getche(); if(k=='y') { printf("请输入新的生产商: \n"); scanf("%s",product[i].boss);} printf("是否修改生产日期 \n"); k=getche(); if(k=='y') { printf("请输入新的生产日期: \n"); scanf("%d",&product[i].date); printf("是否修改数量 \n"); k=getche(); if(k=='y') { printf("请输入新的数量: \n"); scanf("%d",&product[i].count);} printf("是否修改价格 \n"); k=getche(); if(k=='y') { printf("请输入新的价格: \n"); scanf("%d",&product[i].price);} printf("是否修改出库量 \n"); k=getche(); if(k=='y') { printf("请输入新的出库量: \n"); scanf("%d",&product[i].chu);} printf("是否修改入库量 \n"); k=getche(); if(k=='y') { printf("请输入新的入库量: \n"); scanf("%d",&product[i].ru); } } } } voiddisplay() { inti; system("cls");/*清屏*/ printf("\n\n名称\t编号\t生产商\t生产日期\t数量\t价格\t出库\t入库\n"); for(i=0;i printf("%s\t%d\t%s\t%d\t%d\t%d\t%d\t%d\n",product[i].name,product[i].numb, product[i].boss,product[i].date,product[i].count,product[i].price,product[i].chu, product[i].ru); for(i=0;i {printf("\n\n统计并输出商品(出库)的量\n"); printf("名称\t编号\t生产商\t生产日期\t数量\t价格\t出库\t入库\n"); for(i=0;i if(product[i].chu>0) { printf("%s\t%d\t%s\t%d\t%d\t%d\t%d\t%d\n",product[i].name,product[i].numb, product[i].boss,product[i].date,product[i].count,product[i].price,product[i].chu, product[i].ru); } printf("\n\n统计并输出商品(入库)的量\n"); printf("名称\t编号\t生产商\t生产日期\t数量\t价格\t出库\t入库\n"); for(i=0;i if(product[i].ru>0) { printf("%s\t%d\t%s\t%d\t%d\t%d\t%d\t%d\n",product[i].name,product[i].numb, product[i].boss,product[i].date,product[i].count,product[i].price,product[i].chu, product[i].ru); } } printf("按回车键返回! "); getch(); } voidshun() { inti; intj; printf("名称\t编号\t生产商\t生产日期\t数量\t价格\t出库\t入库\n"); for(i=0;i for(j=0;j if(product[j].chu>product[j+1].chu) { goods[0]=product[j]; product[j]=product[j+1]; product[j+1]=goods[0]; } for(i=0;i printf("%s\t%d\t%s\t%d\t%d\t%d\t%d\t%d\n",product[i].name,product[i].numb, product[i].boss,product[i].date,product[i].count,product[i].price,product[i].chu, product[i].ru); printf("按回车键返回! "); getch(); } voiddao() { inti; intj; printf("名称\t编号\t生产商\t生产日期\t数量\t价格\t出库\t入库\n"); for(i=0;i for(j=0;j if(product[j].chu { goods[0]=product[j]; product[j]=product[j+1]; product[j+1]=goods[0]; } for(i=0;i printf("%s\t%d\t%s\t%d\t%d\t%d\t%d\t%d\n",product[i].name,product[i].numb, product[i].boss,product[i].date,product[i].count,product[i].price,product[i].chu, product[i].ru); printf("按回车键返回! "); getch(); } voidorder() { chart; system("cls");/*清屏*/ printf("对于出库的数量,你想看升序请按1,按2为降序\n"); printf("\t请选择[1/2]: \n"); t=getch(); switch(t) {case'1': shun();break; case'2': dao();break; default: break; } } voidquit() { system("cls");/*清屏*/ printf("\n\n\n\t\t\t→※ 谢谢使用 ※←"); printf("\n\n\n\n\n\n\t◆◆◆^v^◆◆◆"); printf("\n\n\n\t\t★〓★〓★商品库存管理系统★〓★〓★"); printf("\n\n\n\t\t\t\t\t→◆作者: 电气121,陈志华"); printf("\n\n\t\t\t\t\t ◎◎◎◎◎2013年6月\n"); printf("\n\n\n\t按回车键进入主菜单: ");/*界面*/ getch(); } voidmain() { charj; save(); read(); printf("\n\n\n\n\n\n\t◆◆◆^v^◆◆◆"); printf("\n\n\n\t\t\t→※ 欢迎使用 ※←"); printf("\n\n\n\t\t★〓★〓★商品库存管理系统★〓★〓★"); printf("\n\n\n\t\t\t\t\t→◆作者: 电气121
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 语言 课程设计 商品 库存 管理 系统