c++课程设计

定型了,不改了!生气

#include<iostream>
#include<string>
#include<fstream>
#include<sstream>
#include<vector>
#include<conio.h>
#include<windows.h>
using namespace std;
static int teacher_count=0;
static int student_count=0;
static int staff_count=0;
//-------------------------------------------------抽象出来的基类
class Base_Class
{
public:
	virtual void Insert(ofstream& in)=0;  //插入函数
	virtual void Query()=0;   //查询函数
	virtual void Delete()=0;  //删除函数
	virtual void Display(ifstream& out)=0; //显示函数
	virtual void Alter()=0;   //修改函数
protected:
	string name;
	int age;
	string id;
};

//-------------------------------------------教师类
class Teacher:public Base_Class
{
public:
	Teacher();
	Teacher(string,int,string,int,int);
    void Insert(ofstream&);
	void Query();
	void Delete();
	void Display(ifstream&);
	void Alter();
	string Get_id(){return id;}
	friend istream& operator>>(istream&,Teacher&);
	friend ostream& operator<<(ostream&,Teacher&);
private:
	int class_hour;
	int class_hour_fee;
};

//-------------------------------------------学生类
class Student:public Base_Class
{
public:
	Student();
	Student(string,int,string,int,int);
	void Insert(ofstream&);
	void Query();
	void Delete();
	void Display(ifstream&);
	void Alter();
	string Get_id(){return id;}
	friend istream& operator>>(istream&,Student&);
	friend ostream& operator<<(ostream&,Student&);
private:
	int grade;
	int tuition;
};

//-----------------------------------------员工类
class Staff:public Base_Class
{
public:
	Staff();
	Staff(string,int,string,int);
	void Insert(ofstream&);
	void Query();
	void Delete();
	void Display(ifstream&);
	void Alter();
	string Get_id(){return id;}
	friend istream& operator>>(istream&,Staff&);
	friend ostream& operator<<(ostream&,Staff&);
private:
	int salary;
};
//---------------------------------------------------教师类的实现---------------------------------------------
Teacher::Teacher()  //构造函数
{
	name=""; age=0; id=""; class_hour=0; class_hour_fee=0;
}

Teacher::Teacher(string _name,int _age,string _id,int _class_hour,int _class_hour_fee)
{
	name=_name; age=_age; id=_id; class_hour=_class_hour; class_hour_fee=_class_hour_fee;
}

istream& operator>>(istream& in,Teacher& a)  //重载">>"运算符
{
	in>>a.name;
	in>>a.age;
	in>>a.id;
	in>>a.class_hour;
	in>>a.class_hour_fee;
	return in;
}

ostream& operator<<(ostream& out,Teacher& a)   //重载"<<"运算符
{
	out<<"|*  Name:"<<a.name<<endl;
	out<<"|*   Age:"<<a.age<<endl;
	out<<"|*    ID:"<<a.id<<endl;
	out<<"|*  Hour:"<<a.class_hour<<endl;
	out<<"|*   Fee:"<<a.class_hour_fee<<endl;
	return out;
}

void Teacher::Insert(ofstream& in)   //插入函数实现
{
	in<<name<<endl;
	in<<age<<endl;
	in<<id<<endl;
	in<<class_hour<<endl;
	in<<class_hour_fee<<endl;
}

void Teacher::Display(ifstream& out) //显示函数实现
{
	out>>name;
	out>>age;
	out>>id;
	out>>class_hour;
	out>>class_hour_fee;
}

void Teacher::Query()  //查询函数
{
	string s;
	cout<<"Please input the teacher's id:\n"<<endl;
	cin>>s;
	ifstream fin("teacher.txt");
	if(!fin)
	{
		cerr<<"Cannot open the file!"<<endl;
		return;
	}
	while(!fin.eof())
	{
		Teacher a;
		a.Display(fin);
		if(a.id==s)
		{
			cout<<"Teacher's information:"<<endl;
			cout<<a<<endl;
			fin.close();
			return;
		}
	}
	cout<<"Cannot find!"<<endl;
	fin.close();
	return ;
}

