仓库物资管理系统C语言.docx

上传人:b****3 文档编号:6762348 上传时间:2023-05-10 格式:DOCX 页数:30 大小:21.25KB
下载 相关 举报
仓库物资管理系统C语言.docx_第1页
第1页 / 共30页
仓库物资管理系统C语言.docx_第2页
第2页 / 共30页
仓库物资管理系统C语言.docx_第3页
第3页 / 共30页
仓库物资管理系统C语言.docx_第4页
第4页 / 共30页
仓库物资管理系统C语言.docx_第5页
第5页 / 共30页
仓库物资管理系统C语言.docx_第6页
第6页 / 共30页
仓库物资管理系统C语言.docx_第7页
第7页 / 共30页
仓库物资管理系统C语言.docx_第8页
第8页 / 共30页
仓库物资管理系统C语言.docx_第9页
第9页 / 共30页
仓库物资管理系统C语言.docx_第10页
第10页 / 共30页
仓库物资管理系统C语言.docx_第11页
第11页 / 共30页
仓库物资管理系统C语言.docx_第12页
第12页 / 共30页
仓库物资管理系统C语言.docx_第13页
第13页 / 共30页
仓库物资管理系统C语言.docx_第14页
第14页 / 共30页
仓库物资管理系统C语言.docx_第15页
第15页 / 共30页
仓库物资管理系统C语言.docx_第16页
第16页 / 共30页
仓库物资管理系统C语言.docx_第17页
第17页 / 共30页
仓库物资管理系统C语言.docx_第18页
第18页 / 共30页
仓库物资管理系统C语言.docx_第19页
第19页 / 共30页
仓库物资管理系统C语言.docx_第20页
第20页 / 共30页
亲,该文档总共30页,到这儿已超出免费预览范围,如果喜欢就下载吧!
下载资源
资源描述

仓库物资管理系统C语言.docx

《仓库物资管理系统C语言.docx》由会员分享,可在线阅读,更多相关《仓库物资管理系统C语言.docx(30页珍藏版)》请在冰点文库上搜索。

仓库物资管理系统C语言.docx

仓库物资管理系统C语言

 

仓库物资管理系统课程设计

 

课程名称:

程序设计基础

姓名:

学号:

班级:

联系方式:

 

1、课程设计目的和要求

目的:

进一步加深、巩固学生所学专业课程《C程序设计》的基

 

本理论知识,理论联系实际,培养学生综合分析问题和解决问题

 

的能力。

掌握运用C语言独立地编写、调试应用程序和进行其它

 

相关设计的技能。

 

要求:

编写仓库管理系统,实现库存记录、出库记录、入库记

 

录等三方面的功能。

2、课程设计名称及内容

2.1课程设计名称

 

仓库物资管理系统

 

2.2设计内容

 

设计一个仓库物资管理系统,该系统要求对仓库物资信息进行管

 

理和维护,实现仓库物资信息化。

 

2.3任务和要求

 

1.创建库存记录文件,根据提示输入若干电器的信息,并将信息保存至一个文件中。

 

2.物资入库管理,创建一个入库记录文件,每次有物资入库,则按入库记录要求输入各项信息,并将该次的入库信息添加到文件中,同时修改相应的库存记录文件。

 

3.物资出库管理,创建一个出库记录文件,每次有物资出库,则按出库记录要求输入各项信息,并将该次的出库信息添加到文件中,同时修改相应的库存记录文件。

注意:

物资出库时要检查出库数

 

量的合法性(即出库数量必须小于库存数量)。

 

4.按不同条件进行查询操作,输出满足条件的物资信息。

 

(1)输入电器名称,在库存记录文件中查找相应的物资信息并输

 

出。

 

(2)输入品牌名称,在库存记录文件中查找该品牌的所有电器信息并输出。

 

(3)输入一个日期(年.月.日),输出该天的入库记录和出库记

 

录。

 

(4)输入电器名称和型号,输出该电器的所有入库记录和出库记

 

录。

 

5.按不同条件对物资信息进行统计工作。

 

(1)输入电器名称,在库存记录文件中统计该电器的现有库存总

 

量。

 

(2)输入电器名称,在入库记录文件中统计该电器的入库次数。

 

