1、using namespace std;conio.h /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;
2、/品牌 string 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; bra
3、nd = brand1; producetime = producetime1; price = price1; EXP = EXP1; total_goods+; goods();class userr/用户类 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 co
4、de2,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 /商品入库类 int count_in; /数量 int count_total; double price_add; string time_in; /入库时间 in *next; /指
5、向自身的指针 /商品入库类构造函数 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, standards1, brand1, producetime1 , price1,EXP1) count_in = count_in1; price_add=price*count_in; time_in =
6、 time_in1; count_total=count_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此时库存里无商品:nex
7、it(0); while(a=) coutno1gname1price1count_intime_in1count_total1) coutt编号:no1| t名称:gname1t价格:price1t此商品库存总数量:count_total1 price_add1=price1*count_total1;t此商品库存总价值:price_add1 total_pricein=total_pricein+price_add1; total_in=total_in+count_total1; fin.close();tt所有库存商品总数量:total_intt所有库存商品总价值:total_pric
8、eina; return;class out:virtual public goods /商品出库类 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 producetime1, double price1,st
9、ring EXP1,int count_out1,string time_out1,double price_out1): 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(); void showgood_out();void out:showgood_out() string no1,gn
10、ame1,time_out1,time_in1;double price1,price_out1,AB1;int count_out1;goods_outfile.txt此时无出库记录:输出所有出库商品基本信息及统计出库商品所获得的总利润:price_out1count_out1time_out1)编号:名称:数量:count_out1时间:time_out1成本价格:出售价格:price_out1AB1=count_out1*(price_out1-price1);利润:AB1 AB_total=AB_total+AB1;coutt出库商品所获得的总利润:AB_totalclass mana
11、ger:public in,public out,public userr int first_face(); /界面 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
12、m_code(); /修改密码函数 void user_select(); 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_price(); /统计库存商品总价格 void add_count(
13、); /统计库存商品总量 int pass();/密码登录函数 int pass1(); void add_userr(); 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(); /商品出库从文
14、件读数据到内存生成链表 void write(); /将链表写入文件 manager(string no1,string gname1,string 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 ,
15、 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. 系统运行时的界面函数int manager:first_face() /登陆界面 char choose2; int cn = 1;endl tt tttt -
16、欢迎使用商品市场营销登录系统- tt 1. 管理员登陆 tt 2. 普通用户登陆 tt 3. 新用户注册 tt 4. 退出系统 endl choose; cn = atoi(choose); if(cn4) cout输入错误,请重新输入:(1-4) else break; return cn;string manager:enter(char pwch=*) /密码 const int length = 18; /最大密码长度=18 char passlength = 0; for(int i=0;ilength-1;i+) passi = getch(); if(passi=r passi
17、= 0; return string(pass); pwch; return string(pass);void manager:add_userr() string number1,code1,code2, name1,sex1,age1,darpt1,photonumber1; char a=|a=Y system( ofstream fout_user(userfile.txt,ios:app);tt tt -欢迎进入新用户注册系统- tt-请输入用户注册基本信息- tt 账号:number1;tt 密码:code1=enter1();tt tt 确认密码:code2=enter1();
18、while(code2!=code1)cout请重新输入:tt 姓名:name1;tt 性别:sex1;tt 年龄:age1;tt 工作单位:darpt1;tt 联系电话:photonumber1; fout_usersetw(10)number1tcode1name1sex1age1darpt1photonumber1tt -恭喜你注册成功- fout_user.close(); ifstream fin(totalfile.txt if(!fin) ofstream fout( fout0total_usertotal_goodstotal_intotal_out; fin.close()
19、; total_user+;total_usertotal_goodstotal_outtt是否还要继续注册:y/nadmin_face() /管理员界面 int cn = 0;tt -欢迎使用商品管理系统- tt 1. 商品储存管理 tt 2. 商品出售管理 tt 3. 查询统计 tt 4. 商品信息修改 tt 5. 用户管理 tt 6. 返回 tt请选择(1-6):6) coutt输入错误,请重新输入:(1-6) return(cn);choose_face2() /选择界面 switch(admin_face() case 1: choose_face1(); break; case 2: goods_out(); case 3: selec
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1