-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
1022 lines (1004 loc) · 29.8 KB
/
main.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
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
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include "Header.h"
#include "NhanVien.h"
#include "KhachHang.h"
#include "MayBay.h"
#include "Ve.h"
#include "Node.cpp"
#include "Queue.cpp"
#include "DanhSachVePending.cpp"
#include "LinkedList.cpp"
#include "ArrayList.cpp"
#include "DanhSachVeSuccess.cpp"
#include "DanhSachMayBay.cpp"
#include "ChuyenBay.cpp"
#include "DanhSachChuyenBay.cpp"
#include "DanhSachNhanVien.cpp"
#include "DanhSachKhachHang.cpp"
int main() {
DanhSachVePending<Ve> listTicketsPending;
DanhSachVeSuccess<Ve> listTicketsSuccess;
DanhSachMayBay<MayBay> listPlanes;
DanhSachChuyenBay<ChuyenBay<Ve>, MayBay, Ve> listFlights(100);
DanhSachNhanVien<NhanVien> listEmployees;
DanhSachKhachHang<KhachHang> listCustomers;
//BAT DAU DOC FILE;
listTicketsPending.xuLyDocFile();
listTicketsSuccess.xuLyDocFile();
listPlanes.xuLyDocFile();
listFlights.xuLyDocFile(listPlanes, listTicketsSuccess);
listEmployees.xuLyDocFile();
listCustomers.xuLyDocFile();
//KET THUC DOC FILE
//update lai trang thai cac chuyen bay
listFlights.updateTrangThai();
//cap nhat lai file danh sach cac chuyen bay
listFlights.updateFile();
int iOption = 0;
NhanVien* nhanVienHienTai = NULL;
do {
system("cls");
menuChucNang();
cin >> iOption;
switch (iOption)
{
case 0: {
//THOAT CHUONG TRINH
exit(0);
break;
}
case 1:
{
//HIEN THI DANH SACH CAC CHUYEN BAY
system("cls");
loading(10, 40);
system("cls");
setColor(4);
cout << "-> ";
setColor(7);
cout << "1. Hien thi danh sach chuyen bay." << endl;
//update lai trang thai cac chuyen bay
listFlights.updateTrangThai();
//hien thi cac chuyen bay
listFlights.hienThiChuyenBay();
//cap nhat lai file danh sach cac chuyen bay
listFlights.updateFile();
system("pause");
break;
}
case 2:
{
// DAT VE
//update lai trang thai cac chuyen bay
listFlights.updateTrangThai();
//cap nhat lai file danh sach cac chuyen bay
listFlights.updateFile();
system("cls");
string hoTen, CMND, maChuyenBay;
int maSoGhe;
setColor(4);
cout << "-> ";
setColor(7);
cout << "2. Dat ve." << endl;
setColor(2);
cout << "\t\t\t\t\t";
cout << "DAT VE:" << endl;
setColor(7);
cout << "\t\t\t";
cout << "Vui Long Dien Thong Tin Ca Nhan" << endl;
setColor(4);
cout << "\t\t\t";
cout << "Luu y: Chi duoc dat ve truoc gio khoi hanh 15 phut!" << endl;
setColor(7);
cout << "\t\t\t";
cout << "Nhap CMND hoac CCCD: ";
cin.ignore();
while (getline(cin, CMND)) {
//Kiem tra khoang trang
if (checkContainsSpacing(CMND)) {
setColor(4);
cout << "\t\t\t";
cout << "CMND hoac CCCD chua khoang trang, vui long nhap lai!" << endl;
setColor(7);
cout << "\t\t\t";
cout << "Nhap CMND hoac CCCD: ";
continue;
}
//Kiem tra co phai la chuoi so hay khong
if (!checkIsNumberString(CMND)) {
setColor(4);
cout << "\t\t\t";
cout << "CMND hoac CCCD khong phai la so, nhap lai! " << endl;
setColor(7);
cout << "\t\t\t";
cout << "Nhap CMND hoac CCCD: ";
continue;
}
//Kiem tra CMND du 9 so, CCCD du 12 so
if (CMND.length() == 9 || CMND.length() == 12) {
break;
}
setColor(4);
cout << "\t\t\t";
cout << "CMND hoac CCCD khong hop le, vui long dien du 9 so (CMND) va 12 so (CCCD)!" << endl;
setColor(7);
cout << "\t\t\t";
cout << "Nhap CMND hoac CCCD: ";
}
//Kiem tra xem khach hang da dat ve truoc do chua
KhachHang* searchKhachHang = listCustomers.timKiemKhachHang(CMND);
if (searchKhachHang == NULL) {
//Neu khach hang chua dat ve truoc do, thi tao moi khach hang
cout << "\t\t\t";
cout << "Nhap Ho Ten: ";
while (getline(cin, hoTen)) {
//Kiem tra Ho ten co chua khoang trang hay khong
if (checkContainsSpacing(hoTen)) {
setColor(4);
cout << "\t\t\t";
cout << "Ho Ten chua khoang trang, vui long nhap lai!" << endl;
setColor(7);
cout << "\t\t\t";
cout << "Nhap Ho Ten: ";
continue;
}
//Kiem tra Ho ten du 2 ki tu
if (hoTen.length() >= 2) {
break;
}
setColor(4);
cout << "\t\t\t";
cout << "Ho Ten khong hop le, vui long nhap lai!" << endl;
setColor(7);
cout << "\t\t\t";
cout << "Nhap Ho Ten: ";
}
//Chuyen thanh UpperCase
hoTen = convertUpperCase(hoTen);
}
else {
//Neu khach hang da dat ve truoc do, thi lay thong tin lai
cout << "\t\t\t";
cout << "Chao mung tro lai! Khach hang: ";
hoTen = searchKhachHang->getHoTen();
setColor(10);
cout << searchKhachHang->getHoTen();
setColor(7);
cout << endl;
}
cout << "\t\t\t";
cout << "Nhap Ma Chuyen Bay: ";
while (getline(cin, maChuyenBay)) {
//Kiem tra Ma chuyen bay co chua khoang trang hay khong
if (checkContainsSpacing(maChuyenBay)) {
setColor(4);
cout << "\t\t\t";
cout << "Ma chuyen bay chua khoang trang, vui long nhap lai!" << endl;
setColor(7);
cout << "\t\t\t";
cout << "Nhap Ma Chuyen Bay: ";
continue;
}
if (maChuyenBay.length() == 0) {
setColor(4);
cout << "\t\t\t";
cout << "Ma chuyen bay khong hop le, vui long nhap lai!" << endl;
setColor(7);
cout << "\t\t\t";
cout << "Nhap Ma Chuyen Bay: ";
continue;
}
break;
}
//chuyen chu thuong thanh chu hoa
maChuyenBay = convertUpperCase(maChuyenBay);
//Tim kiem chuyen bay theo ma chuyen bay
int iSearchChuyenBay = listFlights.timKiemChuyenBay(maChuyenBay);
system("cls");
cout << endl;
if (iSearchChuyenBay == -1) {
setColor(4);
cout << "\t\t\t";
cout << "Khong tim thay Chuyen Bay!" << endl;
setColor(7);
cout << "\t\t\t";
system("pause");
break;
}
//Lay thong tin chuyen bay sau khi tim kiem thanh cong
ChuyenBay<Ve> cbTemp = listFlights.getItem(iSearchChuyenBay);
//Hien thi chi tiet chuyen bay
setColor(2);
cout << "\t\t\t\t";
cout << "THONG TIN CHUYEN BAY " << maChuyenBay << ": " << endl;
setColor(7);
cout << setfill('-');
setColor(4);
cout << setw(145) << "-" << endl;
setColor(7);
cout << setfill(' ');
cout << setw(10) << left << "MAY BAY";
cout << setw(15) << left << "MA CHUYEN BAY";
cout << setw(20) << left << "NGAY KHOI HANH";
cout << setw(15) << left << "SAN BAY DEN";
cout << setw(15) << left << "TRANG THAI";
cout << setw(15) << left << "SO CHO NGOI";
cout << setw(20) << left << "SO CHO NGOI TRONG";
cout << setw(100) << left << "DANH SACH VE DUOC DAT" << endl;
cout << setfill('-');
setColor(4);
cout << setw(145) << "-" << endl;
setColor(7);
cout << setfill(' ');
cbTemp.displayDetail();
cout << setfill('-');
setColor(4);
cout << setw(145) << "-" << endl;
setColor(7);
cout << setfill(' ');
cout << endl;
//KIEM TRA TRANG THAI CUA CHUYEN BAY
//Kiem tra chuyen bay chua bi huy
if (cbTemp.getTrangThai() == 0) {
setColor(4);
cout << "\t\t\t";
cout << "Chuyen bay da bi huy!" << endl;
setColor(7);
system("pause");
break;
}
//Kiem tra chuyen bay chua hoan tat
if (cbTemp.getTrangThai() == 3) {
setColor(4);
cout << "\t\t\t";
cout << "Chuyen bay da hoan tat!" << endl;
setColor(7);
system("pause");
break;
}
//Kiem tra chuyen bay van con cho trong
if (cbTemp.isFullSeat()) {
setColor(4);
cout << "\t\t\t";
cout << "Chuyen bay khong con ghe trong!" << endl;
setColor(7);
system("pause");
break;
}
//Chi cho phep khach hang dat ve truoc gio khoi hanh cua chuyen bay 15 phut.
if (cbTemp.getTimestamp() - 60 * 15 <= getCurrentTimestamp() ) {
setColor(4);
cout << "\t\t\t";
cout << "Vui long dat ve truoc gio khoi hanh 15 phut!" << endl;
setColor(7);
system("pause");
break;
}
cout << "\t\t\t";
cout << "Nhap ma so ghe muon dat: ";
cin >> maSoGhe;
int kiemTraGhe = cbTemp.kiemTraMaSoGhe(maSoGhe);
while (kiemTraGhe != 3) {
//Kiem tra cac trang thai ghe cua chuyen bay dua vao so ghe khach nhap.
setColor(4);
if (kiemTraGhe == 1) {
cout << "\t\t\t";
cout << "Ma so ghe khong hop le, vui long chon ghe khac!" << endl;
}
else if (kiemTraGhe == 2) {
cout << "\t\t\t";
cout << "Ma so ghe da duoc dat, vui long chon ghe khac!" << endl;
}
setColor(7);
cout << "\t\t\t";
cout << "Nhap ma so ghe muon dat: ";
cin >> maSoGhe;
kiemTraGhe = cbTemp.kiemTraMaSoGhe(maSoGhe);
}
//Xac nhan lai thong tin dat ve
system("cls");
setColor(2);
cout << "\t\t\t";
cout << "VUI LONG KIEM TRA LAI THONG TIN DAT VE:" << endl;
setColor(7);
cout << setfill('-');
setColor(4);
cout << setw(130) << "-" << endl;
setColor(7);
cout << setfill(' ');
cout << setw(30) << left << "HO TEN";
cout << setw(15) << left << "CMND";
cout << setw(15) << left << "MA CHUYEN BAY";
cout << setw(20) << left << "SO GHE" << endl;
cout << setfill('-');
setColor(4);
cout << setw(130) << "-" << endl;
setColor(7);
cout << setfill(' ');
cout << setw(30) << left << hoTen;
cout << setw(15) << left << CMND;
cout << setw(15) << left << maChuyenBay;
cout << setw(20) << left << maSoGhe << endl;
cout << setfill('-');
setColor(4);
cout << setw(130) << "-" << endl;
setColor(7);
cout << setfill(' ');
cout << endl;
string strConfirmBook;
cout << "\t\t\t";
cout << "Xac nhan dat ve? Nhap ";
setColor(10);
cout << "YES";
setColor(7);
cout << " neu dong y, ";
setColor(12);
cout << "NO";
setColor(7);
cout << " neu tu choi: ";
setColor(7);
cin.ignore();
getline(cin, strConfirmBook);
//chuyen chu thuong thanh chu hoa
strConfirmBook = convertUpperCase(strConfirmBook);
//kiem tra nguoi dung co nhap yes hay no hay khong
if (strConfirmBook != "YES" && strConfirmBook != "NO") {
setColor(4);
cout << "\t\t\t";
cout << "Vui long nhap YES hoac NO!" << endl;
setColor(7);
system("pause");
break;
}
if (strConfirmBook == "YES") {
system("cls");
loading(10, 40);
system("cls");
//Chi cho phep khach hang dat ve truoc gio khoi hanh cua chuyen bay 15 phut.
if (cbTemp.getTimestamp() - 60 * 15 <= getCurrentTimestamp()) {
setColor(4);
cout << "\t\t\t";
cout << "Vui long dat ve truoc gio khoi hanh 15 phut!" << endl;
setColor(7);
system("pause");
break;
}
//DONG Y DAT VE
//Neu chua co khach hang thi them vao danh sach khach hang
if (searchKhachHang == NULL) {
//Tao mot doi tuong KhachHang moi
KhachHang* khachHangMoi = new KhachHang(CMND, hoTen, listCustomers.getSize() + 1);
//Them doi tuong vao danh sach Khach Hang
listCustomers.addTail(*khachHangMoi);
//Update lai file KhachHang
listCustomers.xuLyGhiFile(*khachHangMoi);
}
//Them vao danh sach ve pending
stringstream ss;
ss << maSoGhe;
string maSoGheString;
ss >> maSoGheString;
string maVe = maChuyenBay + maSoGheString;
//Tao mot doi tuong Ve moi
Ve* veMoi = new Ve(maVe, maChuyenBay, CMND, hoTen, maSoGhe, getCurrentDate());
veMoi->setTimestamp();
//Them vao danh sach Ve Pending
listTicketsPending.enQueue(*veMoi);
//Update lai file VeDangCho
listTicketsPending.xuLyGhiFile(*veMoi);
setColor(3);
cout << "\t\t\t";
cout << "DAT VE THANH CONG! VUI LONG CHO NHAN VIEN XU LY!" << endl;
setColor(7);
}
else {
//HUY DAT VE
setColor(4);
cout << "\t\t\t";
cout << "HUY DAT VE THANH CONG! HEN GAP LAI QUY KHACH!" << endl;
setColor(7);
}
system("pause");
break;
}
case 3:
{
//NHAN VIEN QUAN LY
system("cls");
string strUsername, strPassword;
int iDem = 0;
setColor(4);
cout << "-> ";
setColor(7);
cout << "3. Quan ly." << endl;
setColor(14);
char c;
do {
system("cls");
//Menu chuc nang dang nhap nhan vien
dangNhapNhanVien(strUsername, strPassword);
//Tim kiem nhan vien theo username va password
NhanVien* timKiemNhanVien = listEmployees.timKiemNhanVien(strUsername, strPassword);
if (strUsername.length() == 0) {
system("cls");
setColor(4);
cout << endl << "\t\t\tUsername khong duoc bo trong. \n \t\t\tNhan phim ESC de thoat hoac phim Enter 2 lan de tiep tuc dang nhap!" << endl;
setColor(7);
//Lay du lieu khi nguoi dung nhan phim bat ki
c = getch();
}
else if (strPassword.length() == 0) {
system("cls");
setColor(4);
cout << endl << "\t\t\tPassword khong duoc bo trong. \n \t\t\tNhan phim ESC de thoat hoac phim Enter 2 lan de tiep tuc dang nhap!" << endl;
setColor(7);
//Lay du lieu khi nguoi dung nhan phim bat ki
c = getch();
}
else if (checkContainsSpacing(strUsername)) {
system("cls");
setColor(4);
cout << endl << "\t\t\tUsername khong duoc chua khoang trang. \n \t\t\tNhan phim ESC de thoat hoac phim Enter 2 lan de tiep tuc dang nhap!" << endl;
setColor(7);
//Lay du lieu khi nguoi dung nhan phim bat ki
c = getch();
}
else if (timKiemNhanVien == NULL) {
//Dang nhap that bai
iDem++;
system("cls");
setColor(4);
cout << endl << "\t\t\tSai tai khoan hoac mat khau! Ban con " << 3 - iDem << " lan nhap. \n \t\t\tNhan phim ESC de thoat hoac phim Enter 2 lan de tiep tuc dang nhap!" << endl;
setColor(7);
//Lay du lieu khi nguoi dung nhan phim bat ki
c = getch();
}
else {
//Luu thong tin dang nhap cua nhan vien hien tai
nhanVienHienTai = timKiemNhanVien;
break;
}
if (c == 27) {
//Neu nguoi dung nhap phim ESC thi thoat chuong trinh
exit(1);
break;
}
if (iDem == 3) {
//Neu nguoi dung nhap sai 3 lan thi thoat chuong trinh
exit(1);
break;
}
cout << endl;
} while (iDem < 3 && c != 27);
cout << "DANG NHAP THANH CONG." << endl;
system("cls");
int iOptionAdmin = 0;
do {
system("cls");
cout << "Xin chao, " << nhanVienHienTai->getUsername() << endl;
//Menu chuc nang nhan vien
menuAdmin();
cin >> iOptionAdmin;
cout << endl;
switch (iOptionAdmin) {
case 0: {
//DANG XUAT NHAN VIEN
nhanVienHienTai = NULL;
break;
}
case 1:
{
//XU LY DAT VE
system("cls");
setColor(4);
cout << "-> ";
setColor(7);
cout << "1. Xu ly dat ve." << endl;
setColor(2);
cout << "\t\t\t\t\t";
cout << "DANH SACH VE PENDING:" << endl;
setColor(7);
//Kiem tra danh sach ve pending trong
if (listTicketsPending.getSize() == 0) {
cout << "\t\t\t";
setColor(4);
cout << "Khong co danh sach ve dang cho." << endl;
setColor(7);
system("pause");
break;
}
//Hien thi danh sach ve pending
cout << setfill('-');
setColor(4);
cout << setw(150) << "-" << endl;
setColor(7);
cout << setfill(' ');
cout << setw(20) << left << "MA VE";
cout << setw(20) << left << "MA CHUYEN BAY";
cout << setw(20) << left << "CMND";
cout << setw(20) << left << "HO TEN";
cout << setw(20) << left << "SO GHE";
cout << setw(50) << left << "DATE" << endl;
cout << setfill('-');
setColor(4);
cout << setw(150) << "-" << endl;
setColor(7);
cout << setfill(' ');
listTicketsPending.displayDetail();
cout << setfill('-');
setColor(4);
cout << setw(150) << "-" << endl;
setColor(7);
cout << setfill(' ');
setColor(7);
//Ket thuc hien thi
string strConfirmHandle;
cout << "\t\t\t";
cout << "Bat dau xu ly ve pending? ";
setColor(10);
cout << "YES";
setColor(7);
cout << " neu dong y, ";
setColor(12);
cout << "NO";
setColor(7);
cout << " neu khong dong y! ";
setColor(7);
cin.ignore();
getline(cin, strConfirmHandle);
//Chuyen chu thuong thanh chu hoa
strConfirmHandle = convertUpperCase(strConfirmHandle);
//kiem tra nguoi dung co nhap yes hay no hay khong
if (strConfirmHandle != "YES" && strConfirmHandle != "NO") {
setColor(4);
cout << "\t\t\t";
cout << "Vui long nhap YES hoac NO!" << endl;
setColor(7);
system("pause");
break;
}
if (strConfirmHandle == "YES") {
system("cls");
loading(10, 40);
system("cls");
//Bat dau xu ly ve pending
system("cls");
setColor(2);
cout << "\t\t\t\t\t";
cout << "TIEN TRINH XU LY VE PENDING:" << endl << endl;
setColor(7);
cout << setfill('*');
cout << "\t\t\t\t";
cout << setw(50) << "*" << endl;
cout << setfill(' ');
//Trong khi danh sach ve pending van con ve de xu ly
while (listTicketsPending.getSize() != 0) {
// lay ve dang cho khoi hang doi
Ve veTemp = listTicketsPending.deQueue();
//Hien thi thong tin Ve
cout << "\t\t\t\t\t";
cout << "Ma ve: " << veTemp.getMaVe() << endl;
cout << "\t\t\t\t\t";
cout << "Khach hang: " << veTemp.getHoTen() << endl;
cout << "\t\t\t\t\t";
cout << "Chuyen Bay: " << veTemp.getMaChuyenBay() << endl;
cout << "\t\t\t\t\t";
cout << "Ma So Ghe: " << veTemp.getSoGhe() << endl;
cout << "\t\t\t\t\t";
cout << "Date: " << veTemp.getDate() << endl;
//Tim kiem chuyen bay dua tren ma chuyen bay cua ve
int iSearchChuyenBay = listFlights.timKiemChuyenBay(veTemp.getMaChuyenBay());
ChuyenBay<Ve>* cbTemp = listFlights.getPointerItem(iSearchChuyenBay);
//Cap nhat lai trang thai cua chuyen bay truoc khi thuc thi tiep tuc.
cbTemp->updateTrangThai();
if (cbTemp->getTrangThai() == 3) {
cout << "\t\t\t\t\t";
cout << "Trang thai: ";
setColor(12);
cout << "That bai." << endl;
setColor(7);
cout << "\t\t\t\t\t";
cout << "Ly do: Chuyen bay nay da hoan tat." << endl;
}
else if (cbTemp->getTrangThai() == 0) {
cout << "\t\t\t\t\t";
cout << "Trang thai: ";
setColor(12);
cout << "That bai." << endl;
setColor(7);
cout << "\t\t\t\t\t";
cout << "Ly do: Chuyen bay nay da bi huy." << endl;
}
else {
//Kiem tra so ghe cua ve co hop le hay khong
int iStatusGhe = cbTemp->kiemTraMaSoGhe(veTemp.getSoGhe());
//thanh cong
if (iStatusGhe == 3) {
// tao file ve moi
veTemp.createFile();
//them ve vao danh sach ve cua chuyenbay
cbTemp->themVeMoi(veTemp);
//Sau khi them thi sap xep ve
cbTemp->sapXepDanhSachVe(1);
// remove ghe trong khoi danh sach ghe trong
cbTemp->removeGheTrong(veTemp.getSoGhe());
//sau khi xoa thi sap xep danh sach ghe trong
cbTemp->sapXepDanhSachGheTrong(1);
//update lai trang thai: hoan tat, con ve, het ve.
cbTemp->updateTrangThai();
//them ve moi vao file danh sach ve thanh cong
listTicketsSuccess.xuLyGhiFile(veTemp);
//them ve moi vao danh sach ve thanh cong
listTicketsSuccess.addTail(veTemp);
cout << "\t\t\t\t\t";
cout << "Trang thai: ";
setColor(10);
cout << "Thanh cong.";
setColor(7);
cout << endl;
}
else {
if (iStatusGhe == 2) {
cout << "\t\t\t\t\t";
cout << "Trang thai: ";
setColor(12);
cout << "That bai." << endl;
setColor(7);
cout << "\t\t\t\t\t";
cout << "Ly do: Ma ghe da duoc nguoi khac dat!" << endl;
}
else if (iStatusGhe == 1) {
cout << "\t\t\t\t\t";
cout << "Trang thai: ";
setColor(12);
cout << "That bai." << endl;
setColor(7);
cout << "\t\t\t\t\t";
cout << "Ly do: Ma ghe khong hop le!" << endl;
}
cout << endl;
}
}
cout << setfill('*');
cout << "\t\t\t\t";
cout << setw(50) << "*" << endl;
cout << setfill(' ');
//cap nhat lai file danh sach ve dang cho (VeDangCho) sau khi xu ly 1 ve
listTicketsPending.updateFile();
}
//cap nhat lai file danh sach chuyen bay sau khi xu ly xong tat ca ve pending
listFlights.updateFile();
}
else {
cout << "\t\t\t";
setColor(4);
cout << "Tu choi " << endl;
setColor(7);
}
cout << endl;
system("pause");
break;
}
case 2:
{
//XU LY TRA VE
//update lai trang thai cac chuyen bay
listFlights.updateTrangThai();
//cap nhat lai file danh sach cac chuyen bay
listFlights.updateFile();
system("cls");
setColor(4);
cout << "-> ";
setColor(7);
cout << "2. Xu ly tra ve." << endl;
setColor(2);
cout << "\t\t\t\t\t";
cout << "DANH SACH VE DA DAT THANH CONG:" << endl;
setColor(7);
//Kiem tra danh sach ve pending trong
if (listTicketsSuccess.getSize() == 0) {
cout << "\t\t\t";
setColor(4);
cout << "Khong co danh sach ve thanh cong." << endl;
setColor(7);
system("pause");
break;
}
//Hien thi danh sach ve success
cout << setfill('-');
setColor(4);
cout << setw(150) << "-" << endl;
setColor(7);
cout << setfill(' ');
cout << setw(20) << left << "MA VE";
cout << setw(20) << left << "MA CHUYEN BAY";
cout << setw(20) << left << "CMND";
cout << setw(20) << left << "HO TEN";
cout << setw(20) << left << "SO GHE";
cout << setw(50) << left << "DATE" << endl;
cout << setfill('-');
setColor(4);
cout << setw(150) << "-" << endl;
setColor(7);
cout << setfill(' ');
listTicketsSuccess.displayDetail();
cout << setfill('-');
setColor(4);
cout << setw(150) << "-" << endl;
setColor(7);
cout << setfill(' ');
//Ket thuc hien thi danh sach
cin.ignore();
cout << "\t\t\t";
cout << "Nhap ma ve muon tra ve: ";
string strMaVe;
while (getline(cin, strMaVe)) {
//Kiem tra Ma chuyen bay co chua khoang trang hay khong
if (checkContainsSpacing(strMaVe)) {
setColor(4);
cout << "\t\t\t";
cout << "Ma Ve chua khoang trang, vui long nhap lai!" << endl;
setColor(7);
cout << "\t\t\t";
cout << "Nhap ma ve muon tra ve: ";
continue;
}
if (strMaVe.length() == 0) {
setColor(4);
cout << "\t\t\t";
cout << "Ma Ve khong hop le, vui long nhap lai!" << endl;
setColor(7);
cout << "\t\t\t";
cout << "Nhap ma ve muon tra ve: ";
continue;
}
break;
}
//Chuyen tu chu thuong sang hoa
strMaVe = convertUpperCase(strMaVe);
// tim ve
Ve* timKiemVe = listTicketsSuccess.timKiemVe(strMaVe);
system("cls");
loading(10, 40);
system("cls");
setColor(2);
cout << "\t\t\t\t\t";
cout << "TIEN TRINH XU LY TRA VE:" << endl;
setColor(7);
if (timKiemVe != NULL) {
cout << setfill('*');
cout << "\t\t\t\t";
cout << setw(50) << "*" << endl;
cout << setfill(' ');
cout << "\t\t\t\t\t";
cout << "Ma ve: " << timKiemVe->getMaVe() << endl;
cout << "\t\t\t\t\t";
cout << "Khach hang: " << timKiemVe->getHoTen() << endl;
cout << "\t\t\t\t\t";
cout << "Chuyen Bay: " << timKiemVe->getMaChuyenBay() << endl;
cout << "\t\t\t\t\t";
cout << "Ma So Ghe: " << timKiemVe->getSoGhe() << endl;
cout << "\t\t\t\t\t";
cout << "Date: " << timKiemVe->getDate() << endl;
int iSearchChuyenBay = listFlights.timKiemChuyenBay(timKiemVe->getMaChuyenBay());
ChuyenBay<Ve>* cbTemp = listFlights.getPointerItem(iSearchChuyenBay);
//Kiem tra thoi gian hien tai voi thoi gian khoi hanh
if (getCurrentTimestamp() >= cbTemp->getTimestamp()) {
cout << "\t\t\t\t\t";
cout << "Trang thai: ";
setColor(12);
cout << "That bai." << endl;
setColor(7);
cout << "\t\t\t\t\t";
cout << "Ly do: Chuyen bay nay da hoan tat." << endl;
}
else if (cbTemp->getTrangThai() == 3) {
cout << "\t\t\t\t\t";
cout << "Trang thai: ";
setColor(12);
cout << "That bai." << endl;
setColor(7);
cout << "\t\t\t\t\t";
cout << "Ly do: Chuyen bay nay da hoan tat." << endl;
}
else {
cout << "\t\t\t\t\t";
cout << "Trang thai: ";
setColor(10);
cout << "Thanh cong." << endl;
setColor(7);
//xoa file ve
timKiemVe->deleteFile();
//them ghe trong vao chuyen bay
cbTemp->themGheTrongMoi(timKiemVe->getSoGhe());
//Sau khi them ghe trong thi sap xep lai
cbTemp->sapXepDanhSachGheTrong(1);
// xoa ve khoi chuyen bay
cbTemp->removeVe(timKiemVe->getSoGhe());
//Sau khi xpa ve thi sap xep lai danh sach ve
cbTemp->sapXepDanhSachVe(1);
//xoa khoi danh sach ve success
Node<Ve>* nodeVe = listTicketsSuccess.timKiemNode(strMaVe);
listTicketsSuccess.remove(nodeVe);
//Update lai file VeThanhCong
listTicketsSuccess.updateFile();
//Update lai trang thai cua chuyen bay
cbTemp->updateTrangThai();
//Update file danh sach chuyen bay
listFlights.updateFile();
}
cout << setfill('*');
cout << "\t\t\t\t";
cout << setw(50) << "*" << endl;
cout << setfill(' ');
}
else {
setColor(4);
cout << "\t\t\t";
cout << "Ma ve khong ton tai trong he thong!" << endl;
setColor(7);
}
cout << endl;
system("pause");
break;
}
case 3:
{
int iOptionSubAdmin = 0;
do {
system("cls");
//Menu thong ke
menuAdminThongKe();
cin >> iOptionSubAdmin;
switch (iOptionSubAdmin)
{
case 0: {
break;
}
case 1: {
//THONG KE DANH SACH VE VA DANH SACH GHE TRONG
system("cls");
setColor(4);
cout << "-> ";
setColor(7);
cout << "3.1. Thong ke theo ma chuyen bay." << endl;
cin.ignore();
cout << "\t\t\t";
cout << "Nhap ma chuyen bay: ";
string maChuyenBay;
while (getline(cin, maChuyenBay)) {
//Kiem tra Ma chuyen bay co chua khoang trang hay khong
if (checkContainsSpacing(maChuyenBay)) {
setColor(4);
cout << "\t\t\t";
cout << "Ma chuyen bay chua khoang trang, vui long nhap lai!" << endl;
setColor(7);
cout << "\t\t\t";
cout << "Nhap ma chuyen bay: ";
continue;
}
if (maChuyenBay.length() == 0) {
setColor(4);
cout << "\t\t\t";
cout << "Ma chuyen bay khong hop le, vui long nhap lai!" << endl;
setColor(7);
cout << "\t\t\t";
cout << "Nhap ma chuyen bay: ";
continue;
}
break;
}
//Chuyen tu chu thuong thanh chu hoa
maChuyenBay = convertUpperCase(maChuyenBay);
system("cls");
loading(10, 40);
system("cls");
int iSearchChuyenBay = listFlights.timKiemChuyenBay(maChuyenBay);
if (iSearchChuyenBay == -1) {
setColor(4);
cout << "\t\t\t";
cout << "Ma chuyen bay khong ton tai trong he thong." << endl;
setColor(7);
}
else {
system("cls");
ChuyenBay<Ve>* cbTemp = listFlights.getPointerItem(iSearchChuyenBay);
setColor(2);
cout << "\t\t\t\t\t";
cout << "THONG TIN CHUYEN BAY: " << maChuyenBay << endl << endl;
setColor(7);
//update lai trang thai cac chuyen bay
listFlights.updateTrangThai();
//cap nhat lai file danh sach cac chuyen bay
listFlights.updateFile();
//Hien thi danh sach ve cua chuyen bay tim thay
cbTemp->hienThiDanhSachKhach();
cout << endl;
//Hien thi danh sach ghe trong cua chuyen bay tim thay
cbTemp->hienThiDanhSachGheTrong();
}
cout << endl;
system("pause");
break;
}
case 2: {
//THONG KE SO LAN THUC HIEN CHUYEN BAY THEO MAY BAY
system("cls");
setColor(4);
cout << "-> ";
setColor(7);
cout << "3.2. Thong ke so lan thuc hien chuyen bay theo may bay." << endl;
cin.ignore();
cout << "\t\t\t";
cout << "Nhap so hieu may bay: ";
string soHieuMayBay;
while (getline(cin, soHieuMayBay)) {
//Kiem tra Ma chuyen bay co chua khoang trang hay khong
if (checkContainsSpacing(soHieuMayBay)) {
setColor(4);
cout << "\t\t\t";
cout << "So hieu may bay chua khoang trang, vui long nhap lai!" << endl;
setColor(7);
cout << "\t\t\t";
cout << "Nhap so hieu may bay: ";
continue;
}
if (soHieuMayBay.length() == 0) {
setColor(4);
cout << "\t\t\t";
cout << "So hieu may bay khong hop le, vui long nhap lai!" << endl;
setColor(7);
cout << "\t\t\t";
cout << "Nhap so hieu may bay: ";
continue;
}
break;
}
//Chuyen tu chu thuong thanh chu hoa
soHieuMayBay = convertUpperCase(soHieuMayBay);
system("cls");
loading(10, 40);
system("cls");
MayBay* timKiemMayBay = listPlanes.timKiemMayBay(soHieuMayBay);
if (timKiemMayBay == NULL) {
setColor(4);
cout << "\t\t\t";
cout << "So hieu may bay khong ton tai trong he thong." << endl;
setColor(7);
}
else {
system("cls");
//update lai trang thai cac chuyen bay
listFlights.updateTrangThai();
//cap nhat lai file danh sach cac chuyen bay
listFlights.updateFile();
listFlights.hienThiSoLanBay(soHieuMayBay);
}
cout << endl;
system("pause");
break;
}
default:
exit(1);
break;
}
} while (iOptionSubAdmin != 0);
cout << endl;