void Teacher::Alter()    //修改函数
{
	string s;
	if(teacher_count==0)
	{
		ifstream fin("teacher.txt");
	    vector<Teacher>A(100);
	    int hp=0;
	    while(!fin.eof())
		A[hp++].Display(fin);
	    fin.close();
	    teacher_count=hp-1;
	}
	int flag=0,count=teacher_count;
	cout<<"Please input the teacher's id:"<<endl;
	cin>>s;
	ifstream fin("teacher.txt");
	ofstream out("teacher1.txt");
	if(!fin)
	{
		cerr<<"Cannot open the file!"<<endl;
		return;
	}
	if(!out)
	{
		cerr<<"Cannot open the file!"<<endl;
		return;
	}
	while(count--)
	{
		Teacher a;
		a.Display(fin);
		if(a.id==s)
		{
			flag=1;
			cout<<"Teacher's information:"<<endl;
			cout<<a<<endl;
			cout<<"Please Input the new information:"<<endl;
			Teacher b;
			cin>>b;
			b.Insert(out);
		}
		else
		    a.Insert(out);
	}
	out.close();fin.close();
	remove("teacher.txt"); rename("teacher1.txt","teacher.txt");
	if(flag) cout<<"Modify success!"<<endl;
	else cout<<"Cannot find!"<<endl;
}

void Teacher::Delete()   //删除函数
{
	string s;
	if(teacher_count==0)
	{
		ifstream fin("teacher.txt");
	    vector<Teacher>A(100);
	    int hp=0;
	    while(!fin.eof())
		A[hp++].Display(fin);
	    fin.close();
	    teacher_count=hp-1;
	}
	int flag=0,count=teacher_count;
	cout<<"Please input the teacher's id:"<<endl;
	cin>>s;
	ifstream fin("teacher.txt");
	ofstream out("teacher1.txt");
	if(!fin)
	{
		cerr<<"Cannot open the file!"<<endl;
		return;
	}
	if(!out)
	{
		cerr<<"Cannot open the file!"<<endl;
		return;
	}
	while(count--)
	{
		Teacher a;
		a.Display(fin);
		if(a.id==s)
		{
			flag=1;
			char ch;
			cout<<"Teacher's information:"<<endl;
			cout<<a<<endl;
			cout<<"Are you sure to delete the data?[Y/N]"<<endl;
			cin>>ch;
			if(ch=='Y' || ch=='y') {teacher_count--; cout<<"Delete success!"<<endl;}
			else if(ch=='N' || ch=='n') {cout<<"Failed to delete the data!"<<endl;a.Insert(out);}
			else {cout<<"Input error!"<<endl;a.Insert(out);}
		}
		else
		    a.Insert(out);
	}
	out.close();fin.close();
	remove("teacher.txt"); rename("teacher1.txt","teacher.txt");
	if(flag==0)cout<<"No find!"<<endl;
}


//---------------------------------------------学生类的实现----------------------------------------------
Student::Student()  // 构造函数
{
	name=""; age=0; id=""; grade=0; tuition=0;
}
Student::Student(string _name,int _age,string _id,int _grade,int _tuition)
{
	name=_name; age=_age; id=_id; grade=_grade; tuition=_tuition;
}

istream& operator>>(istream& in,Student& a)   //重载">>"运算符
{
	in>>a.name;
	in>>a.age;
	in>>a.id;
	in>>a.grade;
	in>>a.tuition;
	return in;
}

ostream& operator<<(ostream& out,Student& a)   //重载"<<"运算符
{
	out<<"|*    Name:"<<a.name<<endl;
	out<<"|*     Age:"<<a.age<<endl;
	out<<"|*      ID:"<<a.id<<endl;
	out<<"|*   Grade:"<<a.grade<<endl;
	out<<"|* Tuition:"<<a.tuition<<endl;
	return out;
}

void Student::Insert(ofstream& out)   //插入函数
{
	out<<name<<endl;
	out<<age<<endl;
	out<<id<<endl;
	out<<grade<<endl;
	out<<tuition<<endl;
}

void Student::Display(ifstream& in)  //显示函数
{
	in>>name;
	in>>age;
	in>>id;
	in>>grade;
	in>>tuition;
}

void Student::Query()        //查询函数
{
	string s;
	cout<<"Please input the stduent's id:\n"<<endl;
	cin>>s;
	ifstream fin("student.txt");
	if(!fin)
	{
		cerr<<"Cannot open the file!"<<endl;
		return;
	}
	while(!fin.eof())
	{
		Student a;
		a.Display(fin);
		if(a.id==s)
		{
			cout<<"Student's information:"<<endl;
			cout<<a<<endl;
			fin.close();
			return;
		}
	}
	cout<<"Cannot find!"<<endl;
	fin.close();
	return ;
}

