⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.cpp

📁 本系统面向学校管理员
💻 CPP
字号:
#include<vector>
#include<string>
#include<iostream.h>
#include<fstream.h>
#include<iomanip.h>
#include"assistant.h"
#include"employeer.h"
#include"worker.h"
#include"floater.h"
#include"leader.h"
#include"permanent.h"
#include"professor.h"
#include"teacher.h"
#include"face.h"

std::vector<employeer> vec;   //调用标准库里的容器类

void validate();
void loadData();
void saveData();

 void main()                                                                                                                                                                                                                                                                                                                                       
{	

	validate();
	loadData();

a:  faceout();
	 	
    system("PAUSE");
    system("CLS");
	cout<<"(=^ ^=)(=^ ^=)(=^ ^=)(=^ ^=)(=^ ^=)(=^ ^=)(=^ ^=)(=^ ^=)(=^ ^=)(=^ ^=)(=^ ^=)"<<endl;
	cout<<"                      学校教职工信息资料库                                  "<<endl;
	cout<<"◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆"<<endl;
	cout<<endl;
	cout<<endl;
	
	cout<<"                请键入您的选择:"<<endl;
	cout<<"               ?1.增加员工."<<endl;
	cout<<"               ?2.在校全部教职工基本资料一览."<<endl;
	cout<<"               ?3.查询具体教职工的具体信息."<<endl;
	cout<<"               ?4.删除教职工信息."<<endl;
	cout<<"               ?5.在职教师资料一览."<<endl;
	cout<<"               ?6.在校工人资料一览."<<endl;
	cout<<"               ?7.计算在校教职工工资."<<endl;
	cout<<"               ?8.存盘退出"<<endl;
	cout<<"          !!!若直接点×,将导致此次运行输入的资料丢失"<<endl;
	cout<<endl;
    cout<<"◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆"<<endl;
	cout<<"ゅゅゅゅゅゅゅゅゅゅゅゅゅゅゅゅゅゅゅゅゅゅゅゅゅゅゅゅゅゅゅゅゅゅゅゅゅゅゅゅ"<<endl;
	cout<<endl;
	int a;
	cin>>a;
	switch(a){
		case 1: { 
			cout<<"***********************************************************************"<<endl;
			cout<<endl;
			employeer  EM;
		   	EM.add();
			cout<<endl;
			
			cout<<endl;
			}
			
			cout<<"\n\n\n"<<endl;
			cout<<"☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆"<<endl;
			goto a;break;
			   
		case 2:{cout<<"***********************************************************************"<<endl;
				cout<<endl;
				employeer  EM;
				EM.display();
				cout<<"☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆"<<endl;
				goto a;break;}


        case 3:{ cout<<"***********************************************************************"<<endl;
				cout<<endl;
			   employeer  EM;
			   EM.display();
			   EM.search();
			   cout<<endl;
			   cout<<"☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆"<<endl;
			   goto a;break;}

        case 4:{ cout<<"***********************************************************************"<<endl;
				cout<<endl;
			   employeer  EM;
			   EM.display();
			   EM.remove();
			   cout<<endl;
			   cout<<"☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆"<<endl;
			   goto a;break;}

		case 5:	 { cout<<"***********************************************************************"<<endl;
				cout<<endl;
				teacher teach;
				teach.print();
		        cout<<endl;
			   cout<<"☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆"<<endl;
			   goto a;break;}
			   
		case 6:	  { cout<<"***********************************************************************"<<endl;
				   cout<<endl;
				   worker wor;
				   wor.print();
                	cout<<"☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆"<<endl;
			   goto a;break;}		   
			   
		case 7: { cout<<"***********************************************************************"<<endl;
j:                 cout<<endl;
				   cout<<"                请输入您的选择:"<<endl;
				   cout<<"                ?1.了解领导福利状况"<<endl;
                   cout<<"                ?2.了解助教福利状况"<<endl;
                   cout<<"                ?3.了解教授福利状况"<<endl;
                   cout<<"                ?4.了解固定工福利状况"<<endl;
                   cout<<"                ?5.了解临时工福利状况"<<endl;
                   cout<<"                ?6.返回主菜单   "<<endl;
				   cout<<endl;
				
				   cout<<"☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆"<<endl;
				   int k;
				  cin>>k;
				 switch (k){
				 case 1:{
					   employeer  EM;
					   EM.display();
					   cout<<endl;
					   cout<<"领导分别是:"<<endl;
				       cout<<endl;
					   leader lea;
					   lea.print();
					   cout<<endl;
					   lea.salary();
                        
					   	cout<<"☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆"<<endl;
			           goto j; break;
					   }
				
				case 2:{
					   employeer  EM;
					   EM.display();
				       cout<<"助教分别是:"<<endl;
				       cout<<endl;
					   assistant as;
					   as.print();
					   cout<<endl;
					   as.salary();
                       	
					   cout<<"☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆"<<endl;
			           goto j; break;
					   }
				
				case 3:{
					employeer  EM;
					   EM.display();
				       cout<<"教授分别是:"<<endl;
				       cout<<endl;
					   professor pro;
					   pro.print();
					   cout<<endl;
					   pro.salary();
                       	
					   cout<<"☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆"<<endl;
					goto j;	break;
					   }

				case 4:{
					   employeer  EM;
					   EM.display();
				       cout<<"固定工分别是:"<<endl;
				       cout<<endl;
					   permanent per;
					   per.print();
					   cout<<endl;
					   per.salary();
                       
					   cout<<"☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆"<<endl;
					goto j;break;
					   }

                case 5:{employeer  EM;
					   EM.display();
				       cout<<"临时工分别是:"<<endl;
				       cout<<endl;
					   floater flo;
					   flo.print();
					   cout<<endl;
					   flo.salary();
                       
					   cout<<"☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆"<<endl;
						goto j;break;
				
					   }

                case 6:{goto a;}
				default: cout<<"您的输入有错误,请重新选择\n"<<"^_^不要着急,慢慢来"<<endl;goto j;
					
				
				
				goto a;
				}
				
				
				
  case 8:
	  saveData();
	  return;

		default:  cout<<"您的输入有错误,请重新选择\n"<<"^_^不要着急,慢慢来"<<endl;goto a;}
}


}

