-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.cpp
More file actions
158 lines (152 loc) · 4.38 KB
/
Copy pathMain.cpp
File metadata and controls
158 lines (152 loc) · 4.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#include<iostream>
#include<mysql.h>
#include"mysqlCon.h"
#include"Identyfy.h"
#include"Manager.h"
#include"Student.h"
#include"Teacher.h"
using namespace std;
void managerMenu(Identyfy*& manager) {
while (1) {
manager->openMenu();
//父类指针强转子类指针
Manager* ma = (Manager*)manager;
int select;
cout << "\t\t输入您的选择:";
cin >> select;
switch (select)
{
case 1:ma->addPerson(); break;
case 2:ma->showPerson(); break;
case 3:ma->showRoom(); break;
case 4:ma->clearFile(); break;
case 0:cout << "\t\t\t\t\t注销成功!" << endl; system("pause"); system("cls"); delete manager; return; break;
default:cout << "\t\t\t\t\t输入有误,请重新输入!" << endl; system("pause"); break;
}
}
}
void studentMenu(Identyfy*& student) {
while (1) {
student->openMenu();
//父类指针强转子类指针
Student* stu = (Student*)student;
int select;
cout << "\t\t输入您的选择:";
cin >> select;
switch (select)
{
case 1:stu->applyOrder(); break;
case 2:stu->showMyorder(); break;
case 3:stu->showAllorder(); break;
case 4:stu->cancelOrder(); break;
case 0:cout << "\t\t\t\t\t注销成功!" << endl; system("pause"); system("cls"); delete student; return; break;
default:cout << "\t\t\t\t\t输入有误,请重新输入!" << endl; system("pause"); break;
}
}
}
void teacherMenu(Identyfy*& teacher) {
while (1) {
teacher->openMenu();
//父类指针强转子类指针
Teacher* tea = (Teacher*)teacher;
int select;
cout << "\t\t输入您的选择:";
cin >> select;
switch (select)
{
case 1:tea->showAllorder(); break;
case 2:tea->verifyOrder(); break;
case 0:cout << "\t\t\t\t\t注销成功!" << endl; system("pause"); system("cls"); delete teacher; return; break;
default:cout << "\t\t\t\t\t输入有误,请重新输入!" << endl; system("pause"); break;
}
}
}
void login(int type) {
Identyfy* person = NULL;
mysqlCon* mc = new mysqlCon();
string id;
string username;
string password;
if (type == 1) {
cout << "\t\t请输入用户名:";
cin >> username;
cout << "\t\t请输入密码:";
cin >> password;
if (mc->varify_ma(username, password)) {
cout << "\t\t\t\t\t登陆成功!" << endl;
system("pause");
person = new Manager(username,password);
managerMenu(person);
}
else {
cout << "\t\t\t\t\t验证登录失败!" << endl;
system("pause");
system("cls");
}
}
else if (type == 2) {
cout << "\t\t请输入学号:";
cin >> id;
cout << "\t\t请输入用户名:";
cin >> username;
cout << "\t\t请输入密码:";
cin >> password;
if (mc->varify_stu(id,username, password)) {
cout << "\t\t\t\t\t登陆成功!" << endl;
system("pause");
person = new Student(id,username,password);
studentMenu(person);
}
else {
cout << "\t\t\t\t\t验证登录失败!" << endl;
system("pause");
system("cls");
}
}
else if (type == 3) {
cout << "\t\t请输入工号:";
cin >> id;
cout << "\t\t请输入用户名:";
cin >> username;
cout << "\t\t请输入密码:";
cin >> password;
if (mc->varify_tea(id,username, password)) {
cout << "\t\t\t\t\t登陆成功!" << endl;
system("pause");
person = new Teacher(id,username,password);
teacherMenu(person);
}
else {
cout << "\t\t\t\t\t验证登录失败!" << endl;
system("pause");
system("cls");
}
}
}
int main() {
while (1) {
system("cls");
cout << "\t\t\t\t" << " 欢迎来到机房预约系统" << endl;
cout << "\t\t\t\t" << "============================" << endl;
cout << "\t\t\t\t" << "| 1. 管理员登录 |" << endl;
cout << "\t\t\t\t" << "| |" << endl;
cout << "\t\t\t\t" << "| 2. 学生登录 |" << endl;
cout << "\t\t\t\t" << "| |" << endl;
cout << "\t\t\t\t" << "| 3. 教师登录 |" << endl;
cout << "\t\t\t\t" << "| |" << endl;
cout << "\t\t\t\t" << "| 0. 退出 |" << endl;
cout << "\t\t\t\t" << "============================" << endl;
int key;
cout << "\t\t输入您的选择:";
cin >> key;
switch (key)
{
case 1:login(1); break;
case 2:login(2); break;
case 3:login(3); break;
case 0:cout << "\t\t\t\t\t欢迎下次使用!" << endl;system("pause"); return 0; break;
default:cout << "\t\t\t\t\t输入有误,请重新输入!" << endl; system("pause"); break;
}
}
return 0;
}