(3)输入一个日期(年.月),在出库记录文件中统计该月的出库

 

记录次数。

 

(4)设置一个库存数量警戒值,输出库存数量小于该警戒值的所有库存电器的信息。

3.设计思想

作为仓库物资管理系统,首先要有对物资信息的录入,库存记录

 

应包括以下信息:

电器名称、品牌名称(或生产厂家)、型号、库存数

 

量、价值。

 

主要以录入、查找、增加、修改、删除、显示等功能,贯穿整个

 

程序。

输入要查找的物资名称,系统会自动显示对应的物资信息。

 

最后就是退出程序

4.程序详细设计

程序共有20个函数,分别为

voidCreatStock()

voidCreatInstock()

voidCreatoutstock()

voidSearchElename();

voidSearchBrand();

voidSearchDate();

voidSearchElenameAndBrand();

voidPrintStock(structstock*p);

voidPrintInstock(structinstock*p);

voidPrintOutstock(structoutstock*p)

voidSearchMenu()

voidCountMenu()

voidCount4()

voidmain()

intread_stock()

intread_instock()

intread_outstock()

intCount1()

intCount2()

intCount3()

其中程序末尾定义了main函数,主函数voidmain(),主要通过

 

调用各个成员函数,最终实现物资信息的创建、查找、统计等各项功

 

能。

5.课程设计心得与体会

在这次C语言课程设计中,我收获颇丰也发现了自己许多不足的

 

地方,结合自己所学并通过查阅资料,在程序设计过程中加深了我对

 

面向对象的程序设计方法的认识,在巩固了基本的程序设计方法的基

 

础上进一步学习了C中类的定义、成员方法的使用以及函数的调用

 

等。

同时,在程序的设计过程中暴露出了许多问题,首先,程序设计

 

之初思路混乱,面对程序要求的各项功能如:

教师信息的创建、删除、修改、查找等无从下手,最终通过一个个的子函数分别完成不同的功能并通过主函数调用最终实现程序功能的完整性;第二,平时对于面向对象的程序设计方法仅仅局限于概念上的理解,真正实现起来被每个对象繁杂的属性搞的晕头转向;第三,自己对C语言的学习仅仅局限于课本知识,很少实践,以至于在编程过程中错误不断甚至出现低级的语法错误。

这次课程设计使我的编程能力得到了很大的提高,加深了我对面向对象这一概念的理解,对以后其他面向对象程序语言的学习打好良好基础,同样也在编程方面积累了经验

 

6.参考资料

《C程序设计》

7.程序源代码

#include"stdio.h"

#include

#include

#include

#defineSTOCKNUM3//原来库存中家电的种类

#defineINSTOCKNUM3//每次输入的家电种类

#defineOUTSTOCKNUM3//出库家电的种类

structdate//时间结构

{

intyear;

intmonth;

intday;

};

structstock//库存结构

{

charelename[20];

charbrand[20];

chartype[20];

 

intstocknum;

intvalue;

}stoc[STOCKNUM+INSTOCKNUM];

structinstock//入库结构

{

charelename[20];

charbrand[20];

chartype[20];

intinstocknum;

intprice;

structdateintime;

charsendername[20];

}in[INSTOCKNUM];

structoutstock//出库结构

{

charelename[20];

charbrand[20];

chartype[20];

intoutstocknum;

structdateouttime;

chardelivername[20];

}out[OUTSTOCKNUM];

//-------------------------------------------------------------------------

voidCreatStock()//创建库存记录文件

