-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
2940 lines (2749 loc) · 75 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<graphics.h>
#include"khaibao.h"
#include<iostream>
#include<cmath>
#include<ctime>
#include <conio.h>
using namespace std;
// cac ham tong quat
void normal_box(int, int, int, int, char[], int, int, int);
void highlight_box(int, int, int, int, char[], int, int, int);
void in_main_menu();
void xoa_cn();
void reset_all();
void normal_text();
void charValue(int , char []);
bool ktrVT(int,int,int,int,int,int);
bool ktrKyTu(char &, bool, bool, bool);
int intValue(char []);
void nhap(int, int, int, int, int, int, int, char[], int &, int &);
void reset_temp(char [], char [], char []);
bool xau_trung(char [],char []);
void xoa_tbloi();
void xu_ly_trang(int &,int,int,int);
void giaiphongcay(TREE);
void giaiphong(DSMB,PTR,TREE);
//cac ham may bay
void in_ds_mb(DSMB &, char [][20],int);
void form_mb(char []);
bool ktSua(int &, int , int, int);
bool ktXoa(int &, int , int, int);
void from_xoa(char []);
int SaveFile_MB (char [], DSMB &);
int LoadFileMB(char[], DSMB&);
bool ktrMB(DSMB &,char [],bool,int);
void themmb(DSMB &, char [], char [], char []);
void in_tk_mb(DSMB,int);
void swap_char(char [], char []);
bool check_mbincb(PTR,char[]);
//cac ham chuyen bay
void indsv(PTR, int);
KH getKH(TREE, char []);
void formkhve(TREE, char [],int, int);
int ktrtime(char [], char [],char[]);
void charTTMB(int, char []);
void charTime(TIME, char []);
void in_ds_cb(PTR,int);
void charPhai(bool, char []);
void getidcb(PTR, int, char []);
void setTime(PTR, int, char [], char [], char [], char [], char []);
void sethuyCB(PTR, int);
int ktslcb(PTR);
bool ktscb(int &, int, int, int);
void form_cb();
bool kthcb(int &, int, int, int);
void form_scb();
void from_huy(char []);
int getslchoMB(DSMB, char []);
void them_CB(PTR &,DSMB,char [],char [],char [],char [],char [],char [],char [],char []);
void getcmndghe(PTR ,int, int, char []);
void themve(PTR &,int, int, char []);
void in_ghe(int, char []);
int checkCMNDdatve(PTR,int,TREE,char[]);
void huy_ve(PTR&,int,int,char[]);
bool ktdsve(int &, int, int, int);
void in_dskhincb(PTR,TREE,int,int,int&);
bool ktidmb_dscb(PTR,char[]);
void form_tim_cb();
void in_ds_tim(PTR,char [],char [], char [], char []);
bool tim_cb_ds(CB cb,char [],char [],char [],char []);
int SaveFile_CB (char [], PTR);
int LoadFileCB (char [], PTR &);
void tangsl_bay(DSMB, char []);
void setTTCB(PTR);
bool kt_tt_cb(PTR, int);
bool ktvtve(PTR,int,int &,int x,int y);
bool kt_idcb(PTR,char[]);
//cac ham khach hang
void in_NLR(TREE, int &, int &, int &);
void in_dskh(TREE,int);
void them_1_kh(TREE &, char [], char [], char [], bool);
void getTime(PTR, int, char [], char [], char [], char [], char []);
bool ktdve(int &, int, int, int);
void form_kh();
bool checkCMND (TREE, char []);
void datvekh(PTR&,int,int,char []);
void getslKH(TREE,int&);
int SaveFile_KH(char [] , TREE);
void xuatkh(TREE, int &,char [][10], char [][10], char [][30], bool);
int LoadFile_KH(char [] , TREE &);
void doidaucach(bool, char []);
int main(){
DSMB dsmb;
dsmb.sl_mb=0;
cout<<"\n\tTinh trang Load File MB:"<<LoadFileMB(file_mb,dsmb)<<endl;
PTR dscb=NULL;
cout<<"\n\tTinh trang Load File CB:"<<LoadFileCB("dscb.txt",dscb)<<endl;
TREE dskh=NULL;
cout<<"\n\tTinh trang Load File HK:"<<LoadFile_KH("khachhang.txt",dskh);
setTTCB(dscb);
int x,y;
bool c_1,c_2,c_3,edit_mb,them_mb,xoa_mb,them_cb,edit_cb,huy_cb,them_kh,datve;
c_1=c_2=c_3=edit_mb=them_mb=xoa_mb=them_cb=edit_cb=huy_cb=them_kh=datve=false;//C_... la trang thai chon
initwindow(1280,780);
normal_text();
cleardevice();
settextstyle(f_lon,0,4);
outtextxy(420,1,ten);
in_main_menu();
char sh_temp[16]={'\0'};
char l_temp[41]={'\0'};
char sc_temp[10]={'\0'};
char nd_temp[16]={'\0'};
char shcb_temp[16]={'\0'};
char g_temp[5]={'\0'};
char p_temp[5]={'\0'};
char n_temp[5]={'\0'};
char t_temp[5]={'\0'};
char nam_temp[6]={'\0'};
char ho_temp[16]={'\0'};
char cmnd_temp[11]={'\0'};
char ten_temp[30]={'\0'};
int chon_phai=0;//0 la chua chon, 1 la chon nam ,2 la chon nu
int chiso = 0;
int chisove=0;
int trang=1;
int pt_ds=0;
int slkh_dsve=0;
int slkh=0;
int trang_khdsve=1;
//int slv=0;
bool editve=false;
bool ktkh=false;
bool huyve=false;
bool indskh=false;
bool tim_cb=false;
bool tk_mb=false;
bool menu_chinh;
while(true) {
normal_text();
if (ismouseclick(WM_LBUTTONDOWN)){
getmouseclick(WM_LBUTTONDOWN,x,y);
cout<<"\nvi tri x:"<<x<<" - vi tri y:"<<y<<endl;
if(ktkh||huyve||indskh||tim_cb||tk_mb||editve||edit_mb||them_mb||xoa_mb||them_cb||edit_cb||huy_cb||them_kh||datve)
menu_chinh=false;
else menu_chinh = true;
if(ktrVT(10,50,350,90,x,y)&&menu_chinh){
if(c_1==false){
reset_all();
highlight_box(10,50,350,90,box[0],f_lon,2,4);
c_1 = true; c_2 = c_3 = false;
trang=1;
in_ds_mb(dsmb,ds_mb,trang);
}
else{
reset_all();
c_1 = false;
}
}
else if(ktrVT(425,50,825,90,x,y)&&menu_chinh){
if(c_2==false){
reset_all();
highlight_box(425,50,825,90,box[1],f_lon,2,4);
c_2 = true; c_1 = c_3 = false;
trang=1;
in_ds_cb(dscb,trang);
}
else{
reset_all();
c_2 = false;
}
}
else if(ktrVT(900,50,1270-18,90,x,y)&&menu_chinh){
if(c_3==false){
reset_all();
highlight_box(900,50,1270-18,90,box[2],f_lon,2,4);
c_3 = true; c_1 = c_2 = false;
trang=1;
in_dskh(dskh,trang);
}
else{
reset_all();
c_3 = false;
}
}
else if(ktrVT(1090,5,1270,33,x,y)&&menu_chinh){
setfillstyle(1,10);
setbkcolor(10);
bar(1090,5,1270,33);
settextstyle(f_vua,0,2);
outtextxy(1100,8,"THOAT UNG DUNG");
delay(250);
giaiphong(dsmb,dscb,dskh);
closegraph();
return 0;
}
//chuc nang trong ds may bay
else if(c_1){
if(them_mb==false&&edit_mb==false&&xoa_mb==false&&tk_mb==false){
xu_ly_trang(trang,dsmb.sl_mb,x,y);
in_ds_mb(dsmb,ds_mb,trang);
}
//them may bay
if(ktrVT(1050,120,1200,155,x,y)&&them_mb==false&&edit_mb==false&&xoa_mb==false&&tk_mb==false){
them_mb=true;
highlight_box(1050,120,1200,155,box1[1],f_vua,1,2);
delay(250);
form_mb(box1[1]);
}
else if(them_mb){
nhap(500,270-5,940,270+25,15,1,ID,sh_temp,x,y);
nhap(470,370-5,940,370+25,25,1,ID,l_temp,x,y);
nhap(530,470-5,700,470+25,200,20,So,sc_temp,x,y);
if(ktrMB(dsmb,sh_temp,true,0)) xoa_tbloi();
else if(ktrMB(dsmb,sh_temp,true,0)==false) {
setbkcolor(14);
outtextxy(460,630,"*So hieu may bay da ton tai");
}
//nut huy:
if(ktrVT(750,550,820,580,x,y)){
highlight_box(750,550,820,580,cn[3],f_vua,2,0);
delay(250);
xoa_cn();
reset_temp(sh_temp,l_temp,sc_temp);
them_mb=false;
in_ds_mb(dsmb,ds_mb,trang);
}
//nut luu:
else if(ktrVT(850,550,920,580,x,y)){
if(ktrMB(dsmb,sh_temp,true,0)&&sh_temp!='\0'&&l_temp!='\0'&&sc_temp!='\0'){
highlight_box(850,550,920,580,cn[2],f_vua,2,0);
delay(250);
xoa_cn();
themmb(dsmb,sh_temp,l_temp,sc_temp);
them_mb=false;
SaveFile_MB(file_mb,dsmb);
in_ds_mb(dsmb,ds_mb,trang);
}
}
}
//chinh sua may bay
else if(ktSua(chiso,10,x,y)&&them_mb==false&&edit_mb==false&&xoa_mb==false&&tk_mb==false){
edit_mb=true;
highlight_box(left1[chiso],top1[chiso],right1[chiso],bottom1[chiso],cn[0],f_ds,1,0);
delay(250);
form_mb(box1[2]);
pt_ds=chiso+trang*10-10;
strcpy(sh_temp,dsmb.data[pt_ds]->sohieumb);
strcpy(l_temp,dsmb.data[pt_ds]->loaimaybay);
charValue(dsmb.data[pt_ds]->socho,sc_temp);
setbkcolor(15);
outtextxy(510,270,sh_temp);
outtextxy(480,370,l_temp);
outtextxy(540,470,sc_temp);
if(check_mbincb(dscb,sh_temp)==false){
setbkcolor(14);
outtextxy(460,630,"*May bay da thuc hien chuyen bay");
delay(1500);
chiso=0;
pt_ds=0;
edit_mb=false;
reset_temp(sh_temp,l_temp,sc_temp);
SaveFile_MB(file_mb,dsmb);
in_ds_mb(dsmb,ds_mb,trang);
}
}
else if(edit_mb){
nhap(500,270-5,940,270+25,15,1,ID,sh_temp,x,y);
nhap(470,370-5,940,370+25,25,1,ID,l_temp,x,y);
nhap(530,470-5,700,470+25,200,20,So,sc_temp,x,y);
if(ktrMB(dsmb,sh_temp,false,pt_ds)) xoa_tbloi();
else if(ktrMB(dsmb,sh_temp,false,pt_ds)==false){
setbkcolor(14);
outtextxy(460,630,"*So hieu may bay da ton tai");
}
//nut huy
if(ktrVT(750,550,820,580,x,y)){
highlight_box(750,550,820,580,cn[3],f_vua,2,0);
delay(250);
xoa_cn();
reset_temp(sh_temp,l_temp,sc_temp);
chiso=0;
pt_ds=0;
edit_mb=false;
in_ds_mb(dsmb,ds_mb,trang);
}
//nut luu
else if(ktrVT(850,550,920,580,x,y)){
if(ktrMB(dsmb,sh_temp,false,pt_ds)){
highlight_box(850,550,920,580,cn[2],f_vua,2,0);
delay(250);
xoa_cn();
strcpy(dsmb.data[pt_ds]->sohieumb,sh_temp);
strcpy(dsmb.data[pt_ds]->loaimaybay,l_temp);
int sc = intValue(sc_temp);
dsmb.data[pt_ds]->socho = sc;
chiso=0;
pt_ds=0;
edit_mb=false;
reset_temp(sh_temp,l_temp,sc_temp);
SaveFile_MB(file_mb,dsmb);
in_ds_mb(dsmb,ds_mb,trang);
}
}
}
//xoa may bay
else if(ktXoa(chiso,10,x,y)&&them_mb==false&&edit_mb==false&&xoa_mb==false&&tk_mb==false){
xoa_mb=true;
highlight_box(left2[chiso],top2[chiso],right2[chiso],bottom2[chiso],cn[1],f_ds,1,0);
delay(250);
pt_ds=chiso+trang*10-10;
strcpy(sh_temp,dsmb.data[pt_ds]->sohieumb);
from_xoa(sh_temp);
if(check_mbincb(dscb,sh_temp)==false){
setbkcolor(14);
outtextxy(460,630,"*May bay da thuc hien chuyen bay");
delay(1500);
chiso=0;
pt_ds=0;
xoa_mb=false;
in_ds_mb(dsmb,ds_mb,trang);
}
}
else if(xoa_mb){
//nut huy:
if(ktrVT(750,550,820,580,x,y)){
highlight_box(750,550,820,580,cn[3],f_vua,2,0);
delay(250);
xoa_cn();
reset_temp(sh_temp,l_temp,sc_temp);
chiso=0;
pt_ds=0;
xoa_mb=false;
in_ds_mb(dsmb,ds_mb,trang);
}
//nut co:
else if(ktrVT(850,550,920,580,x,y)){
if(check_mbincb(dscb,sh_temp)){
highlight_box(850,550,920,580,cn[4],f_vua,2,0);
delay(250);
xoa_cn();
for(int i = pt_ds; i < dsmb.sl_mb-1; i++){
strcpy(dsmb.data[i]->sohieumb,dsmb.data[i+1]->sohieumb);
strcpy(dsmb.data[i]->loaimaybay,dsmb.data[i+1]->loaimaybay);
dsmb.data[i]->socho=dsmb.data[i+1]->socho;
}
delete dsmb.data[--dsmb.sl_mb];
chiso=0;
pt_ds=0;
xoa_mb=false;
reset_temp(sh_temp,l_temp,sc_temp);
SaveFile_MB(file_mb,dsmb);
in_ds_mb(dsmb,ds_mb,trang);
}
}
}
else if(ktrVT(800,120,1000,155,x,y)&&them_mb==false&&edit_mb==false&&xoa_mb==false&&tk_mb==false){
highlight_box(800,120,1000,155,"Thong ke bay may",f_vua,1,2);
delay(250);
tk_mb=true;
trang=1;
in_tk_mb(dsmb,trang);
}
else if(tk_mb){
if(ktrVT(1050,120,1230,155,x,y)){
highlight_box(1050,120,1230,155,"Thoat thong ke",f_vua,1,2);
delay(250);
tk_mb=false;
trang=1;
in_ds_mb(dsmb,ds_mb,trang);
}
else{
xu_ly_trang(trang,dsmb.sl_mb,x,y);
in_tk_mb(dsmb,trang);
}
}
}
//quan ly chuyen bay
else if(c_2){
if(them_cb==false&&edit_cb==false&&huy_cb==false&&indskh==false&&tim_cb==false&&datve==false){
xu_ly_trang(trang,ktslcb(dscb),x,y);
in_ds_cb(dscb,trang);
}
if(ktrVT(1050,120,1200,155,x,y)&&them_cb==false&&edit_cb==false&&huy_cb==false&&indskh==false&&tim_cb==false&&datve==false){
them_cb=true;
highlight_box(1050,120,1230,155,"Them Chuyen Bay",f_vua,1,2);
delay(250);
form_cb();
}
else if(them_cb){
nhap(360,270-5,580,270+25,15,1,ID,shcb_temp,x,y);
nhap(690,270-5,940,270+25,15,1,Ho,nd_temp,x,y);
nhap(430,470-5,700,470+25,15,1,ID,sh_temp,x,y);
nhap(350,370-5,410,370+25,24,1,So,g_temp,x,y);
nhap(480,370-5,540,370+25,59,0,So,p_temp,x,y);
nhap(610,370-5,670,370+25,31,1,So,n_temp,x,y);
nhap(750,370-5,810,370+25,12,1,So,t_temp,x,y);
nhap(870,370-5,948,370+25,2100,2021,So,nam_temp,x,y);
int maloitg = ktrtime(n_temp,t_temp,nam_temp);
if(ktrMB(dsmb,sh_temp,true,0)&&sh_temp[0]!='\0'){
xoa_tbloi();
setbkcolor(14);
outtextxy(460,630,"*May bay khong ton tai");
}
else if(ktidmb_dscb(dscb,sh_temp)==false){
xoa_tbloi();
setbkcolor(14);
outtextxy(460,630,"*May bay dang thuc hien chuyen bay khac");
}
else if(kt_idcb(dscb,shcb_temp)==false&&shcb_temp[0]!='\0'){
xoa_tbloi();
setbkcolor(14);
outtextxy(460,630,"*Ma chuyen bay da ton tai");
}
else if(maloitg==1){
xoa_tbloi();
setbkcolor(14);
outtextxy(460,630,"*Ngay Khong Ton Tai");
}
else if(maloitg==2){
xoa_tbloi();
setbkcolor(14);
outtextxy(460,630,"*Khong the lap chuyen bay trong ngay hoac qua khu");
}
else if(maloitg==3){
xoa_tbloi();
setbkcolor(14);
outtextxy(460,630,"*Khong the lap chuyen bay som hon 2 thang");
}
else{
xoa_tbloi();
}
//nut huy:
if(ktrVT(750,550,820,580,x,y)){
highlight_box(750,550,820,580,cn[3],f_vua,2,0);
delay(250);
xoa_cn();
reset_temp(shcb_temp,nd_temp,sh_temp);
reset_temp(g_temp,p_temp,n_temp);
reset_temp(n_temp,t_temp,nam_temp);
them_cb=false;
in_ds_cb(dscb,trang);
}
//nut luu:
else if(ktrVT(850,550,920,580,x,y)&&ktrMB(dsmb,sh_temp,true,0)==false&&kt_idcb(dscb,shcb_temp)&&ktidmb_dscb(dscb,sh_temp)&&ktrtime(n_temp,t_temp,nam_temp)==0){
if((sh_temp[0]=='\0'||shcb_temp[0]=='\0'||nd_temp[0]=='\0'||sh_temp[0]=='\0'||g_temp[0]=='\0'||p_temp[0]=='\0'||n_temp[0]=='\0'||t_temp[0]=='\0'||nam_temp[0]=='\0'));
else{
highlight_box(850,550,920,580,cn[2],f_vua,2,0);
delay(250);
xoa_cn();
them_CB(dscb,dsmb,shcb_temp,nd_temp,sh_temp,g_temp,p_temp,n_temp,t_temp,nam_temp);
reset_temp(shcb_temp,nd_temp,sh_temp);
reset_temp(g_temp,p_temp,n_temp);
reset_temp(n_temp,t_temp,nam_temp);
them_cb=false;
cout<<SaveFile_CB("dscb.txt" ,dscb);
//cout<<"da qua save file chuyen bay..."<<endl;
cout<<SaveFile_MB(file_mb,dsmb);
//cout<<"da qua save file may bay..."<<endl;
in_ds_cb(dscb,trang);
}
}
}
//sua chuyen bay
else if(ktscb(chiso,10,x,y)&&them_cb==false&&edit_cb==false&&huy_cb==false&&indskh==false&&tim_cb==false&&datve==false){
//cout<<"chi so la :"<<chiso<<endl;
edit_cb=true;
highlight_box(l_scb[chiso],t_scb[chiso],r_scb[chiso],b_scb[chiso],"Sua",f_ds,1,0);
delay(250);
form_scb();
pt_ds=chiso+trang*10-10;
getTime(dscb,pt_ds,g_temp,p_temp,n_temp,t_temp,nam_temp);
setbkcolor(15);
outtextxy(350+10,370,g_temp);
outtextxy(480+10,370,p_temp);
outtextxy(610+10,370,n_temp);
outtextxy(750+10,370,t_temp);
outtextxy(870+10,370,nam_temp);
if(kt_tt_cb(dscb,pt_ds)==false){
setbkcolor(14);
outtextxy(460,630,"*Chuyen bay da huy hoac hoan thanh");
delay(1500);
chiso=0;
pt_ds=0;
xoa_cn();
reset_temp(g_temp,p_temp,n_temp);
reset_temp(n_temp,t_temp,nam_temp);
edit_cb=false;
in_ds_cb(dscb,trang);
}
}
else if(edit_cb){
nhap(350,370-5,410,370+25,24,1,So,g_temp,x,y);
nhap(480,370-5,540,370+25,59,0,So,p_temp,x,y);
nhap(610,370-5,670,370+25,31,1,So,n_temp,x,y);
nhap(750,370-5,810,370+25,12,1,So,t_temp,x,y);
nhap(870,370-5,948,370+25,2100,2021,So,nam_temp,x,y);
int maloitg = ktrtime(n_temp,t_temp,nam_temp);
if(maloitg==0) xoa_tbloi();
else if(maloitg==1){
setbkcolor(14);
outtextxy(460,630,"*Ngay Khong Ton Tai");
}
else if(maloitg==2){
setbkcolor(14);
outtextxy(460,630,"*Khong the lap chuyen bay trong ngay hoac qua khu");
}
else if(maloitg==3){
setbkcolor(14);
outtextxy(460,630,"*Khong the lap chuyen bay som hon 2 thang");
}
//nut huy:
if(ktrVT(750,550,820,580,x,y)){
highlight_box(750,550,820,580,cn[3],f_vua,2,0);
delay(250);
xoa_cn();
reset_temp(g_temp,p_temp,n_temp);
reset_temp(n_temp,t_temp,nam_temp);
chiso=0;
pt_ds=0;
edit_cb=false;
in_ds_cb(dscb,trang);
}
//nut luu:
else if(ktrVT(850,550,920,580,x,y)){
highlight_box(850,550,920,580,cn[2],f_vua,2,0);
delay(250);
xoa_cn();
//cout<<"chi so la "<<chiso<<endl;
setTime(dscb,pt_ds,g_temp,p_temp,n_temp,t_temp,nam_temp);
reset_temp(g_temp,p_temp,n_temp);
reset_temp(n_temp,t_temp,nam_temp);
edit_cb=false;
chiso=0;
pt_ds=0;
cout<<SaveFile_CB("dscb.txt" ,dscb);
in_ds_cb(dscb,trang);
}
}
//huy chuyen bay
else if(kthcb(chiso,ktslcb(dscb),x,y)&&them_cb==false&&edit_cb==false&&huy_cb==false&&indskh==false&&tim_cb==false&&datve==false){
//cout<<"chi so la :"<<chiso<<endl;
highlight_box(l_hcb[chiso],t_hcb[chiso],r_hcb[chiso],b_hcb[chiso],"Huy",f_ds,1,0);
delay(250);
pt_ds=chiso+trang*10-10;
getidcb(dscb,pt_ds,shcb_temp);
from_huy(shcb_temp);
huy_cb=true;
}
else if(huy_cb){
//nut huy:
if(ktrVT(750,550,820,580,x,y)){
highlight_box(750,550,820,580,cn[3],f_vua,2,0);
delay(250);
xoa_cn();
huy_cb=false;
shcb_temp[0]='\0';
chiso=0;
pt_ds=0;
in_ds_cb(dscb,trang);
}
//nut co:
else if(ktrVT(850,550,920,580,x,y)){
highlight_box(850,550,920,580,cn[4],f_vua,2,0);
//cout<<"chi so la "<<chiso<<endl;
delay(250);
xoa_cn();//
sethuyCB(dscb,pt_ds);
huy_cb=false;
shcb_temp[0]='\0';
chiso=0;
pt_ds=0;
cout<<SaveFile_CB("dscb.txt" ,dscb);
in_ds_cb(dscb,trang);
}
}
//dat ve
else if(ktdve(chiso,ktslcb(dscb),x,y)&&them_cb==false&&edit_cb==false&&huy_cb==false&&indskh==false&&tim_cb==false&&datve==false){
highlight_box(l_dv[chiso],t_dv[chiso],r_dv[chiso],b_dv[chiso],"Dat Ve",f_ds,1,0);
delay(250);
datve=true;
pt_ds=chiso+trang*10-10;
indsv(dscb,pt_ds);
if(kt_tt_cb(dscb,pt_ds)==false){
xoa_cn();
setbkcolor(14);
outtextxy(460,630,"*Chuyen bay da huy hoac hoan thanh");
delay(1500);
chiso=0;
pt_ds=0;
datve=false;
in_ds_cb(dscb,trang);
}
}
else if(datve){
if(ktrVT(1100,700,1250,735,x,y)&&editve==false){
highlight_box(1100,700,1250,735,"THOAT DAT VE",f_vua,1,2);
chiso=0;
pt_ds=0;
datve=false;
delay(250);
in_ds_cb(dscb,trang);
}
else if(editve){
if(tt_ghe[chisove]==0) nhap(200,630-5,610,630+25,9,9,CMVE,cmnd_temp,x,y);
if(ktrVT(500,715,580,745,x,y)){
highlight_box(500,715,580,745,"THOAT",f_vua,2,0);
delay(250);
editve=false;
cmnd_temp[0]='\0';
indsv(dscb,pt_ds);
chisove=0;
}
else if(ktrVT(620,715,710,745,x,y)&&ktkh==false&&huyve==false&&ktkh==false&&them_kh==false){
if(tt_ghe[chisove]==0){
highlight_box(620,715,710,745,"DAT VE",f_vua,2,0);
delay(250);
if(checkCMNDdatve(dscb,pt_ds,dskh,cmnd_temp)==2){
formkhve(dskh,cmnd_temp,x,y);
ktkh=true;
}
else if(checkCMNDdatve(dscb,pt_ds,dskh,cmnd_temp)==0){
form_kh();
setbkcolor(15);
outtextxy(368,270,cmnd_temp);
them_kh=true;
}
else if(checkCMNDdatve(dscb,pt_ds,dskh,cmnd_temp)==1){
xoa_cn();
setbkcolor(14);
outtextxy(460,630,"*Khach hang trung trong danh sach ve");
delay(2000);
editve=false;
cmnd_temp[0]='\0';
chisove=0;
indsv(dscb,pt_ds);
}
}
else if(tt_ghe[chisove]==1){
highlight_box(620,715,710,745,"HUY VE",f_vua,2,0);
delay(250);
huyve=true;
from_huy("ve cua khach");
}
}
else if(huyve){
//nut huy:
if(ktrVT(750,550,820,580,x,y)){
highlight_box(750,550,820,580,cn[3],f_vua,2,0);
delay(250);
huyve=false;
editve=false;
cmnd_temp[0]='\0';
chisove=0;
indsv(dscb,pt_ds);
}
//nut co:
else if(ktrVT(850,550,920,580,x,y)){
highlight_box(850,550,920,580,cn[4],f_vua,2,0);
delay(250);
huy_ve(dscb,pt_ds,chisove,cmnd_temp);
huyve=false;
editve=false;
cmnd_temp[0]='\0';
chisove=0;
cout<<SaveFile_CB("dscb.txt" ,dscb);
indsv(dscb,pt_ds);
}
}
else if(ktkh){
//nut huy:
if(ktrVT(750,550,820,580,x,y)){
highlight_box(750,550,820,580,cn[3],f_vua,2,0);
delay(250);
xoa_cn();
ktkh=false;
editve=false;
cmnd_temp[0]='\0';
chisove=0;
indsv(dscb,pt_ds);
}
//nut luu:
else if(ktrVT(850,550,920,580,x,y)){
highlight_box(850,550,920,580,cn[2],f_vua,2,0);
//cout<<"chi so la "<<chiso<<endl;
delay(250);
datvekh(dscb,pt_ds,chisove,cmnd_temp);
xoa_cn();
ktkh=false;
editve=false;
cmnd_temp[0]='\0';
chisove=0;
cout<<SaveFile_CB("dscb.txt",dscb);
indsv(dscb,pt_ds);
}
}
else if(them_kh){
nhap(690,270-5,940,270+25,10,2,Ho,ho_temp,x,y);
nhap(350,370-5,940,370+25,28,2,Ten,ten_temp,x,y);
//chon nam
if(ktrVT(450,470-5,500,470+25,x,y)){
settextstyle(f_vua,0,1);
setfillstyle(1,10);
setbkcolor(10);
bar3d(450,470-5,500,470+25,0,1);
outtextxy(458,470,"NAM");
setfillstyle(1,15);
setbkcolor(15);
bar3d(550,470-5,600,470+25,0,1);
outtextxy(558,470,"NU");
normal_text();
chon_phai = 1;
}
//chon nu
if(ktrVT(550,470-5,600,470+25,x,y)){
settextstyle(f_vua,0,1);
setfillstyle(1,10);
setbkcolor(10);
bar3d(550,470-5,600,470+25,0,1);
outtextxy(558,470,"NU");
setfillstyle(1,15);
setbkcolor(15);
bar3d(450,470-5,500,470+25,0,1);
outtextxy(458,470,"NAM");
normal_text();
chon_phai = 2;
}
//nut huy:
if(ktrVT(750,550,820,580,x,y)){
highlight_box(750,550,820,580,cn[3],f_vua,2,0);
delay(250);
xoa_cn();
them_kh=false;
editve=false;
chisove=0;
reset_temp(cmnd_temp,ho_temp,ten_temp);
//in_dskh(dskh);
indsv(dscb,pt_ds);
}
//nut luu:
if(ktrVT(850,550,920,580,x,y)&&ho_temp[0]!='\0'&&ten_temp[0]!='\0'&&cmnd_temp[0]!='\0'&&chon_phai!=0&&checkCMND(dskh,cmnd_temp)==false){
highlight_box(850,550,920,580,cn[2],f_vua,2,0);
delay(250);
xoa_cn();
datvekh(dscb,pt_ds,chisove,cmnd_temp);
bool phai;
if(chon_phai == 1) phai=true;
else if(chon_phai == 2) phai=false;
them_1_kh(dskh,cmnd_temp,ho_temp,ten_temp,phai);
reset_temp(cmnd_temp,ho_temp,ten_temp);
chisove=0;
cout<<SaveFile_CB("dscb.txt" ,dscb);
cout<<"luu khach hang:"<<SaveFile_KH("khachhang.txt",dskh)<<endl;
them_kh=false;
editve=false;
indsv(dscb,pt_ds);
}
}
}
else if(ktvtve(dscb,pt_ds,chisove,x,y)&&editve==false){
//cout<<"chi so ve :"<<chisove<<endl;
editve=true;
if(tt_ghe[chisove]==1 || tt_ghe[chisove]==2) getcmndghe(dscb,pt_ds,chisove,cmnd_temp);
else cmnd_temp[0]='\0';
in_ghe(chisove,cmnd_temp);
}
}
//in ds khanh dat ve
else if(ktdsve(chiso,ktslcb(dscb),x,y)&&them_cb==false&&edit_cb==false&&huy_cb==false&&indskh==false&&tim_cb==false&&datve==false){
highlight_box(l_dsv[chiso],t_dsv[chiso],r_dsv[chiso],b_dsv[chiso],"Danh Sach Ve",f_ds,1,0);
delay(250);
indskh=true;
pt_ds=chiso+trang*10-10;
in_dskhincb(dscb,dskh,trang_khdsve,pt_ds,slkh_dsve);
}
else if(indskh){
if(ktrVT(1050,120,1230,155,x,y)){
highlight_box(1050,120,1230,155,"Thoat Danh Sách",f_vua,1,2);
delay(250);
indskh=false;
chiso=0;
pt_ds=0;
trang_khdsve=1;
in_ds_cb(dscb,trang);
}
else{
xu_ly_trang(trang_khdsve,slkh_dsve,x,y);
in_dskhincb(dscb,dskh,trang_khdsve,pt_ds,slkh_dsve);
}
}
//tim kiem chuyen bay
else if(ktrVT(800,120,980,155,x,y)&&them_cb==false&&edit_cb==false&&huy_cb==false&&indskh==false&&tim_cb==false&&datve==false){
highlight_box(800,120,980,155,"Tim Chuyen Bay",f_vua,1,2);
delay(250);
tim_cb=true;
form_tim_cb();
}
else if(tim_cb){
nhap(590,270-5,840,270+25,16,2,Ho,nd_temp,x,y);
nhap(400,370-5,460,370+25,31,1,So,n_temp,x,y);
nhap(600,370-5,660,370+25,12,1,So,t_temp,x,y);
nhap(790,370-5,870,370+25,2100,2021,So,nam_temp,x,y);
//nut huy:
if(ktrVT(750,550,820,580,x,y)){
highlight_box(750,550,820,580,cn[3],f_vua,2,0);
delay(250);
tim_cb=false;
nd_temp[0]=n_temp[0]=t_temp[0]=nam_temp[0]='\0';
in_ds_cb(dscb,trang);
}
//nut tim:
else if(ktrVT(850,550,920,580,x,y)){
highlight_box(850,550,920,580," Tim",f_vua,2,0);
delay(250);
in_ds_tim(dscb,nd_temp,n_temp,t_temp,nam_temp);
nd_temp[0]=n_temp[0]=t_temp[0]=nam_temp[0]='\0';
}
else if(ktrVT(1050,120,1230,155,x,y)){
highlight_box(1050,120,1230,155,"Thoat Tim",f_vua,1,2);
delay(250);
tim_cb=false;
in_ds_cb(dscb,trang);
}
}
}
//quan ly khach
else if(c_3){
if(ktrVT(1050,120,1230,155,x,y)&&them_kh==false){
them_kh=true;
highlight_box(1050,120,1230,155,"Them Khach Hang",f_vua,1,2);
delay(250);
form_kh();
}
else if(them_kh){
nhap(360,270-5,580,270+25,9,9,CMND,cmnd_temp,x,y);
nhap(690,270-5,940,270+25,10,2,Ho,ho_temp,x,y);
nhap(350,370-5,940,370+25,28,2,Ten,ten_temp,x,y);
//chon nam
if(ktrVT(450,470-5,500,470+25,x,y)){
settextstyle(f_vua,0,1);
setfillstyle(1,10);
setbkcolor(10);
bar3d(450,470-5,500,470+25,0,1);
outtextxy(458,470,"NAM");
setfillstyle(1,15);
setbkcolor(15);
bar3d(550,470-5,600,470+25,0,1);
outtextxy(558,470,"NU");
normal_text();
chon_phai = 1;
}
//chon nu
else if(ktrVT(550,470-5,600,470+25,x,y)){
settextstyle(f_vua,0,1);
setfillstyle(1,10);
setbkcolor(10);
bar3d(550,470-5,600,470+25,0,1);
outtextxy(558,470,"NU");
setfillstyle(1,15);
setbkcolor(15);
bar3d(450,470-5,500,470+25,0,1);
outtextxy(458,470,"NAM");
normal_text();
chon_phai = 2;
}
//nut huy:
else if(ktrVT(750,550,820,580,x,y)){
highlight_box(750,550,820,580,cn[3],f_vua,2,0);
delay(250);
xoa_cn();
them_kh=false;
reset_temp(cmnd_temp,ho_temp,ten_temp);
in_dskh(dskh,trang);
}
//nut luu:
else if(ktrVT(850,550,920,580,x,y)&&ho_temp[0]!='\0'&&ten_temp[0]!='\0'&&cmnd_temp[0]!='\0'&&chon_phai!=0&&checkCMND(dskh,cmnd_temp)==false){
highlight_box(850,550,920,580,cn[2],f_vua,2,0);
delay(250);
xoa_cn();
bool phai;
if(chon_phai == 1) phai=true;
else if(chon_phai == 2) phai=false;
them_1_kh(dskh,cmnd_temp,ho_temp,ten_temp,phai);
cout<<"luu khach hang:"<<SaveFile_KH("khachhang.txt",dskh)<<endl;
them_kh=false;
reset_temp(cmnd_temp,ho_temp,ten_temp);
in_dskh(dskh,trang);
}
}
else{
slkh=0;
getslKH(dskh,slkh);
xu_ly_trang(trang,slkh,x,y);
in_dskh(dskh,trang);
}
}
}
delay(0.0001);
}
closegraph();
return 0;
}
bool kt_idcb(PTR dscb, char macb[]){
PTR get;
for(get=dscb;get!=NULL;get=get->next){
if(xau_trung(get->data.machuyenbay,macb)) return false;
}
return true;
}
void xu_ly_trang(int &trang,int slpt,int x,int y){
if(ktrVT(520,730,550,760,x,y)&&trang>1){
setfillstyle(1,10);
setbkcolor(10);
bar3d(520,730,550,760,0,1);
outtextxy(528,735,"<");
delay(200);
trang--;
}
else if(ktrVT(610,730,640,760,x,y)&&slpt>(trang*10)){
setfillstyle(1,10);
setbkcolor(10);
bar3d(610,730,640,760,0,1);
outtextxy(618,735,">");
delay(200);
trang++;
}
}
void giaiphongcay(TREE dskh){
if(dskh == NULL) return;
giaiphongcay(dskh->left);
giaiphongcay(dskh->right);
delete dskh;
}
void giaiphong(DSMB dsmb,PTR dscb,TREE dskh){
for(int i=0;i<dsmb.sl_mb;i++){
delete dsmb.data[i];
}
PTR get;
while(dscb=NULL){
get=dscb;
dscb=dscb->next;
for(int i=0; i<get->sldat;i++){
delete get->dsve[i];
}
delete get;
}
giaiphongcay(dskh);
dskh=NULL;
}
bool kt_tt_cb(PTR dscb, int chiso){
PTR get;
int i;
for(get=dscb,i=0;i<chiso;get=get->next,i++);
if(get->data.trang_thai==0) return false;
else if(get->data.trang_thai==3) return false;
return true;
}
void setTTCB(PTR dscb){
PTR set;
char ngay[5];
char thang[5];
char nam[5];
for(set=dscb;set!=NULL;set=set->next){
charValue(set->data.time_xp.ngay,ngay);
charValue(set->data.time_xp.thang,thang);
charValue(set->data.time_xp.nam,nam);
int kt= ktrtime(ngay,thang,nam);
if(kt==2) set->data.trang_thai=3;
else if((set->slve-set->sldat)==0) set->data.trang_thai=2;
}
}