1、 C++ 课程设计报告 题 目: 商场营销管理系统——类定义、注册新用户、商品入库、商品查询 学生姓名: 伍云 学 号: 200917010224 专业班级: 计科09102班 同组姓名: 廖湘桂 指导教师: 易 明
2、 设计时间: 2010年上学期第1~2周 指导老师意见: 评定成绩: 签名: 日期: 商场营销管理系统大纲 第一章、 系统流程设计图。 第二章、 功能流程设计图。 第三章、 涉及类的定义。 第四章、 模块源代码。 第五章、 运行结果图。 第六章、 小结与参考书籍。 第一章、 系统设计 商场营销管理系统 管理员登陆 货物信息 修改 货物信息查询 货 物 入
3、 库 管理 货物信息删除 新货物入库 货 物 信 息 管 理 货 物 出 库 管理 按编号查询 按 名称查询 按价格高低输出 货物信息统计 查询所有出入库信息 统计货物总价格 统计货物总量 修改商品名称规格单位品牌生产日期价格保质期 已有货物入库 用户信息管理 修改登录密码 第二章、功能流程设计 是否存在此用户? 输入用户名 注册新用户 c 返回用户名输入 N Y 输入密码 注册成功!
4、
图一、用户注册流程图
图2 货物入库流程图
是否新货物?
输入商品各种基本信息
输入要入库数量
输入商品编号
入库开始
结束
N
Y
图3 货物查询流程图
选择查询方式
输入查询信息
是否库存商品?
N
输出提示库存无此商品。
Y
显示库存商品信息
结束
基础类的定义:
#include
5、setw(),setiosflags(ios::left)
using namespace std;
#include
6、 no; //编号 string gname; //名称 string unit; //单位 string standards; //规格 string brand; //品牌 string producetime; //生产日期 double price; //价格 string EXP;//保质期 void show(); //void showa(goods *p); ///商品类构造函数 goods(string no1,string gname1,stri
7、ng unit1,string standards1,string brand1,string producetime1, double price1,string EXP1) { no = no1; gname = gname1; unit = unit1; standards = standards1; brand = brand1; producetime = producetime1; price =
8、price1; EXP = EXP1; total_goods++; } goods(){} }; class userr//用户类 { public: userr *next; string number; string code; string code_1; string name; string sex; string age; string darpt; string photonumber; string enter1(char p); userr(string num
9、ber1,string code1,string code2,string name1,string sex1,string darpt1,string photonumber1) :number(number1),code(code1),code_1(code2),name(name1),sex(sex1),darpt(darpt1),photonumber(photonumber1){} userr(){} }; class in:virtual public goods //商品入库类 { public: int count_in; //数量
10、 int count_total; double price_add; string time_in; //入库时间 in *next; //指向自身的指针 /////商品入库类构造函数 in(string no1,string gname1,string unit1,string standards1,string brand1,string producetime1, double price1,string EXP1,int count_in1,string time_in1):goods(no1, gname1, unit1, st
11、andards1, 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(){}; void show_in(); void showcount_in(); }; void in::showcount_in() //统计入库商品总数量
12、函数
{
system("cls");
string no1;string gname1;double price1;int count_total1; string time_in1;double price_add1;char a='y';
ifstream fin("goods_infile.txt");
if(!fin) {cout<<"此时库存里无商品:\n";exit(0);}
while(a=='y')
{
cout<<"输出所有库存商品基本信息及统计总商品量:"<
13、e1>>count_in>>time_in1>>count_total1)
{
cout<<"\t编号:"< 14、l_in=total_in+count_total1;
}
fin.close();
cout<<"\t\t所有库存商品总数量:"< 15、ddout;
double AB;
//static double AB_total;
out *next; //指向自身的指针
string time_out; //出库时间
/////商品出库类构造函数
out(string no1,string gname1,string unit1,string standards1,string brand1,string producetime1,
double price1,string EXP1,int count_out1,string time_out1,double price_out 16、1):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(){}
void show_out();
17、
void showgood_out();
};
void out::showgood_out()
{
system("cls");
string no1,gname1,time_out1,time_in1;double price1,price_out1,AB1;int count_out1;char a='y';
ifstream fin("goods_outfile.txt");
if(!fin) {cout<<"此时无出库记录:\n";exit(0);}
while(a=='y')
{
cout<<"输出所有出库商品基本信息及统计出库商品所获得 18、的总利润:"< 19、cout<<"利润:"< 20、/界面
void choose_face3(); //界面
int admin_face(); //首页
int common_face(); //界面
void goods_in(); //商品添加函数
void add_goodsin(); //添加入库商品函数
void goods_in1(); //已有商品入库
void goods_out(); //出库函数
string enter(char p);
void m_code(); //修改密码函数
void user_sele 21、ct();
void admin_user();
void select_user();
void select(); //查询
void select_no(); //按编号查询
void select_gname(); //按名称查询
void select_all(); //查询所有信息
void select_out(); //查询出库信息
void modify(); //修改页面函数
void select_price(); //按价格排序函数
void add_ 22、price(); //统计库存商品总价格
void add_count(); //统计库存商品总量
int pass();//密码登录函数
int pass1();
void add_userr();
void m_gname(); //修改商品名称
void m_standards(); //修改商品规格
void m_unit(); //修改商品单位
void m_brand(); //修改商品品牌
void m_producetime(); //修改商品生产日期
voi 23、d m_EXP(); //修改商品保质期
void m_price(); //修改商品价格
void list_in(); //商品入库从文件读数据到内存生成链表
void list_out(); //商品出库从文件读数据到内存生成链表
void write(); //将链表写入文件
manager(string no1,string gname1,string unit1,string standards1,string brand1,string producetime1,double pric 24、e1,string EXP1,int count_in1,string time_in1,int count_out1,string time_out1,double price_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, brand 25、1, producetime1 , price1,EXP1,count_out1,time_out1,price_out1)
{}
manager(){}
};
//1. 系统运行时的界面函数
int manager::first_face() //登陆界面
{
char choose[2];
int cn = 1;
system("cls");
cout< 26、录系统---- ◆"
< 27、 28、length = 18; //最大密码长度=18
char pass[length] = {0};
for(int i=0;i 29、er1,code1,code2, name1,sex1,age1,darpt1,photonumber1;
char a='y';
while(a=='y'||a=='Y')
{
system("cls");
ofstream fout_user("userfile.txt",ios::app);
cout< 30、户注册系统---- ◆"
< 31、 "
< 32、别:";cin>>sex1;
cout< 33、n>>photonumber1;
cout< 34、
< 35、out("totalfile.txt",ios::out||ios::app);
fin>>total_user>>total_goods>>total_in>>total_out;
fin.close();
total_user++;
fout<<'\t'< 36、e() //管理员界面
{
system("cls");
char choose[2];
int cn = 0;
cout< 37、l <<"\t\t◆ 2. 商品出售管理 ◆"
< 38、<"\t\t◆ 6. 返回 ◆"
< 39、cn);
}
void manager::choose_face2() //选择界面
{
while(1)
{
switch(admin_face())
{
case 1: choose_face1();
break;
case 2: goods_out();
break;
case 3: select();
break;
case 4: modify();
break;
case 5: admin_user();
break;
case 6: return; 40、
}
}
}
void manager::admin_user()
{
system("cls");
char choose[2];
int cn = 0;
cout< 41、 ◆"
< 42、in>>choose;
cn = atoi(choose);
if(cn<1||cn>3) cout< 43、arpt1,photonumber1;char a='y';
ifstream fin("userfile.txt");
if(!fin)
{
cout<<"此时无用户:"< 44、<<"||"
<<"姓名:"< 45、面
{
int cn = 0;
char choose[3];
while (1)
{
system("cls");
cout << endl << endl;
cout << "\t======================================" << endl
<< "\t|" << endl
<< "\t| -------商品储存管理------- |" << endl
<< "\t|" << endl
<< "\t| 46、 1. 新商品添加 |"<< endl
<< "\t|" << endl
<< "\t| 2. 已有入库商品 |"<< endl
<< "\t|" << endl
<< "\t| 3. 添加入库商品 |"<< endl
<< "\t|" << endl
<< "\t| 4. 返回 |"<< endl
<< "\ 47、t|" < 48、in();
break;
case 2:
goods_in1();
break;
case 3:
add_goodsin();
case 4:
return;
}
}
}
void manager::goods_in()//添加新商品函数
{
system("cls");
bool flag=false;
string no1,gname1,unit1,standards1,brand1,producetime1,EXP1,no2;
double price1;
char a='y'; 49、string b="yes";
while(a=='y')
{
system("cls");
ifstream fin("goodsfile.txt");
ofstream fout("goodsfile.txt",ios::app);
cout<<"请输入新商品信息:"< 50、
{cout<<"该商品已存在请重新输入:";goto flag1;}
}
cout<<"名称:";cin>>gname1;
cout<<"单位:";cin>>unit1;
cout<<"规格:";cin>>standards1;
cout<<"品牌:";cin>>brand1;
cout<<"生产日期:";cin>>producetime1;
cout<<"价格:";cin>>price1;
cout<<"保质期:";cin>>EXP1;
fout<