void Student::Alter()    //修改函数
{
	string s;
	if(student_count==0)
	{
		ifstream fin("student.txt");
	    vector<Student>A(100);
	    int hp=0;
	    while(!fin.eof())
		A[hp++].Display(fin);
	    fin.close();
	    student_count=hp-1;
	}
	int flag=0,count=student_count;
	cout<<"Please input the student's id:"<<endl;
	cin>>s;
	ifstream fin("student.txt");
	ofstream out("student1.txt");
	if(!fin)
	{
		cerr<<"Cannot open the file!"<<endl;
		return;
	}
	if(!out)
	{
		cerr<<"Cannot open the file!"<<endl;
		return;
	}
	while(count--)
	{
		Student a;
		a.Display(fin);
		if(a.id==s)
		{
			flag=1;
			cout<<"Student's information:"<<endl;
			cout<<a<<endl;
			cout<<"Please Input the new information:"<<endl;
			Student b;
			cin>>b;
			b.Insert(out);
		}
		else
		    a.Insert(out);
	}
	out.close();fin.close();
	remove("student.txt"); rename("student1.txt","student.txt");
	if(flag) cout<<"Modify success!"<<endl;
	else cout<<"Cannot find!"<<endl;
}

void Student::Delete()  //删除函数
{
	string s;
	if(student_count==0)
	{
		ifstream fin("student.txt");
	    vector<Student>A(100);
	    int hp=0;
	    while(!fin.eof())
		A[hp++].Display(fin);
	    fin.close();
	    student_count=hp-1;
	}
	int flag=0,count=student_count;
	cout<<"Please input the student's id:"<<endl;
	cin>>s;
	ifstream fin("student.txt");
	ofstream out("student1.txt");
	if(!fin)
	{
		cerr<<"Cannot open the file!"<<endl;
		return;
	}
	if(!out)
	{
		cerr<<"Cannot open the file!"<<endl;
		return;
	}
	while(count--)
	{
		Student a;
		a.Display(fin);
		if(a.id==s)
		{
			flag=1;
			char ch;
			cout<<"Student's information:"<<endl;
			cout<<a<<endl;
			cout<<"Are you sure to delete the data?[Y/N]"<<endl;
			cin>>ch;
			if(ch=='Y' || ch=='y') {student_count--;cout<<"Delete success!"<<endl;}
			else if(ch=='N' || ch=='n') {cout<<"Failed to delete the data!"<<endl;a.Insert(out);}
			else {cout<<"Input error!"<<endl;a.Insert(out);}
		}
		else
		    a.Insert(out);
	}
	out.close();fin.close();
	remove("student.txt"); rename("student1.txt","student.txt");
	if(flag==0)cout<<"No find!"<<endl;
}

//-----------------------------------------------------员工类实现-----------------------------------
Staff::Staff()  //构造函数
{
	name=""; age=0; id=""; salary=0;
}
Staff::Staff(string _name,int _age,string _id,int _salary)
{
	name=_name; age=_age; id=_id; salary=_salary;
}

istream& operator>>(istream& in,Staff& a)   // 重载">>"运算符
{
	in>>a.name;
	in>>a.age;
	in>>a.id;
	in>>a.salary;
	return in;
}

ostream& operator<<(ostream& out,Staff& a)  //重载"<<"运算符
{
	out<<"|*    Name:"<<a.name<<endl;
	out<<"|*     Age:"<<a.age<<endl;
	out<<"|*      ID:"<<a.id<<endl;
	out<<"|*  Salary:"<<a.salary;
	return out;
}

void Staff::Insert(ofstream& out)  //插入函数
{
	out<<name<<endl;
	out<<age<<endl;
	out<<id<<endl;
	out<<salary<<endl;
}

void Staff::Display(ifstream& in)  //显示函数
{
	in>>name;
	in>>age;
	in>>id;
	in>>salary;
}

void Staff::Query()  //查询函数
{
	string s;
	cout<<"Please input the staff's id:\n"<<endl;
	cin>>s;
	ifstream fin("staff.txt");
	if(!fin)
	{
		cerr<<"Cannot open the file!"<<endl;
		return;
	}
	while(!fin.eof())
	{
		Staff a;
		a.Display(fin);
		if(a.id==s)
		{
			cout<<"Staff's information:"<<endl;
			cout<<a<<endl;
			fin.close();
			return;
		}
	}
	cout<<"Cannot find!"<<endl;
	fin.close();
	return ;
}

