-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStudent.cpp
More file actions
148 lines (141 loc) · 3.93 KB
/
Copy pathStudent.cpp
File metadata and controls
148 lines (141 loc) · 3.93 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
#include"Student.h"
#include<string>
#include"mysqlCon.h"
Student::Student()
{
}
Student::Student(string sid, string username, string password) {
this->sid = sid;
this->username = username;
this->password = password;
}
void Student::openMenu()
{
system("cls");
cout << "\t\t\t\t" << " 欢迎" + this->username + "学生登录" << 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" << "| 4. 取消预约 |" << endl;
cout << "\t\t\t\t" << "| |" << endl;
cout << "\t\t\t\t" << "| 0. 注销登录 |" << endl;
cout << "\t\t\t\t" << "================================" << endl;
}
void Student::applyOrder()
{
mysqlCon::query_room();
int r;
cout << "\t\t请输入你要预约的机房:" ;
cin >> r;
if (!(r >= 1 && r <= 3)) {
cout << "\t\t输入有误,请重新选择!" << endl; system("pause");
return;
}
string room = to_string(r);
cout << "\t\t请输入你要预约的时间:周一至周五(1-5):";
int c;
cin >> c;
int c2;
string id = this->sid;
switch (c)
{
case 1:
cout << "\t\t选择具体时间:1.上午\t2.下午:";
cin >> c2;
if (c2 == 1) {
mysqlCon::apply(room, id,"周一上午");
}
else if (c2 == 2) {
mysqlCon::apply(room, id, "周一下午");
}
else cout << "\t\t输入有误,请重新选择!" << endl; system("pause"); return; break;
break;
case 2:
cout << "\t\t选择具体时间:1.上午\t2.下午:";
cin >> c2;
if (c2 == 1) {
mysqlCon::apply(room, id, "周二上午");
}
else if (c2 == 2) {
mysqlCon::apply(room, id, "周二下午");
}
else cout << "\t\t输入有误,请重新选择!" << endl; system("pause"); return; break;
break;
case 3:
cout << "\t\t选择具体时间:1.上午\t2.下午:";
cin >> c2;
if (c2 == 1) {
mysqlCon::apply(room, id, "周三上午");
}
else if (c2 == 2) {
mysqlCon::apply(room, id, "周三下午");
}
else cout << "\t\t输入有误,请重新选择!" << endl; system("pause"); return; break;
break;
case 4:
cout << "\t\t选择具体时间:1.上午\t2.下午:";
cin >> c2;
if (c2 == 1) {
mysqlCon::apply(room, id, "周四上午");
}
else if (c2 == 2) {
mysqlCon::apply(room, id, "周四下午");
}
else cout << "\t\t输入有误,请重新选择!" << endl; system("pause"); return; break;
break;
case 5:
cout << "\t\t选择具体时间:1.上午\t2.下午:";
cin >> c2;
if (c2 == 1) {
mysqlCon::apply(room, id, "周五上午");
}
else if (c2 == 2) {
mysqlCon::apply(room, id, "周五下午");
}
else cout << "\t\t输入有误,请重新选择!" << endl; system("pause"); return; break;
break;
default:cout << "\t\t输入有误,请重新选择!" << endl; system("pause"); return; break;
}
}
void Student::showAllorder()
{
mysqlCon::allOrder();
}
void Student::showMyorder()
{
string id = this->sid;
mysqlCon::myOrder(id);
}
void Student::cancelOrder()
{
string id = this->sid;
if (mysqlCon::delorder(id)) {
string room;
cout << "\t\t请选择你要删除的预约机房:";
cin >> room;
cout << "\t\t请输入你要删除的预约时间:";
string time;
cin >> time;
if (mysqlCon::verify(room, time)) {
int c;
cout << "\t\t是否确认要删除?输入1确认:";
cin >> c;
if (c == 1) {
mysqlCon::cancel(id, time);
}
else {
cout << "\t\t\t\t\t取消删除。";
system("pause");
}
}
else {
cout << "\t\t您的输入有误,请重新输入!" << endl;
system("pause");
return;
}
}
}