C语言课程设计商品库存管理系统Word文件下载.docx
《C语言课程设计商品库存管理系统Word文件下载.docx》由会员分享,可在线阅读,更多相关《C语言课程设计商品库存管理系统Word文件下载.docx(41页珍藏版)》请在冰点文库上搜索。
![C语言课程设计商品库存管理系统Word文件下载.docx](https://file1.bingdoc.com/fileroot1/2023-4/29/a97477e8-8356-4371-aa56-de6eed18a3f3/a97477e8-8356-4371-aa56-de6eed18a3f31.gif)
商品信息的盘点
voidshun();
商品出库按升序排序
voiddao();
商品出库按降序排序
voidquit();
退出系统
图1
.1.2流程图
1.主函数:
main函数
函数原型:
voidmain()
功能是输出一个欢迎界面,并调用函数,提供1-7个功能选项。
图2
2.分函数
(1)商品入库:
input
voidinput()
功能是录入商品信息
图3
2)商品出库:
output
voidoutput()
功能是商品出库(减少库存商品数量)
图4
(3)查询商品find
voidfind()
voidfind_2()
voidfind_3()
三种方式查询
图5
1,.按名称查询
Y
图6
2.按代码查询
图7
3.按生产商查询
图8
4.修改商品change()函数原型:
voidchange()
图9
6,出库排序
图10
2.2系统编码
#include"
stdio.h"
string.h"
#include<
stdlib.h>
#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()/*保存商品的信息*/
{
if((fp=fopen("
w"
))==NULL)
cannotopenfile"
return;
for(i=0;
i<
num;
i++)
if(fwrite(&
product[i],sizeof(structa),1,fp)!
=1)
printf("
filewriteerror\n"
/*清屏*/
//printf("
商品已保存!
//getch();
fclose(fp);
{chara[10],g;
intm,i;
输入商品名称:
"
scanf("
%s"
a);
{if(strcmp(product[i].name,a)==0)
{printf("
请输入商品数量:
scanf("
%d"
&
m);
product[i].count=product[i].count+m;
入库后该商品的数量:
product[i].count);
该商品入库量:
product[i].ru=m;
product[i].ru);
getch();
break;
}
}
if(i>
=num)
{
库存中无此商品!
请输入商品名称:
scanf("
product[num].name);
printf("
请输入商品代码:
product[num].numb);
请输入商品生产商:
product[num].boss);
请输入商品生产日期:
product[num].date);
product[num].count);
请输入商品价格:
product[num].price);
printf("
请输入商品入库:
product[num].ru);
请输入商品出库:
product[num].chu);
num++;
save();
是否还想入库商品?
?
按y为继续添加,按n为不添加"
\n%c"
g);
if(g=='
y'
)
{input();
}
intk,i;
charstr[10],l;
/*清屏*/
\n请输入要出库的商品名称:
str);
getchar();
if(strcmp(str,product[i].name)==0)
{
\n请输入出库商品数量:
k);
if(k<
=product[i].count)
{
\n剩余的库存商品数量:
product[i].count-k);
product[i].count=product[i].count-k;
显示该库存商品的出库量:
product[i].chu=product[i].chu+k;
%d\n"
product[i].chu);
elseprintf("
库存数量不足\n"
break;
=num)
没有该商品!
\r\n"
是否还想出库商品?
按y为继续出库,按n为不出库\n"
l=getche();
if(l=='
output();
save();
charstr[10];
输入要找的商品的名称\n"
名称\t代码\t生产商\t生产日期\t数量\t价格\t出库\t入库\n"
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);
}
while(i>
=num)
没有该商品"
按回车键返回!
intx;
输入要找的商品的代码\n"
x);
if(x==product[i].numb)
{
chara[6];
输入要找的商品的生产商\n"
if((strcmp(a,product[i].boss))==0)
voidfind()
intj;
查询商品,用商品名称查询请按1,用代码查询请按2,用商品生产商查询请按3"
j);
switch(j)
{case1:
printf("
按商品名称查询\n"
find_1();
break;
case2:
按代码查询\n"
find_2();
case3:
按生产商查询\n"
find_3();
default:
voidchange()
inti,k;
charstr[10];
输入准备修改的商品名称:
if((strcmp(str,product[i].name))==0)
%s\t%d\t%s\t%d\t%d\t%d\t%d\t%d\n\n"
是否修改名称<
y/n>
:
k=getche();
if(k=='
请输入新的名称:
scanf("
product[i].name);
是否修改代码<
k=getche();
if(k=='
请输入新的代码:
product[i].numb);
是否修改生产商<
请输入新的生产商:
product[i].boss);
是否修改生产日期<
请输入新的生产日期:
product[i].date);
是否修改数量<
if(k=='
请输入新的数量:
product[i].count);
是否修改价格<
{
请输入新的价格:
product[i].price);
是否修改出库量<
请输入新的出库量:
product[i].chu);
是否修改入库量<
请输入新的入库量:
product[i].ru);
}
voiddisplay()
\n\n名称\t编号\t生产商\t生产日期\t数量\t价格\t出库\t入库\n"
%s\t%d\t%s\t%d\t%d\t%d\t%d\t%d\n"
product[i].ru);
\n\n统计并输出商品(出库)的量\n"
名称\t编号\t生产商\t生产日期\t数量\t价格\t出库\t入库\n"
for(i=0;
if(product[i].chu>
0)
\n\n统计并输出商品(入库)的量\n"
if(product[i].ru>
voidshun()
num-1;
for(j=0;
j<
num-1-i;
j++)
if(product[j].chu>
product[j+1].chu)
goods[0]=product[j];
product[j]=product[j+1];
product[j+1]=goods[0];
voiddao()
if(product[j].chu<
goods[0]=product[j];
product[j]=product[j+1];
voidorder()
chart;
对于出库的数量,你想看升序请按1,按2为降序\n"
\t请选择[1/2]:
\n"
t=getch();
switch(t)
{case'
1'
shun();
case'
2'
dao();
voidquit()
\n\n\n\t\t\t→※ 谢谢使用 ※←"
\n\n\n\n\n\n\t◆◆◆^v^◆◆◆"
\n\n\n\t\t★〓★〓★商品库存管理系统★〓★〓★"
\n\n\n\t\t\t\t\t→◆作者:
电气121,陈志华"
\n\n\t\t\t\t\t ◎◎◎◎◎2013年6月\n"
\n\n\n\t按回车键进入主菜单:
/*界面*/
getch();
voidmain()
charj;
read();
\n\n\n\t\t\t→※ 欢迎使用 ※←"
\n\n\n\t\t★〓★〓★商品库存管理系统★