-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathUser.cpp
453 lines (419 loc) · 10.8 KB
/
User.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
#include "User.h"
QuanLyPhim QLP;
QuanLyNhanVien QLNV;
vector<Customer> CTM;
QLPhongChieu QLPC;
QuanLyLichChieu QLLC;
QuanLyVe QLV;
int SoKhach;
// void Menu_DangNhap();
// void User(int index);
// void ThanhToan(int index, int indexmave, int SoVe);
// void DoiMatKhau(int index);
void thanhcong()
{
CanLe();
cout << "------------------" << endl;
SetColor(0, 9);
CanLe();
cout << " Yeu cau cua ban da duoc thuc hien" << endl;
intime();
SetColor(0, 7);
CanLe();
cout << "------------------" << endl;
}
void InVe(vector<int>A, int indexPhim, int indexPC, int indexLichChieu, int indexMave){
ofstream inve;
inve.open("Titket.txt", ios::trunc);
inve << get_day() << " " << get_time() << endl;
inve << QLP[indexPhim].getTenPhim() << endl;
inve << "Ngay:" << QLLC[indexLichChieu].getNgay() << " Gio Chieu:" << QLLC[indexLichChieu].getGio()<< " ";
inve << QLPC[indexPC].getMaPhongChieu() << endl;
inve << "Ghe Da Dat: ";
for (int i = 0; i < A.size(); i++)
{
inve << A[i] << " ";
}
inve << " So Tien: " << QLV[indexMave].getGiaLoaiVe()*A.size();
inve << endl;
inve << "Cam On Ban Da Su Dung Dich Vu Cua Chung Toi!";
inve.close();
}
void DatVe(int index){
string maPhim,maXuatChieu;
// DocFile(QLNV, QLP, QLLC, QLPC, QLV, CTM, SoKhach);
int SoVe;
CanLe();
cout << "Nhap Ma Phim Ban Muon Dat Ve: ";
cin >> maPhim;
int indexMaphim = QLP.CheckMS(maPhim);
while(indexMaphim<0){
CanLe();
cout << "Khong Co Ma Phim Nao Trung Khop, Xin Nhap Lai: ";
cin >> maPhim;
}
system("cls");
QLLC.XemLichChieuCuaPhim(QLP[indexMaphim].getTenPhim());
CanLe();
cout << "Nhap Ma Xuat Chieu: ";
cin >> maXuatChieu;
while(QLLC.CheckMS(maXuatChieu) < 0){
CanLe();
cout << "Khong Co Ma Xuat Chieu Nao Trung Khop, Xin Nhap Lai: ";
cin >> maXuatChieu;
}
int k = QLLC.CheckMS(maXuatChieu);
string XuatChieu = QLLC[k].Xuat();
string a = QLLC[k].getPhongChieu();
int h = QLPC.CheckMS(a);
system("cls");
GoTo(5,3);
cout << "Ban Muon Dat Bao Nhieu Ve? ";
cin >> SoVe;
string loaikhachhang = CTM[index].LoaiKhachHang;
int indexmave = QLV.GetMaVe(maPhim, loaikhachhang);
QLV[indexmave].ThemSoVeDaBan(SoVe);
UpdateFile_Ve(QLV);
QLPC[h].DisplayTable(XuatChieu);
vector<int> A;
int ghe;
for(int i = 0; i < SoVe; i++){
CanLe();
cout << "Nhap Ghe Ma Ban Muon Dat: ";
cin >> ghe;
A.push_back(ghe);
QLPC[h].GhiFileDatGhe(ghe,XuatChieu);
}
// QLPC[h].DatGhe(SoVe);
ThanhToan(index, indexmave, SoVe);
system("cls");
GoTo(5,3);
cout << "Ban Co Muon In Ve Khong?" << endl;
vector<string> m1 = {"Co","Khong"};
int In = menu2(m1);
switch (In)
{
case 1:
InVe(A,indexMaphim,h,k,indexmave);
thanhcong();
CanLe();
cout << "Hay Kiem Tra Ve Cua Ban O File Titket.txt" << endl;
break;
case 2:
CanLe();
cout << "Cam On Ban Da Gop Phan Bao Ve Moi Truong <3" << endl;
default:
break;
}
CanLe();
cout << "Dat Ve Hoan Tat!!" << endl;
vector<string> m2 = {"Dat Them Ve","Tro Ve Man Hinh Chon"};
int chon2 = menu2(m2);
switch (chon2)
{
case 1:
system("cls");
QLP.Show();
DatVe(index);
break;
case 2:
User(index);
break;
default:
break;
}
}
void ThanhToan(int index, int indexmave, int SoVe){
DocFile_Khach(CTM,SoKhach);
CanLe();
cout << "Ban Muon Thanh Toang Bang Gi: " << endl;
vector<string> m1 = {"Thanh Toan Bang The","Thanh Toan Bang Tien Mat"};
int thanhtoan = menu2(m1);
switch (thanhtoan)
{
case 1:
if(CTM[index].CheckSoDu(QLV[indexmave].getGiaLoaiVe()*SoVe)){
CanLe();
cout << "Thanh Toan Thanh Cong!" << endl;
UpdateFile_Khach(CTM,SoKhach);
}
else{
CanLe();
cout << "So Du Cua Ban Khong Du!" << endl;
vector<string> m2 = {"Nap Tien","Thanh Toan Bang Tien Mat"};
int thanhtoan2 = menu2(m2);
switch (thanhtoan2)
{
case 1:
CTM[index].NapTien();
if(CTM[index].CheckSoDu(QLV[indexmave].getGiaLoaiVe()*SoVe)){
CanLe();
cout << "Thanh Toan Thanh Cong!" << endl;
UpdateFile_Khach(CTM,SoKhach);
}
break;
case 2:
CanLe();
cout << "Da Thanh Toan Bang Tien Mat!" << endl;
break;
default:
break;
}
}
break;
case 2:
CanLe();
cout << "Da Thanh Toan Bang Tien Mat!" << endl;
break;
default:
break;
}
CanLe();
cout << "Nhan Phim Ban Ki De Tiep Tuc" << endl;
getch();
}
int TimTaiKhoan(string tk, string mk){
DocFile_Khach(CTM,SoKhach);
int index = -1;
for (int i = 0; i < CTM.size(); i++)
{
if(CTM[i].checkTaiKhoan(tk,mk)){
index = i;
break;
}
}
return index;
}
void User(int index)
{
DocFile(QLNV, QLP, QLLC, QLPC, QLV, CTM, SoKhach);
vector<string> me = {"Dat Ve","Tro Ve"};
vector<string> mm4 = {"Nap Tien","Tro Ve"};
system("cls");
SetColor(0,2);
GoTo(80,10);
cout<<"Dang Nhap Thanh Cong!"<<endl;
SetColor(0,7);
GoTo(80,11);
cout<<"Xin Chao ";
SetColor(0,9);
cout << CTM[index].HoTen;
SetColor(0,14);
vector<string> m = {"Xem Hom Nay Co Phim Gi", "Tim Kiem Phim", "Tim Kiem Phim Theo The Loai", "Doi Mat Khau", "Xem Thong Tin Ca Nhan", "Dang Xuat"};
SetColor(0,7);
int ma = menu(m);
switch(ma)
{
case 1:
int lenh;
system("cls");
QLP.Show();
lenh = menu2(me);
switch (lenh)
{
case 1:
DatVe(index);
break;
case 2:
system("cls");
User(index);
break;
default:
break;
}
break;
case 2:
QLP.TimKiemPhim();
CanLe();
cout<<"----------------------" << endl;
SetColor(0,14);
int lenh2;
lenh2 = menu2(me);
SetColor(0,7);
switch (lenh2)
{
case 2:
User(index);
break;
case 1:
DatVe(index);
break;
default:
break;
}
break;
case 3:
int Lenh4;
QLP.XemTheloaiPhim();
QLP.XemDSPhimCuaTheLoai();
Lenh4 = menu2(me);
SetColor(0,7);
switch (Lenh4)
{
case 2:
User(index);
break;
case 1:
DatVe(index);
break;
default:
break;
}
break;
case 4:
DoiMatKhau(index);
break;
case 5:
CTM[index].Show2();
int naptien;
naptien = menu2(mm4);
switch (naptien)
{
case 1:
CTM[index].NapTien();
User(index);
break;
case 2:
User(index);
break;
default:
break;
}
break;
default:
DangNhap_Khach();
break;
}
}
void DangNhap(){
string gmail,mk;
system("cls");
GoTo(80,5);
cout << "Nhap Gmail: ";cin >> gmail;
GoTo(80,7);
cout << "Nhap Mat Khau: ";cin >> mk;
int index = TimTaiKhoan(gmail,mk);
if(gmail == "0"){
DangNhap_Khach();
}
if(index == -1){
system("cls");
GoTo(80,3);
cout << "Tai Khoan Hoac Mat Khau Khong Dung!";
getch();
DangNhap();
}
else{
User(index);
}
}
void DangKy(){
system("cls");
DocFile_Khach(CTM,SoKhach);
string gmail, mk, mk2, ten;
GoTo(80,5);
cout << "Nhap Gmail Cua Ban: ";cin >> gmail;
GoTo(80,7);
cout << "Nhap Mat Khau: ";cin >> mk;
GoTo(80,9);
cout << "Nhap Lai Mat khau: ";cin >> mk2;
for (int i = 0; i < CTM.size(); i++)
{
if(gmail == CTM[i].getGmail()){
system("cls");
GoTo(80,7);
cout << "Tai Khoan Da Ton Tai" << endl;
getch();
DangKy();
break;
}
}
while(mk!=mk2){
system("cls");
GoTo(80,5);
cout << "(Nhan 0 De Thoat)" << endl;
GoTo(80,7);
cout << "Mat Khau Khong Trung Khop" << endl;
GoTo(80,9);
cout << "Nhap Gmail Cua Ban: " << gmail << endl;
GoTo(80,11);
cout << "Nhap Mat Khau:"; cin >> mk;
if(mk == "0"){
DangNhap_Khach();
}
GoTo(80,13);
cout << "Nhap Lai Mat Khau: ";cin >> mk2;
}
system("cls");
GoTo(80,7);
cout << "Nhap Ho Ten Cua Ban: ";
fflush(stdin);
getline(cin,ten);
Customer temp(gmail,mk,ten);
CTM.push_back(temp);
SoKhach++;
UpdateFile_Khach(CTM, SoKhach);
GoTo(80,9);
cout << "Dang Ky Thanh Cong"<< endl;
GoTo(80,11);
cout << "Nhan Phim Bat Ky De Tro Ve";
getch();
DangNhap_Khach();
}
void DoiMatKhau(int index){
system("cls");
DocFile_Khach(CTM, SoKhach);
string mkc,mkm,mkm2;
GoTo(5,3);
cout << "Nhap Mat Khau Cu:";cin >> mkc;
CanLe();
cout << "Nhap Mat Khau Moi:";cin >> mkm;
CanLe();
cout << "Nhap Lai Mat Khau Moi:";cin >> mkm2;
if(mkc != CTM[index].getMatKhau()){
CanLe();
cout << "Mat Khau Cu Khong Chinh Xac!" << endl;
getch();
DoiMatKhau(index);
} else{
while(mkm!=mkm2){
CanLe();
cout << "Mat Khau Moi Khong Trung Khop!" << endl;
getch();
system("cls");
GoTo(5,3);
cout << "Nhap Mat Khau Cu: " << mkc << endl;
CanLe();
cout << "Nhap Mat Khau Moi:";cin >> mkm;
CanLe();
cout << "Nhap Lai Mat Khau Moi:";cin >> mkm2;
}
}
CTM[index].setMatKhau(mkm);
UpdateFile_Khach(CTM, SoKhach);
CanLe();
cout << "Doi Mat Khau Thanh Cong!" << endl;
CanLe();
cout << "Nhap Phim Bat Ky De Tro Ve" << endl;
getch();
User(index);
}
void DangNhap_Khach(){
int chon;
system("cls");
vector<string> m = {"Dang Nhap","Dang Ky","Thoat"};
chon = menu(m);
switch (chon)
{
case 1:
DangNhap();
break;
case 2:
DangKy();
break;
case 3:
exit(1);
default:
break;
}
}