c++ 課程設計 ——公司設備管理系統

寫了幾天的課程設計啊,終於感覺能拿出手了!!

感覺寫完之後對c++面相對象的思想又有了一點新的感悟了,要想學好一門語言還是得多寫代碼!

vip 管理員賬號:admin   密碼:123456

普通管理員的賬戶可以由vip管理員添加

#include<iostream>
#include<string>
#include<cstring>
#include <iomanip>
#include <cstdlib>
#include<conio.h>
#include<fstream>
#include<windows.h>
using namespace std;
#define H "----------------------------------------------------------------\n"
#define H1 "|   編號    |     類別  |    名稱    |    價格    |  庫存數量  |\n"
#define H2 "|-----------|-----------|------------|------------|------------|\n"
#define H3 "--------------------------\n"
#define H4 "|   賬號    |    密碼    |\n"
#define H5 "|-----------|------------|\n"
class machine
{
public:
     machine();
	 machine(string a,string b,string c,double d,int e);
	 //char inter_face();//首頁
     void add();//添加數據
     void dele();//刪除數據
     void show();//顯示所有
     void alter();//修改數據
     void select();//查詢數據
     void save_new();//保存新增加數據
private:
	string num;
	string category;
	string name;
	double price;
	int quantity;
};
class account
{
public:
    account();
    char home_face();
	virtual void entrance();
   // void enter;
private:
    string id;
    string password;
};
class admin:public account
{
public:
   admin();
   virtual void admin_enter();
   void entrance();
private:
    string id;
    string password;
};
class vip:public admin
{
public:
	vip();
	void vip_enter();
	void entrance();
	void inter_face();//首頁
    void add();//添加數據
    void dele();//刪除數據
    void show();//顯示所有
    void alter();//修改數據
    void select();//查詢數據
    void save_new();//保存新增加數據
private:
    string id;
    string password;
};
machine::machine()
{
	 num=" ";
	 category=" ";
	 name=" ";
	 price=0;
	 quantity=0;
}
account::account()
{
	id=" ";
	password=" ";
}
admin::admin()
{
	id=" ";
	password=" ";
}
vip::vip()
{
	id="admin";
	password="123456";
}
void account::entrance()
{
	system("color 0b");
    char n;
    machine m;
	while(1)
	{
    system("cls");
    cout <<endl;
	cout<<"\t\t  O(∩_∩)O~~ 歡迎進入南陽康佳公司的設備管理系統\n\n";
    cout<<"\t\t╔*☆***◎***◇***☆*** 菜單 ***☆***◇***◎***☆*╗\n";
    cout<<"\t\t|★|\t\t               \t\t\t|★|\n";
	cout<<"\t\t|☆|\t\t               \t\t\t|☆|\n";
	cout<<"\t\t|★|\t\t 1.設備信息顯示\t\t\t|★|\n";
    cout<<"\t\t|☆|\t\t 2.設備信息查詢\t\t\t|☆|\n";
	cout<<"\t\t|★|\t\t 3.返回        \t\t\t|★|\n";
	cout<<"\t\t|☆|\t\t               \t\t\t|☆|\n";
	cout<<"\t\t|★|\t\t               \t\t\t|★|\n";
	cout<<"\t\t|☆|\t\t               \t\t\t|☆|\n";
	cout<<"\t\t╚*☆***◎***◇****☆****★****☆****◇***◎***☆*╝\n\n";
    cout<<"\t\t請選擇您要實現的功能選項 (1-3): [ ]\b\b";
	while(1)
	{
		cin>>n;getchar();
		if(n<'1'||n>'3')
			printf("輸入錯誤,請您重新輸入選項(1-3):[ ]\b\b");
		else
			break;
	}
	if(n=='1') {m.show();}
	if(n=='2') m.select();
	if(n=='3') return;
	}
}
void admin::admin_enter()
{
    string pp;
	char m;
	admin Admin;
	system("cls");
	cout<<endl<<endl<<endl;
	cout<<"\t\t O(∩_∩)O~~ 歡迎進入南陽康佳公司的設備管理系統\n\n\n";
   while(1)
   {
	ifstream inData("e:\\Document.txt",ios::in);
   cout<<"\t\t 請輸入您的管理員賬號:\n\t\t  (若返回上一個頁面,請輸入#號)"<<endl;
   cout<<"\t\t ";
   cin>>pp;
    if (!inData)
    {
        cout <<endl <<"\n對不起!賬號不存在" <<endl;
        system("pause");
        return;
    }
   if(pp=="#") return;
    string qq;
    l:; cout<<"\t\t 請輸入您的密碼:\n";
    cout<<"\t\t ";
    while(1)
    {
       m=getch();
       if(m==13) break;
       if(m!=8) qq+=m;
       if(m==8) {cout<<endl;goto l;}
       cout<<"*";
    }
    bool flag =true;
    string str;
    while (inData>>id>>password)
    {
        getline(inData, str);
        if (id==pp)
        {
			flag = false;
			if(password==qq)
			{
                 Admin.entrance();
                 return;
			}
            else
             cout<<"\n\t\t    對不起!密碼錯誤!!\n"<<endl;
        }
    }
    if(flag)
    {
        cout<<"\n\t\t    對不起!賬號不存在!!\n"<<endl;
        //system("pause");
    }

   }

}
void vip::vip_enter()
{
   string pp;
   char m;
   vip VIP;
   admin Admin;
   system("cls");
   cout<<endl<<endl;
   cout<<"\t\t O(∩_∩)O~~ 歡迎進入南陽康佳公司的設備管理系統\n\n\n";
   while(1)
   {
   cout<<"\t\t   請輸入您的vip管理員賬號:\n\t\t     (若返回上一個頁面,請輸入#號)"<<endl;
   cout<<"\t\t   ";
   cin>>pp;
   getchar();
   if(pp=="#") return;
   if(pp==VIP.id)
   {
	   L:;cout<<"\t\t   請輸入您的密碼:"<<endl;
	   cout<<"\t\t   ";
       string qq;
       while(1)
       {
       m=getch();
       if(m==13) break;
       if(m!=8) qq+=m;
       if(m==8)
        {
            cout<<endl;goto L;
        }
       cerr<<"*";
       }
	   if(qq==VIP.password)
	   {
		   VIP.entrance();
		   break;
	   }
	   else
	   {
		  cout<<"\n\t\t    對不起!密碼錯誤!!\n"<<endl;
	   }
   }
   else
   {
          cout<<"\t\t    對不起!賬號不存在!!\n"<<endl;
   }
   }
}
void admin::entrance()
{
   system("color 0c");
   char n;
    machine Machine;
	account Account;
	while(1)
	{
    system("cls");
    cout <<endl;
	cout<<"\t\t  O(∩_∩)O~~ 歡迎進入南陽康佳公司的設備管理系統\n\n";
    cout<<"\t\t╔*☆***◎***◇***☆*** 菜單 ***☆***◇***◎***☆*╗\n";
    cout<<"\t\t|★|\t\t               \t\t\t|★|\n";
	cout<<"\t\t|☆|\t\t 1.設備信息錄入\t\t\t|☆|\n";
	cout<<"\t\t|★|\t\t 2.設備信息顯示\t\t\t|★|\n";
    cout<<"\t\t|☆|\t\t 3.設備信息查詢\t\t\t|☆|\n";
	cout<<"\t\t|★|\t\t 4.設備信息修改\t\t\t|★|\n";
	cout<<"\t\t|☆|\t\t 5.設備信息刪除\t\t\t|☆|\n";
	cout<<"\t\t|★|\t\t 6.返回\t\t\t\t|★|\n";
	cout<<"\t\t|☆|\t\t               \t\t\t|☆|\n";
	cout<<"\t\t╚*☆***◎***◇****☆****★****☆****◇***◎***☆*╝\n\n";
    cout<<"\t\t請選擇您要實現的功能選項 (1-6): [ ]\b\b";
	while(1)
	{
		cin>>n;getchar();
		if(n<'1'||n>'6')
			printf("輸入錯誤,請您重新輸入選項(1-6):[ ]\b\b");
		else
			break;
	}
    switch(n)
	{
    case '1':Machine.add();break;
	case '2':Machine.show();break;
	case '3':Machine.select();break;
	case '4':Machine.alter();break;
	case '5':Machine.dele();break;
    case '6':return;
	}
	}
}
void vip::entrance()
{
   system("color 0e");
    char n;
    machine Machine;
	vip VIP;
	while(1)
	{
    system("cls");
    cout <<endl;
	cout<<"\t\t  O(∩_∩)O~~ 歡迎進入南陽康佳公司的設備管理系統\n\n";
    cout<<"\t\t╔*☆***◎***◇***☆*** 菜單 ***☆***◇***◎***☆*╗\n";
    cout<<"\t\t|★|\t\t                    \t\t|★|\n";
	cout<<"\t\t|☆|\t\t1.設備信息錄入      \t\t|☆|\n";
	cout<<"\t\t|★|\t\t2.設備信息顯示      \t\t|★|\n";
    cout<<"\t\t|☆|\t\t3.設備信息查詢      \t\t|☆|\n";
	cout<<"\t\t|★|\t\t4.設備信息修改      \t\t|★|\n";
	cout<<"\t\t|☆|\t\t5.設備信息刪除      \t\t|☆|\n";
	cout<<"\t\t|★|\t\t6.編輯管理員信息    \t\t|★|\n";
	cout<<"\t\t|★|\t\t7.返回              \t\t|★|\n";
	cout<<"\t\t|☆|\t\t                    \t\t|☆|\n";
	cout<<"\t\t╚*☆***◎***◇****☆****★****☆****◇***◎***☆*╝\n\n";
    cout<<"\t\t請選擇您要實現的功能選項 (1-7): [ ]\b\b";
	while(1)
	{
		cin>>n;getchar();
		if(n<'1'||n>'7')
			printf("輸入錯誤,請您重新輸入選項(1-7):[ ]\b\b");
		else
			break;
	}
    switch(n)
	{
    case '1':Machine.add();break;
	case '2':Machine.show();break;
	case '3':Machine.select();break;
	case '4':Machine.alter();break;
	case '5':Machine.dele();break;
	case '6':VIP.inter_face();break;
    case '7':return;
	}
	}
}
void vip::inter_face()
{
   system("color 0c");
   char n;
    vip VIP;
	account Account;
	while(1)
	{
    system("cls");
    cout <<endl;
	cout<<"\t\t  O(∩_∩)O~~ 歡迎進入南陽康佳公司的設備管理系統\n\n";
    cout<<"\t\t╔*☆***◎***◇***☆*** 菜單 ***☆***◇***◎***☆*╗\n";
    cout<<"\t\t|★|\t\t                       \t\t|★|\n";
	cout<<"\t\t|☆|\t\t 1.管理員信息錄入      \t\t|☆|\n";
	cout<<"\t\t|★|\t\t 2.管理員信息顯示      \t\t|★|\n";
    cout<<"\t\t|☆|\t\t 3.管理員信息查詢      \t\t|☆|\n";
	cout<<"\t\t|★|\t\t 4.管理員信息修改      \t\t|★|\n";
	cout<<"\t\t|☆|\t\t 5.管理員信息刪除      \t\t|☆|\n";
	cout<<"\t\t|★|\t\t 6.返回                \t\t|★|\n";
	cout<<"\t\t|☆|\t\t                       \t\t|☆|\n";
	cout<<"\t\t╚*☆***◎***◇****☆****★****☆****◇***◎***☆*╝\n\n";
    cout<<"\t\t請選擇您要實現的功能選項 (1-6): [ ]\b\b";
	while(1)
	{
		cin>>n;getchar();
		if(n<'1'||n>'6')
			printf("輸入錯誤,請您重新輸入選項(1-6):[ ]\b\b");
		else
			break;
	}
    switch(n)
	{
    case '1':VIP.add();break;
	case '2':VIP.show();break;
	case '3':VIP.select();break;
	case '4':VIP.alter();break;
	case '5':VIP.dele();break;
    case '6':return;
	}
	}
}
void Get_xy(int x,int y)   //獲取鼠標位置
{
    COORD pos;
    pos.X=x;
    pos.Y=y;
    HANDLE hout=GetStdHandle(STD_OUTPUT_HANDLE);
    SetConsoleCursorPosition(hout,pos);
}
char account::home_face()
{
	system("color 0d");
    char n;
    system("cls");
    cout <<endl;

    for(int i=0;i<9;i++)   //出現閃動效果
    {
    Get_xy(8,4);
	if(i%2==0)  cout<<"\t   O(∩_∩)O~~ 歡迎進入南陽康佳公司的設備管理系統\n\n";
	else cout<<endl<<endl;
    if(i%2==0) cout<<"\t\t╔*☆***◎***◇***☆*** 菜單 ***☆***◇***◎***☆*╗\n";
    else cout<<endl;
    cout<<"\t\t|★|\t\t               \t\t\t|★|\n";
	if(i%2==0) cout<<"\t\t|☆|\t\t               \t\t\t|☆|\n";
    else cout<<endl;
	cout<<"\t\t|★|\t\t1.普通登錄     \t\t\t|★|\n";
    cout<<"\t\t|☆|\t\t2.管理員登錄   \t\t\t|☆|\n";
	cout<<"\t\t|★|\t\t3.VIP管理員登錄\t\t\t|★|\n";
	cout<<"\t\t|☆|\t\t4.退出         \t\t\t|☆|\n";
    if(i%2==0)cout<<"\t\t|★|\t\t               \t\t\t|★|\n";
    else cout<<endl;
	cout<<"\t\t|☆|\t\t               \t\t\t|☆|\n";
	if(i%2==0)cout<<"\t\t╚*☆***◎***◇****☆****★****☆****◇***◎***☆*╝\n\n";
	else cout<<endl<<endl;
    cout<<"\t\t請選擇您要實現的功能選項 (1-4): [ ]\b\b";
    Sleep(50); if(i<8)system("cls");
    }
	while(1)
	{
		cin>>n;getchar();
		if(n<'1'||n>'4')
			printf("輸入錯誤,請您重新輸入選項(1-4):[ ]\b\b");
		else
			return n;
	}
}
//添加設備
void machine::add()
{
     char m;
     bool flag=true;
     ifstream inData("e:\\pbook.txt",ios::in);
     do
     {
    cout <<endl <<"根據下面提示添加新設備的信息" <<endl <<endl
        <<"編號 : " ;
    cin >>num;
    cout <<"類別 : ";
    do
    {
        cin >>category;
        if(category=="tv"||category=="dvd"||category=="tv_dvd") break;
        else
          cout<<"請輸入tv或dvd或tv_dvd  " <<endl ;
    }while(1);
    cout <<"名稱 : ";
    cin >>name;
    cout <<"價格 : ";
    cin >>price;
    cout <<"庫存數量 : ";
    cin >>quantity;
    if (!inData)
    {
        flag=true;
    }
    string sign,str;
    while (inData>>sign)
    {
        getline(inData, str);
        if (num==sign)
        {
            flag = false;
        }
    }
    if(flag) save_new();
    else
    cout <<endl <<endl <<"設備編號已經存在,不能重複添加" <<endl <<endl;
    cout<<"\t是否繼續添加?(y/n):[ ]\b\b";
    cin>>m;
    if(m=='n') break;
    }while(1);
}
//添加管理員
void vip::add()
{
     char m;
     bool flag=true;
     ifstream inData("e:\\Document.txt",ios::in);
     do
     {
    cout <<endl <<"根據下面提示添加新管理員的信息" <<endl <<endl
        <<"賬號 : " ;
    cin >>id;
    cout<<"密碼 : ";
    cin >>password;
    if (!inData)
    {
        flag=true;
    }
    string sign,str;
    while (inData>>sign>>str)
    {
        if (id==sign)
        {
            flag = false;
        }
    }
    if(flag) save_new();
    else
    cout <<endl <<endl <<"管理員號已經存在,不能重複添加" <<endl <<endl;
    cout<<"\t是否繼續添加?(y/n):[ ]\b\b";
    cin>>m;
    if(m=='n') break;
    }while(1);
}
//刪除設備
void machine::dele()
{
    ofstream outData("e:\\temp.txt", ios::out);
    ifstream inData("e:\\pbook.txt", ios::in);
    if (!inData)
    {
        cout <<endl <<"對不起!!!!找不到文件!!!!" <<endl;
        system("pause");
        return;
    }
    string sign;
    cout <<endl <<"你要刪除設備的編號 :";
    cin >>sign;
    string str1;
    bool flag = true;
    string str;
    while(inData>>num)
    {
        getline(inData,str);
        if(sign==num)
        {
            cout <<endl <<"你想刪除的設備:" <<endl <<endl;
			cout<<H<<H1<<H2;
            cout<<setw(10)<<num<<str<<endl;
	        cout<<H2;
            flag = false;
            break;
        }
        outData<<setiosflags(ios::left)<<num<<setw(10)<<str<<endl;
    }
    if (flag)
    {
        cout <<endl <<"對不起!!!沒有你找的設備!!!!" <<endl <<endl;
    }
    else
    {
        while (getline(inData, str))
        {
            outData<<str<<endl;
        }
        outData.close();
        inData.close();
        ofstream out("e:\\pbook.txt", ios::out);
        ifstream in("e:\\temp.txt", ios::in);
        if (!out||!in)
        {
            cout <<endl <<"對不起,不能打開文件!!!" <<endl <<endl;
            system("pause");
            return;
        }
        while (getline(in,str))
        {
            out<<str<<endl;
        }
        out.close();
        in.close();
        cout <<endl <<"這個設備的信息已經刪除!!!" <<endl <<endl;
    }
    system("pause");
}
//刪除管理員
void vip::dele()
{
    ofstream outData("e:\\temp1.txt", ios::out);
    ifstream inData("e:\\Document.txt", ios::in);
    if (!inData)
    {
        cout <<endl <<"對不起!!!!找不到文件!!!!" <<endl;
        system("pause");
        return;
    }
    string sign;
    cout <<endl <<"你要刪除管理員的帳號 :";
    cin >>sign;
    string str1;
    bool flag = true;
    string str;
    while(inData>>id)
    {
        getline(inData,str);
        if(sign==id)
        {
            cout <<endl <<"你想刪除的管理員:" <<endl <<endl;
			cout<<H3<<H4<<H5;
            cout<<setw(10)<<id<<str<<endl;
			cout<<H5;
            flag = false;
            break;
        }
        outData<<setiosflags(ios::left)<<id<<setw(10)<<str<<endl;
    }
    if (flag)
    {
        cout <<endl <<"對不起!!!沒有你找的管理員信息!!!!" <<endl <<endl;
    }
    else
    {
        while (getline(inData, str))
        {
            outData<<str<<endl;
        }
        outData.close();
        inData.close();
        ofstream out("e:\\Document.txt", ios::out);
        ifstream in("e:\\temp1.txt", ios::in);
        if (!out||!in)
        {
            cout <<endl <<"對不起,不能打開文件!!!" <<endl <<endl;
            system("pause");
            return;
        }
        while (getline(in,str))
        {
            out<<str<<endl;
        }
        out.close();
        in.close();
        cout <<endl <<"這個管理員的信息已經刪除!!!" <<endl <<endl;
    }
    system("pause");
}
//顯示所有信息
void machine::show()
{
    ifstream inData("e:\\pbook.txt",ios::in);
    if (!inData)
    {
        cout <<endl <<"對不起!!!!沒有找到文件!!!!!" <<endl;
        system("pause");
        return;
    }
    bool flag = true;
    string record;
    while (getline(inData, record))
    {
        if (flag)
        {
            cout <<endl <<"所有設備信息如下: "<<endl;
			cout<<H<<H1<<H2;
        }

        cout <<record<<endl;
		cout<<H2;
        flag = false;
    }

    if (flag)
    {
        cout <<endl <<"系統中沒有設備信息!!!!!" <<endl <<endl;
    }
    else
    {
        cout <<endl <<"所有設備信息已經全部顯示出來!!!!!" <<endl <<endl;
    }

    system("pause");
}
void vip::show()
{
    ifstream inData("e:\\Document.txt",ios::in);
    if (!inData)
    {
        cout <<endl <<"對不起!!!!沒有找到文件!!!!!" <<endl;
        system("pause");
        return;
    }
    bool flag = true;
    string record;
    while (getline(inData, record))
    {
        if (flag)
        {
            cout <<endl <<"所有管理員信息如下: "<<endl;
			cout<<H3<<H4<<H5;
        }
        cout <<record<<endl;
		cout<<H5;
        flag = false;
    }

    if (flag)
    {
        cout <<endl <<"系統中沒有管理員信息!!!!!" <<endl <<endl;
    }
    else
    {
        cout <<endl <<"所有管理員信息已經全部顯示出來!!!!!" <<endl <<endl;
    }

    system("pause");
}
//修改信息
void machine::alter()
{
    ofstream outData("e:\\temp.txt", ios::out);
    ifstream inData("e:\\pbook.txt", ios::in);
    if (!inData)
    {
        cout <<endl <<"對不起!!!!找不到文件!!!!" <<endl;
        system("pause");
        return;
    }
    string sign;
    cout <<endl <<"你要修改設備的編號 :";
    cin >>sign;
    bool flag = true;
    string str;
    while (inData>>num)
    {
        getline(inData, str);
        if (sign==num)
        {
            cout <<endl <<"你想修改的設備信息:" <<endl <<endl;
			cout<<H<<H1<<H2;
            cout<<setw(10)<<num<<str<<endl;
			cout<<H2;
            cout <<endl <<"請根據下面提示修改信息 : " <<endl;
            cout<<"編號 : " ;
            cin >>num;
            cout <<"類別 : ";
            cin >>category;
            cout <<"名稱 : ";
            cin >>name;
            cout <<"價格 : ";
            cin >>price;
            cout <<"庫存數量 : ";
            cin >>quantity;
            save_new();
            flag = false;
            break;
        }
        outData<<setiosflags(ios::left)<<num<<setw(10)<<str<<endl;
    }
    if (flag)
    {
        cout <<endl <<"對不起!!!沒有找到這個設備!!!!" <<endl <<endl;
    }
    else
    {
        while(getline(inData, str))
        {
            outData <<str <<endl;
        }
        outData.close();
        inData.close();
        ofstream out("e:\\pbook.txt", ios::out);
        ifstream in("e:\\temp.txt", ios::in);
        if (!out||!in)
        {
            cout <<endl <<"對不起不能打開文件!!!" <<endl <<endl;
            system("pause");
            return;
        }
        while (getline(in, str))
        {
            out <<str <<endl;
        }
        out.close();
        in.close();
        cout <<endl <<"這個設備的信息已經修改!!!" <<endl <<endl;
    }
    system("pause");
}
void vip::alter()
{
    ofstream outData("e:\\temp1.txt", ios::out);
    ifstream inData("e:\\Document.txt", ios::in);
    if (!inData)
    {
        cout <<endl <<"對不起!!!!找不到文件!!!!" <<endl;
        system("pause");
        return;
    }
    string sign;
    cout <<endl <<"你要修改管理員的帳號 :";
    cin >>sign;
    bool flag = true;
    string str;
    while (inData>>id)
    {
        getline(inData, str);
        if (sign==id)
        {
            cout <<endl <<"你想修改的管理員信息:" <<endl <<endl;
			cout<<H3<<H4<<H5;
            cout<<setw(10)<<id<<str<<endl;
			cout<<H5;
            cout <<endl <<"請根據下面提示修改信息 : " <<endl;
            cout<<"帳號 : " ;
            cin >>id;
            cout <<"密碼 : ";
            cin >>password;
            save_new();
            flag = false;
            break;
        }
        outData<<setiosflags(ios::left)<<id<<setw(10)<<str<<endl;
    }
    if (flag)
    {
        cout <<endl <<"對不起!!!沒有找到這個管理員信息!!!!" <<endl <<endl;
    }
    else
    {
        while(getline(inData, str))
        {
            outData <<str <<endl;
        }
        outData.close();
        inData.close();
        ofstream out("e:\\Document.txt", ios::out);
        ifstream in("e:\\temp1.txt", ios::in);
        if (!out||!in)
        {
            cout <<endl <<"對不起不能打開文件!!!" <<endl <<endl;
            system("pause");
            return;
        }
        while (getline(in, str))
        {
            out <<str <<endl;
        }
        out.close();
        in.close();
        cout <<endl <<"這個設備的信息已經修改!!!" <<endl <<endl;
    }
    system("pause");
}
//查詢設備
void machine::select()
{
    ifstream inData("e:\\pbook.txt",ios::in);
    if (!inData)
    {
        cout <<endl <<"對不起!文件找不到" <<endl;
        system("pause");
        return;
    }
    string sign;
    cout <<endl <<"輸入你想查找的設備編號: ";
    cin >>sign;
    string str1;
    bool flag =true;
    string str;
    while (inData>>num)
    {
        getline(inData, str);
        if (num==sign)
        {
            cout <<endl <<"你要查找的設備是: " <<endl <<endl;
			cout<<H<<H1<<H2;
            cout <<setw(10)<<num<<str<<endl;
			cout<<H2;
            flag = false;
            system("pause");
            break;
        }
    }
    if(flag)
    {
        cout <<endl <<"你要查找的設備不存在!" <<endl <<endl;
        system("pause");
    }
}
void vip::select()
{
   ifstream inData("e:\\Document.txt",ios::in);
    if (!inData)
    {
        cout <<endl <<"對不起!文件找不到" <<endl;
        system("pause");
        return;
    }
    string sign;
    cout <<endl <<"輸入你想查找的管理員帳號: ";
    cin >>sign;
    string str1;
    bool flag =true;
    string str;
    while (inData>>id)
    {
        getline(inData, str);
        if (id==sign)
        {
            cout <<endl <<"你要查找的管理員信息是: " <<endl <<endl;
			cout<<H3<<H4<<H5;
            cout<<setw(10)<<id<<str<<endl;
			cout<<H5;
            flag = false;
            system("pause");
            break;
        }
    }
    if(flag)
    {
        cout <<endl <<"你要查找的管理員信息不存在!" <<endl <<endl;
        system("pause");
    }
}
void machine::save_new()
{
    ofstream outData("e:\\pbook.txt", ios::app);
    if (!outData)
    {
        cout <<endl <<"對不起!!!打開文件失敗!!!!" <<endl <<endl;
        system("pause");
        return;
    }
	outData	<<setw(10)<<num
        <<" " << setw(10) <<category <<" "
        <<setw(10)<< name <<" "
        <<setw(10)<<price<<" "
        <<setw(10)<<quantity
        <<endl;
    outData.close();
}
void vip::save_new()
{
    ofstream outData("e:\\Document.txt", ios::app);
    if (!outData)
    {
        cout <<endl <<"對不起!!!打開文件失敗!!!!" <<endl <<endl;
        system("pause");
        return;
    }
    outData<<setw(10)<<id
        <<" " << setw(10) <<password <<" "<<endl;
    outData.close();
}
int main()
{
    machine Machine;
    account Account;
	admin Admin;
	vip VIP;
    while(1)
    {
      switch(Account.home_face())
      {
         case '1':Account.entrance();break;
	     case '2':Admin.admin_enter();break;
		 case '3':VIP.vip_enter();break;
		 case '4': MessageBox(NULL,"  Thanks for you!! \n\n \t\t---Made by hrdv \t  ","☆Bye☆Bye☆",0);return 0;//彈框
      }
    }
}


發佈了73 篇原創文章 · 獲贊 18 · 訪問量 12萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章