{

inti;

FILE*fp;

if((fp=fopen("stock.txt","w"))==NULL)

{

printf("Can'topenfile!

\n");

exit(0);

}

for(i=0;i

{

printf("请输入电器的信息!

\n");

printf("\n电器名称品牌名称型号库存数量价值\n");

 

scanf("%s%s%s%d%d",stoc[i].elename,stoc[i].brand,stoc[i].type,&stoc[i].stocknu

m,&stoc[i].value);

fwrite(&stoc[i],sizeof(structstock),1,fp);

}

fclose(fp);

}

//-----------------------------------------------------------------------------

 

intread_stock()//读取库存文件到stoc[]

{

inti=0;

FILE*fp;

if((fp=fopen("stock.txt","r"))==NULL)

{

printf("Can'topen!

\n");

return0;

}

if(fgetc(fp)<0)//读入的是文件结束符

return0;

rewind(fp);//使位置指针重新移到文件开头

while(!

feof(fp))

{

fread(&stoc[i],sizeof(structstock),1,fp);

i++;

}

fclose(fp);

return--i;//返回库存家电的种类

}

//----------------------------------------------------

intread_instock()//读取入库文件到in[]

{

inti=0;

FILE*fp;

if((fp=fopen("instock.txt","r"))==NULL)

{

printf("Can'topen!

\n");

return0;

}

if(fgetc(fp)<0)return0;

rewind(fp);

while(!

feof(fp))

{

fread(&in[i],sizeof(structinstock),1,fp);

i++;

}

fclose(fp);

return--i;//返回入库家电的种类

}

//-----------------------------------------------------

intread_outstock()//读取出库文件到out[]

{

inti=0;

 

FILE*fp;

if((fp=fopen("outstock.txt","r"))==NULL)

{

printf("Can'topen!

\n");

return0;

}

if(fgetc(fp)<0)return0;

rewind(fp);

while(!

feof(fp))

{

fread(&out[i],sizeof(structoutstock),1,fp);

i++;

}

fclose(fp);

return--i;//返回出库家电的种类

}

//-----------------------------------------------------------------------------

voidCreatInstock()//创建入库记录并改变库存记录

{

inti,j,k;

intan=STOCKNUM;

intboolean=0;

FILE*fp;

if((fp=fopen("instock.txt","w"))==NULL)

{

printf("Can'topenfile!

\n");

exit(0);

}

for(i=0;i

{

 

printf("电器名称品牌名称型号入库数量单价入库时间(年月日)送货人

姓名\n");

 

scanf("%s%s%s%d%d%d%d%d%s",in[i].elename,in[i].brand,in[i].type,&in[i].ins

tocknum,&in[i].price,&in[i].intime.year,&in[i].intime.month,&in[i].intime.day,in[i].sendername);

printf("有物资入库!

\n");

fwrite(&in[i],sizeof(structinstock),1,fp);

}

fclose(fp);

read_instock();//读取instock.txt入in[];

read_stock();//读取stock.txt入stoc[];

for(k=0;k

{

 

boolean=0;

for(j=0;j

{

if(strcmp(stoc[j].elename,in[k].elename)==0&&

strcmp(stoc[j].brand,in[k].brand)==0&&strcmp(stoc[j].type,in[k].type)==0)

{

stoc[j].stocknum=stoc[j].stocknum+in[k].instocknum;

boolean=1;

}

 

}

if(boolean==0)//原来库存中没有此类家电

{

strcpy(stoc[an].elename,in[k].elename);

strcpy(stoc[an].brand,in[k].brand);

strcpy(stoc[an].type,in[k].type);

stoc[an].stocknum=in[k].instocknum;

stoc[an].value=in[k].price;

an++;

}

}

if((fp=fopen("stock.txt","w"))==NULL)

{

printf("Can'topenfile!

\n");

exit(0);

}

fwrite(stoc,sizeof(structstock),an,fp);

fclose(fp);

}

//------------------------------------------------------------------------

 

voidCreatoutstock()//创建出库记录并改变库存记录

{

inti=0,j=0,k=0,n=0;

intsum_stock=0;

FILE*fp;

sum_stock=read_stock();//读取stock.txt入stoc[]

printf("共有家电物资%d种\n",sum_stock);

for(n=0;n

{

 

printf("电器名称品牌名称型号出库数量出库时间(年月日)提货人姓名

\n");

 

scanf("%s%s%s%d%d%d%d%s",out[n].elename,out[n].brand,out[n].type,&out[n].outstocknum,&out[n].outtime.year,&out[n].outtime.month,&out[n].outtime.day,out[n].delivername);

printf("有物资出库!

\n");

}

 

if((fp=fopen("outstock.txt","w"))==NULL)

{

printf("Can'topenfile!

\n");

exit(0);

}

for(j=0;j

{

for(i=0;i<3;i++)

 

if((strcmp(stoc[i].elename,out[j].elename)==0)&&(strcmp(stoc[i].brand,out[j].brand)==0)&&(strcmp(stoc[i].type,out[j].type)==0))

{

k=1;

if(out[j].outstocknum<=stoc[i].stocknum)

{

fwrite(&out[j],sizeof(structoutstock),1,fp);

stoc[i].stocknum=stoc[i].stocknum-out[j].outstocknum;

printf("资源%s出库成功!

\n",out[j].elename);

}

else

if(out[j].outstocknum>stoc[i].stocknum)

 

//else

{printf("\n

 

超出库存量!

 

\n

 

按任意键继续

 

!

\n");

 

getch();}

}

if(k==0)

{

printf("\n

库存中不存在该信息!

\n

按任意键继续

!

\n");

getch();}

 

}

fclose(fp);

if((fp=fopen("stock.txt","w"))==NULL)

{

printf("Can'topen!

\n");

exit(0);

}

fwrite(stoc,sizeof(structstock),sum_stock,fp);

fclose(fp);

}

 

//--------------------------------------------

voidSearchElename();

voidSearchBrand();

voidSearchDate();

voidSearchElenameAndBrand();

voidPrintStock(structstock*p);

voidPrintInstock(structinstock*p);

voidPrintOutstock(structoutstock*p);

//--------------------------------------------------------------------

voidSearchMenu()//查询菜单

{

intselect;

while

(1)

{

printf("\n欢迎使用查询功能!

\n");

printf("*****************************************************\n");

printf("

输入

1

按电器名称查询

\n");

printf("

输入

2

按品牌名称查询

\n");

printf("

输入

3

按日期查询

\n");

printf("

输入

4

按电器名称和型号查询

\n");

printf("

输入

0

退出查询功能\n");

printf("\n请选择查询方式:

");

scanf("%d",&select);

getchar();

switch(select)

{

case1:

SearchElename();break;

case2:

SearchBrand();break;

case3:

SearchDate();break;

case4:

SearchElenameAndBrand();break;

case0:

return;

default:

printf("\n错误!

请重新选择!

\n");

}

}

}

//-----------------------------------------------------

voidSearchElename()//按照电器名称查询

{

inti;

intsum_stock=0;

intboolean=0;

charcelename[20],c='y';

sum_stock=read_stock();//库存中家电的种类

while(c=='y'||c=='Y')

 

{

boolean=0;

printf("\n请输入电器名称:

");

scanf("%s",celename);

getchar();

for(i=0;i

if(strcmp(stoc[i].elename,celename)==0)

{

printf("\n库存电器%d的信息\n",i);

PrintStock(&stoc[i]);

boolean=1;

printf("\n按任意键继续!

\n");

getch();

 

}

if(boolean==0)

printf("没有电器:

%s\n",celename);

printf("\n继续查询其他库存信息吗?

)(y/n):

");

c=getchar();

getchar();

}

}

//--------------------------------------------------------

voidSearchBrand()//按照品牌名称查询

{

inti;

intsum_stock=0;

intboolean=0;

charcbrand[20],c='y';

sum_stock=read_stock();//库存中家电的种类

while(c=='y'||c=='Y')

{

boolean=0;

printf("\n请输入品牌名称:

");

scanf("%s",cbrand);

for(i=0;i

if(strcmp(stoc[i].brand,cbrand)==0)

{

printf("\n库存电器%d的信息\n",i);

PrintStock(&stoc[i]);

boolean=1;

printf("\n按任意键继续!

\n");

getch();

}

 

if(boolean==0)

printf("没有电器:

%s\n",cbrand);

printf("\n继续查询其他库存信息吗?

)(y/n):

");

c=getchar();

getchar();

}

}

//---------------------------------------------------------

voidSearchDate()//按照日期查询

{

inti,j;

intsum_instock=0,sum_outstock=0;

intbooleanin=0,booleanout=0;

structdatetime;

sum_instock=read_instock();

sum_outstock=read_outstock();

printf("\n请输入日期:

");

scanf("%d%d%d",&time.year,&time.month,&time.day);

for(i=0;i

{

if(in[i].intime.year==time.year

&&in[i].intime.month==time.month

&&

in[i].intime.day==time.day)

{

PrintInstock(&in[i]);

booleanin++;

}

}

for(j=0;j

{

if(out[j].outtime.year=

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 党团工作 > 入党转正申请

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2