void Staff::Alter()    //修改函数
{
	string s;
	if(staff_count==0)
	{
		ifstream fin("staff.txt");
	    vector<Staff>A(100);
	    int hp=0;
	    while(!fin.eof())
		A[hp++].Display(fin);
	    fin.close();
	    staff_count=hp-1;
	}
	int flag=0,count=staff_count;
	cout<<"Please input the staff's id:"<<endl;
	cin>>s;
	ifstream fin("staff.txt");
	ofstream out("staff1.txt");
	if(!fin)
	{
		cerr<<"Cannot open the file!"<<endl;
		return;
	}
	if(!out)
	{
		cerr<<"Cannot open the file!"<<endl;
		return;
	}
	while(count--)
	{
		Staff a;
		a.Display(fin);
		if(a.id==s)
		{
			flag=1;
			cout<<"Staff's information:"<<endl;
			cout<<a<<endl;
			cout<<"Please Input the new information:"<<endl;
			Staff b;
			cin>>b;
			b.Insert(out);
		}
		else
		    a.Insert(out);
	}
	out.close();fin.close();
	remove("staff.txt"); rename("staff1.txt","staff.txt");
	if(flag) cout<<"Modify success!"<<endl;
	else cout<<"Cannot find!"<<endl;
}

void Staff::Delete()  //删除函数
{
	string s;
	if(staff_count==0)
	{
		ifstream fin("staff.txt");
	    vector<Staff>A(100);
	    int hp=0;
	    while(!fin.eof())
		A[hp++].Display(fin);
	    fin.close();
	    staff_count=hp-1;
	}
	int flag=0,count=staff_count;
	cout<<"Please input the staff's id:"<<endl;
	cin>>s;
	ifstream fin("staff.txt");
	ofstream out("staff1.txt");
	if(!fin)
	{
		cerr<<"Cannot open the file!"<<endl;
		return;
	}
	if(!out)
	{
		cerr<<"Cannot open the file!"<<endl;
		return;
	}
	while(count--)
	{
		Staff a;
		a.Display(fin);
		if(a.id==s)
		{
			flag=1;
			char ch;
			cout<<"Staff's information:"<<endl;
			cout<<a<<endl;
			cout<<"Are you sure to delete the data?[Y/N]"<<endl;
			cin>>ch;
			if(ch=='Y' || ch=='y') {staff_count--;cout<<"Delete success!"<<endl;}
			else if(ch=='N' || ch=='n') {cout<<"Failed to delete the data!"<<endl;a.Insert(out);}
			else {cout<<"Input error!"<<endl;a.Insert(out);}
		}
		else
		    a.Insert(out);
	}
	out.close();fin.close();
	remove("staff.txt"); rename("staff1.txt","staff.txt");
	if(flag==0)cout<<"No find!"<<endl;
}

//---------------------------------------显示菜单---------------------------------------
void menu()  //主菜单
{
    ostringstream os[6];
    os[0]<<"    ~~~~欢迎您使用本信息管理系统,请不要进行非法操作,谢谢您的配合!~~~~"<<endl;
    os[1]<<"    -----------------------------信息管理系统---------------------------"<<endl;
    os[2]<<"    |*|                     1. 教师信息管理系统                      |*|"<<endl;
    os[3]<<"    |*|                     2. 学生信息管理系统                      |*|"<<endl;
    os[4]<<"    |*|                     3. 员工信息管理系统                      |*|"<<endl;
    os[5]<<"    --------------------------------------------------------------------"<<endl;
    for(int i=5;i>=0;i--)
    {
        system("cls");Sleep(100);
        for(int j=i;j<6;j++)
        {
            cout<<endl<<endl<<os[j].str();
        }
    }
}

