1、 VC+VC+课程设计报告课程设计报告 2012013 3 年年 12 12 月月 课 程: VC+课程设计 系 别: 计算机系 班 级: 计科一班 学 号: 姓 名: 课题名称: 物品库存管理 起止时间: 2013.11.262013.12.11 指导教师: 1 1 程序功能介绍程序功能介绍 用文件系统实现的物品库存管理程序。一种商品的品种里面包括(Item_code; coutnBrnd; /循环实现品牌数据的输入,count为商品总数 for(int i=0,count=0;ibrndi.Brand_code; coutbrndi.brnd_price; count+=brndi.qua
2、ntity; 3 quantity=count; if(n=1) ofstream file(“进货清单.txt“,ios:out|ios:ate); if(!file) coutchoice; while(choice=1 while(countbrndchoice-1.quantity) coutchoice; ofstream file(“出货清单.txt“,ios:out|ios:ate); if(!file) 5 coutcount; brndi.quantity+=count; quantity+=count; flag=1; break; if(flag=0) strcpy(br
3、ndnBrnd.brnd_name,name); coutbrndnBrnd.quantity; coutchoice; if(choice=y|choice=Y) n=1; else n=0; ofstream file(“进货清单.txt“,ios:out|ios:ate); if(!file) coutchoice; switch(choice) case 1: coutcode; strcpy(name1,“null“); break; fstream file( “客户资料.txt“ ,ios:in); if(!file) 9 coutchoice; if(choice=1) cou
4、tcode; strcpy(name1,“null“); ifstream file( “客户资料.txt“ ,ios:in ); ofstream temp( “delete2.txt“, ios:trunc); if( !file |!temp) coutSetItem(); pn=new CNode; pn-InputData(p); list.Insert(pn); system(“cls“); break; 问题问题 5 5:以什么方式打开文件? 解决办法:解决办法:给出的参考源程序中有很多文件的打开方式,一开始我很不理解他们的具体含义。经过 查阅教材,知道了:以 in 方式打开的文
5、件,只能从文件中读取数据;以 out 方式打开的文件,只 能将数据写入文件中;ate 方式不能单独使用,out|ate 的作用是在文件打开时,将文件指针移到 文件的结尾处,文件中原来的内容不变,向文件中写入的数据增加到文件中;明确以 binary 方式 12 打开的文件,才是二进制文件,它总是与读或写方式同时使用。 void customer:add() /加入客户资料 ofstream file( “客户资料.txt“, ios:out |ios:ate ); if(!file) cout“错误,无法打开文件“; getch(); exit(1); customer p2; p2.getda
6、ta(); /从键盘输入客户资料 /将该客户的资料传到文件中 file.write(reinterpret_cast (/reinterpret_cast 将其他类型的数 据转换为字符指针 6 课程设计中所课程设计中所改变改变的功能模块的功能模块 课程设计中所课程设计中所增加增加的功能模块的功能模块 根据对程序的需求分析,我增加了客户类,其中包括:添加、删除、查询和显示这四个模块。 7 课程设计结果课程设计结果 物品库存管理系统首页 1.添加物品品种 13 2.显示商品品种 3.查询商品 5.商品出库 6.商品进库 14 7.添加客户 9.查询客户 10.显示客户 8 还存在的不足之处还存在的不足之处 功能:功能:没有能够实现将客户类与品种和品牌类联系起来,虽然添加了客户类,但还是独立的个体。 实现方法