综合性程序设计报告.docx

上传人:b****8 文档编号:11154740 上传时间:2023-02-25 格式:DOCX 页数:28 大小:558.73KB
下载 相关 举报
综合性程序设计报告.docx_第1页
第1页 / 共28页
综合性程序设计报告.docx_第2页
第2页 / 共28页
综合性程序设计报告.docx_第3页
第3页 / 共28页
综合性程序设计报告.docx_第4页
第4页 / 共28页
综合性程序设计报告.docx_第5页
第5页 / 共28页
点击查看更多>>
下载资源
资源描述

综合性程序设计报告.docx

《综合性程序设计报告.docx》由会员分享,可在线阅读,更多相关《综合性程序设计报告.docx(28页珍藏版)》请在冰豆网上搜索。

综合性程序设计报告.docx

综合性程序设计报告

综合性程序设计报告

 

设计题目:

粮油公司进销存管理系统

指导教师:

班级:

51104

学号:

5110418

设计者:

宋玉峰

成绩:

_______________

设计时间:

2012年11月23日

 

主体目录

1.课程设计要求

2.题目描述   

3.功能模块分解集说明

4.树状图解析

5.数据库设计及说明

6.结构体

7.代码及注释

8.设计测试说明

9.设计体会

课程设计要求

 

题目描述

1.问题分析:

先定义合适的结构体,存储物品信息。

在程序中建立一个文件用于存储,凡进行了进货操作的物品在文件中都有记录,进货时由于尚不知售货时间与售价、利润,故此三项(实际为四项,时间分为年、月两项)暂先赋值为零,待进行售货操作时再输入各数值,其中利润由系统自动计算得出并保存。

账目清单分为已售、仓储两部分,由此可看到所有购进、卖出的货物信息。

利润查询可查得所输入到目前为止的各类所售货物数量与利润。

2.问题概要

该系统用于处理粮油公司的物资买入,卖出,仓储等设备账目。

在买入物资时,记录物资的数量名称(如小麦,玉米,大豆等)和价钱,并在库房纪录中添加设备,在卖出物资时从库房中减掉该设备,并根据卖出的数量型号和价钱得出每一笔买出的利润。

每隔一段时间盘点库房和账目计算出利润等数据。

基本要求:

有货物管理(物资的添加,删除,修改)

有账目管理

可以查询账目清单

可以计算年度或月份或季度利润

 

功能模块分解集说明

根据问题描述和要求,系统要求能够实现物资基本信息管理和物资的查询与统计。

确定程序至少应该具备如下功能:

“进货操作”、“售货操作”、“修改信息”、“账目清单”、“月利润查询”等基本模块。

“进货操作”模块的作用是向物资链中增加物资;

“售货操作”模块的作用是记录物资链中售出的商品信息;

“修改信息”模块的作用是修改商品链中的物资信息;

“账目清单”模块的作用是把所有物资的买入与售出信息输出到显示器上;

“利润查询”模块的作用是查询粮油公司的月利润。

经综合考虑系统具有下面5项功能模块:

物资买入,物资卖出,修改信息,账目清单,利润查询……

树状图解析

 

数据库设计及说明

函数模块

inport();//为输入操作函数

detail();//为账目清单函数

change();//为修改信息函数

outport();//为收获操作函数

fun1();//为菜单函数

profit();//为月利润查询函数

结构体

structitem

{

intnum1;

charname[9];

floatprize;

floatnum2;

structitem*next;

};

说明:

此为物资基本信息包括:

编号,商品名称,进价,数量。

运用动态链表,可以多次输入。

指针

structitem*head;

structitem*p1,*p2;//定义此指针*p1,*p2指向struct结构体,运用链表不断延伸。

宏定义

#definelengthsizeof(structitem)

#definelength1sizeof(structitem1)

#definelength2sizeof(structitem2)

文件操作

本程序建”xls,xls1”两个,每次操作后,文件中信息得到相应修改并重新储存

 

界面说明

进入菜单,会有六个选项,功能如上图。

输入对应的代码,可执行该功能。

设定共可以管理的物资有四种,分别为小麦、大米、大豆利润查询功能中只处理以上三种名称。

在进货时输入进货编号、进价等,售货时输入售价与售货日期,程序自动计算出利润。

 

示例:

1.进入程序出现主菜单如图

2.选“1”进行进货操作,界面如图:

3.选“2”,进行售货操作,界面如图:

4.选“3”,进行修改信息,界面如图:

5.选“4”,查看账目信息,结果如图:

6.选“5”,查询月利润,如图

代码及注释

#include

#include

#include

#include

#definelengthsizeof(structitem)

#definelength1sizeof(structitem1)

#definelength2sizeof(structitem2)

voidinport()