void validate() {

	char inputUser[20];
	char inputPassword[20];
	int fault = 0;
    cout<<"默认用户名user1 密码123456\n修改用户可在本文件夹里的user.dat文件来查看和添加用户"<<endl;
input1:
	cout<<"请输入用户名:";
	cin.getline(inputUser, sizeof(inputUser));

	ifstream f("user.dat");
	char user[20];
	char password[20];
	while(!f.eof()) {
		f.get(user, 20, '\t');
		f.get();
		f.get(password, 20, '\n');
		f.get();
		if(strcmp(user, inputUser) == 0) {
input2:
			cout<<"请输入密码:";
			cin.getline(inputPassword, sizeof(inputPassword));
			cout<<endl;
			if(strcmp(password, inputPassword) == 0) {
				break;
			}
			else {
				cout<<"密码错误"<<endl;
				if(++fault == 3)
					exit(1);
				goto input2;
			}
		}
	}

	if(f.eof()) {
		cout<<"此用户不存在"<<endl<<endl;
			if(++fault == 3)
				exit(1);
		goto input1;
	}

	system("CLS");
}

//读出
void loadData(){

	ifstream f("employeer.dat");
	employeer EM;
	f.seekg(0, ios::end);
	long pos = f.tellg();
	f.seekg(0, ios::beg);
	while(f.tellg() != pos) {
		f.read(reinterpret_cast<char *>(&EM), sizeof(EM)); 
		vec.push_back(EM);
	}
	
}

//存盘
void saveData(){

	ofstream f("employeer.dat", ios::binary); 
	for(int j = 0; j<vec.size(); j++) {
		employeer EM = (employeer)(vec[j]);
		f.write(reinterpret_cast<char *>(&EM), sizeof (EM)); 
	}
	f.close(); 

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -