服装销售管理系统---课程设计(C/C++简易版)

2023-11-02

目录

        基于大一学期对C/C++的学习做的一个关于实现一个服装销售管理系统的课程设计,强化自己关于面向对象(OOP)编程思想(耗时4~5天左右,功能大抵实现)。

        流程图:

         源代码:

         总结

        基于大一学期对C/C++的学习做的一个关于实现一个服装销售管理系统的课程设计,强化自己关于面向对象(OOP)编程思想(耗时4~5天左右,功能大抵实现)。

        流程图:

         源代码:

//#include "fdefine.h"  //引入含各函数定义的头文件
#include <iostream>
#include <bits/stdc++.h> //万能头文件include <fstream>  文件操作头文件
#include <windows.h>
using namespace std;
//采用类储存数据
class Goods_report;
class Administrator {  //管理员 
public:
    static int adnum;
    string ID;  //ID
    string password;  //密码
    //其他信息
    void setpassword(string pword);
}admin[100];
class Shopkeeper:public Administrator {   //店长公有继承管理员的数据ID与密码)   
public:
    //其他信息
    static int skp;
    void setpassword(string pword);
    void setID(string id);
}shopkeeper[100];
class Seller {  //销售员
public:
    static int snum;
    string ID1;     //营业ID号
    string name;   //姓名
    string ID2;    //所属店长ID号
    //goods* good;   //指向该销售员销售的商品信息
    //其他信息
}seller[100];
class Goods {       //商品           
public:
    static int gnum;
    string name;    //商品名
    string code;     //商品代码
    string producer;  //制造商
    float price; //价格
    friend void print(Goods&a,Goods_report&b);
}goods[100];
class Goods_report { //商品报表
public:
    static int rnum;
    string name;     //商品
    float num;         //商品销售数量
    float money;       //商品销售总额
    void set(float x, float y);
    Goods_report operator+(Goods_report& temp);
    Goods_report operator++();
}report1[100], report2[100];
//初始化各个类的静态变量
int Administrator::adnum = 0;
int Shopkeeper::skp = 0;
int Seller::snum = 0;
int Goods::gnum = 0;
int Goods_report::rnum = 0;
//系统函数
void Delay(int time){
    clock_t  now = clock();
    while (clock() - now < time);
}
void pcout(char x) {
    int i;
    cout << "\t\t\t\t";
    for (i = 0; i < 62; i++) {
        Delay(4);   cout << x;
    }
    cout << '\n';
}
void start() {
    int i;
    cout << "加载中,请稍后";
    for (i = 0; i < 80; i++) {
        Delay(10);   //需要#include<windows.h>
        cout << ".";      
    }
    system("cls");  //清屏
}
//管理员类函数
void Administrator::setpassword(string pword) {
    this->password = pword;
}
//店长类函数
void Shopkeeper::setpassword(string pword) {
    this->password = pword;
}
void Shopkeeper::setID(string id) {
    this->ID = id;
}
//商品信息的函数(含友元函数)
void Goods_report::set(float x, float y) {
    this->num = x;
    this->money = y;
}
void print(Goods& a, Goods_report& b) {
    Delay(7);    cout << "\t\t\t\t" << "该商品的名称为:" << a.name << endl;
    Delay(7);    cout << "\t\t\t\t该商品的制作商为:" << a.producer << endl;
    Delay(7);    cout << "\t\t\t\t该商品的价格为:$" << a.price << endl;
    Delay(7);    cout << "\t\t\t\t" << "该商品的日销售量为:" << b.num << endl;
    Delay(7);    cout << "\t\t\t\t该商品的日销售额为:$" << b.money << endl;
}
Goods_report Goods_report::operator+(Goods_report& temp) {
    Goods_report t;
    t.num = num + temp.num;
    t.money = money + temp.money;
    return t;
}
Goods_report Goods_report::operator++() {
    num++;
    return *this;
}
//从文件中导入数据函数
void inp1(Administrator* p1) {   //管理员模块文件输入
    ifstream infile1("Admin.txt");
    string aID, apassword;
    while (!infile1.eof()) {
        infile1 >> aID >> apassword;
        p1[Administrator::adnum].ID = aID;
        p1[Administrator::adnum].password = apassword;
        Administrator::adnum++;
    }
    infile1.close();
}
void inp2(Shopkeeper* p2) {  //店员模块文件输入
    ifstream infile2("Shopkeeper.txt");
    string bID, bpassword;
    while (!infile2.eof()) {
        infile2 >> bID >> bpassword;
        p2[Shopkeeper::skp].ID = bID;
        p2[Shopkeeper::skp].password = bpassword;
        Shopkeeper::skp++;
    }
    infile2.close();
}
void inp3(Seller* p3) {
    ifstream infile3("Seller.txt");
    string cID1, cname, cID2;
    while (!infile3.eof()) { //销售员模块文件输入
        infile3 >> cID1 >> cname >> cID2;
        p3[Seller::snum].ID1 = cID1;
        p3[Seller::snum].name = cname;
        p3[Seller::snum].ID2 = cID2;
        Seller::snum++;
    }
    infile3.close();
}
void inp4(Goods* p4) { //服装商品模块文件写入
    ifstream infile4("Goods.txt");
    string gname, gcode, gproducer;
    float gprice;
    while (!infile4.eof()) {
        infile4 >> gname >> gcode >> gproducer >> gprice;
        p4[Goods::gnum].name = gname;
        p4[Goods::gnum].code = gcode;
        p4[Goods::gnum].producer = gproducer;
        p4[Goods::gnum].price = gprice;
        Goods::gnum++;
    }
    infile4.close();
}
void inp5(Goods_report* p5, Goods_report* p6) {
    ifstream infile5("Goods_reportday.txt");
    ifstream infile6("Goods_reportmonth.txt");
    string rname;
    float rn, rmoney;
    while (!infile5.eof()) {
        infile5 >> rname >> rn >> rmoney;
        p5[Goods_report::rnum].name = rname;
        p5[Goods_report::rnum].num = rn;
        p5[Goods_report::rnum].money = rmoney;
        infile6 >> rname >> rn >> rmoney;
        p6[Goods_report::rnum].name = rname;
        p6[Goods_report::rnum].num = rn;
        p6[Goods_report::rnum].money = rmoney;
        Goods_report::rnum++;
    }
    infile5.close();
    infile6.close();
}
//文件中做出本次操作修改函数
void outp(Administrator* r1,int n1) {
    ofstream out1("Admin.txt");
    int i;
    for (i = 0; i < n1-1; i++) {
        out1 << r1->ID << " " << r1->password << endl;
        r1++;
    }
    out1.close();
}
void outp(Shopkeeper* r2, int n2) {
    ofstream out2("Shopkeeper.txt");
    int i;
    for (i = 0; i < n2-1; i++) {
        out2 << r2->ID << " " << r2->password << endl;
        r2++;
    }
    out2.close();
}
void outp(Seller* r3, int n3) {
    ofstream out3("Seller.txt");
    int i;
    for (i = 0; i < n3-1; i++) {
        out3 << r3->ID1 << " " << r3->name << " " << r3->ID2 << endl;
        r3++;
    }
    out3.close();
}
void outp(Goods* r4, int n4) {
    ofstream out4("Goods.txt");
    int i;
    for (i = 0; i < n4-1; i++) {
        out4 << r4->name << " " << r4->code << " " << r4->producer << " " << r4->price << endl;
        r4++;
    }
    out4.close();
}
void outp(Goods_report* r5, Goods_report* r6, int n5) {
    ofstream out5("Goods_reportday.txt");
    ofstream out6("Goods_reportmonth.txt");
    int i;
    for (i = 0; i < n5; i++) {
        out5 << r5->name << " " << r5->num << " " << r5->money << endl;
        out6 << r6->name << " " << r6->num << " " << r6->money << endl;
        r5++;
        r6++;
    }
    out5.close();
    out6.close();
}
void sort(Goods *gp,int n) {
    int i, j;
    for (i = 0; i < n - 2; i++)
        for (j = i + 1; j < n - 1; j++)
            if ((gp + i)->code > (gp + j)->code) {
                string t1;
                float t2;
                t1 = (gp + i)->code;
                (gp + i)->code = (gp + j)->code;
                (gp + j)->code = t1;
                t1 = (gp + i)->name;
                (gp + i)->name = (gp + j)->name;
                (gp + j)->name = t1;
                t1 = (gp + i)->producer;
                (gp + i)->producer = (gp + j)->producer;
                (gp + j)->producer = t1;
                t2 = (gp + i)->price;
                (gp + i)->price = (gp + j)->price;
                (gp + j)->price = t2;
            }
}
//不同模块操作函数定义
void changeA(Administrator* p11, int k) {
    string newpassword;
    Delay(7);    cout << "\t\t\t\t" << "请输入您的新密码:";
    cin >> newpassword;
    Delay(7);    p11[k].setpassword(newpassword);    cout << "\t\t\t\t" << "密码修改成功!!!" << endl;
}
void changeS(Shopkeeper* p55, int k) {
    string newpassword;
    Delay(7);    cout << "\t\t\t\t" << "请输入您的新密码:";
    cin >> newpassword;
    p55[k].setpassword(newpassword);
    Delay(7);    cout << "\t\t\t\t" << "密码修改成功!!!" << endl;
}
void addadmin(Administrator* p1) {
    string nID, npassword;
    Delay(7);    cout << "\t\t\t\t" << "请输入新管理员的ID和密码..." << endl;
    Delay(7);    cout << "\t\t\t\t" << "ID:";
    cin >> nID;
    Delay(7);    cout << "\t\t\t\t" << "密码:";
    cin >> npassword;
    p1[Administrator::adnum].ID = nID;
    p1[Administrator::adnum].password = npassword;
    Administrator::adnum++;
    Delay(7);    cout << "\t\t\t\t" << "添加管理员成功!!!" << endl;
}
void addskp(Shopkeeper* p2) {
    string nID, npassword;
    Delay(7);    cout << "\t\t\t\t" << "请输入新销售员的ID和密码..." << endl;
    Delay(7);    cout << "\t\t\t\t" << "ID:";
    cin >> nID;
    Delay(7);    cout << "\t\t\t\t" << "密码:";
    cin >> npassword;
    p2[Shopkeeper::skp].ID = nID;
    p2[Shopkeeper::skp].password = npassword;
    Shopkeeper::skp++;
    Delay(7);    cout << "\t\t\t\t" << "添加店员成功!!!" << endl;
}
void addseller(Seller* p3) {
    string nID1, nID2, nname;
    Delay(7);    cout << "\t\t\t\t" << "请输入新销售员的ID1(所属管理员ID)、ID2和姓名..." << endl;
    Delay(7);    cout << "\t\t\t\t" << "ID1(所属管理员ID):";
    cin >> nID1;
    Delay(7);    cout << "\t\t\t\t" << "ID1(所属店员ID):";
    cin >> nID2;
    Delay(7);    cout << "\t\t\t\t" << "姓名:";
    cin >> nname;
    p3[Seller::snum].ID1 = nID1;
    p3[Seller::snum].ID1 = nID2;
    p3[Seller::snum].name = nname;
    Seller::snum++;
    Delay(7);    cout << "\t\t\t\t" << "添加销售员成功!!!" << endl;
}
void printadmin(Administrator* p33) {
    system("cls");
    cout << "\n\n\n\n";
    pcout('*');
    Delay(7);    cout << "\t\t\t\t" << "*              管理员ID                用户密码              *\n";
    int a;
    for (a = 0; a < Administrator::adnum - 1; a++) {
        Delay(7);   cout << "\t\t\t\t" << "                " << std::left << setw(24) << p33[a].ID << p33[a].password << endl;
    }
    pcout('*');
}
void printgoods(Goods* p44) {
    system("cls");
    cout << "\n\n\n\n";
    pcout('-');
    Delay(7);    cout << "\t\t\t\t" << "| 商品名          商品代码        商品制造商         商品价格 |" << endl;
    int a;
    for (a = 0; a < Goods::gnum - 1; a++) {
        Delay(7);    cout << "\t\t\t\t" << std::left << setw(21) << p44[a].name << setw(17) << p44[a].code << setw(17) << p44[a].producer << p44[a].price << endl;
        pcout('-');
    }
}
void Sprintgoods(Goods* p44) {
    system("cls");
    int a;
    for (a = 0; a < Goods::gnum - 1; a++) {
        cout << "\n\n\n\n";
        Delay(7);    cout << "\t\t\t\t" << "商品名:    " << p44[a].name << endl;
        cout << '\n';
        Delay(7);    cout << "\t\t\t\t" << "商品代码:  " << p44[a].code << endl;
        cout << '\n';
        Delay(7);    cout << "\t\t\t\t" << "商品制造商:" << p44[a].producer << endl;
        cout << '\n';
        Delay(7);    cout << "\t\t\t\t" << "商品价格:  " << p44[a].price << endl;
        cout << "\t\t\t\t";
        system("pause");
        system("cls");
    }
}
void printtype() {
    pcout('*');
    Delay(7);    cout << "\t\t\t\t" << "*                          查看方式                          *\n";
    Delay(7);    cout << "\t\t\t\t" << "********         1.单屏输出        2.多屏输出         ********\n";
    pcout('*');
    Delay(7);    cout << "\t\t\t\t" << "请输入:";
    int v;
    cin >> v; 
    cout << '\n';
    if (v == 1) 
        printgoods(goods);
    else 
        Sprintgoods(goods);
}
void printreport(Goods_report* p77) {
    pcout('*');
    cout << '\n';
    Delay(7);    cout << "\t\t\t\t" << "* 商品名                   销售数量                 总销售额 *" << endl;
    int a;
    for (a = 0; a < Goods_report::rnum; a++) {
        Delay(7);    cout << "\t\t\t\t" << std::left << setw(31) << p77[a].name << setw(23) << p77[a].num << "$" << p77[a].money << endl;
    }
    pcout('*');
}
void printreserve() {
    system("cls");
    cout << "\n\n\n\n";
    pcout('-');
    Delay(7);    cout << "\t\t\t\t" << "| 商品编号                   商品名称                储备数量 |" << endl;
    ifstream fin("Goodsreserve.txt");
    int rid;
    string rename, renum;
    while (!fin.eof()) {
        fin >> rid >> rename >> renum;
        Delay(7);    cout << "\t\t\t\t     " << std::left << setw(24) << rid << setw(25) << rename << "$" << renum << endl;
        pcout('-');
    }
    fin.close();
}
void setskp(Shopkeeper* p66, int k) {
    string nID, npassword;
    Delay(7);    cout << "\t\t\t\t" << "请输入您的新ID和新密码..." << endl;
    Delay(7);    cout << "\t\t\t\t" << "新ID:";
    cin >> nID;
    Delay(7);    cout << "\t\t\t\t" << "新密码:";
    cin >> npassword;
    p66[k].setID(nID);
    p66[k].setpassword(npassword);
    Delay(7);    cout << "\t\t\t\t" << "修改成功!!!" << endl;
}
//登陆菜单界面函数,采用循环式登录方式
int log() { 
    while (1) {
        pcout('*');
        Delay(7);    cout << "\t\t\t\t" << "*                  欢迎进入服装销售系统!                    *\n";
        pcout('*');
        Delay(7);    cout << "\t\t\t\t" << "*                   请选择您的登录身份...                    *\n";
        Sleep(50);    cout << "\t\t\t\t" << "*                                                            *\n";
        Delay(7);
        Delay(7);    cout << "\t\t\t\t" << "*************      1.管理员       2.店员      ****************\n";
        Delay(7);    cout << "\t\t\t\t" << "*************      3.销售员       4.退出      ****************\n";
        pcout('*');
        Delay(7);    cout << "\t\t\t\t" << "请选择:";
        string x;
        cin >> x;
        cout << '\n';
        if (x == "1") 
            return 1;
        else if (x == "2") 
            return 2;
        else if (x == "3") 
            return 3;
        else if (x == "4") 
            return 4;
        try {
            if (x != "1" && x != "2" && x != "3" && x != "4") {
                throw runtime_error("您的输入有误,请输入正确的选项(1/2/3/4),正在为您重新进入系统......."); // 抛出异常
            }  
        }// 执行相应操作
        catch (runtime_error& e) { // 捕获异常,并输出错误信息
            Delay(7);    cout << "\t\t\t\t" << "错误信息:" << e.what() << endl;
            Delay(7);    cout << "\n\n\n\n";
            system("cls");
        }
    }
}
int cb() {
    cout << '\n';
    cout << '\n';
    cout << "\t\t\t\t";
    system("pause");
    pcout('*');
    Delay(7);    cout << "\t\t\t\t" << "*                     请选择您的下一步操作                   *\n";
    Delay(7);    cout << "\t\t\t\t" << "**************    1.返回         2.退出         **************\n";
    pcout('*');
    Delay(7);    cout << "\t\t\t\t" << "请输入:";
    int v;
    cin >> v;
    cout << '\n';
    return v;
}
void save() {
    system("cls");
    cout << "\n\n\n"; 
    pcout('*');
    Delay(7);    cout << "\t\t\t\t" << "*                        是否保存数据                        *\n";
    Delay(7);    cout << "\t\t\t\t" << "**************         1.是        2.否         **************\n";
    pcout('*');
    Delay(7);    cout << "\t\t\t\t" << "请输入:";
    int v;
    cin >> v;
    cout << '\n';
    if (v == 1) {
        outp(admin, Administrator::adnum);
        outp(shopkeeper, Shopkeeper::skp);
        outp(seller, Seller::snum);
        outp(goods, Goods::gnum);
        outp(report1, report2, Goods_report::rnum);
    }
}
void typestyle() {
    inp1(admin); 
    inp2(shopkeeper); 
    inp3(seller); 
    inp4(goods); 
    inp5(report1, report2);
    sort(goods, Goods::gnum - 1); //根据商品编号冒泡排序
    start();
    while (1) {
        int type; //记录用户登录方式
        type = log();
        //管理员模块********************
        if (type == 1) {
            Delay(7);    cout << "\t\t\t\t" << "您选择的登录方式是管理员..." << endl;
            Delay(7);    cout << "\t\t\t\t" << "请输入您的ID和密码..." << endl;
            string id1, password1;
            Delay(7);    cout << "\t\t\t\t" << "ID:";
            cin >> id1;
            Delay(7);    cout << "\t\t\t\t" << "密码:";
            cin >> password1;
            int i, leap = 0, pot;
            for (i = 0; i < Administrator::adnum - 1; i++) {
                if (admin[i].ID == id1 && admin[i].password == password1) {
                    leap = 1;
                    pot = i;
                    break;
                }
            }
            if (leap == 0) {
                Delay(7);    cout << "\t\t\t\t" << "抱歉,输入的用户名或密码错误!没有找到您的信息...正在返回..." << endl;
                cout << "\n\n\n";
                system("pause");
                system("cls");
                continue;
            }
            else {
                int style;
                cout << '\n';
                system("cls");
                cout << "\n\n\n\n";
                pcout('*');
                Delay(7);    cout << "\t\t\t\t" << "*                 欢迎进入,请选择您的下一步操作             *\n";
                Delay(7);    cout << "\t\t\t\t" << "*                                                            *\n";
                Delay(7);    cout << "\t\t\t\t" << "**************    1.修改密码     2.添加用户     **************\n";
                Delay(7);    cout << "\t\t\t\t" << "**************    3.管理员信息   4.商品信息     **************\n";
                Delay(7);    cout << "\t\t\t\t" << "**************    5.返回         6.退出         **************\n";
                pcout('*');
                Delay(7);    cout << "\t\t\t\t" << "请选择:";
                cin >> style;
                cout << '\n';
                if (style == 1) {
                    changeA(admin, pot);
                    int vv = cb();
                    if (vv == 1) {
                        system("cls");
                        continue;
                    }
                    else {
                        system("cls");
                        break;
                    }
                }
                else if (style == 2) {
                    pcout('*');
                    Sleep(200);    cout << "\t\t\t\t" << "*              请选择添加管理员、店员还是销售员:             *\n";
                    Sleep(200);    cout << "\t\t\t\t" << "*             1.管理员      2.店员       3.销售员            *\n";
                    pcout('*');
                    Sleep(200);    cout << "\t\t\t\t" << "请选择:";
                    int kk;
                    cin >> kk;
                    cout << '\n';
                    switch (kk) {
                    case 1:
                        addadmin(admin);
                        break;
                    case 2:
                        addskp(shopkeeper);
                        break;
                    case 3:
                        addseller(seller);
                        break;
                    }
                    int vv = cb();
                    if (vv == 1) {
                        system("cls");
                        continue;
                    }
                    else {
                        system("cls");
                        break;
                    }
                }
                else if (style == 3) {
                    printadmin(admin);
                    int vv = cb();
                    if (vv == 1) {
                        system("cls");
                        continue;
                    }
                    else {
                        system("cls");
                        break;
                    }
                }
                else if (style == 4) {
                    printtype();
                    int vv = cb();
                    if (vv == 1) {
                        system("cls");
                        continue;
                    }
                    else {
                        system("cls");
                        break;
                    }
                }
                else if (style == 5) {
                    system("cls");
                    continue;
                }
                else if (style == 6) {
                    system("cls");
                    break;
                }
            }
        }
        //店员模块**********************
        else if (type == 2) {
            Delay(7);    cout << "\t\t\t\t" << "您选择的登录方式是店员..." << endl;
            Delay(7);    cout << "\t\t\t\t" << "请输入您的ID和密码..." << endl;
            string id, password;
            Delay(7);    cout << "\t\t\t\t" << "ID:";
            cin >> id;
            Delay(7);    cout << "\t\t\t\t" << "密码:";
            cin >> password;
            int i, leap = 0, pot;
            for (i = 0; i < Shopkeeper::skp - 1; i++) {
                if (shopkeeper[i].ID == id && shopkeeper[i].password == password) {
                    leap = 1;
                    pot = i;
                    break;
                }
            }
            if (leap == 0) {
                cout << "\t\t\t\t" << "抱歉,输入的用户名或密码错误!没有找到您的信息...正在返回..." << endl;
                system("pause");
                system("cls");
                continue;
            }
            else {
                int style;
                cout << '\n';
                system("cls");
                cout << "\n\n\n\n";
                pcout('*');
                Delay(7);    cout << "\t\t\t\t" << "*                   欢迎进入,请选择您的下一步操作           *\n";
                Delay(7);    cout << "\t\t\t\t" << "*                                                            *\n";
                Delay(7);    cout << "\t\t\t\t" << "**************    1.修改密码     2.修改个人信息 **************\n";
                Delay(7);    cout << "\t\t\t\t" << "**************    3.商品信息     4.查看报表     **************\n";
                Delay(7);    cout << "\t\t\t\t" << "**************    5.商品储备信息 6.商品销量情况 **************\n";
                Delay(7);    cout << "\t\t\t\t" << "**************    7.返回         8.退出         **************\n";
                pcout('*');
                Delay(7);    cout << "\t\t\t\t" << "请选择:";
                cin >> style;
                cout << '\n';
                if (style == 1) {
                    changeS(shopkeeper, pot);
                    int vv = cb();
                    if (vv == 1) {
                        system("cls");
                        continue;
                    }
                    else {
                        system("cls");
                        break;
                    }
                }
                else if (style == 2) {
                    setskp(shopkeeper, pot);
                    int vv = cb();
                    if (vv == 1) {
                        system("cls");
                        continue;
                    }
                    else {
                        system("cls");
                        break;
                    }
                }
                else if (style == 3) {
                    printtype();
                    int vv = cb();
                    if (vv == 1) {
                        system("cls");
                        continue;
                    }
                    else {
                        system("cls");
                        break;
                    }
                }
                else if (style == 4) {
                    system("cls");
                    cout << "\n\n\n\n";
                    pcout('*');
                    Delay(7);    cout << "\t\t\t\t" << "*                            本日报表                        *\n";
                    cout << "\t\t\t\t" << "*                        日期:2023年6月7日                  *\n";
                    printreport(report1);
                    pcout('*');
                    Delay(7);    cout << "\t\t\t\t" << "*                            本月报表                        *\n";
                    Delay(7);    cout << "\t\t\t\t" << "*                         日期:2023年6月                    *\n";
                    printreport(report2);
                    int vv = cb();
                    if (vv == 1) {
                        system("cls");
                        continue;
                    }
                    else {
                        system("cls");
                        break;
                    }
                }
                else if (style == 5) {
                    printreserve();
                    int vv = cb();
                    if (vv == 1) {
                        system("cls");
                        continue;
                    }
                    else {
                        system("cls");
                        break;
                    }
                }
                else if (style == 6) {
                    system("cls");
                    cout << "\n\n\n";
                    int ii;
                    Goods_report temp1, temp2;
                    temp1.set(0, 0);
                    temp2.set(0, 0);
                    for (ii = 0; ii < Goods_report::rnum - 1; ii++) {
                        temp1 = temp1 + report1[ii];
                        temp2 = temp2 + report2[ii];
                    }
                    pcout('*');
                    Delay(7);    cout << "\t\t\t\t" << "*            本日总销售量            本日销售总额            *\n";
                    Delay(7);    cout << "\t\t\t\t" << std::left << "                 " << setw(24) << temp1.num << temp1.money << endl;
                    Delay(7);    cout << "\t\t\t\t" << "*            本月总销售量            本月销售总额            *\n";
                    Delay(7);    cout << "\t\t\t\t" << std::left << "                 " << setw(24) << temp2.num << temp2.money << endl;
                    pcout('*');
                    int vv = cb();
                    if (vv == 1) {
                        system("cls");
                        continue;
                    }
                    else {
                        system("cls");
                        break;
                    }
                }
                else if (style == 7) {
                    system("cls");
                    continue;
                }
                else if (style == 8) {
                    system("cls");
                    break;
                }   
            }
        }
        //销售员模块********************
        else if (type == 3) {
            Delay(7);    cout << "\t\t\t\t" << "您选择的登录方式是销售员..." << endl;
            Delay(7);    cout << "\t\t\t\t" << "请输入您的姓名、营业号ID和所属店长ID号..." << endl;
            string sname, id1, id2;
            Delay(7);    cout << "\t\t\t\t" << "姓名:";
            cin >> sname;
            Delay(7);    cout << "\t\t\t\t" << "营业号ID:";
            cin >> id1;
            Delay(7);    cout << "\t\t\t\t" << "所属店长ID号:";
            cin >> id2;
            int i, leap = 0, pot;
            for (i = 0; i < Seller::snum - 1; i++) {
                if (seller[i].name == sname && seller[i].ID1 == id1 && seller[i].ID2 == id2) {
                    leap = 1;
                    pot = i;
                    break;
                }
            }
            if (leap == 0) {
                Delay(7);    cout << "抱歉,输入的信息错误!没有找到您的信息...正在返回..." << endl;
                system("pause");
                system("cls");
                continue;
            }
            else {
                int style;
                system("cls");
                cout << '\n';
                pcout('*');
                Delay(7);    cout << "\t\t\t\t" << "*                 欢迎进入,请选择您的下一步操作             *\n";
                pcout('*');
                Delay(7);    cout << "\t\t\t\t" << "*                                                            *\n";
                Delay(7);    cout << "\t\t\t\t" << "**************    1.商品浏览     2.查找商品     **************\n";
                Delay(7);    cout << "\t\t\t\t" << "**************    3.出售商品     4.查看报表     **************\n";
                Delay(7);    cout << "\t\t\t\t" << "**************    5.返回         6.退出         **************\n";
                pcout('*');
                Delay(7);    cout << "\t\t\t\t" << "请选择:";
                cin >> style;
                cout << '\n';
                if (style == 1) {
                    printtype();
                    int vv = cb();
                    if (vv == 1) {
                        system("cls");
                        continue;
                    }
                    else {
                        system("cls");
                        break;
                    }
                }
                else if (style == 2) {
                    Delay(7);    cout << "\t\t\t\t" << "请输入您想要查找的商品编号:";
                    string shopcode;
                    cin >> shopcode;
                    cout << '\n';
                    int si, spot, sleap = 0;
                    for (si = 0; si < Goods::gnum - 1; si++) {
                        if (goods[si].code == shopcode) {
                            sleap = 1;
                            spot = si;
                            break;
                        }
                    }
                    if (sleap == 0) {
                        Delay(7);    cout << "\t\t\t\t" << "抱歉,没有找到该商品的信息...正在返回上级菜单..." << endl;
                        system("cls");
                        continue;
                    }
                    else {
                        print(goods[spot],report1[spot]);
                        int vv = cb();
                        if (vv == 1) {
                            system("cls");
                            continue;
                        }
                        else {
                            system("cls");
                            break;
                        }
                    }
                }
                else if (style == 3) {
                    Delay(7);    cout << "\t\t\t\t" << "请输入您想要出售的商品编号:";
                    string shopcode;
                    cin >> shopcode;
                    int si, spot, sleap = 0;
                    for (si = 0; si < Goods::gnum - 1; si++) {
                        if (goods[si].code == shopcode) {
                            sleap = 1;
                            spot = si;
                            break;
                        }
                    }
                    if (sleap == 0) {
                        Delay(7);    cout << "抱歉,没有找到该商品的信息...正在返回上级菜单..." << endl;
                        system("cls");
                        continue;
                    }
                    else {
                        ++report1[spot];
                        report1[spot].money += goods[spot].price;
                        ++report2[spot];
                        report2[spot].money += goods[spot].price;  //测试cout << report1[spot].money << " " << report1[spot].num;
                        Delay(7);    cout << "\t\t\t\t" << "出售成功!!!您出售了" << goods[spot].name << endl;
                        int vv = cb();
                        if (vv == 1) {
                            system("cls");
                            continue;
                        }
                        else {
                            system("cls");
                            break;
                        }
                    }
                }
                else if (style == 4) {
                    pcout('*');
                    Delay(7);    cout << "\t\t\t\t" << "*                            本日报表                        *\n";
                    Delay(7);    cout << "\t\t\t\t" << "*                        日期:2023年6月7日                  *\n";
                    printreport(report1);
                    pcout('*');
                    Delay(7);    cout << "\t\t\t\t" << "*                            本月报表                        *\n";
                    Delay(7);    cout << "\t\t\t\t" << "*                         日期:2023年6月                    *\n";
                    printreport(report2);
                    int vv = cb();
                    if (vv == 1) {
                        system("cls");
                        continue;
                    }
                    else {
                        system("cls");
                        break;
                    }
                }
                else if (style == 5) {
                    system("cls");
                    continue;
                }
                else if (style == 6) {
                    system("cls");
                    break;
                }
            }
        }
        else if (type == 4) {
            system("cls");
            break;
        }     
    }
    save();
    Delay(7);    cout << "\t\t\t\t" << "****************欢迎下次使用本系统!!!谢谢!!**************\n";
}
int main(){  
    system("color EA");
    typestyle();
    return 0;
}

         代码运行视频见发布视频live.csdn.net/v/306329

         总结

        在课程设计中,不仅学习了C++语言的基础知识,还学习了如何运用C++语言进行面向对象的编程设计。通过本次实验,进一步理解了面向对象程序设计的基本思想与方法,提高了我的程序设计和编程能力。编程之路,道阻且长!

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

