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

📄 interface.cpp

📁 1.管理信息系统(学生成绩) 两种用户等级:管理员和用户
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/***************************************************
menu.cpp
用户界面
****************************************************/

#include "ManagerInterface.h"

ManagerInterface::ManagerInterface()
{
	ManagerInterface::start(user);
}

void ManagerInterface::menu_student()
{
	while (1)
	{
		system("cls");
		cout<<"\n"
			<<"\t1. 修改密码\n"
			<<"\t2. 查询本用户信息\n"
			<<"\t3. 修改个人信息\n"
			<<"\t4. 保存记录\n"
			<<"\t5. 结束运行\n"
			<<"\n左边数字对应功能选择,请选择1~5: ";
		int choice;
		int subchoice;
		while (1)
		{
			cin>>choice;
			if (choice<1||choice>5) cout<<"\n输入错误,重选1~5\n";
			else break;
		}
		switch (choice)
		{
		case 1:
			InfoManager::ChangePWD(user);
			break;
		case 2:
			InfoManager::Show_Sgl_Stu(user);
			system("pause");
			break;
		case 3:
			system("cls");
			cout<<"\n"
				<<"\t1. 修改年龄\n"
				<<"\t2. 修改性别\n"
				<<"\t3. 修改所在班级\n"
				<<"\t4. 返回上层菜单\n"
				<<"\n请输入:";

			while (1)
			{
				cin.sync();
				cin>>subchoice;
				if (subchoice<1||subchoice>4) cout<<"\n输入错误,重选1~4\n";
				else break;
			}
			system("cls");
			switch (subchoice)
			{
				case 1:
					InfoManager::ChangeOld(user);
					break;
				case 2:
					InfoManager::ChangeSex(user);
					break;
				case 3:
					InfoManager::ChangeClass(user);
					break;
				case 4:
					break;
			}
			break;	
		case 4:
			InfoManager::Save();
			break;
		case 5:
			if (Unit::isModified==1)
			{
				cout<<"记录已修改,是否保存?[Y/N]"<<endl;
				char i;
				do
				{
					cin.sync();
					cin>>i;
					if (i=='y'||i=='Y'||i=='n'||i=='N') break;
					else cout<<"输入错误,请重新输入!"<<endl;;
				} while (1);
				if (toupper(i)=='Y') InfoManager::Save();
			}
			return;
		}
	}
}


void ManagerInterface::menu_teacher()
{
	while (1)
	{
		system("cls");
		cout<<"\n"
			<<"\t1. 显示记录\n"
			<<"\t2. 查询记录\n"
			<<"\t3. 增加记录\n"
			<<"\t4. 删除记录\n"
			<<"\t5. 修改记录\n"
			<<"\t6. 记录排序\n"
			<<"\t7. 统计信息\n"
			<<"\t8. 保存记录\n"
			<<"\t9. 结束运行\n"
			<<"\n左边数字对应功能选择,请选择1~9: ";
		int choice;
		while (1)
		{
			cin.sync();
			cin>>choice;
			if (choice<1||choice>9) cout<<"\n输入错误,重选1~9\n";
			else break;
		}
		switch (choice)
		{
		case 1:
			ManagerInterface::display();
			break;
		case 2:
			ManagerInterface::search();
			break;
		case 3:
			ManagerInterface::add();
			break;	
		case 4:
			ManagerInterface::del();
			break;
		case 5:
			ManagerInterface::edit();
			break;
		case 6:
			ManagerInterface::sort();
			break;
		case 7:
			ManagerInterface::Statistics();
			break;
		case 8:
			InfoManager::Save();
			break;
		case 9:
			if (Unit::isModified==1)
			{
				cout<<"记录已修改,是否保存?[Y/N]"<<endl;
				char i;
				do
				{
					cin.sync();
					cin>>i;
					if (i=='y'||i=='Y'||i=='n'||i=='N') break;
					else cout<<"输入错误,请重新输入!"<<endl;;
				} while (1);
				if (toupper(i)=='Y') InfoManager::Save();
			}
			return;
		}
	}
}

void ManagerInterface::display()
{
	while (1)
	{
		system("cls");
		int choice;
		cout<<"\n";
		cout<<"\t1. 本用户信息\n"
			<<"\t2. 所有学生信息\n"
			<<"\t3. 所有教师信息\n"
			<<"\t4. 返回上层菜单\n"
			<<"\n请输入:";
		while (1)
		{
			cin.sync();
			cin>>choice;
			if (choice<1||choice>4) cout<<"\n输入错误,重选1~4\n";
			else break;
		}
		system("cls");
		switch (choice)
		{
		case 1:
			InfoManager::Show_Sgl_Tea(user);
			system("pause");
			break;
		case 2:
			if (InfoManager::Get_Head(0))
			{
				cout<<"\n\t\t\t\t所有学生信息\n\n";
				InfoManager::Show_All_Stu(InfoManager::Get_Head(0));
			}
			else cout<<"管理系统中没有学生记录!"<<endl;
			system("pause");
			break;
		case 3:
			cout<<"\n\t\t\t所有教师信息\n\n";
			InfoManager::Show_All_Tea(InfoManager::Get_Head(1));
			system("pause");
			break;
		case 4:
			return;
		}
	}
}

