物资管理系统c++Word下载.docx
《物资管理系统c++Word下载.docx》由会员分享,可在线阅读,更多相关《物资管理系统c++Word下载.docx(11页珍藏版)》请在冰点文库上搜索。
intItem_code;
//品种代号
charcolour[10];
//颜色
floatItem_price;
//新增成员价格
charItem_date[14];
//日期
Brandbrnd[3];
//3个品牌
voidadd();
voidremove();
voidsearch();
voidshowab();
voidprint();
//打印当日进货表
voidprint2();
//打印出货表
//私有的成员函数在内部使用
//GETBrandDATA
//获取商标的数据,这是临时存储空间
voidBrand:
:
getdata()
{//改用中文
cout<
<
"
\n\n\t\t\t\t输入商标名称"
;
cin>
>
brnd_name;
\n\t\t\t\t输入商标代码"
Brand_code;
\n\t\t\t\t输入数量"
quantity;
\n\t\t\t\t输入价格"
brnd_price;
}
//SHOWBrandDATA
//显示商标的数据
showdata()
\n\n\t\t\t\t名称:
"
cout<
\n\n\t\t\t\t代码:
\n\n\t\t\t\t数量:
\n\n\t\t\t\t价格:
//GETItemDATA
//获取项目的数据,这是临时存储空间
voidItem:
\n\t\t\t\t输入商品名称"
Item_name;
\n\t\t\t\t输入商品代码"
Item_code;
\n\t\t\t\t输入颜色"
colour;
//为按价格检索输入价格
Item_price;
\n\t\t\t\t输入日期"
//为打印进货表输入日期
Item_date;
system("
cls"
);
\n\n\t\t\t\t输入商标1"
brnd[0].getdata();
\n\n\t\t\t\t输入商标2"
brnd[1].getdata();
\n\n\t\t\t\t输入商标3"
brnd[2].getdata();
//SHOWItemDATA
//显示项目的数据
\n\n\t\t\t\t\t\t商品资料"
\n\n\t\t\t\t商品名称:
//写一个字符串到标准的输出流(或缓冲区)-Writeastringtostdout
\n\n\t\t\t\t商品代码:
\n\n\t\t\t\t颜色:
//可显示价格和日期
\n\n\t\t\t\t日期:
getch();
//清屏
\n\n\t\t\t\t商标1"
endl;
brnd[0].showdata();
//清屏
\n\n\t\t\t\t商标2"
brnd[1].showdata();
\n\n\t\t\t\t商标3"
brnd[2].showdata();
//AddItem
/*这个函数先把数据缓存,再放到硬盘上
*/
add()
//loop1:
ofstreamfile("
TIS.txt"
ios:
out|ios:
ate);
//打开程序以输入
if(!
file)//如果程序不能被打开
\n\t\t\t\t错误无法打开文件\n"
exit
(1);
Itemp1;
p1.getdata();
//把数据写到硬盘上
file.write(reinterpret_cast<
constchar*>
(&
p1),sizeof(Item));
//TRAVERSE
/*thisfunctionshowsthelistofalltheBrands*/
showab()
//loop2:
ifstreamfile("
ios:
in);
//打开文件以输出
file)
file.read(reinterpret_cast<
char*>
(&
p1),sizeof(Item));
//存储数据
while(!
file.eof())
p1.showdata();
//在屏幕上显示
//等待键盘输入
p1),
sizeof(Item));
search()
//clrscr();
//loop3:
charname1[10];
intcode;
floatprice;
//新增选项
intoption;
\n\t\t\t\t
(1)按名称搜索\n\t\t\t\t
(2)按代码检索\n\t\t\t\t(3)按价格检索"
\n\t\t\t\t输入选择:
option;
//增加按价格搜索功能,用多重选择替原换条件语句
switch(option)
case1:
name1;
code=0;
price=0;
break;
case2:
code;
strcpy(name1,"
null"
case3:
\n\t\t\t\t输入商品价格"
price;
fstreamfile("
//OpenFileForOutput/Read
file)//IfFileCouldNotBeOpened
charflag='
a'
//FlagToCheckIfFound
//ReadDataToObject
file.eof())//UntillThereAreContacts
if((strcmp(p1.Item_name,name1)==0)||(p1.Item_code==code)||(p1.Item_price==price))//Compare
p1.showdata();
flag='
z'
//SetFlag
//BreakLoop
//ReadNextContact
if(flag!
='
)//IfNotFound
("
\n\t\t\t\t商品未找到\n"
//REMOVEItem
//removeisabitdifferentfirstallthedataexcepttheItemtobedeletedissavedinanotherfilecalleddelete...
//thentheoriginalfileiswashedandallthedataiscopiedbackagain
remove()
//loop4:
//clrscr();
\n\t\t\t\t
(1)按名称删除\n\t\t\t\t
(2)按代码删除"
if(option==1)
else
in);
ofstreamtemp("
delete.txt"
trunc);
ofstreamtemp2("
delete2.txt"
ios:
out|ios:
ate);
//将删除商品写入"
delete2"
文件中
if(!
file||!
temp||!
temp2)
\n\t\t\t\t无法打开文件\n"
file.seekg(0);
temp.seekp(0);
//读出商品资料
file.eof())
if((strcmp(name1,p1.Item_name)==0)||(code==p1.Item_code))//比较商品资料以判断是否记入出货列表
temp2.write(reinterpret_cast<
//将资料写入delete2文件
//从TIS中读下一条内容
temp.write(reinterpret_cast<
//将信息暂存在delete文件内
p1),sizeof(Item));
file.close();
//关闭文件
temp.close();
ifstreamtemp1("
//定义读文件
ofstreamfile1("
//定义写文件
temp1.seekg(0);
//指针移到文件首
file1.seekp(0);
temp1.read(reinterpret_cast<
temp1.eof())
file1.write(reinterpret_cast<
temp1.close();
file1.close();
print()//按日期打印进货列表
//loop5:
chardate1[14];
\t\t\t\t输入日期"
//输入日期与商品资料进行核对
date1;
//OpenFileForOutput/Read
//读取文件TIS
if(strcmp(p1.Item_date,date1)==0)//比较日期
//显示出一个商品
//读取下一个商品
)
print2()//打印出货表
//loop6:
fstreamtemp2("
temp2)
}
Itemp2;
temp2.read(reinterpret_cast<
p2),sizeof(Item));
//读取文件DELETE2
temp2.eof())
{
p2.showdata();
//显示出货表
//读取下一商品
temp2.close();
//客户管理程序
voidmain()
{system("
system("
colorf1"
Itemm;
intchoice;
while
(1)
\n\t\t\t\t详细目录系统(TIS)"
\n\n\t\t\t\t
(1)增加商品品种\n\n\t\t\t\t
(2)显示商品资料\n\n\t\t\t\t(3)搜索商品品种\n\n\t\t\t\t(4)删除商品\n\n\t\t\t\t(5)商品出货表\n\n\t\t\t\t(6)商品进货表\n\n\t\t\t\t(0)退出TIS"
\n\n\t\t\t\t输入选择"
choice;
switch(choice)
m.add();
//system("
//gotoloop1;
m.showab();
//gotoloop2;
m.search();
//gotoloop3;
case4:
m.remove();
//gotoloop4;
case5:
m.print2();
//gotoloop5;
case6:
m.print();
//gotoloop6;
case0: