-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmenu.cpp
More file actions
482 lines (390 loc) · 9.69 KB
/
Copy pathmenu.cpp
File metadata and controls
482 lines (390 loc) · 9.69 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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
#pragma once
/**************************
*函数定义
****************************/
#include"main.h"
#include"Fuction.h"
#include"goodsClass.h"
#define TITLE "商品管理"
#pragma warning(disable:4996)
void systemStart() {
SetConsoleTitle(TITLE);
printDividerStar();
cout << "*****\t\t\t\t\t\t\t*****";
cout << '\n';
printShortStar();
cout << "\t\t";
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED);
cout << "欢迎来到商品后台管理系统";
cout << "\t\t";
printShortStar();
cout << "\n";
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_GREEN);
cout << "*****\t\t\t\t\t\t\t*****";
cout << "\n";
printDividerStar();
Sleep(2000);
cout << endl;
printShortStar();
cout << "你是管理员吗?那就请登录吧......";
printShortStar();
cout << endl;
Sleep(1000);
administratorLigin();
}
void printDividerStar() {
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_GREEN);
cout << "*************************************************************"<<endl;
}
void printDividerStarPurple() {
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_BLUE| FOREGROUND_RED);
cout << "**************************************************************************************";
cout << endl;
cout << endl;
}
void printShortStar() {
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_GREEN | FOREGROUND_RED);
cout << "*****";
}
void printShortWhiteStar() {
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE);
cout << "*****";
}
void printLongStar() {
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_GREEN | FOREGROUND_RED);
cout <<"********";
}
void printLongDash() {
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE);
cout << "-------------------------------------------------------------" << endl;
}
void printShortDash() {
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE);
cout << "-----";
}
void printLongerDash() {
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE);
cout << "---------------";
}
void printBlank() {
cout << "\t\t";
}
void printSystemTime() {
time_t rawtime;
struct tm *ptminfo;
time(&rawtime);
ptminfo = localtime(&rawtime);
cout << "当前系统时间:"
<< ptminfo->tm_year + 1900 << "-"
<< ptminfo->tm_mon + 1 << "-"
<< ptminfo->tm_mday << " "
<< ptminfo->tm_hour << ":"
<< ptminfo->tm_min << ":"
<< ptminfo->tm_sec;
}
bool isLogin(string password) {
if (password == PASSWORD)
return true;
else return false;
}
void administratorLigin() {
string password;
int tryInputPassword=0;
cout << endl;
cout << "请输入密码:";
cin >> password;
if (isLogin(password)) {
cout << endl;
printShortStar();
cout << "登录成功!";
printSystemTime();
printShortStar();
cout << "\n\n";
printDividerStar();
}
else{
cout << endl;
printShortStar();
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_RED);
cout << "登录失败!";
cout << "没关系,再试一次吧!";
printShortStar();
cout << endl;
Sleep(1000);
cout << endl;
cout << "请输入密码:";
cin >> password;
if (isLogin(password)) {
cout << endl;
printShortStar();
cout << "登录成功!";
printSystemTime();
printShortStar();
cout << endl;
}
else {
cout << endl;
printShortStar();
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED);
cout << "登录失败!";
cout << "你一定不是管理员,再见!";
printShortStar();
cout << endl;
exit(0);
}
}
}
void printChildMenu() {
cout << endl;
cout << endl;
printLongStar();
cout << "\t你现在处于商品管理界面!\t";
printLongStar();
cout << endl;
cout << endl;
printShortWhiteStar();
cout << "\t\t[1] 添加商品\t\t";
printShortWhiteStar();
cout << endl;
printShortWhiteStar();
cout << "\t\t[2] 商品查询\t\t";
printShortWhiteStar();
cout << endl;
printShortWhiteStar();
cout << "\t\t[3] 修改商品信息\t";
printShortWhiteStar();
cout << endl;
printShortWhiteStar();
cout << "\t\t[4] 删除商品\t\t";
printShortWhiteStar();
cout << endl;
printShortWhiteStar();
cout << "\t\t[0] 返回上一层\t\t";
printShortWhiteStar();
}
void printMainMenu() {
cout << endl;
printShortWhiteStar();
cout << "\t\t[1] 商品出售\t\t";
printShortWhiteStar();
cout << endl;
printShortWhiteStar();
cout << "\t\t[2] 退货\t\t";
printShortWhiteStar();
cout << endl;
printShortWhiteStar();
cout << "\t\t[3] 商品统计\t\t";
printShortWhiteStar();
cout << endl;
printShortWhiteStar();
cout << "\t\t[4] 商品管理系统\t";
printShortWhiteStar();
cout << endl;
printShortWhiteStar();
cout << "\t\t[0] 离开\t\t";
printShortWhiteStar();
}
void printModifyMenu() {
cout << endl;
printShortWhiteStar();
cout << "\t\t[1] 商品编号\t\t";
printShortWhiteStar();
cout << endl;
printShortWhiteStar();
cout << "\t\t[2] 生产厂家\t\t";
printShortWhiteStar();
cout << endl;
printShortWhiteStar();
cout << "\t\t[3] 商品类型\t\t";
printShortWhiteStar();
cout << endl;
printShortWhiteStar();
cout << "\t\t[4] 商品名\t\t";
printShortWhiteStar();
cout << endl;
printShortWhiteStar();
cout << "\t\t[5] 价格\t\t";
printShortWhiteStar();
cout << endl;
printShortWhiteStar();
cout << "\t\t[6] 商品品牌\t\t";
printShortWhiteStar();
cout << endl;
printShortWhiteStar();
cout << "\t\t[0] 返回上一层\t\t";
printShortWhiteStar();
}
void printSelectMenu() {
cout << endl;
cout << endl;
printLongStar();
cout << "您正处于分类查找界面!正如你所见,有以下查找依据!!";
printLongStar();
cout << endl;
cout << endl;
printShortWhiteStar();
cout << "\t\t[1] 商品名称\t\t";
printShortWhiteStar();
cout << endl;
printShortWhiteStar();
cout << "\t\t[2] 生产厂家\t\t";
printShortWhiteStar();
cout << endl;
printShortWhiteStar();
cout << "\t\t[3] 商品类别\t\t";
printShortWhiteStar();
cout << endl;
printShortWhiteStar();
cout << "\t\t[0] 返回上一层\t\t";
printShortWhiteStar();
}
void selectFunction() {
printSelectMenu();
string chooseId;
cout << '\n' << '\n';
printDividerStar();
printDividerStar();
cout << '\t';
cout << "你打算怎样查找呢?做个简单的选择吧:";
cin >> chooseId;
if (chooseId.size() > 1) {
cout << endl;
cout << endl;
printShortStar();
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED);
cout << "选项不合法!!!请重试";
printShortStar();
cout << endl;
selectFunction();
}
else {
char i_chooseId = chooseId[0];
switch (i_chooseId) {
case '1':SelectByName(ListOfGoods); break;
case '2':SelectByMfr(ListOfGoods); break;
case '3':SelectByClass(ListOfGoods); break;
case '0':returnChildLast(); break;
default:
cout << endl;
cout << endl;
printShortStar();
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED);
cout << "!!!未找到您的选项呢,要不再试试?";
printShortStar();
cout << endl;
selectFunction();
}
}
}
void switchFunction() {
printMainMenu();
string chooseId;
cout << '\n' << '\n';
printDividerStar();
printDividerStar();
cout << '\t';
cout << "您想做些什么呢?动动手,做个简单的选择吧:";
cin >> chooseId;
if (chooseId.size() > 1) {
cout << endl;
cout << endl;
printShortStar();
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED);
cout << "选项不合法!!!请重试";
printShortStar();
cout << endl;
switchFunction();
}
else {
char i_chooseId = chooseId[0];
switch (i_chooseId) {
case '1':sale(ListOfGoods); break; //销售功能
case '2':retrunSale(ListOfGoods); break; //退货功能
case '3':analyseData(ListOfGoods); break; //统计功能
case '4':manageFunction(); break; //商品管理功能
case '0':exitSystem(); break; //退出系统
default:
cout << endl;
cout << endl;
printShortStar();
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED);
cout << "!!!未找到您的选项呢,要不再试试?";
printShortStar();
cout << endl;
}
}
}
void modifyFunction(chartMerchan &ListOfGoods) {
string id;
cout << endl;
printLongDash();
cout << endl;
cout << "准备好要修改商品的信息了吗?那就请输入商品编号吧:";
cin >> id;
while (id.size() != 6) {
cout << endl;
printShortDash();
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED);
cout << "注意!!!商品编号需6位";
printShortDash();
cout << endl;
cout << "请再次输入商品号:";
cin.clear();
cin.ignore(1024, '\n');
cin >> id;
};
if (ListOfGoods.checkDataId(id)) {
selectModify(ListOfGoods.modifyStatus(id));
}
else {
cout << endl;
printShortDash();
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED);
cout << "数据库无与此商品相关信息";
printShortDash();
cout << "\n\n";
manageFunction();
}
}
void printHeaderLine() {
cout << "*商品编号*"
<< "\t*商品名*"
<< "\t*价格*"
<< "\t\t*生产厂商*"
<< "\t*品牌*\t"
<<"\t*状态*"<< "\n\n";
}
/**
void modifyFunction(chartMerchan &ListOfGoods) {
string id;
cout << endl;
printLongDash();
cout << endl;
cout << "请输入您要修改的商品的ID商品号:";
cin >> id;
while (id.size() != 6) {
cout << endl;
printShortDash();
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED);
cout << "注意!!!商品编号需6位";
printShortDash();
cout << endl;
cout << "请再次输入商品号:";
cin.clear();
cin.ignore(1024, '\n');
cin >> id;
};
if (ListOfGoods.checkDataId(id)) {
ListOfGoods.modifyStatus(id)->display();
selectModify(ListOfGoods.modifyStatus(id));
}else{
cout << endl;
printShortDash();
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED);
cout << "数据库无与此商品相关信息";
printShortDash();
cout << "\n\n";
manageFunction();
}
}
*/