void ManagerInterface::add()
{
	while (1)
	{
		system("cls");
		int choice;
		cout<<"\n";
		cout<<"\t1. 添加学生信息\n"
			<<"\t2. 添加教师信息\n"
			<<"\t3. 返回上层菜单\n"
			<<"\n请输入:";
		while (1)
		{
			cin.sync();
			cin>>choice;
			if (choice<1||choice>3) cout<<"\n输入错误,重选1~3\n";
			else break;
		}
		system("cls");
		switch (choice)
		{
			case 1:
				InfoManager::AddSTU ();
				break;
			case 2:
				InfoManager::AddTEA ();
				break;
			case 3:
				return;
		}
	}
}

void ManagerInterface::search()
{
	while (1)
	{
		system("cls");
		cout<<"\n"
			<<"\t1. 单项查询\n"
			<<"\t2. 多项查询\n"
			<<"\t3. 返回上层菜单\n"
			<<"\n请输入:";
		int choice;
		while (1)
		{
			cin.sync();
			cin>>choice;
			if (choice<1||choice>3) cout<<"\n输入错误,重选1~3\n";
			else break;
		}
		system("cls");
		switch (choice)
		{
		case 1:
			ManagerInterface::single_search();
			break;
		case 2:
			ManagerInterface::multi_search();
			break;
		case 3:
			return;
		}
	}
}

void ManagerInterface::single_search()
{
	int count=0;//统计人数
	system("cls");
	cout<<"\n"
		<<"\t1. 按姓名查询\n"
		<<"\t2. 按年龄查询\n"
		<<"\t3. 按学号查询\n"
		<<"\t4. 按班级查询\n"
		<<"\t5. 按数学成绩查询\n"
		<<"\t6. 按语文成绩查询\n"
		<<"\t7. 按英语成绩查询\n"
		<<"\t8. 按平均分查询\n"
		<<"\t9. 按总分查询\n"
		<<"\t10. 返回上级菜单\n"
		<<"\n请输入:";
	int subchoice;
	while (1)
	{
		cin.sync();
		cin>>subchoice;
		if (subchoice<1||subchoice>10) cout<<"\n输入错误,重选1~10\n";
		else break;
	}
	system("cls");
	switch (subchoice)
	{
	case 1:
		InfoManager::SearchByName ();
		system("pause");
		break;
	case 2:
		InfoManager::Show_All_Stu(InfoManager::SearchByOld(InfoManager::Get_Head(0),count));
		cout<<"\n共有"<<count<<"人符合查询条件\n"<<endl;
		system("pause");
		break;
	case 3:
		InfoManager::SearchByID();
		system("pause");
		break;
	case 4:
		InfoManager::Show_All_Stu(InfoManager::SearchByClass(InfoManager::Get_Head(0),count));
		cout<<"\n共有"<<count<<"人符合查询条件\n"<<endl;
		system("pause");
		break;
	case 5:
		InfoManager::Show_All_Stu(InfoManager::SearchByMath(InfoManager::Get_Head(0),count));
		cout<<"\n共有"<<count<<"人符合查询条件\n"<<endl;
		system("pause");
		break;
	case 6:
		InfoManager::Show_All_Stu(InfoManager::SearchByChinese(InfoManager::Get_Head(0),count));
		cout<<"\n共有"<<count<<"人符合查询条件\n"<<endl;
		system("pause");
		break;
	case 7:
		InfoManager::Show_All_Stu(InfoManager::SearchByEnglish(InfoManager::Get_Head(0),count));
		cout<<"\n共有"<<count<<"人符合查询条件\n"<<endl;
		system("pause");
		break;
	case 8:
		InfoManager::Show_All_Stu(InfoManager::SearchByAverage(InfoManager::Get_Head(0),count));
		cout<<"\n共有"<<count<<"人符合查询条件\n"<<endl;
		system("pause");
		break;
	case 9:
		InfoManager::Show_All_Stu(InfoManager::SearchByTotal(InfoManager::Get_Head(0),count));
		cout<<"\n共有"<<count<<"人符合查询条件\n"<<endl;
		system("pause");
		break;
	case 10:
		return;
	}
}

void ManagerInterface::multi_search()
{
	int count=0;//统计人数
	system("cls");
	cout<<"\n\t请复选查询的项目:\n"
		<<"\t\t(请连续输入要查询项目前的数字,各项之间不需要空格、回车)\n"
		<<"\t1. 男生\n"
		<<"\t2. 女生\n"
		<<"\t3. 年龄\n"
		<<"\t4. 班级\n"
		<<"\t5. 数学成绩\n"

⌨️ 快捷键说明

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