{

staticinta;

charc1[8];

FILE*p;

structitem

{

intnum1;

charname[9];

floatprice;

floatnum2;

structitem*next;

};

structitem*head,*p1,*p2;

p1=p2=(structitem*)malloc(length);/*开辟一个新单元*/

if((p=fopen("xls","a+"))==0)

{

printf("文件打开错误");

}

a=0;

head=NULL;

for(;;)

{

printf("请输入商品的编号\n");

scanf("%d",&p1->num1);getchar();

printf("请输入商品的名称\n");

scanf("%s",p1->name);

printf("请输入商品的进价\n");

scanf("%f",&p1->price);

printf("请输入商品的数量(kg)\n");

scanf("%f",&p1->num2);

if(fwrite(p1,length,1,p)!

=1)

printf("无法保存!

\n");

else

printf("保存成功!

\n");

printf("\t\t是否继续输入?

(y/n)\n");

scanf("%s",&c1);

if(strcmp(c1,"n")==0||strcmp(c1,"N")==0)

break;

if((a+1)==1)head=p1;

else

p2->next=p1;

p2=p1;

p1=(structitem*)malloc(length);

}

p2->next=NULL;

}

voidoutport()

{

staticinta;

charc1[2]="n";

FILE*fp;

structitem

{

charnum1[3];

charname[9];

floatprice;

floatnum2;

floatnum3;

structitem*next;

};

structitem*head,*p1,*p2;

p1=p2=(structitem*)malloc(length);/*开辟一个新单元*/

if((fp=fopen("xls1","a+"))==NULL)printf("文件打开错误!

\n");

head=NULL;

for(a=1;a;a++)

{

printf("请输入销售商品的年月日(如2011/1/12)\n");

scanf("%s",p1->num1);

printf("请输入商品的名称\n");

scanf("%s",p1->name);

printf("请输入商品的编号");

scanf("%d",&p1->num3);

printf("请输入商品的售价\n");

scanf("%f",&p1->price);

printf("请输入商品的数量\n");

scanf("%f",&p1->num2);

if(fwrite(p1,length,1,fp)!

=1)

printf("无法保存!

\n");elseprintf("保存成功!

");

printf("\t\t是否继续输入?

(y/n)\n");

scanf("%s",c1);

if((strcmp(c1,"n")==0)||(strcmp(c1,"N")==0))break;

if(a==1)head=p1;

elsep2->next=p1;

p2=p1;

p1=(structitem*)malloc(length);

}

p2->next=NULL;

}

voidchange()

{

FILE*p,*fp;

inta,b,e,f,d;

chars[2];

structitem1

{

intnum1;

charname[9];

floatprice;

floatnum2;

structitem1*next;

};

structitem2

{

intnum1[3];

charname[9];

floatprice;

floatnum2;

intnum3;

structitem2*next;

};

structitem1*head1=NULL,*p1,*p2;

structitem2*head2=NULL,*p3,*p4;

p1=p2=(structitem1*)malloc(length1);/*开辟一个新单元*/

p3=p4=(structitem2*)malloc(length2);

for(;;)

{

printf("修改选项如下:

\n1.进货情况;\n2.销售情况\n");

scanf("%d",&a);

switch(a)

{

case1:

{

if((p=fopen("xls","rb"))==NULL)

{

printf("打不开文件\n");

system("pause");

}

p1=p2=(structitem1*)malloc(length1);

for(e=0;(!

feof(p))==0;e++)

{

if(fread(p1,length1,1,p)==0)

{

printf("无此项纪录!

");

system("pause");

}

if(e==0)

head1=p1;

else

p2->next=p1;

p2=p1;

p1=(structitem1*)malloc(length1);

}

p2->next=NULL;

printf("请输入欲修改物品的编号:

");

scanf("%d",&f);

while(p2->next)

{

if((f==p1->num1))

{

printf("请输入要修改的项目:

\n1.商品名称\n2.进价\n数量\n");

scanf("%d",&d);

switch(d)

{

case1:

{

printf("请输入商品名称:

");

scanf("%s",p1->name);

};break;

case2:

{

printf("请输入商品进价:

");

scanf("%f",&p1->price);break;}

case3:

{printf("请输入商品数量:

");

scanf("%f",&p1->num2);break;}

default:

{

printf("输入错误!

");

system("pause");

}

fun1();

break;}

}

break;

}

fclose(p);

case2:

{

if((fp=fopen("xls1","rb"))==NULL)

{

printf("打不开文件\n");

system("pause");

}

p4=p3=(structitem2*)malloc(length2);

for(e=0;!

feof(fp);e++)

{

if(fread(p3,length2,1,fp)!

=1)

{

printf("无此项纪录!

");

system("pause");

}

if(e==0)

head2=p3;

else

p4->next=p3;

p4=p3;

p3=(structitem2*)malloc(length2);

}

p4->next=NULL;

printf("请输入欲修改商品编号:

");

scanf("%d",&f);

while(p4->next)

{

if(f==(p3->num3))

{

printf("请输入要修改的项目:

\n1.商品名称\n2.售价\n数量\n");

scanf("%d",&d);

switch(d)

{

case1:

{

printf("请输入商品名称:

");

scanf("%s",p3->name);

};break;

case2:

{

printf("请输入商品售价:

");

scanf("%f",&p3->price);break;}

case3:

{printf("请输入商品数量:

");

scanf("%f",&p3->num2);break;}

default:

{

printf("输入错误!

\n");

system("pause");

}

break;

}

}

break;

}

};

fclose(fp);

break;

default:

printf("输入错误!

\n");

}

printf("是否继续y/n?

");

scanf("%s",s);

if(strcmp(s,"y")||strcmp(s,"Y")==0)

break;

}

}}

voiddetail()

{

FILE*p,*fp;

inta,b,c,e,f,d;

chars[2];

structitem2

{

charnum1[3];

charname[9];

floatprice;

floatnum2;

intnum3;

structitem2*next;

};

structitem1

{

intnum1;

charname[9];

floatprice;

floatnum2;

structitem1*next;

};

structitem1*head1=NULL,*p1,*p2;

structitem2*head2=NULL,*p3,*p4;

p1=p2=(structitem1*)malloc(length1);/*开辟一个新单元*/

p3=p4=(structitem2*)malloc(length2);

if(((p=fopen("xls","rb"))==0))

{

printf("打不开文件\n");

system("pause");

}

else

{

printf("进货情况如下:

\n");

while(feof(p)!

=0)

{

if(fread(p1,length1,1,p)!

=0){printf("\t商品编号\t商品名称\t进价\t数量\t\n");

printf("\t%d\t%s\t%f\t%f\n",p3->num1,p3->name,p3->price,p3->num2);}

else{

printf("无此项纪录!

");

system("pause");

}

if(e==0)

head1=p1;

else

p2->next=p1;

p2=p1;

p1=(structitem1*)malloc(length1);

}

p2->next=NULL;

}

fclose(p);

if(((fp=fopen("xls1","rb"))==0))

{

printf("打不开文件\n");

}

else{

printf("销售情况如下:

");

while(!

feof(fp)==0)

{

if(fread(p3,length2,1,fp)!

=0){printf("销售日期\t商品名称\t售价\t数量\t商品编号");

printf("%s\t%s\t%f\t%f\n",p3->num1,p3->name,p3->price,p3->num2);}

else{

printf("无此项纪录!

");

system("pause");

}

if(f==0)

head2=p3;

else

p4->next=p3;

p4=p3;

p3=(structitem2*)malloc(length2);

}

fclose(fp);

p4->next=NULL;

}

system("pause");

}

 

voidprofit()

{

FILE*p;

FILE*fp;

inta,b,c,e,f,d,i1,j1,g1,i2,j2,g2;

chars[2];

structitem2

{

charnum1[3];

charname[9];

floatprice;

floatnum2;

floatnum3;

structitem2*next;

};

structitem2*head2=NULL,*p3,*p4;

structitem1

{

intnum1;

charname[9];

floatprice;

floatnum2;

structitem1*next;

};

structitem1*head1=NULL,*p1,*p2;

head1=NULL;head2=NULL;

p1=p2=(structitem1*)malloc(length1);/*开辟一个新单元*/

p3=p4=(structitem2*)malloc(length2);

if((p=fopen("xls","rb"))==NULL)

{

printf("打不开文件\n");

system("pause");

}

else

{

for(e=0;(!

feof(p)==0);)

{

if((fread(p1,length1,1,p))!

=0)

{

if(p1->num1==1)

i1+=(p1->num2)*(p1->price);

else

if(p1->num1==2)

j1+=(p1->num2)*(p1->price);

else

g1+=(p1->num2)*(p1->price);

}

else

{

printf("无此项纪录!

");

system("pause");

}

if(e==0)

head1=p1;

else

p2->next=p1;

p2=p1;

p1=(structitem1*)malloc(length1);

}

p2->next=NULL;

}

fclose(p);

if((fp=fopen("xls1","rb"))==NULL)

{

printf("打不开文件\n");

system("pause");

}

else

{

for(f=0;((!

feof(fp))==0);f++)

{

if((fread(p3,length2,1,fp))!

=0)

{

if((p3->num3)==1)

i2+=(p3->num2)*(p3->price);

else

if(p3->num3==2)

i2+=(p3->num2)*(p3->price);

else

g2+=(p3->num2)*(p3->price);

}

else

{

printf("无此项纪录!

");

system("pause");

}

if(f==0)

head2=p3;

else

p4->next=p3;

p4=p3;

p3=(structitem2*)malloc(length2);

}

p4->next=NULL;

}

fclose(fp);

printf("商品\t\t利润\n");

printf("玉米\t\t%f/n大豆\t\t%f\n小麦\t\t%f\n",i2-i1,j2-j1,g2-g1);

}

voidfun1()

{

system("cls");

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

printf("\t*****************************菜单************************\n");

printf("\t\t欢迎进入粮油公司进销存管理系统!

\n\n");

printf("\t\t0.退出\n");

printf("\t\t1.进货操作\n");

printf("\t\t2.售货操作\n");

printf("\t\t3.修改信息\n");

printf("\t\t4.账目清单\n");

printf("\t\t5.利润查询\n"

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

当前位置:首页 > 初中教育 > 语文

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1