1、 C+ 课程设计汇报 题 目: 商场营销管理系统类定义、注册新用户、商品入库、商品查询 学生姓名: 伍云 学 号: 17010224 专业班级: 计科09102班 同组姓名: 廖湘桂 指导老师: 易 明 设计时间: 上学期第12周 指导老师意见: 评定成绩: 署名: 日期:商场营销管理系统纲领第一章、 系统步骤设计图。第二章、 功效步骤设计图。第三章、 包含类定义。第四章、 模块源代码。第五章、 运行结果图。第六章、 小结和参考书籍。 第一章、 系统设计商场营销管理系统管理员登陆货物信息修改货物信息查询货物入库管理货物信息删除新货物入库货 物 信 息 管 理货物出库管理按编号查询按名称查询按价
2、格高低输出货物信息统计查询全部出入库信息统计货物总价格统计货物总量修改商品名称规格单位品牌生产日期价格保质期已经有货物入库用户信息管理修改登录密码 第二章、功效步骤设计是否存在此用户?输入用户名注册新用户c返回用户名输入NY输入密码注册成功!图一、用户注册步骤图图2 货物入库步骤图是否新货物?输入商品多种基础信息输入要入库数量输入商品编号入库开始结束NY图3 货物查询步骤图选择查询方法输入查询信息是否库存商品?N输出提醒库存无此商品。Y显示库存商品信息结束基础类定义:#include#include#include#include /setw(),setiosflags(ios:left)us
3、ing namespace std;#include /getch()int total_in=0;int total_goods=0;int total_user=0;int total_out=0;int user_out=0;double total_pricein=0;double AB_total=0;class in;class out;class goods /商品类public:goods *next; string no; /编号string gname; /名称string unit; /单位string standards; /规格string brand; /品牌str
4、ing producetime; /生产日期double price; /价格string EXP;/保质期void show();/void showa(goods *p);/商品类结构函数goods(string no1,string gname1,string unit1,string standards1,string brand1,string producetime1, double price1,string EXP1)no = no1; gname = gname1; unit = unit1; standards = standards1; brand = brand1; p
5、roducetime = producetime1; price = 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 number1,string code1,string code2,string name1,st
6、ring 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; /数量 int count_total;double price_add;string time_in; /入库时间in *next; /指向本身指针/商品入库类结构函数in
7、(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, standards1, brand1, producetime1 , price1,EXP1)count_in = count_in1;price_add=price*count_in;time_in = time_in1;count_total=co
8、unt_total+count_in;in():goods();void show_in();void showcount_in();void in:showcount_in() /统计入库商品总数量函数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输出全部库存商品
9、基础信息及统计总商品量:no1gname1price1count_intime_in1count_total1)coutt编号:no1|t名称:gname1|t价格:price1|t此商品库存总数量:count_total1|;price_add1=price1*count_total1;coutt此商品库存总价值:price_add1endl; total_pricein=total_pricein+price_add1;total_in=total_in+count_total1;fin.close(); couttt全部库存商品总数量:total_inendl; couttt全部库存商品
10、总价值:total_priceinendl; couta;return;class out:virtual public goods /商品出库类public:int count_out;/数量double price_out;double price_addout;double AB;/static double AB_total;out *next; /指向本身指针string time_out; /出库时间/商品出库类结构函数out(string no1,string gname1,string unit1,string standards1,string brand1,string p
11、roducetime1,double price1,string EXP1,int count_out1,string time_out1,double price_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_to
12、tal=AB_total+AB;out()void show_out(); 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输出全部出库商品基础信息及统计出库商品所取得总利润:no1gname1price
13、1price_out1count_out1time_out1)cout编号:no1|名称:gname1|数量:count_out1|时间:time_out1|成本价格:price1|出售价格:price_out1|;AB1=count_out1*(price_out1-price1); cout利润:AB1endl;AB_total=AB_total+AB1;fin.close();coutt出库商品所取得总利润:AB_totalendl;couta;return;class manager:public in,public out,public userrpublic:int first_f
14、ace(); /界面void choose_face1(); /界面void choose_face2(); /界面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_select();void admin
15、_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_price(); /统计库存商品总价格 void add_count(); /统计库存商品总量int pass();/密码登录函数int pass1();void add_userr(
16、);void m_gname(); /修改商品名称void m_standards(); /修改商品规格void m_unit(); /修改商品单位void m_brand(); /修改商品品牌void m_producetime(); /修改商品生产日期void m_EXP(); /修改商品保质期void m_price(); /修改商品价格void list_in(); /商品入库从文件读数据到内存生成链表void list_out(); /商品出库从文件读数据到内存生成链表void write(); /将链表写入文件manager(string no1,string gname1,str
17、ing unit1,string standards1,string brand1,string producetime1,double price1,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 ,
18、price1,EXP1,count_in1,time_in1),out(no1, gname1, unit1, standards1, brand1, producetime1 , price1,EXP1,count_out1,time_out1,price_out1)manager();/1.系统运行时界面函数int manager:first_face() /登陆界面char choose2;int cn = 1;system(cls); coutendl tt endl tt endl tt -欢迎使用商品市场营销登录系统- endl tt endl tt 1. 管理员登陆 endl t
19、t endl tt 2. 一般用户登陆 endl tt endl tt 3. 新用户注册 endl tt endl tt 4. 退出系统 endltt endl endl tt; coutendlchoose;cn = atoi(choose);if(cn4) cout输入错误,请重新输入:(1-4) ;else break;return cn;string manager:enter(char pwch=*) /密码const int length = 18; /最大密码长度=18char passlength = 0;for(int i=0;ilength-1;i+) passi = ge
20、tch();if(passi=r)passi = 0;coutendl;return string(pass);coutpwch;coutendl;return string(pass);void manager:add_userr()string number1,code1,code2, name1,sex1,age1,darpt1,photonumber1;char a=y;while(a=y|a=Y)system(cls);ofstream fout_user(userfile.txt,ios:app);coutendl tt endl tt endl tt -欢迎进入新用户注册系统-
21、endl tt endl tt-请输入用户注册基础信息- endl number1;coutendl tt endl tt 密码:;code1=enter1();coutendl tt endl tt 确定密码:;code2=enter1();while(code2!=code1)cout请重新输入:;code2=enter1();coutendl tt endl name1;coutendl tt endl sex1;coutendl tt endl age1;coutendl tt endl darpt1;coutendl tt endl photonumber1;coutendl tt
22、endl tt;fout_usersetw(10)number1tsetw(10)code1tsetw(10)name1tsetw(10)sex1tsetw(10)age1tsetw(10)darpt1tsetw(10)photonumber1endl;coutendl tt -恭喜你注册成功- endl;fout_user.close();ifstream fin(totalfile.txt);if(!fin) ofstream fout(totalfile.txt); foutt0t0t0t0total_usertotal_goodstotal_intotal_out;fin.close(
23、);total_user+;foutttotal_userttotal_goodsttotal_inttotal_outendl;fin.close();couta;int manager:admin_face() /管理员界面system(cls);char choose2;int cn = 0;coutendl;coutendl tt endl tt endl tt -欢迎使用商品管理系统- endl tt endl tt 1. 商品储存管理 endl tt endl tt 2. 商品出售管理 endl tt endl tt 3. 查询统计 endl tt endl tt 4. 商品信息修
24、改 endl tt endl tt 5. 用户管理 endl tt endl tt 6. 返回 endl tt endltt endl endl tt;coutendlchoose;cn = atoi(choose);if(cn6) coutendlt输入错误,请重新输入:(1-6) ;else break;return(cn);void manager:choose_face2() /选择界面while(1)switch(admin_face()case 1: choose_face1(); break; case 2: goods_out();break; case 3: select()
25、; break; case 4: modify(); break; case 5: admin_user(); break; case 6: return;void manager:admin_user()system(cls);char choose2;int cn = 0;coutendl;coutendl tt endl tt endl tt -欢迎使用用户管理系统- endl tt endl tt 1. 查询全部用户信息 endl tt endl tt 2. 修改用户密码 endl tt endl tt 3. 返回上一页 endl tt endltt endl endl tt;cout
26、endlchoose;cn = atoi(choose);if(cn3) coutendlt输入错误,请重新输入:(1-3) ;else break;switch(cn)case 1: user_select();break;case 2: m_code(); break;case 3: return;void manager:user_select()system(cls);string number1,code1,code_2,name1,sex1,age1,darpt1,photonumber1;char a=y;ifstream fin(userfile.txt);if(!fin)co
27、ut此时无用户:endl;exit(0);while(a=y)couttt全部用户信息:number1code1name1sex1age1darpt1photonumber1)cout账号:number1| 密码:code1|姓名:name1|性别:sex1|年纪:age1|工作单位:darpt1|联络电话:photonumber1endl;total_user+;fin.close();couttt目前全部用户总数量:total_userendl;couta;void manager:choose_face1() /选择界面int cn = 0;char choose3;while (1)
28、system(cls); cout endl endl; cout t= endl t| endl t| -商品储存管理- | endl t| endl t| 1. 新商品添加 | endl t| endl t| 2. 已经有入库商品 | endl t| endl t| 3. 添加入库商品 | endl t| endl t| 4. 返回 | endl t| endl t= endl endl tt; coutendlchoose;cn = atoi(choose);if(cn4) coutendlt输入错误,请重新输入:(1-4) ;else break;switch (cn) case 1:
29、 goods_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;string b=yes;while(a=y)system(cls);ifstream fin(goodsfile.txt);ofstream fout(goodsfile.txt,ios:app);cout请输入新商品信息:endl; flag1:coutno1;while(finno2gname1unit1standards1brand1producetime1price1EXP1)if(no1=no2)cout该商品已存在请重新输入:;goto flag1;coutgname1;coutunit1;coutstandards1;coutbrand1;coutproducetime1;coutprice1;coutEXP1;foutsetw(10)no1tsetw(10)gname1t