商品市场营销管理系统1.docx
《商品市场营销管理系统1.docx》由会员分享,可在线阅读,更多相关《商品市场营销管理系统1.docx(47页珍藏版)》请在冰点文库上搜索。
商品市场营销管理系统1
C++课程设计报告
题目:
商品市场营销管理系统——类定义、文件读写、主菜单、商品储存与销售管理、用户管理与注册、商品查询与统计
学生姓名:
廖湘桂
学号:
200917010223
专业班级:
计科09102班
同组姓名:
伍云
指导教师:
易明
设计时间:
2009年下学期第3~4周
1系统设计
图1管理员登录系统功能模块图
图2普通用户登录系统功能模块图
图3普通用户登录流程图
图3商品查询/修改流程图
图4商品出售流程图
基础类的定义:
#include
#include
#include
#include
usingnamespacestd;
#include
inttotal_in=0;//库存商品总数量
inttotal_pricein=0;//入库商品总价值
inttotal_use=0;//用户总人数
inttotal_out=0;//出售商品总数量
doubleAB_total=0;//总利润
classin;
classout;
//类的定义
classgoods//商品类
{
public:
goods*next;
stringno;//编号
stringgname;//名称
stringunit;//单位
stringstandards;//规格
stringbrand;//品牌
stringproducetime;//生产日期
doubleprice;//价格
stringEXP;//保质期
voidshow();//商品基本信息显示函数
//voidshowa(goods*p);
///商品类构造函数
goods(stringno1,stringgname1,stringunit1,stringstandards1,stringbrand1,stringproducetime1,doubleprice1,stringEXP1)
{
no=no1;
gname=gname1;
unit=unit1;
standards=standards1;
brand=brand1;
producetime=producetime1;
price=price1;
EXP=EXP1;
total_goods++;
}
goods(){}
};
classuser//用户类
{
public:
user*next;
stringnumber;//用户账号
stringcode;//密码
stringcode_1;//确认密码
stringname;//用户名
stringsex;//性别
stringage;//年龄
stringdarpt;//工作单位
stringphotonumber;//联系电话
stringenter1(charp);
user(stringnumber1,stringcode1,stringcode2,stringname1,stringsex1,stringdarpt1,stringphotonumber1)
:
number(number1),code(code1),code_1(code2),name(name1),sex(sex1),darpt(darpt1),photonumber(photonumber1){}
user(){}
};
classin:
virtualpublicgoods//商品入库类
{
public:
intcount_in;//入库时间
intcount_total;//入库数量
doubleprice_add;
stringtime_in;//入库时间
in*next;//指向自身的指针
/////商品入库类构造函数
in(stringno1,stringgname1,stringunit1,stringstandards1,stringbrand1,stringproducetime1,
doubleprice1,stringEXP1,intcount_in1,stringtime_in1):
goods(no1,gname1,unit1,standards1,brand1,producetime1,price1,EXP1)
{
count_in=count_in1;
price_add=price*count_in;
time_in=time_in1;
count_total=count_total+count_in;
}
in():
goods(){};
voidshow_in();//入库商品显示函数
voidshowcount_in();//入库商品统计函数
};
voidin:
:
showcount_in()//统计入库商品总数量函数
{
system("cls");
stringno1;stringgname1;doubleprice1;intcount_total1;stringtime_in1;doubleprice_add1;chara='y';
ifstreamfin("goods_infile.txt");
if(!
fin){cout<<"此时库存里无商品:
\n";exit(0);}
while(a=='y')
{
cout<<"输出所有库存商品基本信息及统计总商品量:
"<while(fin>>no1>>gname1>>price1>>count_in>>time_in1>>count_total1)
{
cout<<"\t编号:
"<<<"\t名称:
"<<<"\t价格:
"<<<"\t此商品库存总数量:
"<price_add1=price1*count_total1;
cout<<"\t此商品库存总价值:
"<total_pricein=total_pricein+price_add1;
total_in=total_in+count_total1;
}
fin.close();
cout<<"\t\t所有库存商品总数量:
"<cout<<"\t\t所有库存商品总价值:
"<cout<<"返回上一页请输入:
n";cin>>a;
}
return;
}
classout:
virtualpublicgoods//商品出售类
{
public:
intcount_out;//出售数量
doubleprice_out;//出售价格
doubleprice_addout;
doubleAB;//利润
//staticdoubleAB_total;
out*next;//指向自身的指针
stringtime_out;//出库时间
/////商品出库类构造函数
out(stringno1,stringgname1,stringunit1,stringstandards1,stringbrand1,stringproducetime1,
doubleprice1,stringEXP1,intcount_out1,stringtime_out1,doubleprice_out1):
goods(no1,gname1,unit1,standards1,brand1,producetime1,price1,EXP1)
{
price_out=price_out1;
count_out=count_out1;
time_out=time_out1;
price_addout=count_out*price_out;
AB=price_addout-count_out*price;
//AB_total=AB_total+AB;
}
out(){}
voidshow_out();//出售商品显示函数
voidshowgood_out();//统计出售商品函数
};
voidout:
:
showgood_out(){}//统计出售商品函数
classmanager:
publicin,publicout,publicuser
{
public:
intfirst_face();//登录界面
voidchoose_face1();//界面
voidchoose_face2();//界面
voidchoose_face3();//界面
intadmin_face();//管理员首页
intcommon_face();//普通用户首页
voidgoods_in();//商品添加函数
voidadd_goodsin();//添加入库商品函数
voidgoods_in1();//已有商品入库
voidgoods_out();//出库函数
stringenter(charp);//输入密码函数
voidm_code();//修改密码函数
voiduse_select();//查询所有用户信息函数
voidadmin_use();//用户管理界面函数
voidselect_use();//普通用户查询界面函数
voidselect();//查询
voidselect_no();//按编号查询
voidselect_gname();//按名称查询
voidselect_all();//查询所有信息
voidselect_out();//查询出库信息
voidmodify();//修改页面函数
voidselect_price();//按价格排序函数
intpass();//管理员登录函数
intpass1();//普通用户登录函数
voidadd_user();//新用户注册函数
voidm_gname();//修改商品名称
voidm_standards();//修改商品规格
voidm_unit();//修改商品单位
voidm_brand();//修改商品品牌
voidm_producetime();//修改商品生产日期
voidm_EXP();//修改商品保质期
voidm_price();//修改商品价格
manager(stringno1,stringgname1,stringunit1,stringstandards1,stringbrand1,stringproducetime1,doubleprice1,stringEXP1,intcount_in1,stringtime_in1,intcount_out1,stringtime_out1,doubleprice_out1):
goods(no1,gname1,unit1,standards1,brand1,producetime1,price1,EXP1),in(no1,gname1,unit1,standards1,brand1,producetime1,price1,EXP1,count_in1,time_in1),out(no1,gname1,unit1,standards1,brand1,producetime1,price1,EXP1,count_out1,time_out1,price_out1)
{}
manager(){}
};
//二用户的登录
//1.管理员登录/密码修改
stringmanager:
:
enter(charpwch='*')//输入密码函数
{
constintlength=18;//最大密码长度=18
charpass[length]={0};
for(inti=0;i{
pass[i]=getch();
if(pass[i]=='\r')
{
pass[i]=0;
cout<returnstring(pass);
}
cout<}
cout<returnstring(pass);
}
//2.系统运行时的界面函数
intmanager:
:
first_face()//登陆界面
{
charchoose[2];
intcn=1;
system("cls");
cout<<<<<<<<<<<<cout<";
while
(1)
{
cin>>choose;
cn=atoi(choose);
if(cn<1||cn>4)
cout<<"输入错误,请重新输入:
(1-4)";
elsebreak;
}
returncn;
}
intmanager:
:
pass(){}//管理员登陆函数
intmanager:
:
pass1()//普通用户登录函数
{
stringb,d;chara='y';user*head,*p;head=newuser;p=head;
inti=0;
ifstreamfin("usefile.txt");
if(!
fin)
{
cout<<"\t\t你还没注册,请先注册在登录:
谢谢合作"<exit(0);
}
else
{
fin.close();
system("cls");
do
{
system("cls");
stringnumber1,code1,code_2,name1,sex1,age1,darpt1,photonumber1;boolflage=false;
cout<"<cout<<<<<";
cin>>b;
ifstreamfin("usefile.txt");
while(fin>>number1>>code1>>name1>>sex1>>age1>>darpt1>>photonumber1)
{
if(number1==b){flage=true;break;}
}
if(!
flage){cout<<"该账号不存在,请重新输入!
\n"<cout<cout<";
if(code1==enter())
{
choose_face3();
return0;
}
else
{
cout<\n"<system("pause");
i++;////错误次数计数
}
}while(i<3);
if(i==3)
{
cout<"<exit(0);
}
}
return0;
}
voidmanager:
:
add_user()//新用户注册函数
{
stringnumber1,code1,code2,name1,sex1,age1,darpt1,photonumber1;
chara='y';
while(a=='y'||a=='Y')
{
system("cls");
ofstreamfout_use("usefile.txt",ios:
:
app);
ifstreamfin_use(“usefile.txt”);
cout<<<<<Flag:
<";cin>>number1;while(fin_use>>number2>>code1>>name1>>sex1>>age1>>darpt1>>photonumber1)
{If(number1==number2){cout<<”该账号已存在,请重新输入:
”;gotoflag;}elsecontinue;}
cout<<";code1=enter1();
cout<<";code2=enter1();while(code2!
=code1){cout<<"请重新输入:
";code2=enter1();}
cout<<";cin>>name1;
cout<<";cin>>sex1;
cout<<";cin>>age1;
cout<<";cin>>darpt1;
cout<<";cin>>photonumber1;
cout<<fout_use<<<<<<<cout<fout_use.close();
ifstreamfin("totalfile.txt");
if(!
fin)
{
ofstreamfout("totalfile.txt");
fout<<'\t'<<0<<'\t'<<0<<'\t'<<0<<'\t'<<0<fout.close();
}
ofstreamfout("totalfile.txt",ios:
:
out||ios:
:
app);
fin>>total_use>>total_goods>>total_in>>total_out;
fin.close();
total_use++;
fout<<'\t'<fin.close();
cout<<"\t\t是否还要继续注册:
y/n";cin>>a;
}
}
//三管理员系统功能
intmanager:
:
admin_face()//管理员界面
{
system("cls");
charchoose[2];
intcn=0;
cout<cout<<<<<