小型书店进销存管理系统Word格式.doc
《小型书店进销存管理系统Word格式.doc》由会员分享,可在线阅读,更多相关《小型书店进销存管理系统Word格式.doc(20页珍藏版)》请在冰点文库上搜索。
先对书店书进行盘点,确定是否要进购书:
进购书本:
销售书本:
库存不足查询:
再次进行盘点(同时添加书本):
更新记录(将序号1的书本改为序号5,进价改为25,售价改为30):
查询记录:
查询序号为1的书(查询失败,因为序号已被改为5):
查询序号为5的书:
财务统计(所输入的书本序号应为5):
如果输入的序号为1:
输入的序号为5:
重组文件后退出。
*/
二、数据处理方法
MicrosoftVisualStudio2010旗舰版
三、实验步骤
第一步:
,定义书店结构booktype,构建类manage
(1)类manage中定义功能函数
voidAddbook();
//进书
voidAdditional();
//追加
voidUpdatebook();
//更新
voidSellbook();
//销售
voidTell();
//库存不足
voidcount();
//财务统计
voidSearchbook();
//查询
voidPack();
//删除
(2)编写代码实现各类功能函数
(3)编写程序实行函数Run()
第二步:
定义Main函数
Manageobj;
if(obj.file.fail())throw("
打开文件失败¨
!
"
);
if(!
obj.file.fail())
{
obj.Run();
}
return0;
第三步:
修改代码以及运行程序
指导老师对实验设计方案的意见:
指导老师签名:
年月日
二、实验结果与分析
1、实验目的、场地及仪器、设备和材料、实验思路等见实验设计方案
2、实验现象、数据及结果
#include<
iostream>
fstream>
iomanip>
usingnamespacestd;
structbooktype//书店结构
booldelTag;
//删除标志
unsignedintseat;
//序号
charname[16];
//书名
charauthor[16];
//作者
floatenter_price;
//进价
floatsale_price;
//售价
intsale;
//销售量
intday;
//销售日号
staticfloatday_sum;
//当日销售额统计
staticfloatmonth_sum;
//当月销售额统计
staticfloatday_Profit;
//当日销售盈利
staticdoublediscount;
//优惠折扣
intquantity;
//书的数量
};
classManage
private:
voidAddbook();
//进书
voidAdditional();
//追加
voidUpdatebook();
//更新数据
voidSellbook();
//销售
voidTell();
//库存不足提示
voidcount();
//财务统计
voidSearchbook();
//查询
voidPack();
//删除作有删除记录标记的记录
public:
Manage();
//无参构造函数
virtual~Manage(){file.close();
}//析构函数
voidRun();
//处理
fstreamfile;
//书店文件
Manage:
:
Manage()//无参构造函数
ifstreamiFile("
M.dat"
//建立输入文件
if(iFile.fail())//打开文件失败
{
ofstreamoFile("
//建立输入出文件
if(oFile.fail())throw("
打开文件失败!
//抛出异常
oFile.close();
//关闭文件
}
elseiFile.close();
//文件存在,关闭文件
file.open("
ios:
in|ios:
out|ios:
binary);
//以读写方式打开文件
if(file.fail())throw("
//进书
voidManage:
Addbook()
booktypeM;
M.delTag=false;
//正常,未作删除标志
chartag='
Y'
;
while(tag=='
)
{cout<
<
******输入进购书本的信息*******"
endl;
cout<
输入要进购书的序号:
"
cin>
>
M.seat;
cout<
输入该书的书名:
M.name;
输入该书的作者名:
M.author;
cout<
输入要进购的数量:
M.quantity;
cout<
输入该书的进价:
cin>
M.enter_price;
输入该书的售价:
M.sale_price;
file.write((char*)&
M,sizeof(booktype));
//写入文件
是否继续进购?
(是Y,否N):
tag;
//追加(添加书本,显示进货前和进货后的记录)
Additional()
unsignedintseat;
intamount;
//进购的数量
cout<
输入要追加书本的序号:
cin>
seat;
file.seekg(0);
//定位
file.read((char*)&
//读记录
while(!
file.eof())//文件末结束
if(M.seat==seat&
&
M.delTag)break;
//序号相同,记录正常,未作删除标志
file.read((char*)&
if(!
file.eof())
******输出添加前的数据******"
该书的序号:
M.seat<
该书的书名:
M.name<
该书的作者名:
M.author<
该书的现存数量:
M.quantity<
cout<
该书的进价:
M.enter_price<
该书的售价:
M.sale_price<
//输出记录
输入该书还需添加的数量:
amount;
M.quantity=M.quantity+amount;
******输出添加后的数据******"
file.seekg(-sizeof(booktype),ios:
cur);
file.write((char*)&
//写入记录
else
======本书店没有此书的记录,需要进购该书!
======"
file.clear();
//更新记录(对书本信息记录进行更新,本实验对序号为1的书本进行了更新(将信号更新为5,进价更新为25,售价更新为30)
Updatebook()
booktypeM;
unsignedintseat;
cout<
输入要更新书的序号:
cin>
file.seekg(0);
//定位
file.read((char*)&
while(!
if(M.seat==seat&
//序号相同,记录正常,未作删除标志
file.read((char*)&
}
if(!
file.eof())//查询成功
{
******输出更新前的数据******"
******输入书本更新的数据******"
输入该书的序号:
输入书名:
cin>
输入现存的数量:
cin>
file.seekg(-sizeof(booktype),ios:
file.write((char*)&
else
{
cout<
======本书店没有此书的记录,请添加该书的记录!
file.clear();
}
//销售(支持折扣优惠促销,这里将其设置为对一次购5本以上者,可以享受8.5折优惠)
floatbooktype:
day_sum=0;
//当日销售额统计
month_sum=0;
//当月销售额统计
floatbooktype:
day_Profit=0;
//当日盈利统计
doublebooktype:
discount=0.15;
//优惠折扣
Sellbook()
{
unsignedintseat;
cout<
输入书的序号:
cin>
file.seekg(0);
//定位
file.read((char*)&
while(!
if(M.seat==seat&
M.delTag)break;
//序号相同,记录正常,未作删除标志
file.read((char*)&
******输出要被售出的书本信息******"
输入卖出的数量:
M.sale;
输入该书销售的日号:
M.day;
if(M.sale<
=M.quantity)
{
floatn=1.0;
if(M.sale>
5)n=0.85*n;
//对一次购5本以上者,还可以享受8.5折优惠
M.day_sum=M.day_sum+n*(1-M.discount)*M.sale*M.sale_price;
//该书当日销售额统计
M.day_Profit=M.day_Profit+n*(1-M.discount)*M.sale*(M.sale_price-M.enter_price);
//该书当日盈利统计
M.quantity=M.quantity-M.sale;
file.seekg(-sizeof(booktype),ios:
file.write((char*)&
cout<
=====销售成功!
}
elseif(M.sale>
M.quantity)
cout<
=======库存不足,需要进购该书!
======="
else
{
======本书店没有此书的记录!
file.clear();
//清除文件结束标志
}
//库存不足提示(这里设置当书本数量小于10时,库存不足)
Tell()
booktypeM;
该书现有的数量:
if(M.quantity>
=10)
=====无库存不足现象,暂不需进购新书!
elsecout<
======该书库存不足,需立即进购!
file.write((char*)&
file.clear();
//财务统计(统计该书店当日某书的销售额及其盈利)
count()
if(!
******对售出书本进行财务统计******"
该书售出的数量:
M.sale<
该书售出的日号:
M.day<
输出该书当日销售额为:
M.day_sum<
输出该书当日销售盈利:
M.day_Profit<
}