资源描述
设计题目:仓库物资管理系统
班 级:网络0901班
姓 名:水土第一
学 号:20091221***
完成日期:2010-9-9
注意事项:免积分下载,还请亲们给个好评。思密达
目 录
1 课程设计目的和要求 2
1.1 课程设计的目的: 2
1.2 课程设计的要求: 2
2 课程设计任务内容: 2
3 详细设计说明 3
3.1 功能模块图: 3
3.2 数据结构设计: 4
3.3 功能模块设计: 5
4 软件使用说明: 6
5 课程设计心得与体会: 6
6 参考文献: 7
7 附录:部分程序清单: 7
1 课程设计目的和要求
1.1 课程设计的目的:
通过一个学年的学习,对《c程序设计》这门课程之中所讲的知识有了一定的了解。但是作为一名合格的大学生,不仅要认真阅读课本知识,还要通过上机实践来增强和巩固自己的知识。特别是作为工科类学生,更要注重实践这一环节。因为只有这样我们才能成为合格的计算机人材。
1.2 课程设计的要求:
在实践过程之中,重要的是独立思考,这样,不仅有利于提高自己对知识的理解,还更有助于提高自己的实践动手能力。与此同时,还应该注意主动与别人交流,这样便有利于就业之后与团队进行合作。
2 课程设计任务内容:
仓库管理系统是各个大型商店进行管理的重要组成部分,其内容较多,为了满足工作需求,要求设计的管理系统能够完成以下五种功能:
1.创建库存记录文件。根据提示输入若干电器的“电器名称、品牌名称(或生产厂家)、型号、库存数量、价值”等信息,并将信息保存至一个文件中。
2.物资入库管理,创建一个入库记录文件,每次有物资入库,则按入库记录要求输入“电器名称、品牌名称、型号、入库数量、单价、入库时间(年.月.日)、送货人姓名”等信息,并将该次的入库信息添加到文件中,同时修改相应的库存记录文件。
3.物资出库管理,创建一个出库记录文件,每次有物资出库,则按出库记录要求输入各项信息,并将该次的出库信息添加到文件中,同时修改相应的库存记录文件。在此过程之中,检查出库数量的合法性(即出库数量必须小于库存数量)。
4. 按不同条件进行查询操作,输出满足条件的物资信息。
(1) 输入电器名称,在库存记录文件中查找相应的物资信息并输出。
(2) 输入品牌名称,在库存记录文件中查找该品牌的所有电器信息并输出。
(3) 输入一个日期(年.月.日),输出该天的入库记录和出库记录。
(4) 输入电器名称和型号,输出该电器的所有入库记录和出库记录。
5. 按不同条件对物资信息进行统计工作。
(1) 输入电器名称,在库存记录文件中统计该电器的现有库存总量。
(2) 输入电器名称,在入库记录文件中统计该电器的入库次数。
(3) 输入一个日期(年.月),在出库记录文件中统计该月的出库记录次数。
(4) 设置一个库存数量警戒值,输出库存数量小于该警戒值的所有库存电器的信息。
3 详细设计说明
3.1 功能模块图:
系统功能模块图
3.2 数据结构设计:
系统共定义了四个结构体类型,包括日期类型、库存类型、入库类型和出库类型,其中在入库类型和出库类型中要使用日期类型,定义如下:
struct goods
{
char name[10]; //电器名称
char brand[10]; //电器品牌
char style[10]; //电器型号
int num; //库存数量
float money; //价值
}stu_1[SIZE]; //库存结构
struct date
{
int year; //年份
int month; //月份
int day; //日期
}; //日期结构
struct entrance
{
char name[10]; //电器名称
char brand[10]; //电器品牌
char style[10]; //电器型号
int num; //入库数量
float money; //单价
struct date time; //入库日期
char stuf[10]; //送货人姓名
}stu_2[SIZE]; //入库结构
struct exit
{
char name[10]; //电器名称
char brand[10]; //电器品牌
char style[10]; //电器型号
int num; //出库数量
struct date time; //出库日期
char stuf[10]; //提货人姓名
}stu_3[SIZE]; //出库结构
系统定义了宏变量,存放电器种类,具体定义如下:
#define SIZE 10
3.3 功能模块设计:
main函数的设计:由于第一次使用,在库存文件,入库文件和出库文件之中,没有任何信息,所以,要求我们先输入应有的信息,才能进行查询和统计。用If语句和for循环结构进行提示输入相应的数字,然后利用switch语句选择定义的各种函数应该进行的操作,为用户提供服务。
建立库存记录文件模块包括scan_1()与save_1()两个函数组成,该模块有main函数调用。Scan_1()函数用于输入各个库存信息,save_1()函数将库存信息保存成文件。
建立入库记录文件模块包括scan_2(),save_2()与change_1(),save_1()四个函数组成,该模块有main函数调用。scan_2()函数用于输入入库信息,save_2()函数用于保存入库信息,change_1()用于更改库存信息,save_1()函数将更改之后的库存信息保存成文件。
建立出库记录文件模块包括scan_3(),save_3()与change_2(),save_1()四个函数组成,该模块有main函数调用。scan_3()函数用于输入出库信息,save_3()用于保存出库信息,change_2()函数用于更改库存信息,save_1()函数用于将更改之后的库存信息保存成文件。
查询功能模块包find_1()函数,find_2(),函数find_3()与函数find_4()函数四个函数,该模块有main函数调用。其中find_1()函数包括open_1()函数,它将库存记录打开,然后,然后读出数据,经过判断输出信息,完成4.1。find_2()函数包括open_1()函数,它将库存记录打开,然后,然后读出数据,经过判断输出信息,完成4.2。find_3()函数包括open_2(),open_3()函数,它们分别将入库记录和出库记录打开,然后,然后读出数据,使数据和输入的年月日比较,然后输出所要查询的信息,完成4.3。find_4()函数包括open_2(),open_3()函数,它们分别将入库记录和出库记录打开,然后,然后读出数据,使数据和输入的名称和型号比较,然后输出所要查询的信息,完成4.4
统计功能模块包find_5()函数,find_6(),函数find_7()与函数find_8()函数四个函数,该模块有main函数调用。其中find_5()函数包括open_1()函数,将库存记录打开,使数据与输入的名称比较,然后选择性相加,输出所统计的对象。find_6()函数包括open_2()函数,将入库记录打开,读出数据,与新输入的数据比较,然后进行选择性相加,输出数据。函数find_7()包括open_3()函数,打开出库记录,读出数据,查找在一定年月的出库记录,并将出库次数相加。find_8()函数包括open_1()函数,将库存记录打开,读出数据,使一定数据与设定的数量警戒值比较,将小于警戒值的电器的信息输出。
4 软件使用说明:
在软件使用之前,一定先输入库存记录(对应数字“1”),入库记录(对应数字“2”)和出库记录(对应数字“3”),因为只有经过这三个步骤,才能进行查询和统计工作。以下为数字相对应的操作:
1. 根据要求建立库存文件
2. 根据要求建立入库文件
3. 根据要求建立出库文件
4. 输入电器名称,在库存记录文件中查找相应的物资信息并输出。
5. 输入品牌名称,在库存记录文件中查找该品牌的所有电器信息并输出。
6. 输入一个日期(年.月.日),输出该天的入库记录和出库记录。
7. 输入电器名称和型号,输出该电器的所有入库记录和出库记录。
8. 输入电器名称,在库存记录文件中统计该电器的现有库存总量。
9. 输入电器名称,在入库记录文件中统计该电器的入库次数。
10. 输入一个日期(年.月),在出库记录文件中统计该月的出库记录次数。
11. 设置一个库存数量警戒值,输出库存数量小于该警戒值的所有库存电器的信息。
5 课程设计心得与体会:
经过一个星期的上机实践学习,使我对c语言有了更进一步的认识和了解,要想学好它要重在实践,要通过不断的上机操作才能更好地学习它,通过实践,我也发现我的好多不足之处,首先是自己在指法上还不行,经常按错字母,通过学习也有所改进;再有对c语言的一些标准库函数不太了解,还有对函数调用的正确使用不够熟悉,还有对c语言中经常出现的错误也不了解,通过实践,使我在这几个方面的认识有所提高。
通过实践的学习,我认到学好计算机要重视实践操作,不仅仅是学习c语言,还是其它的语言,以及其它的计算机方面的知识都要重在实践,所以后在学习过程中,我会更加注视实践操作,使自己便好地学好计算机。
6 参考文献:
《C程序设计》
7 附录:部分程序清单:
#include"stdafx.h"
#include"stdio.h"
#include"string.h"
#define SIZE 2//SIZE为仓库电器种类
struct goods//库存结构
{
char name[10];//电器名称
char brand[10];//电器品牌
char style[10];//电器型号
int num; //库存数量
float money; //价值
}stu_1[SIZE];
struct date//日期结构
{
int year;//年份
int month;//月份
int day;//日期
};
struct entrance //入库结构
{
char name[10]; //电器名称
char brand[10]; //电器品牌
char style[10]; //电器型号
int num; //入库数量
float money; //单价
struct date time; //入库日期
char stuf[10]; //送货人姓名
}stu_2[SIZE];
struct exit //出库结构
{
char name[10]; //电器名称
char brand[10]; //电器品牌
char style[10]; //电器型号
int num; //出库数量
struct date time; //出库日期
char stuf[10]; //提货人姓名
}stu_3[SIZE];
void save_1();//将库存信息保存成文件
void save_2();//将入库信息保存成文件
void save_3();//将出库信息保存成文件
void change_1();//入库时电器数量增加,并将信息加入库存文件
void change_2();//出库时电器数量减少,并将信息加入库存文件
void scan_1();//输入库存信息
void scan_2();//输入入库信息
void scan_3();//输入出库信息,判断电器出库数量与现有库存的大小关系
FILE* open_1();//打开库存文件
FILE* open_2();//打开入库文件
FILE* open_3();//打开出库文件
void find_1();//4.1
void find_2();//4.2
void find_3();//4.3
void find_4();//4.4
void find_5();//5.1
void find_6();//5.2
void find_7();//5.3
void find_8();//5.4
void load_1();//读stu_list_1中的数据
void main()
{
int i,j;
printf("what do you want to do?\nplease input the number according to the explaination.\n");
for(i=1;i<12;i++)
printf("if you input %d;then it will work out the %d.\n",i,i);
printf("If you are first use it,please input 1,2 or 3.\nNow please input the number:\n");
scanf("%d",&j);
switch(j)
{
case 1:scan_1();save_1();break; //1
case 2:scan_2();save_2();change_1();break; //2
case 3:scan_3();save_3();change_2();break; //3
case 4:find_1();break;//4.1
case 5:find_2();break;//4.2
case 6:find_3();break;//4.3
case 7:find_4();break;//4.4
case 8:find_5();break;//5.1
case 9:find_6();break;//5.2
case 10:find_7();break;//5.3
case 11:find_8();break;//5.4
default:printf("error\n");
}
}
void scan_1()//输入库存
{
int i;
printf("please input the information:\n");
for(i=0;i<SIZE;i++)
{
scanf("%s%s%s%d%f",stu_1[i].name,stu_1[i].brand,stu_1[i].style,&stu_1[i].num,&stu_1[i].money);
}
}
void scan_2()//输入入库信息
{
int i;
printf("请输入物资入库信息:\n");
for(i=0;i<SIZE;i++)
scanf("%s%s%s%d%f%d%d%d%s",stu_2[i].name,stu_2[i].brand,stu_2[i].style,&stu_2[i].num,&stu_2[i].money,&stu_2[i].time.year,&stu_2[i].time.month,&stu_2[i].time.day,stu_2[i].stuf);
}
void scan_3()//输入出库信息
{
int i;
printf("请输入出库信息:\n");
for(i=0;i<SIZE;i++)
{
scanf("%s%s%s%d%d%d%d%s",stu_3[i].name,stu_3[i].brand,stu_3[i].style,&stu_3[i].num,&stu_3[i].time.year,&stu_3[i].time.month,&stu_3[i].time.day,stu_3[i].stuf);
}
for(i=0;i<SIZE;i++)
{
if(strcmp(stu_1[i].name,stu_3[i].name)==0&&strcmp(stu_1[i].brand,stu_3[i].brand)==0&&strcmp(stu_1[i].style,stu_3[i].style)==0)
if(stu_3[i].num>stu_1[i].num)
{
printf("the error number.please input again\n");
scanf("%s%s%s%d%d%d%d%s",stu_3[i].name,stu_3[i].brand,stu_3[i].style,&stu_3[i].num,&stu_3[i].time.year,&stu_3[i].time.month,&stu_3[i].time.day,stu_3[i].stuf);
}
}
}
void save_1()//将库存信息保存成文件
{
FILE *fp;
int i;
if((fp=fopen("stu_list_1.txt","wb"))==NULL)
{
printf("connot open the file\n");
return;
}
for(i=0;i<SIZE;i++)
{
if(fwrite(&stu_1[i],sizeof(struct goods),1,fp)!=1)
printf("file write error\n");
}
fclose(fp);
}
void save_2()//将入库信息保存成文件
{
FILE *fp;
int i;
if((fp=fopen("stu_list_2.txt","wb"))==NULL)
{
printf("connot open the file\n");
return;
}
for(i=0;i<SIZE;i++)
{
if(fwrite(&stu_2[i],sizeof(struct entrance),1,fp)!=1)
printf("file write error\n");
}
fclose(fp);
}
void change_1()//入库时电器数量增加,并将信息加入库存文件
{
int i;
load_1();
for(i=0;i<SIZE;i++)
{
if(strcmp(stu_1[i].name,stu_2[i].name)==0&&strcmp(stu_1[i].brand,stu_2[i].brand)==0&&strcmp(stu_1[i].style,stu_2[i].style)==0)
{
stu_1[i].num=stu_1[i].num+stu_2[i].num;
}
}
save_1();
}
void save_3()//将出库信息保存成文件
{
FILE *fp;
int i;
if((fp=fopen("stu_list_3.txt","wb"))==NULL)
{
printf("connot open the file\n");
return;
}
for(i=0;i<SIZE;i++)
{
if(fwrite(&stu_3[i],sizeof(struct exit),1,fp)!=1)
printf("file write error\n");
}
fclose(fp);
}
void change_2()//出库时电器数量减少,并将信息加入库存文件
{
int i;
load_1();
for(i=0;i<SIZE;i++)
{
if(strcmp(stu_1[i].name,stu_3[i].name)==0&&strcmp(stu_1[i].brand,stu_3[i].brand)==0&&strcmp(stu_1[i].style,stu_3[i].style)==0)
{
stu_1[i].num=stu_1[i].num-stu_3[i].num;
}
}
save_1();
}
FILE* open_1()//打开库存记录
{
FILE *fp;
if((fp=fopen("stu_list_1.txt","rb"))==NULL)
{
printf("connot open the file!\n");
return NULL;
}
return fp;
}
FILE* open_2()//打开入库记录
{
FILE *fp;
if((fp=fopen("stu_list_2.txt","rb"))==NULL)
{
printf("connot open the file!\n");
return NULL;
}
return fp;
}
FILE* open_3()//打开出库记录
{
FILE *fp;
if((fp=fopen("stu_list_3.txt","rb"))==NULL)
{
printf("connot open the file!\n");
return NULL;
}
return fp;
}
void find_1()//完成4.1
{
FILE *fp=NULL;
int i;
char name[10];
fp=open_1();
printf("please input the name:\n");//4.1
scanf("%s",name);
printf("the information of the good:\n");
for(i=0;i<SIZE;i++)
{
if(fread(&stu_1[i],sizeof(struct goods),1,fp)==1)//4.1 在库存记录之中查找
{
if(strcmp(name,stu_1[i].name)==0)
{
printf("%s %s %s %d %.2f\n",stu_1[i].name,stu_1[i].brand,stu_1[i].style,stu_1[i].num,stu_1[i].money);
}
}
}
fclose(fp);
}
void find_5()//完成5.1
{
FILE *fp=NULL;
int i;
int sum=0;
char name[10];
fp=open_1();
printf("please input the name:\n");//5.1
scanf("%s",name);
printf("the information of the good:\n");
for(i=0;i<SIZE;i++)
{
if(fread(&stu_1[i],sizeof(struct goods),1,fp)==1)//5.1 在库存记录之中查找
{
if(strcmp(name,stu_1[i].name)==0)
{
sum=sum+stu_1[i].num;
}
}
}
printf("the number of this %s is %d.\n",name[10],sum);
fclose(fp);
}
void find_2()//完成4.2
{
FILE *fp=NULL;
int i;
char brand[10];
printf("please input the brand:\n");//4.2
scanf("%s",brand);
fp=open_1();
for(i=0;i<SIZE;i++)
{
if(fread(&stu_1[i],sizeof(struct goods),1,fp)==1) //4.2
{
if(strcmp(brand,stu_1[i].brand)==0)
{
printf("the information of the good:\n");
printf("%s %s %s %d %.2f\n",stu_1[i].name,stu_1[i].brand,stu_1[i].style,stu_1[i].num,stu_1[i].money);
}
}
}
fclose(fp);
}
void find_3()//完成4.3
{
int i;
FILE *fp2=NULL, *fp3=NULL;
int year,month,day;
printf("please input year,month,day,then find the exit and entrance:\n");//4.3
scanf("%d%d%d",&year,&month,&day);
fp2=open_2();
fp3=open_3();
printf("the information of entrance is:\n");
for(i=0;i<SIZE;i++)
{
if(fread(&stu_2[i],sizeof(struct entrance),1,fp2)==1)//读出入库信息
{
if((stu_2[i].time.year==year)&&(stu_2[i].time.month==month)&&(stu_2[i].time.day==day))//入库信息4.3
{
printf("%s %s %s %d %.2f %d %d %d %s\n",stu_2[i].name,stu_2[i].brand,stu_2[i].style,stu_2[i].num,stu_2[i].money,stu_2[i].time.year,stu_2[i].time.month,stu_2[i].time.day,stu_2[i].stuf);
}
}
}
printf("the information of exit is:\n");
for(i=0;i<SIZE;i++)
{
if(fread(&stu_3[i],sizeof(struct exit),1,fp3)==1)//读出出库信息
{
if((stu_3[i].time.year==year)&&(stu_3[i].time.month==month)&&(stu_3[i].time.day==day))//出库信息4.3
{
printf("%s %s %s %d %d %d %d %s\n",stu_3[i].name,stu_3[i].brand,stu_3[i].style,stu_3[i].num,stu_3[i].time.year,stu_3[i].time.month,stu_3[i].time.day,stu_3[i].stuf);
}
}
}
fclose(fp2);
fclose(fp3);
}
void find_4()//完成4.4
{
int i;
FILE *fp2=NULL,*fp3=NULL;
char name[10],style[10];
printf("please input the name and style of the goods,then find the entrance and exit:\n");//4.3
scanf("%s%s",name,style);
fp2=open_2();
fp3=open_3();
printf("the entrance information of the good is:\n");
for(i=0;i<SIZE;i++)//4.4
{
if(fread(&stu_2[i],sizeof(struct entrance),1,fp2)==1)//读出入库信息
{
if((strcmp(stu_2[i].name,name))==0&&(strcmp(stu_2[i].style,style))==0)//入库信息4.4
{
printf("%s %s %s %d %f %d %d %d %s\n",stu_2[i].name,stu_2[i].brand,stu_2[i].style,stu_2[i].num,stu_2[i].money,stu_2[i].time.year,stu_2[i].time.month,stu_2[i].time.day,stu_2[i].stuf);
}
}
}
printf("the exit information of the good is:\n");
for(i=0;i<SIZE;i++)//4.4
{
if(fread(&stu_3[i],sizeof(struct exit),1,fp3)==1)//读出出库信息
{
if((strcmp(stu_3[i].name,name))==0&&(strcmp(stu_3[i].style,style))==0)//出库信息4.4
{
printf("%s %s %s %d %d %d %d %s\n",stu_3[i].name,stu_3[i].brand,stu_3[i].style,stu_3[i].num,stu_3[i].time.year,stu_3[i].time.month,stu_3[i].time.day,stu_3[i].stuf);
}
}
}
fclose(fp2);
fclose(fp3);
}
void find_6()//完成5.2
{
int i;
int sum=0;
FILE *fp=NULL;
char name[10];
printf("please input the name of the good,then output the number of its entrance:\n");//5.2
scanf("%s",name);
fp=open_2();
for(i=0;i<SIZE;i++)
{
if(fread(&stu_2[i],sizeof(struct entrance),1,fp)==1)//读出入库信息
{
if((strcmp(stu_2[i].name,name))==0)//入库信息4.4
{
sum=sum+stu_2[i].num;
}
}
}
printf("the number of the goods' entrance is %d.\n",sum);
fclose(fp);
}
void find_7()//完成5.3
{
int i;
int sum=0;
int year,month;
FILE *fp=NULL;
printf("please input year and month,then output the number of exit in this month:\n");//5.3
scanf("%d%d",&year,&month);
fp=open_3();
printf("the number of exit good in this month is:");
for(i=0;i<SIZE;i++)//5.3在出库记录文件中统计该月的出库记录次数。
{
if((fread(&stu_3[i],sizeof(struct exit),1,fp)==1))
if(stu_3[i].time.year==year&&stu_3[i].time.month==month)
{
sum=sum+1;
}
}
printf("%d\n",sum);
fclose(fp);
}
void find_8()//完成5.4
{
int i,j;
FILE *fp=NULL;
printf("please input the red number,then output all the informations of the goods:\n");
getchar();
scanf("%d",&j);
fp=open_1();
for(i=0;i<SIZE;i++)//5.4输出库存数量小于该警戒值的所有库存电器的信息
{
if((fread(&stu_1[i],sizeof(struct goods),1,fp)==1))
{
if(stu_1[i].num<j)
{
printf("the information of the good are:\n");
printf("%s %s %s %d %.2f\n",stu_1[i].name,stu_1[i].brand,stu_1[i].style,stu_1[i].num,stu_1[i].money);
}
}
}
fclose(fp);
}
void load_1()//读stu_list_1中的数据
{
FILE *fp=NULL;
fp = open_1();
fread(stu
展开阅读全文