服装销售管理系统---课程设计(C/C++简易版) 的相关文章

  • windows软件或程序服务开机自启动的四种方式

    目录 方式一 1 脚本类型1 放入原脚本的快捷方式 脚本类型的 2 脚本类型2 自己写脚本 指向原服务路径 服务或软件类型的 方式二 添加任务计划方式 1 打开计算机管理 2 创建任务 添加任务名称和描述 根据需要随便填写 3 新建触发任务
  • 简单几何图形的识别与标记(opencv)

    一 实现目标 手绘简单几何图形 拍照后处理可识别并标记图形相应关键点 直线 识别并标记始末点 三角形 识别并标记三个角点 矩形 识别并标记四个角点 二 实现流程 通过Python与OpenCV进行编程 采用了获取图形角点数量的方式来识别图形
  • 3-1 客户评级

    某电商要对平台上客户进行评级 按客户的月平均消费情况进行评级 规则如下 输入年度的消费额 根据上表的月平均消费情况输出相应的 数 输入格式 输入年度消费额 输出格式 相应的 数 输入样例 在这里给出一组输入 例如 25000 输出样例 在这

随机推荐

  • nginx热备配置

    nginx热备是指主服务器发生宕机 或者其他原因导致服务不可用时启用备用服务器继续提供服务 下面来看看nginx是怎么配置的 upstream backend server 127 0 0 1 9001 主服务器 server 127 0
  • Ubuntu18.04 LTS下安装Clang

    Ubuntu18 04 LTS下安装Clang 一 在新系统后Ubuntu18 04 LTS下安装Clang会出现依赖缺失的问题 但一步步安装之后依旧是缺失依赖无法安装 正在读取软件包列表 完成 正在分析软件包的依赖关系树 正在读取状态信息
  • 【ML】介绍 PandasAI:生成式 AI Python 库

    大家好 我是Sonhhxg 柒 希望你看完之后 能对你有所帮助 不足请指正 共同学习交流 个人主页 Sonhhxg 柒的博客 CSDN博客 欢迎各位 点赞 收藏 留言 系列专栏 机器学习 ML 自然语言处理 NLP 深度学习 DL fore
  • pm2查看、重启服务和日志

    简单科普 SSH 是一种网络协议 用于计算机之间的加密登录 PM2 是一个守护进程管理器 它将帮助您管理和保持应用程序在线 1 ssh远程登录 ssh hostAddress 通过输入密码 成功会登录到对应主机 如果失败会被拒绝 2 pm2
  • CSS基础学习--25 border(边框)进阶

    一 边框常见属性 border radius box shadow border image 属性 说明 CSS border image 设置所有边框图像的速记属性 3 border radius 一个用于设置所有四个边框 半径属性的速记
  • 15【背景 渐变色】

    26 背景 26 1 背景颜色 background color 属性定义了元素的背景颜色 background color 颜色值 一般情况下元素背景颜色默认值是 transparent 透明 我们也可以手动指定背景颜色为透明色 back
  • 如何做出领导满意的测试报告?Parasoft自动化软件测试数据管理了解一下

    大家在做自动化测试时是如何管理测试数据的呢 测试情况是如何实时把控的呢 对于领导来说 需要的是一份报告 而对于开发测试人员 这份数据报告的内容和形式就非常重要 这里为大家介绍一款专门针对代码级开发测试的数据管理平台 Parasoft DTP
  • HCIP笔记

    HCIP笔记 IERS OSPF协议基础 基于HCIA笔记 链路状态路由协议 OSPF的一些补充 RIP的不足 RIP是基于距离矢量算法的路由协议 RIP协议的组播地址为224 0 0 9 存在收敛速度慢 度量值不科学 扩展性差问题 互联网
  • 物联网毕设分享 火灾报警系统设计与实现

    文章目录 1 简介 2 绪论 2 1 课题背景与目的 3 烟雾传感器介绍 3 1 类型 3 2 MQ系列传感器介绍 3 3 模块介绍 4 系统设计 4 1 自诊断故障报警功能 4 2 烟雾浓度显示 4 3 烟雾报警功能 4 4 防止报警器误
  • 性能测试的方法及步骤

    一 测试方向 总体方向 性能效率测试是通过站在用户体验的角度 使用专业的负载生成设备 在性能模型的基础上验证系统是否能够达到用户提出的性能指标 是否符合用户文档中对系统设计时的性能关注点 在系统正常交互量及峰值交互量的情况下发现系统中存在的
  • Python基础:按位异或 ^ ,按位或

    前言 文的文字及图片来源于网络 仅供学习 交流使用 不具有任何商业用途 版权归原作者所有 如有问题请及时联系我们以作处理 PS 如有需要Python学习资料的小伙伴可以加点击下方链接自行获取http t cn A6Zvjdun 使用按位异或
  • JDK8 JVM参数与实际环境中的优化配置实践

    如何配置我们的JVM呢 首先我们需要知道JVM的参数有哪些 然后根据这些参数的意义去分析自己的程序的JVM需要的配置 可以事先做一些尝试 再逐步调优 这个调优也是一个过程 没有足够的经验而做到一步到位是一件很困难的事情 事情是一点点做的 不
  • 关于内存的编程题,对异常: 0xC0000005 的分析以及解决办法

    一 内存的思考题 请问运行Test函数会有什么样的结果 第一题 void GetMemory char p p char malloc 100 void Test void char str NULL GetMemory str strcp
  • Node.js到底是个啥?干什么用的?优缺点是什么?

    Nodejs简介 Node js是一个Javascript运行环境 runtime 是一个可以快速构建网络服务及应用的平台 是用Javascript语言构建的服务平台 可用于后端建立服务器 Node js与Javascript的区别 nod
  • error: cannot call member function ‘void me::sendMessage()‘ without object

    error cannot call member function void me sendMessage without object 原因分析 解决方案 原因分析 在connect中 传递函数地址不用带括号 参考函数指针的赋值 incl
  • 将tensorflow模型部署到服务器上

    基本思路 利用tensorflow官方提供的tensorflow serving进行部署 同时 为了免去环境配置等麻烦操作 可借助docker容器 一 服务器环境选择 首先肯定要去租一个服务器 例如阿里云 一开始选了window serve
  • C++ 如何调用 通过Boost.python 封装的python函数(安装与配置注意事项)

    一 下载好相匹配的版本python与boost 1 建议使用新版的比较方便 也没有太多的bug 2 我使用的Boost 库是1 82 0 点击下载 Boost 1 82 0 3 使用的是python 3 10 11版本 点击下载 pytho
  • 【代码扫描修复】绝对路径遍历(高危)

    漏洞描述 摘要 允许用户输入控制文件系统操作所用的路径会导致攻击者能够访问或修改其他受保护的系统资源 缺陷描述 当满足以下两个条件时 就会产生路径遍历错误 攻击者可以指定某一文件系统操作中所使用的路径 攻击者可以通过指定特定资源来获取某种权
  • SpringMVC架构浅析

    SpringMVC概述 Spring的web框架围绕DispatcherServlet设计 DispatcherServlet的作用是将请求分发到不同的处理器 Spring的web框架包括可配置的处理器 handler 映射 视图 view
  • 服装销售管理系统---课程设计(C/C++简易版)

    目录 基于大一学期对C C 的学习做的一个关于实现一个服装销售管理系统的课程设计 强化自己关于面向对象 OOP 编程思想 耗时4 5天左右 功能大抵实现 流程图 源代码 总结 基于大一学期对C C 的学习做的一个关于实现一个服装销售管理系统