void teacher_menu()   //教师信息管理系统菜单
{
	cout<<"\n\n    ----------------------------教师管理系统-------------------------"<<endl;
	cout<<"\n\n    |*|                      1. 存储教师信息                      |*|"<<endl;
	cout<<"\n\n    |*|                      2. 显示教师信息                      |*|"<<endl;
	cout<<"\n\n    |*|                      3. 查询教师信息                      |*|"<<endl;
	cout<<"\n\n    |*|                      4. 修改教师信息                      |*|"<<endl;
	cout<<"\n\n    |*|                      5. 删除教师信息                      |*|"<<endl;
	cout<<"\n\n    |*|                      0. 退出                              |*|"<<endl;
	cout<<"\n\n    -----------------------------------------------------------------"<<endl;
}

void student_menu()  //学生信息管理系统菜单
{
	cout<<"\n\n    ----------------------------学生管理系统-------------------------"<<endl;
	cout<<"\n\n    |*|                      1. 存储学生信息                      |*|"<<endl;
	cout<<"\n\n    |*|                      2. 显示学生信息                      |*|"<<endl;
	cout<<"\n\n    |*|                      3. 查询学生信息                      |*|"<<endl;
	cout<<"\n\n    |*|                      4. 修改学生信息                      |*|"<<endl;
	cout<<"\n\n    |*|                      5. 删除学生信息                      |*|"<<endl;
	cout<<"\n\n    |*|                      0. 退出                              |*|"<<endl;
	cout<<"\n\n    -----------------------------------------------------------------"<<endl;
}

void staff_menu()   //员工信息管理系统菜单
{
	cout<<"\n\n    ----------------------------员工管理系统-------------------------"<<endl;
	cout<<"\n\n    |*|                      1. 存储员工信息                      |*|"<<endl;
	cout<<"\n\n    |*|                      2. 显示员工信息                      |*|"<<endl;
	cout<<"\n\n    |*|                      3. 查询员工信息                      |*|"<<endl;
	cout<<"\n\n    |*|                      4. 修改员工信息                      |*|"<<endl;
	cout<<"\n\n    |*|                      5. 删除员工信息                      |*|"<<endl;
	cout<<"\n\n    |*|                      0. 退出                              |*|"<<endl;
	cout<<"\n\n    -----------------------------------------------------------------"<<endl;
}

//------------------------------操作--------------------------------------------------------

//---------教师操作
void teacher_write()
{
    int flag=1,sp=0;
    string B[100];
    ifstream fcin("teacher.txt");
    if(!fcin)
    {
        flag=0; fcin.close();
    }
    if(flag)
    {
        while(!fcin.eof())
        {
            Teacher a;
            a.Display(fcin);
            B[sp++]=a.Get_id();
        }
        fcin.close();
    }
	ofstream fout("teacher.txt",ios::out|ios::app);
	cout<<"How many do you want to insert?"<<endl;
    int n; cin>>n;
	vector<Teacher>A(n);
	cout<<"Please input "<<n<<" teacher's information:"<<endl;
	for(int i=0,j;i<n;i++)
	{
		cin>>A[i];
		bool flag=true;
		for(j=0;j<sp+i;j++)
		{
		    if(A[i].Get_id()==B[j])
		    {
		        cout<<"There were this data! Please input again!"<<endl;
		        i--; flag=false; break;
		    }
		}
		if(flag)
		{
            B[i+sp]=A[i].Get_id();
		    A[i].Insert(fout);
		}
	}
	fout.close(); teacher_count+=n;
	cout<<"\n   Insert Success!"<<endl;
}
void teacher_read()
{
	ifstream fin("teacher.txt");
    if(!fin)
	{
	    cerr<<"cannot open the file!"<<endl;
	    exit(1);
	}
	vector<Teacher>A(100);
	int hp=0;
	while(!fin.eof())
		A[hp++].Display(fin);
	fin.close();
	teacher_count=hp-1;
	for(int i=0;i<teacher_count;i++)
		 cout<<A[i]<<endl;
}
void teacher_()
{
	while(1)
	{
	    system("color 1b");
		system("cls");
	    teacher_menu();
		Teacher s;
	    cout<<"\nPlease input the number in every particular to choose what you want to do:"<<endl;
	    int _number; cin>>_number;
	    switch(_number)
	    {
	    case 0: goto l;
	    case 1:
			 teacher_write();
		     break;
	     case 2:
			 teacher_read();
			 break;
	     case 3:
			 s.Query();
			 break;
	     case 4:
			 s.Alter();
			 break;
	     case 5:
			 s.Delete();
			 break;
	     default:
			 cout<<"Input Error!"<<endl;
			 break;
	    }
		cout<<"Do you want to continue?[Y/N]"<<endl;
		char _ch; cin>>_ch;
		if(_ch=='N' || _ch=='n') break;
	}
	l:return;
}

