-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmoney.py
1117 lines (966 loc) · 42.3 KB
/
money.py
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
import sys
from datetime import datetime
from PyQt5 import QtWidgets, QtCore, QtGui
from test2 import dataz
from StartScreen import Ui_Form as ui1
from Login_Screen import Ui_Form as ui2
from Registration_Screen import Ui_Form as ui3
from User_Card import Ui_Form as ui4
from User_Paypal import Ui_Form as ui5
from Driver_Card import Ui_Form as ui6
from Driver_Paypal import Ui_Form as ui7
from Thank_You import Ui_Form as ui8
from Verification_Screen import Ui_Form as ui9
from Congratulations import Ui_Form as ui10
from forgotChoices import Ui_Form as ui11
from changePassword import Ui_Form as ui12
from UserScreen import Ui_Form as ui13
from User_Submit_Payment import Ui_Form as ui14
from change_User_First_Name import Ui_Form as ui15
from change_User_Last_Name import Ui_Form as ui16
from change_User_Email import Ui_Form as ui17
from change_User_Password import Ui_Form as ui18
from change_User_Phone_Number import Ui_Form as ui19
from DriverScreen import Ui_Form as ui20
from BackEnd import BackEnd
from random import randint
import numpy as np
import sqlite3
import re
conn = sqlite3.connect("assessment2.db")
c = conn.cursor()
class change_User_Phone_Number(QtWidgets.QWidget):
def __init__(self):
super(change_User_Phone_Number, self).__init__()
self.ui19 = ui19()
self.ui19.setupUi(self)
self.qss()
def hit_Submit(self):
self.o21 = UserMainScreen()
self.o21.Phone_Number_Label.setText(self)
self.o21.show()
self.close()
def qss(self):
qss_file = 'QSS/OrangeDark.qss'
with open(qss_file, "r") as fh:
self.setStyleSheet(fh.read())
class change_User_Password(QtWidgets.QWidget):
def __init__(self):
super(change_User_Password, self).__init__()
self.ui18 = ui18()
self.ui18.setupUi(self)
self.qss()
def hit_Submit(self):
self.o21 = UserMainScreen()
self.o21.show()
self.close()
def qss(self):
qss_file = 'QSS/OrangeDark.qss'
with open(qss_file, "r") as fh:
self.setStyleSheet(fh.read())
class change_User_Email(QtWidgets.QWidget):
def __init__(self):
super(change_User_Email, self).__init__()
self.ui17 = ui17()
self.ui17.setupUi(self)
self.qss()
def hit_Submit(self):
self.o21 = UserMainScreen()
self.o21.Email_Label.setText(self)
self.o21.show()
self.close()
def qss(self):
qss_file = 'QSS/OrangeDark.qss'
with open(qss_file, "r") as fh:
self.setStyleSheet(fh.read())
class change_User_LastName(QtWidgets.QWidget):
def __init__(self):
super(change_User_LastName, self).__init__()
self.ui16 = ui16()
self.ui16.setupUi(self)
self.qss()
def hit_Submit(self):
self.o21 = UserMainScreen()
self.o21.Last_Name_Label.setText(self)
self.o21.show()
self.close()
def qss(self):
qss_file = 'QSS/OrangeDark.qss'
with open(qss_file, "r") as fh:
self.setStyleSheet(fh.read())
class change_User_FirstName(QtWidgets.QWidget):
def __init__(self):
super(change_User_FirstName, self).__init__()
self.ui15 = ui15()
self.ui15.setupUi(self)
self.qss()
def hit_Submit(self):
self.o21 = UserMainScreen()
self.o21.First_Name_Label.setText(self)
self.o21.show()
self.close()
def qss(self):
qss_file = 'QSS/OrangeDark.qss'
with open(qss_file, "r") as fh:
self.setStyleSheet(fh.read())
class User_Submit_Payment(QtWidgets.QWidget):
def __init__(self):
super(User_Submit_Payment, self).__init__()
self.ui14 = ui14()
self.ui14.setupUi(self)
self.qss()
self.ui14.User_Submit_Payment_Method.clicked.connect(self.clos)
def clos(self):
self.close()
def qss(self):
qss_file = 'QSS/OrangeDark.qss'
with open(qss_file, "r") as fh:
self.setStyleSheet(fh.read())
class changePassword(QtWidgets.QWidget):
def __init__(self):
super(changePassword, self).__init__()
self.ui12 = ui12()
self.ui12.setupUi(self)
self.qss()
self.ui12.changePassword.clicked.connect(self.clos)
def qss(self):
qss_file = 'QSS/OrangeDark.qss'
with open(qss_file, "r") as fh:
self.setStyleSheet(fh.read())
def clos(self):
self.close()
class forgotChoices(QtWidgets.QWidget):
def __init__(self):
super(forgotChoices, self).__init__()
self.ui11 = ui11()
self.ui11.setupUi(self)
self.qss()
self.ui11.verify_button.clicked.connect(self.verify)
def qss(self):
qss_file = 'QSS/OrangeDark.qss'
with open(qss_file, "r") as fh:
self.setStyleSheet(fh.read())
def verify(self):
self.o10 = changePassword()
self.o10.show()
self.close()
class Congratulations(QtWidgets.QWidget):
def __init__(self):
super(Congratulations, self).__init__()
self.ui10 = ui10()
self.ui10.setupUi(self)
self.qss()
self.ui10.go2Login.clicked.connect(self.back2Login)
def qss(self):
qss_file = 'QSS/OrangeDark.qss'
with open(qss_file, "r") as fh:
self.setStyleSheet(fh.read())
def back2Login(self):
self.o9 = LoginScreen()
self.o9.show()
self.close()
class Verification_Screen(QtWidgets.QWidget):
def __init__(self):
super(Verification_Screen, self).__init__()
self.ui9 = ui9()
self.ui9.setupUi(self)
self.qss()
self.ui9.Complete_Verification.clicked.connect(self.go_to_Account_Activated)
def qss(self):
qss_file = 'QSS/OrangeDark.qss'
with open(qss_file, "r") as fh:
self.setStyleSheet(fh.read())
def go_to_Account_Activated(self):
self.o8 = Congratulations()
self.o8.show()
self.close()
class Thank_You(QtWidgets.QWidget):
def __init__(self):
super(Thank_You, self).__init__()
a = randint(0, 1000)
self.ui8 = ui8()
self.ui8.setupUi(self)
self.qss()
self.ui8.Verify_Now.clicked.connect(self.open_Verification_Screen)
self.ui8.Security_Code.setText("%d" % a)
def qss(self):
qss_file = 'QSS/OrangeDark.qss'
with open(qss_file, "r") as fh:
self.setStyleSheet(fh.read())
# self.ui8.Security_Code.setText(self.Security_generator)
def open_Verification_Screen(self):
self.o7 = Verification_Screen()
self.o7.show()
self.close()
class Driver_Paypal(QtWidgets.QWidget):
def __init__(self):
super(Driver_Paypal, self).__init__()
self.ui7 = ui7()
self.ui7.setupUi(self)
self.qss()
self.ui7.Submit_Details4.clicked.connect(self.open_Thankyou)
def qss(self):
qss_file = 'QSS/OrangeDark.qss'
with open(qss_file, "r") as fh:
self.setStyleSheet(fh.read())
def open_Thankyou(self):
self.o6 = Thank_You()
self.o6.show()
self.close()
self.take_Driver_Paypal_Inputs()
def take_Driver_Paypal_Inputs(self):
driver_paypal_payme = self.ui7.Driver_Paypal_payme.text()
driver_card_name = 0
driver_card_account_number = 0
driver_sort_code = 0
self.d5 = dataz()
self.d5.Insert_into_driver_payments(driver_card_name, driver_card_account_number, driver_sort_code,
driver_paypal_payme)
class Driver_Card(QtWidgets.QWidget):
def __init__(self):
super(Driver_Card, self).__init__()
self.ui6 = ui6()
self.ui6.setupUi(self)
self.qss()
self.ui6.Submit_Details3.clicked.connect(self.open_Thankyou)
def qss(self):
qss_file = 'QSS/OrangeDark.qss'
with open(qss_file, "r") as fh:
self.setStyleSheet(fh.read())
def open_Thankyou(self):
self.o6 = Thank_You()
self.o6.show()
self.close()
self.take_Driver_Card_Inputs()
def take_Driver_Card_Inputs(self):
driver_card_name = self.ui6.Drive_Card_Name.text()
driver_card_account_number = self.ui6.Driver_card_account_number.text()
driver_sort_code1 = self.ui6.Driver_Card_SortCode1.text()
driver_sort_code2 = self.ui6.Driver_Card_SortCode2.text()
driver_sort_code3 = self.ui6.Driver_Card_SortCode3.text()
driver_sort_code = str(driver_sort_code1) + "-" + str(driver_sort_code2) + "-" + str(driver_sort_code3)
driver_paypal_payme = 0
self.d4 = dataz()
self.d4.Insert_into_driver_payments(driver_card_name, driver_card_account_number, driver_sort_code,
driver_paypal_payme)
class User_Paypal(QtWidgets.QWidget):
def __init__(self):
super(User_Paypal, self).__init__()
self.ui5 = ui5()
self.ui5.setupUi(self)
self.qss()
self.ui5.Submit_Details2.clicked.connect(self.open_Thankyou)
def qss(self):
qss_file = 'QSS/OrangeDark.qss'
with open(qss_file, "r") as fh:
self.setStyleSheet(fh.read())
def open_Thankyou(self):
self.o6 = Thank_You()
self.o6.show()
self.close()
self.take_User_Paypal_Inputs()
def take_User_Paypal_Inputs(self):
user_paypal_email = self.ui5.User_Paypal_Email.text()
user_paypal_password = self.ui5.User_Paypal_Password.text()
user_card_name = 0
user_card_number = 0
user_card_cvv = 0
self.d3 = dataz()
self.d3.Insert_into_customer_payments(user_card_name, user_card_number, user_card_cvv, user_paypal_email,
user_paypal_password)
class User_Card(QtWidgets.QWidget):
def __init__(self):
super(User_Card, self).__init__()
self.ui4 = ui4()
self.ui4.setupUi(self)
self.qss()
self.ui4.Submit_Details1.clicked.connect(self.open_Thankyou)
def qss(self):
qss_file = 'QSS/OrangeDark.qss'
with open(qss_file, "r") as fh:
self.setStyleSheet(fh.read())
def open_Thankyou(self):
self.o6 = Thank_You()
self.o6.show()
self.close()
self.take_User_Card_Inputs()
def take_User_Card_Inputs(self):
user_card_name = self.ui4.User_Card_Name.text()
user_card_number = self.ui4.User_Card_Number.text()
user_card_cvv = self.ui4.User_Card_CVV.text()
user_paypal_email = 0
user_paypal_password = 0
self.d2 = dataz()
self.d2.Insert_into_customer_payments(user_card_name, user_card_number, user_card_cvv, user_paypal_email,
user_paypal_password)
class RegisterScreen(QtWidgets.QWidget):
def __init__(self):
super(RegisterScreen, self).__init__()
self.ui3 = ui3()
self.ui3.setupUi(self)
self.qss()
self.ui3.User_Submit_Button.clicked.connect(self.User_Payment)
self.ui3.Driver_Submit_Button.clicked.connect(self.Driver_Payment)
self.user_check_states1()
self.user_check_states2()
self.driver_check_states1()
self.driver_check_states2()
def qss(self):
qss_file = 'QSS/OrangeDark.qss'
with open(qss_file, "r") as fh:
self.setStyleSheet(fh.read())
def driver_check_car_color_state(self):
input_car_color_name = self.ui3.Driver_Car_Color
regexp = QtCore.QRegExp(r"^[A-Za-z -]+$")
validator = QtGui.QRegExpValidator(regexp)
state = validator.validate(input_car_color_name.text(), 0)[0]
if state == QtGui.QValidator.Acceptable:
color = '#456B19'
elif state == QtGui.QValidator.Intermediate:
color = ''
else:
color = ''
input_car_color_name.setStyleSheet('QLineEdit { background-color: %s }' % color)
def driver_check_car_make_state(self):
input_car_make_name = self.ui3.Driver_Car_Make_Text
regexp = QtCore.QRegExp(r"^[A-Za-z0-9 .-]+$")
validator = QtGui.QRegExpValidator(regexp)
state = validator.validate(input_car_make_name.text(), 0)[0]
if state == QtGui.QValidator.Acceptable:
color = '#456B19'
elif state == QtGui.QValidator.Intermediate:
color = ''
else:
color = ''
input_car_make_name.setStyleSheet('QLineEdit { background-color: %s }' % color)
def driver_check_car_license_state(self):
input_car_license_name = self.ui3.Driver_Car_Number
regexp = QtCore.QRegExp(
r"(^[A-Z]{2}[0-9]{2}\s?[A-Z]{3}$)|(^[A-Z][0-9]{1,3}[A-Z]{3}$)|(^[A-Z]{3}[0-9]{1,3}[A-Z]$)|(^[0-9]{1,4}[A-Z]{1,2}$)|(^[0-9]{1,3}[A-Z]{1,3}$)|(^[A-Z]{1,2}[0-9]{1,4}$)|(^[A-Z]{1,3}[0-9]{1,3}$)|(^[A-Z]{1,3}[0-9]{1,4}$)|(^[0-9]{3}[DX]{1}[0-9]{3}$)")
validator = QtGui.QRegExpValidator(regexp)
state = validator.validate(input_car_license_name.text(), 0)[0]
if state == QtGui.QValidator.Acceptable:
color = '#456B19'
elif state == QtGui.QValidator.Intermediate:
color = ''
else:
color = ''
input_car_license_name.setStyleSheet('QLineEdit { background-color: %s }' % color)
def driver_check_drivers_license_state(self):
input_drivers_license_name = self.ui3.Driver_License_Number
regexp = QtCore.QRegExp(r"^[A-Z9]{5}\d{6}[A-Z9]{2}\d[A-Z]{2}$")
validator = QtGui.QRegExpValidator(regexp)
state = validator.validate(input_drivers_license_name.text(), 0)[0]
if state == QtGui.QValidator.Acceptable:
color = '#456B19'
elif state == QtGui.QValidator.Intermediate:
color = ''
else:
color = ''
input_drivers_license_name.setStyleSheet('QLineEdit { background-color: %s }' % color)
def driver_check_confirm_password_state(self):
input_confirm_password_name = self.ui3.Driver_Confirm_Password_Text
regexp = QtCore.QRegExp(r"^[A-Za-z0-9 .-_]{7,20}+$")
validator = QtGui.QRegExpValidator(regexp)
state = validator.validate(input_confirm_password_name.text(), 0)[0]
if state == QtGui.QValidator.Acceptable:
color = '#456B19'
elif state == QtGui.QValidator.Intermediate:
color = ''
else:
color = ''
input_confirm_password_name.setStyleSheet('QLineEdit { background-color: %s }' % color)
def user_check_confirm_password_state(self):
input_confirm_password_name = self.ui3.User_Confirm_Password_Text
regexp = QtCore.QRegExp(r"^[A-Za-z0-9 .-_]{7,20}+$")
validator = QtGui.QRegExpValidator(regexp)
state = validator.validate(input_confirm_password_name.text(), 0)[0]
if state == QtGui.QValidator.Acceptable:
color = '#456B19'
elif state == QtGui.QValidator.Intermediate:
color = ''
else:
color = ''
input_confirm_password_name.setStyleSheet('QLineEdit { background-color: %s }' % color)
def driver_check_password_state(self):
input_password_name = self.ui3.Driver_Password_Text
regexp = QtCore.QRegExp(r"^[A-Za-z0-9 .-_]{7,20}+$")
validator = QtGui.QRegExpValidator(regexp)
state = validator.validate(input_password_name.text(), 0)[0]
if state == QtGui.QValidator.Acceptable:
color = '#456B19'
elif state == QtGui.QValidator.Intermediate:
color = ''
else:
color = ''
input_password_name.setStyleSheet('QLineEdit { background-color: %s }' % color)
def user_check_password_state(self):
input_password_name = self.ui3.User_Password_Text
regexp = QtCore.QRegExp(r"^[A-Za-z0-9 .-_]{7,20}+$")
validator = QtGui.QRegExpValidator(regexp)
state = validator.validate(input_password_name.text(), 0)[0]
if state == QtGui.QValidator.Acceptable:
color = '#456B19'
elif state == QtGui.QValidator.Intermediate:
color = ''
else:
color = ''
input_password_name.setStyleSheet('QLineEdit { background-color: %s }' % color)
def driver_check_last_name_state(self):
input_last_name = self.ui3.Driver_Last_Name_Text
regexp = QtCore.QRegExp(r"^[A-Za-z .-]+$")
validator = QtGui.QRegExpValidator(regexp)
state = validator.validate(input_last_name.text(), 0)[0]
if state == QtGui.QValidator.Acceptable:
color = '#456B19'
elif state == QtGui.QValidator.Intermediate:
color = ''
else:
color = ''
input_last_name.setStyleSheet('QLineEdit { background-color: %s }' % color)
def user_check_last_name_state(self):
input_last_name = self.ui3.User_Last_Name_Text
regexp = QtCore.QRegExp(r"^[A-Za-z .-]+$")
validator = QtGui.QRegExpValidator(regexp)
state = validator.validate(input_last_name.text(), 0)[0]
if state == QtGui.QValidator.Acceptable:
color = '#456B19'
elif state == QtGui.QValidator.Intermediate:
color = ''
else:
color = ''
input_last_name.setStyleSheet('QLineEdit { background-color: %s }' % color)
def driver_check_first_name_state(self):
input_first_name = self.ui3.Driver_First_Name_Text
regexp = QtCore.QRegExp(r"^[A-Za-z .-]+$")
validator = QtGui.QRegExpValidator(regexp)
state = validator.validate(input_first_name.text(), 0)[0]
if state == QtGui.QValidator.Acceptable:
color = '#456B19'
elif state == QtGui.QValidator.Intermediate:
color = ''
else:
color = ''
input_first_name.setStyleSheet('QLineEdit { background-color: %s }' % color)
def user_check_first_name_state(self):
input_first_name = self.ui3.User_First_Name_Text
regexp = QtCore.QRegExp(r"^[A-Za-z .-]+$")
validator = QtGui.QRegExpValidator(regexp)
state = validator.validate(input_first_name.text(), 0)[0]
if state == QtGui.QValidator.Acceptable:
color = '#456B19'
elif state == QtGui.QValidator.Intermediate:
color = ''
else:
color = ''
input_first_name.setStyleSheet('QLineEdit { background-color: %s }' % color)
def driver_check_email_state(self):
input_email = self.ui3.Driver_Email_Text
regexp = QtCore.QRegExp(r"^([a-z\d.-]+)@([a-z\.d-]+)\.([a-z]{2,8})(\.[a-z]{2,8})?$")
validator = QtGui.QRegExpValidator(regexp)
state = validator.validate(input_email.text(), 0)[0]
if state == QtGui.QValidator.Acceptable:
color = '#456B19'
elif state == QtGui.QValidator.Intermediate:
color = ''
else:
color = ''
input_email.setStyleSheet('QLineEdit { background-color: %s }' % color)
def user_check_email_state(self):
input_email = self.ui3.User_Email_Text
regexp = QtCore.QRegExp(r"^([a-z\d.-]+)@([a-z\.d-]+)\.([a-z]{2,8})(\.[a-z]{2,8})?$")
validator = QtGui.QRegExpValidator(regexp)
state = validator.validate(input_email.text(), 0)[0]
if state == QtGui.QValidator.Acceptable:
color = '#456B19'
elif state == QtGui.QValidator.Intermediate:
color = ''
else:
color = ''
input_email.setStyleSheet('QLineEdit { background-color: %s }' % color)
def driver_check_contact_state(self):
input_contact_number = self.ui3.Driver_Phone_Number_Text
regexp = QtCore.QRegExp(r"^[0-9\-\+]{9,15}$")
validator = QtGui.QRegExpValidator(regexp)
state = validator.validate(input_contact_number.text(), 0)[0]
if state == QtGui.QValidator.Acceptable:
color = '#456B19'
elif state == QtGui.QValidator.Intermediate:
color = ''
else:
color = ''
input_contact_number.setStyleSheet('QLineEdit { background-color: %s }' % color)
def user_check_contact_state(self):
input_contact_number = self.ui3.User_Contact_Number_Text
regexp = QtCore.QRegExp(r"^[0-9\-\+]{9,15}$")
validator = QtGui.QRegExpValidator(regexp)
state = validator.validate(input_contact_number.text(), 0)[0]
if state == QtGui.QValidator.Acceptable:
color = '#456B19'
elif state == QtGui.QValidator.Intermediate:
color = ''
else:
color = ''
input_contact_number.setStyleSheet('QLineEdit { background-color: %s }' % color)
def driver_check_states1(self):
self.driver_check_first_name_state()
self.driver_check_email_state()
self.driver_check_contact_state()
self.driver_check_last_name_state()
self.driver_check_password_state()
self.driver_check_confirm_password_state()
self.driver_check_drivers_license_state()
self.driver_check_car_license_state()
self.driver_check_car_make_state()
self.driver_check_car_color_state()
def user_check_states1(self):
self.user_check_first_name_state()
self.user_check_email_state()
self.user_check_contact_state()
self.user_check_last_name_state()
self.user_check_password_state()
self.user_check_confirm_password_state()
def driver_check_states2(self):
self.ui3.Driver_Car_Color.textEdited.connect(self.driver_check_car_color_state)
self.ui3.Driver_Car_Color.textEdited.emit(self.ui3.Driver_Car_Color.text())
self.ui3.Driver_Car_Make_Text.textEdited.connect(self.driver_check_car_make_state)
self.ui3.Driver_Car_Make_Text.textEdited.emit(self.ui3.Driver_Car_Make_Text.text())
self.ui3.Driver_Car_Number.textEdited.connect(self.driver_check_car_license_state)
self.ui3.Driver_Car_Number.textEdited.emit(self.ui3.Driver_Car_Number.text())
self.ui3.Driver_License_Number.textEdited.connect(self.driver_check_drivers_license_state)
self.ui3.Driver_License_Number.textEdited.emit(self.ui3.Driver_License_Number.text())
self.ui3.Driver_Last_Name_Text.textEdited.connect(self.driver_check_last_name_state)
self.ui3.Driver_Last_Name_Text.textEdited.emit(self.ui3.Driver_Last_Name_Text.text())
self.ui3.Driver_First_Name_Text.textEdited.connect(self.driver_check_first_name_state)
self.ui3.Driver_First_Name_Text.textEdited.emit(self.ui3.Driver_First_Name_Text.text())
self.ui3.Driver_Email_Text.textEdited.connect(self.driver_check_email_state)
self.ui3.Driver_Email_Text.textEdited.emit(self.ui3.Driver_Email_Text.text())
self.ui3.Driver_Phone_Number_Text.textEdited.connect(self.driver_check_contact_state)
self.ui3.Driver_Phone_Number_Text.textEdited.emit(self.ui3.Driver_Phone_Number_Text.text())
self.ui3.Driver_Password_Text.textEdited.connect(self.driver_check_password_state)
self.ui3.Driver_Password_Text.textEdited.emit(self.ui3.Driver_Password_Text.text())
self.ui3.Driver_Confirm_Password_Text.textEdited.connect(self.driver_check_confirm_password_state)
self.ui3.Driver_Confirm_Password_Text.textEdited.emit(self.ui3.Driver_Confirm_Password_Text.text())
def user_check_states2(self):
self.ui3.User_Last_Name_Text.textEdited.connect(self.user_check_last_name_state)
self.ui3.User_Last_Name_Text.textEdited.emit(self.ui3.User_Last_Name_Text.text())
self.ui3.User_First_Name_Text.textEdited.connect(self.user_check_first_name_state)
self.ui3.User_First_Name_Text.textEdited.emit(self.ui3.User_First_Name_Text.text())
self.ui3.User_Email_Text.textEdited.connect(self.user_check_email_state)
self.ui3.User_Email_Text.textEdited.emit(self.ui3.User_Email_Text.text())
self.ui3.User_Contact_Number_Text.textEdited.connect(self.user_check_contact_state)
self.ui3.User_Contact_Number_Text.textEdited.emit(self.ui3.User_Contact_Number_Text.text())
self.ui3.User_Password_Text.textEdited.connect(self.user_check_password_state)
self.ui3.User_Password_Text.textEdited.emit(self.ui3.User_Password_Text.text())
self.ui3.User_Confirm_Password_Text.textEdited.connect(self.user_check_confirm_password_state)
self.ui3.User_Confirm_Password_Text.textEdited.emit(self.ui3.User_Confirm_Password_Text.text())
def take_user_inputs(self):
user_first_name = self.ui3.User_First_Name_Text.text()
user_last_name = self.ui3.User_Last_Name_Text.text()
user_email = self.ui3.User_Email_Text.text()
user_contact_number = self.ui3.User_Contact_Number_Text.text()
user_password = self.ui3.User_Password_Text.text()
user_payment = self.ui3.comboBox.currentText()
self.d1 = dataz()
self.d1.Insert_Into_customers(user_first_name, user_last_name, user_email, user_contact_number, user_password,
user_payment)
def take_driver_inputs(self):
driver_first_name = self.ui3.Driver_First_Name_Text.text()
driver_last_name = self.ui3.Driver_Last_Name_Text.text()
driver_email = self.ui3.Driver_Email_Text.text()
driver_password = self.ui3.Driver_Password_Text.text()
driver_contact_number = self.ui3.Driver_Phone_Number_Text.text()
driver_license = self.ui3.Driver_License_Number.text()
driver_car_license = self.ui3.Driver_Car_Number.text()
driver_car_make = self.ui3.Driver_Car_Make_Text.text()
driver_car_color = self.ui3.Driver_Car_Color.text()
driver_payment = self.ui3.comboBox_2.currentText()
self.d2 = dataz()
self.d2.Insert_Into_drivers(driver_first_name, driver_last_name, driver_email, driver_password,
driver_contact_number, driver_license, driver_car_license, driver_car_make,
driver_car_color, driver_payment)
def open_User_Card(self):
self.o2 = User_Card()
self.o2.show()
self.close()
def open_User_Paypal(self):
self.o3 = User_Paypal()
self.o3.show()
self.close()
def open_Driver_Card(self):
self.o4 = Driver_Card()
self.o4.show()
self.close()
def open_Driver_Paypal(self):
self.o5 = Driver_Paypal()
self.o5.show()
self.close()
def Delete_Dup_Customers(self):
self.d9 = dataz()
self.d9.Delete_Duplicates_Customers()
def Delete_Dup_Drivers(self):
self.d10 = dataz()
self.d10.Delete_Duplicates_Drivers()
def User_Payment(self):
self.user_check_email_state()
self.take_user_inputs()
self.Delete_Dup_Customers()
if self.ui3.User_Password_Text.text() == self.ui3.User_Confirm_Password_Text.text():
if self.ui3.comboBox.currentText() == "Card":
self.ui3.User_Submit_Button.clicked.connect(self.open_User_Card)
elif self.ui3.comboBox.currentText() == "PayPal":
self.ui3.User_Submit_Button.clicked.connect(self.open_User_Paypal)
else:
self.ui3.User_Invalid_Password.setText("Passwords Mismatch, try again")
def Driver_Payment(self):
self.take_driver_inputs()
self.Delete_Dup_Drivers()
if self.ui3.Driver_Password_Text.text() == self.ui3.Driver_Confirm_Password_Text.text():
if self.ui3.comboBox_2.currentText() == "Card":
self.ui3.Driver_Submit_Button.clicked.connect(self.open_Driver_Card)
elif self.ui3.comboBox_2.currentText() == "PayPal":
self.ui3.Driver_Submit_Button.clicked.connect(self.open_Driver_Paypal)
else:
self.ui3.Driver_Invalid_Password.setText("Passwords Mismatch, try again")
def containsDigits(self, s):
for char in s:
if char.isdigit():
contains_digit = True
else:
contains_digit = False
# return contains_digit
def emailCheck(self, m):
if re.match(r"[^@]+@[^@]+\.[^@]+", m):
return True
else:
return False
class LoginScreen(QtWidgets.QWidget):
def __init__(self):
super(LoginScreen, self).__init__()
self.ui2 = ui2()
self.ui2.setupUi(self)
self.qss()
self.ui2.user_ForgotPass.clicked.connect(self.forgetPass)
self.ui2.driver_ForgotPass.clicked.connect(self.forgetPass)
self.ui2.user_Submit.clicked.connect(self.userChecker)
self.ui2.driver_Submit.clicked.connect(self.driverChecker)
def qss(self):
qss_file = 'QSS/OrangeDark.qss'
with open(qss_file, "r") as fh:
self.setStyleSheet(fh.read())
def forgetPass(self):
self.o11 = forgotChoices()
self.o11.show()
def openUserLogin(self):
self.o12 = UserMainScreen()
self.o12.show()
self.close()
def openDriverLogin(self):
self.o21 = DriverScreen()
self.o21.show()
id_ = DriverScreen().takePass('pass.txt')
self.close()
def pushToTxt(self, file, id):
with open(file, 'w') as f:
id = str(id)
f.write(id)
def userChecker(self):
"""Login verification for the customers."""
user_login = str(self.ui2.userLoginEC.text())
user_Password = str(self.ui2.userPass.text())
self.o13 = dataz()
try:
c = self.o13.get_customer_userID_by_password(user_Password)
except TypeError:
self.ui2.user_login_Fail.setText("Try Again")
list_of_emails = BackEnd().customerEmailList()
list_of_phone_numbers = BackEnd().customerPhoneNumberList()
if user_login in list_of_emails:
a = self.o13.get_customer_userID_by_email(user_login)
c = self.o13.get_customer_userID_by_password(user_Password)
if a == c:
self.pushToTxt('pass.txt', c)
self.openUserLogin()
elif user_login in list_of_phone_numbers:
b = self.o13.get_customer_userID_by_phone_number(user_login)
c = self.o13.get_customer_userID_by_password(user_Password)
if b == c:
self.pushToTxt('pass.txt', c)
self.openUserLogin()
else:
self.ui2.user_login_Fail.setText("Try Again")
def driverChecker(self):
"""Login verification for the drivers."""
driver_login = str(self.ui2.driverLoginEC.text())
driver_password = str(self.ui2.driverPass.text())
self.o13 = dataz()
try:
c = self.o13.get_driver_driverID_by_password(driver_password)
except TypeError:
self.ui2.user_login_Fail.setText("Try Again")
list_of_emails = BackEnd().driverEmailList()
list_of_phone_numbers = BackEnd().driverPhoneNumberList()
if driver_login in list_of_emails:
a = self.o13.get_driver_driverID_by_email(driver_login)
c = self.o13.get_driver_driverID_by_password(driver_password)
if a == c:
self.pushToTxt('pass.txt', c)
self.openDriverLogin()
if driver_login in list_of_phone_numbers:
b = self.o13.get_driver_driverID_by_phone_number(driver_login)
c = self.o13.get_driver_driverID_by_password(driver_password)
if b == c:
self.pushToTxt('pass.txt', c)
self.openDriverLogin()
else:
self.ui2.driver_login_Fail.setText('Try Again')
class DriverScreen(QtWidgets.QWidget):
def __init__(self):
super(DriverScreen, self).__init__()
self.ui20 = ui20()
self.ui20.setupUi(self)
# self.ui20.Select_Payment_Method_Btn.clicked.connect(self.open_User_Payment_Options)
self.ui20.Logout_Btn.clicked.connect(self.open_Start_Screen)
self.ui20.change_First_Name.clicked.connect(self.open_Change_First_Name)
self.ui20.change_Last_Name.clicked.connect(self.open_Change_Last_Name)
self.ui20.change_Email.clicked.connect(self.open_Change_Email)
self.ui20.change_Phone_Number.clicked.connect(self.open_Change_Phone_Number)
self.ui20.change_Password.clicked.connect(self.open_Change_Password)
self.ui20.change_Card.clicked.connect(self.open_Card_Change)
self.ui20.change_Paypal.clicked.connect(self.open_Paypal_Change)
self.qss()
self.ui20.pushButton.clicked.connect(self.findOrderButton)
self.ui20.accept_order.clicked.connect(self.emptySomething)
self.ui20.accept_order.clicked.connect(self.deleteOrder)
self.ui20.decline_order.clicked.connect(self.emptyEverything)
self.loaddata()
pass__ = self.takePass('pass.txt')
a, b, c, d = self.getDriver(pass__)
self.phillOut(a, b, c, d)
def takePass(self, file):
with open(file, 'r') as f:
id_ = f.read()
return id_
def getDriver(self, v):
fn = dataz().get_driver_username_by_id(v)
ln = dataz().get_driver_lastname_by_id(v)
email = dataz().get_driver_email_by_id(v)
pn = dataz().get_driver_pn_by_id(v)
return fn, ln, email, pn
def phillOut(self, fn, ln, email, pn):
self.ui20.First_Name_Label.setText(fn)
self.ui20.Last_Name_Label.setText(ln)
self.ui20.Email_Label.setText(email)
self.ui20.Phone_Number_Label.setText(pn)
def loaddata(self):
connection = sqlite3.connect('assessment2.db')
cur = connection.cursor()
sqlstr = 'SELECT * FROM journey'
tablerow = 0
results = cur.execute(sqlstr)
self.ui20.tableWidget.setRowCount(40)
for row in results:
self.ui20.tableWidget.setItem(tablerow, 0, QtWidgets.QTableWidgetItem(row[0]))
self.ui20.tableWidget.setItem(tablerow, 1, QtWidgets.QTableWidgetItem(row[1]))
self.ui20.tableWidget.setItem(tablerow, 2, QtWidgets.QTableWidgetItem(row[2]))
tablerow += 1
def deleteOrder(self):
id = BackEnd().getOrderID()
dataz().Delete_Row_orders(id)
def findOrderButton(self):
start_location, destination, order_id = BackEnd().findOrder()
self.getNewOrder(start_location, destination)
self.ui20.from_value.setText(start_location)
self.ui20.To_value.setText(destination)
def emptyEverything(self):
self.ui20.sl_value.setText('')
self.ui20.el_value.setText('')
self.ui20.from_value.setText('')
self.ui20.To_value.setText('')
def emptySomething(self):
self.ui20.sl_value.setText('')
self.ui20.el_value.setText('')
def placeOrderToUpcomingJourney(self, start, end):
self.ui20.from_value.setText(start)
self.ui20.To_value.setText(end)
def open_User_Payment_Options(self):
self.o13 = User_Submit_Payment()
self.o13.show()
self.getNewBookingItems()
def open_Start_Screen(self):
self.o14 = StartScreen()
self.o14.show()
self.close()
def open_Change_First_Name(self):
self.o15 = change_User_FirstName()
self.o15.show()
self.close()
def open_Change_Last_Name(self):
self.o16 = change_User_LastName()
self.o16.show()
self.close()
def open_Change_Email(self):
self.o17 = change_User_Email()
self.o17.show()
self.close()
def open_Change_Password(self):
self.o18 = change_User_Password()
self.o18.show()
self.close()
def open_Change_Phone_Number(self):
self.o19 = change_User_Phone_Number()
self.o19.show()
self.close()
def open_Card_Change(self):
self.o20 = User_Card()
self.o20.show()
self.close()
def open_Paypal_Change(self):
self.o21 = User_Paypal()
self.o21.show()
self.close()
def qss(self):
qss_file = 'QSS/OrangeDark.qss'
with open(qss_file, "r") as fh:
self.setStyleSheet(fh.read())
def getNewOrder(self, start_point, end_point):
self.ui20.sl_value.setText(start_point)
self.ui20.el_value.setText(end_point)
class UserMainScreen(QtWidgets.QWidget):
def __init__(self):
super(UserMainScreen, self).__init__()
self.ui13 = ui13()
self.ui13.setupUi(self)
self.loaddata()
self.ui13.Select_Payment_Method_Btn.clicked.connect(self.open_User_Payment_Options)
self.ui13.Logout_Btn.clicked.connect(self.open_Start_Screen)
self.ui13.change_First_Name.clicked.connect(self.open_Change_First_Name)
self.ui13.change_Last_Name.clicked.connect(self.open_Change_Last_Name)
self.ui13.change_Email.clicked.connect(self.open_Change_Email)
self.ui13.change_Phone_Number.clicked.connect(self.open_Change_Phone_Number)
self.ui13.change_Password.clicked.connect(self.open_Change_Password)
self.ui13.change_Card.clicked.connect(self.open_Card_Change)
self.ui13.change_Paypal.clicked.connect(self.open_Paypal_Change)
self.ui13.Refresh_Btn.clicked.connect(self.hit_refresh)
self.qss()
#pass__ = DriverScreen().takePass('pass.txt')
#un, ln, email, pn = self.getUser(pass__)
#self.phillOut(un, ln, email, pn)
def phillOut(self, a, b, c, d):
self.ui13.First_Name_Label.setText(a)
self.ui13Last_Name_Label.setText(b)
self.ui13.Email_Label.setText(c)
self.ui13.Phone_Number_Label.setText(c)
def getUser(self, pass__):
un = dataz().get_customer_username_by_id(pass__)
ln = dataz().get_customer_lastname_by_id(pass__)
email = dataz().get_customer_email_by_id(pass__)
pn = dataz().get_customer_phone_number_by_id(pass__)
return un, ln, email, pn
def getNewBookingItems(self):
start_point = self.ui13.comboBox.currentText()
end_point = self.ui13.comboBox_2.currentText()
car_type = self.ui13.comboBox_3.currentText()
distance, price = BackEnd.priceCalc(BackEnd.locations[start_point], BackEnd.locations[end_point])
distance = format(distance, '.2f') + 'km'
price = format(price, '.2f') + '£'
date, time = BackEnd().getDateAndTime()
jID = BackEnd().getJourneyID()
driver_name, car_make, car_color = BackEnd().assignTheDriver()
eta = BackEnd().getETA()