-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathteacher.cpp
132 lines (124 loc) · 3.62 KB
/
teacher.cpp
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
#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::operMenu()
{
cout << "欢迎教师:" << this->m_Name << "登陆!" << endl;
cout << "\t\t ------------------------------\n";
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()
{
system("clear");
OrderFile of;
if (of.m_Size == 0)
{
system("clear");
cout << "无预约记录" << endl;
return;
}
for (int i = 0; i < of.m_Size; i++)
{
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 = " 状态:";
// 0 取消的预约 1 审核中 2 已预约 -1 预约失败
int ofStatus = atoi(of.m_orderData[i]["status"].c_str());
switch (ofStatus)
{
case 1:
status += "审核中";
break;
case 2:
status += "已预约";
break;
case -1:
status += "预约失败";
default:
status += "预约已取消";
break;
}
cout << status << endl;
}
}
// 审核预约
void Teacher::validOrder()
{
system("clear");
OrderFile of;
if (of.m_Size == 0)
{
cout << "无预约记录" << endl;
return;
}
cout << "待审核的预约记录如下:" << endl;
vector<int> v;
int index = 0;
for (int i = 0; i < of.m_Size; i++)
{
if (of.m_orderData[i]["status"] == "1")
{
v.push_back(i);
cout << ++index << "、";
cout << "预约日期:周" << of.m_orderData[i]["date"];
cout << " 时段:" << (of.m_orderData[i]["interval"] == "1" ? "上午" : "下午");
cout << " 机房:" << of.m_orderData[i]["roomId"];
cout << " 状态:审核中" << endl;
}
}
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.通过 2.不通过" << endl;
cin >> ret;
if (ret == 1)
{
of.m_orderData[v[select - 1]]["status"] = "2";
}
else if (ret == 2)
{
of.m_orderData[v[select - 1]]["status"] = "-1";
}
of.updateOrder();
cout << "操作成功" << endl;
break;
}
}
cout << "输入有误,请重新输入" << endl;
}
}