欢迎来到天天文库
浏览记录
ID:11194635
大小:39.50 KB
页数:21页
时间:2018-07-10
《商品库存管理(commodity inventory control)》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、商品库存管理(commodityinventorycontrol)#include"stdafx.h"#include"iostream.h"#include"fstream.h"#include"string.h"#include"stdlib.h"structgoods{charnum[9];charnm[20];intinprice;intoutprice;charblack[20];charseller[20];};classgoods{goodsgs;thestaticfstream*pf;public:voidwrite();voidadd();voidsearch();m
2、odify(void);voiddel();sequence(void);voidcount();staticintpractice();staticintclose();};fstream*goods::pf=0;intgoods::practice(){if(pf==0){pf=newfstream;pf->open(".\goods",108::out
3、sag::in
4、sag:binary);}return0;}voidgoods::write(){goodss;if(pf)->eof())pf>clear();pf->seekg(0,108:pitch);while(!pf>
5、eof())//查找对象{pf>read((unsignedchar*)&s,sizeof(goods);if(strcmp(gs.nm,s.nm)==0)//存在,则不写{cout<<"已经存在"<eof())pf>clear();pf->seekg(0,108:pitch);while(!pf>eof())//查找空对象{pf>read((unsignedchar*)&s,sizeof(goods);if(strlen(s.nm)==0)//存在空对象,将新对象写入改位置{pf->seekp(-1*sizeof(goods),108:
6、:cur);pf>write((unsignedchar*)&gs,sizeof(goods);return;}}//不存在空对象,则将对象写在文件尾部if(pf)->eof())pf>clear();pf->seekp(0,108::than);pf>write((unsignedchar*)&gs,sizeof(goods);}voidgoods::add(){practice();goodss;charch='y';die{cout<<"请输入你想要添加的商品名称:";cin>>gs.nm;if(pf)->eof())pf>clear();pf->seekg(0,108:pitc
7、h);while(!pf>eof()){pf>read((unsignedchar*)&s,sizeof(goods);if(strcmp(gs.nm,s.nm)==0){cout<<"该生信息存在"<8、<"编号:";cin>>gs.num;cout<<"名称:"<<<>gs.inprice;cout<<"销售价格:";cin>>gs.outprice;cout<<"种类:";cin>>gs.sort;cout<<"供应商:";cin>>gs.seller;cout<<"开始保存该生信息......"<>ch;}while((ch=='y'9、10、ch=='y');}voidgoods:part(){goodss;intflag=0;c11、out<<"请输入你要删除的商品名:";cin>>gs.nm;if(pf)->eof())pf>clear();pf->seekg(0,108:pitch);while(!pf>eof()){pf>read((unsignedchar*)&s,sizeof(goods);If(StrCmp(gs.NM,s.NM)==0)//,istowritetheemptyrecord{Cout<<"thisproducthasbeendeleted!"<<
8、<"编号:";cin>>gs.num;cout<<"名称:"<<<>gs.inprice;cout<<"销售价格:";cin>>gs.outprice;cout<<"种类:";cin>>gs.sort;cout<<"供应商:";cin>>gs.seller;cout<<"开始保存该生信息......"<>ch;}while((ch=='y'
9、
10、ch=='y');}voidgoods:part(){goodss;intflag=0;c
11、out<<"请输入你要删除的商品名:";cin>>gs.nm;if(pf)->eof())pf>clear();pf->seekg(0,108:pitch);while(!pf>eof()){pf>read((unsignedchar*)&s,sizeof(goods);If(StrCmp(gs.NM,s.NM)==0)//,istowritetheemptyrecord{Cout<<"thisproducthasbeendeleted!"<<
此文档下载收益归作者所有