//-------------学生操作
void student_write()
{
    int flag=1,sp=0;
    string B[100];
    ifstream fcin("student.txt");
    if(!fcin)
    {
        flag=0; fcin.close();
    }
    if(flag)
    {
        while(!fcin.eof())
        {
            Teacher a;
            a.Display(fcin);
            B[sp++]=a.Get_id();
        }
        fcin.close();
    }
	ofstream fout("student.txt",ios::out|ios::app);
	cout<<"How many do you want to insert?"<<endl;
    int n; cin>>n;
	vector<Student>A(n);
	cout<<"Please input "<<n<<" student's information:"<<endl;
	for(int i=0,j;i<n;i++)
	{
		cin>>A[i];
        bool flag=true;
		for(j=0;j<sp+i;j++)
		{
		    if(A[i].Get_id()==B[j])
		    {
		        cout<<"There were this data! Please input again!"<<endl;
		        i--; flag=false; break;
		    }
		}
		if(flag)
		{
            B[i+sp]=A[i].Get_id();
		    A[i].Insert(fout);
		}
	}
	fout.close(); student_count+=n;
	cout<<"   Insert Success!"<<endl;
}
void student_read()
{
	ifstream fin("student.txt");
    if(!fin)
	{
	    cerr<<"cannot open the file!"<<endl;
	    exit(1);
	}
	vector<Student>A(100);
	int hp=0;
	while(!fin.eof())
		A[hp++].Display(fin);
	fin.close();
	student_count=hp-1;
	for(int i=0;i<student_count;i++)
		cout<<A[i]<<endl;
}
void student_()
{
	while(1)
	{
	    system("color 9f");
		system("cls");
	    student_menu();
		Student s;
	    cout<<"\nPlease input the number in every particular to choose what you want to do:"<<endl;
	    int _number; cin>>_number;
	    switch(_number)
	    {
	    case 0: goto l;
	    case 1:
			 student_write();
		     break;
	     case 2:
			 student_read();
			 break;
	     case 3:
			 s.Query();
			 break;
	     case 4:
			 s.Alter();
			 break;
	     case 5:
			 s.Delete();
			 break;
	     default:
			 cout<<"Input Error!"<<endl;
			 break;
	    }
		cout<<"Do you want to continue?[Y/N]"<<endl;
		char _ch; cin>>_ch;
		if(_ch=='N' || _ch=='n') break;
	}
	l:return;
}

