-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathteacher.cpp
More file actions
138 lines (128 loc) · 3.39 KB
/
teacher.cpp
File metadata and controls
138 lines (128 loc) · 3.39 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
#include "teacher.h"
Teacher::Teacher()
{
}
Teacher::Teacher(int empId, string name, string pwd)
{
this->m_EmpId = empId;
this->m_Name = name;
this->m_Pwd = pwd;
}
void Teacher::openMenu()
{
cout << "欢迎教师:" << this->m_Name << "登录!" << endl;
cout << "==================欢迎来到机房预约系统===================" << endl;
//cout << endl << "请输入您的身份" << endl;
cout << "\t\t ===================================\n";
cout << "\t\t 1.查看所有预约 \n";
cout << "\t\t \n";
cout << "\t\t 2.审核预约 \n";
cout << "\t\t \n";
cout << "\t\t 0.注销登录 \n";
cout << "\t\t \n";
cout << "\t\t ===================================\n";
cout << "请输入您的选择:" << endl;
}
void Teacher::showAllOrder()
{
OrderFile of;
if (of.m_size == 0) {
cout << "无预约记录!" << endl;
system("pause");
system("cls");
return;
}
for (int i = 0; i < of.m_size; i++) {
//string 转 int
//string 利用.c_str()转const char*
//利用atoi将(const char*) 转 int
cout << i * 1 << "、";
cout << "预约日期:周" << of.m_orderData[i]["date"];
cout << " 时间段:" << (of.m_orderData[i]["interval"] == "1" ? "上午" : "下午");
cout << " 学号:" << of.m_orderData[i]["stuId"];
cout << " 姓名:" << of.m_orderData[i]["stuName"];
cout << " 机房号:" << of.m_orderData[i]["roomId"];
string status = " 状态:";
if (of.m_orderData[i]["status"] == "1") {
status += "审核中";
}
else if (of.m_orderData[i]["status"] == "2") {
status += "预约成功";
}
else if (of.m_orderData[i]["status"] == "3") {
status += "预约失败,审核未成功";
}
else {
status += "预约已取消";
}
cout << status << endl;
}
system("pause");
system("cls");
}
void Teacher::validOrder()
{
OrderFile of;
if (of.m_size == 0) {
cout << "无预约记录!" << endl;
system("pause");
system("cls");
return;
}
cout << "待审核的预约记录如下:" << endl;
vector<int> v;
int index = 1;
bool flag = false;
for (int i = 0; i < of.m_size; i++) {
if (of.m_orderData[i]["status"] == "1") {
flag = true;
v.push_back(i);
cout << index++ << "、";
cout << "预约日期:周" << of.m_orderData[i]["date"];
cout << " 时间段:" << (of.m_orderData[i]["interval"] == "1" ? "上午" : "下午");
cout << " 学号:" << of.m_orderData[i]["stuId"];
cout << " 姓名:" << of.m_orderData[i]["stuName"];
cout << " 机房号:" << of.m_orderData[i]["roomId"];
string status = " 状态:";
if (of.m_orderData[i]["status"] == "1") {
status += "审核中";
}
cout << status << endl;
}
}
if (flag == false) {
cout << "抱歉,您暂无可以审核的记录!" << endl;
system("pause");
system("cls");
return;
}
cout << "请输入审核的预约记录,0代表返回" << endl;
int select = 0; //接收用户选择的预约记录
int ret = 0;//接收预约结果记录
while (true) {
cin >> select;
if (select >= 0 && select <= v.size()) {
if (select == 0) {
break;
}
else {
cout << "请输入审核结果" << endl;
cout << "1、通过" << endl;
cout << "2、不通过" << endl;
cin >> ret;
if (ret == 1) {
of.m_orderData[v[select - 1]]["status"] = "2";
}
else {
of.m_orderData[v[select - 1]]["status"] = "-1";
}
of.updateOrder();
cout << "审核完毕" << endl;
break;
}
}
cout << "输入有误,请重新输入!" << endl;
}
system("pause");
system("cls");
}