//--------------员工操作
void staff_write()
{
    int flag=1,sp=0;
    string B[100];
    ifstream fcin("staff.txt");
    if(!fcin)
    {
        flag=0; fcin.close();
    }
    if(flag)
    {
        while(!fcin.eof())
        {
            Teacher a;
            a.Display(fcin);
            B[sp++]=a.Get_id();
        }
        fcin.close();
    }
	ofstream fout("staff.txt",ios::out|ios::app);
	cout<<"How many do you want to insert?"<<endl;
    int n; cin>>n;
	vector<Staff>A(n);
	cout<<"Please input "<<n<<" staff's information:"<<endl;
	for(int i=0,j;i<n;i++)
	{
		cin>>A[i];
        bool flag=true;
		for(j=0;j<sp+i;j++)
		{
		    if(A[i].Get_id()==B[j])
		    {
		        cout<<"There were this data! Please input again!"<<endl;
		        i--; flag=false; break;
		    }
		}
		if(flag)
		{
            B[i+sp]=A[i].Get_id();
		    A[i].Insert(fout);
		}
	}
	fout.close(); staff_count+=n;
	cout<<"   Insert Success!"<<endl;
}
void staff_read()
{
	ifstream fin("staff.txt");
	if(!fin)
	{
	    cerr<<"cannot open the file!"<<endl;
	    exit(1);
	}
	vector<Staff>A(100);
	int hp=0;
	while(!fin.eof())
		A[hp++].Display(fin);
	fin.close();
	staff_count=hp-1;
	for(int i=0;i<staff_count;i++)
		cout<<A[i]<<endl;
}
void staff_()
{
	while(1)
	{
	    system("color 0a");
		system("cls");
	    staff_menu();
		Staff s;
	    cout<<"\nPlease input the number in every particular to choose what you want to do:"<<endl;
	    int _number; cin>>_number;
	    switch(_number)
	    {
	    case 0: goto l;
	    case 1:
			 staff_write();
		     break;
	     case 2:
			 staff_read();
			 break;
	     case 3:
			 s.Query();
			 break;
	     case 4:
			 s.Alter();
			 break;
	     case 5:
			 s.Delete();
			 break;
	     default:
			 cout<<"Input Error!"<<endl;
			 break;
	    }
		cout<<"Do you want to continue?[Y/N]"<<endl;
		char _ch; cin>>_ch;
		if(_ch=='N' || _ch=='n') break;
	}
	l: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);
}
//----------------------------------------------主函数-----------------------------------
int main()
{
	system("color 9a");
	for(int i=0;i<3;i++)
	{
	    Get_xy(10,8); cout<<"                   ~~~~Welcome!~~~~";Sleep(50); system("cls");Sleep(500);
	}
	Get_xy(10,8);
	cout<<"您"; Sleep(200);cout<<"好"; Sleep(200); cout<<',';Sleep(200);cout<<"欢";Sleep(200);
    cout<<"迎"; Sleep(200); cout<<"使"; Sleep(200); cout<<"用"; Sleep(200);
	cout<<"本"; Sleep(200); cout<<"操"; Sleep(200); cout<<"作"; Sleep(200);
	cout<<"系"; Sleep(200); cout<<"统";Sleep(200); cout<<"!"; Sleep(600); cout<<"  祝您使用愉快!";Sleep(1500);
	system("cls");
	loop:system("color f0");
	Get_xy(10,8); cout<<"Please input the administrator's password:";
	string hp="\0";
	char ch;
	int hp1=0;
	while(1)
	{
	    ch=getch();
	    if(ch==13) {cout<<endl;break;}
	    if(ch==8)
	    {
	        system("cls");
	        Get_xy(10,8);
	        cout<<"Please input the administrator's password:";
	        if(hp1){
	            hp1--;
	        for(int i=0;i<hp1;i++)
	           cout<<"*";
            hp.erase(hp1,1);
	        }
	        continue;
        }
	    hp+=ch; hp1++; cout<<"*";
	}
	if(hp=="admin")
	{
	while(1)
	{
	    system("color a1");
		system("cls");
        cout<<"\n\n    ~~~~欢迎您使用本信息管理系统,请不要进行非法操作,谢谢您的配合!~~~~"<<endl;
	    menu();
	    cout<<"\nPlease input the number in every particular to choose what you want to do:"<<endl;
	    int number;
	    cin>>number;
	    switch(number)
	    {
	     case 0:
            MessageBox(NULL,"Thanks for your use!Bye-bye!","BYE!",MB_OK);
	        goto t;
	     case 1:
		     teacher_();
			 break;
	     case 2:
			 student_();
			 break;
	     case 3:
			 staff_();
			 break;
	     default:
		     cout<<"Input Error!"<<endl;
			 goto t;
	     }
	}
	}
	else
	{
        cout<<"          Input error!"<<endl;
        char ch;
        cout<<"          Do you want to try again?[Y/N]";
        cin>>ch;
        if(ch=='Y' || ch=='y') {system("cls"); goto loop;}
	}
	t:return 0;
}


//-----------------------------输入数据------------------------------
/*

//---------------------------------教师数据
张三 23 411522199301124538 10 50
李四 25 411522196587485968 10 51
王五 26 411522111111111111 9 55
赵六 27 411522000000000000 11 53
嬴政 36 411522555555555555 12 59
小平 20 411522199301124539 9 59
建国 36 411522458665656565 6 36

//----------------------------------学生数据
张三 23 411522199301124538 3 2000
李四 25 411522196587485968 2 3000
王五 26 411522111111111111 4 3500
赵六 27 411522000000000000 1 3700
嬴政 36 411522555555555555 3 2000
小平 20 411522199301124539 2 3700
李红 21 411522585684444555 4 3750

//----------------------------------员工数据
张三 23 411522199301124538 2700
李四 25 411522196587485968 3000
王五 26 411522111111111111 5000
赵六 27 411522000000000000 2698
嬴政 36 411522555555555555 3500
小平 20 411522199301124539 4000
鸣人 21 411522548777889865 5500

*/


  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值