-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_project.py
1411 lines (1181 loc) · 72.1 KB
/
main_project.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 os # for creating directories Admin/Customer if it is not exists.
from datetime import date # for date of account creation when new customer account is created.
import tkinter as tk
from tkinter import *
# Backend python functions code starts :
def is_valid(customer_account_number):
try:
customer_database = open("./database/Customer/customerDatabase.txt")
except FileNotFoundError:
os.makedirs("./database/Customer/customerDatabase.txt", exist_ok=True)
print("# Customer database doesn't exists!\n# New Customer database created automatically.")
customer_database = open("./database/Customer/customerDatabase.txt", "a")
else: # if customer account number is already allocated then this will return false. otherwise true.
if check_credentials(customer_account_number, "DO_NOT_CHECK", 2, True):
return False
else:
return True
customer_database.close()
def check_leap(year):
return ((int(year) % 4 == 0) and (int(year) % 100 != 0)) or (int(year) % 400 == 0)
def check_date(date):
days_in_months = ["31", "28", "31", "30", "31", "30", "31", "31", "30", "31", "30", "31"]
days_in_months_in_leap_year = ["31", "29", "31", "30", "31", "30", "31", "31", "30", "31", "30", "31"]
if date == "":
return False
date_elements = date.split("/")
day = int(date_elements[0])
month = int(date_elements[1])
year = int(date_elements[2])
if (year > 2021 or year < 0) or (month > 12 or month < 1):
return False
else:
if check_leap(year):
numOfDays = days_in_months_in_leap_year[month - 1]
else:
numOfDays = days_in_months[month - 1]
return int(numOfDays) >= day >= 1
def is_valid_mobile(mobile_number):
if mobile_number.__len__() == 10 and mobile_number.isnumeric():
return True
else:
return False
def append_data(database_path, data):
customer_database = open(database_path, "a")
customer_database.write(data)
def display_account_summary(identity, choice): # choice 1 for full summary; choice 2 for only account balance.
flag = 0
customer_database = open("./database/Customer/customerDatabase.txt")
output_message = ""
for line in customer_database:
if identity == line.replace("\n", ""):
if choice == 1:
output_message += "Account number : " + line.replace("\n", "") + "\n"
customer_database.__next__() # skipping pin
output_message += "Current balance : " + customer_database.__next__().replace("\n", "") + "\n"
output_message += "Date of account creation : " + customer_database.__next__().replace("\n", "") + "\n"
output_message += "Name of account holder : " + customer_database.__next__().replace("\n", "") + "\n"
output_message += "Type of account : " + customer_database.__next__().replace("\n", "") + "\n"
output_message += "Date of Birth : " + customer_database.__next__().replace("\n", "") + "\n"
output_message += "Mobile number : " + customer_database.__next__().replace("\n", "") + "\n"
output_message += "Gender : " + customer_database.__next__().replace("\n", "") + "\n"
output_message += "Nationality : " + customer_database.__next__().replace("\n", "") + "\n"
output_message += "KYC : " + customer_database.__next__().replace("\n", "") + "\n"
else:
customer_database.readline() # skipped pin
output_message += "Current balance : " + customer_database.readline().replace("\n", "") + "\n"
flag = 1
break
else:
for index in range(11):
fetched_line = customer_database.readline()
if fetched_line is not None:
continue
else:
break
if flag == 0:
print("\n# No account associated with the entered account number exists! #")
return output_message
def delete_customer_account(identity, choice): # choice 1 for admin, choice 2 for customer
customer_database = open("./database/Customer/customerDatabase.txt")
data_collector = ""
flag = 0
for line in customer_database:
if identity == line.replace("\n", ""):
flag = 1
for index in range(11):
customer_database.readline() # skipping the line
else:
data_collector += line
for index in range(11):
data_collector += customer_database.readline()
customer_database = open("./database/Customer/customerDatabase.txt", "w")
customer_database.write(data_collector)
if flag == 1:
output_message = "Account with account no." + str(identity) + " closed successfully!"
if choice == 1:
adminMenu.printMessage_outside(output_message)
print(output_message)
else:
output_message = "Account not found !"
if choice == 1:
adminMenu.printMessage_outside(output_message)
print(output_message)
def create_admin_account(identity, password):
admin_database = open("./database/Admin/adminDatabase.txt", "a")
admin_id = identity
admin_password = password
append_data("./database/Admin/adminDatabase.txt", admin_id + "\n" + admin_password + "\n" + "*\n")
output_message = "Admin account created successfully !"
adminMenu.printMessage_outside(output_message)
print(output_message)
admin_database.close()
def delete_admin_account(identity):
admin_database = open("./database/Admin/adminDatabase.txt")
data_collector = ""
flag = 0
for line in admin_database:
if identity == line.replace("\n", ""):
flag = 1
for index in range(2):
admin_database.readline()
else:
data_collector += line
for index in range(2):
data_collector += admin_database.readline()
admin_database = open("./database/Admin/adminDatabase.txt", "w")
admin_database.write(data_collector)
if flag == 1:
output_message = "Account with account id " + identity + " closed successfully!"
print(output_message)
adminMenu.printMessage_outside(output_message)
else:
output_message = "Account not found :("
adminMenu.printMessage_outside(output_message)
print(output_message)
def change_PIN(identity, new_PIN):
customer_database = open("./database/Customer/customerDatabase.txt")
data_collector = ""
for line in customer_database:
if identity == line.replace("\n", ""):
data_collector += line # ID
data_collector += str(new_PIN) + "\n" # PIN changed
customer_database.readline()
for index in range(10):
data_collector += customer_database.readline()
else:
data_collector += line
for index in range(11):
data_collector += customer_database.readline()
customer_database.close()
customer_database = open("./database/Customer/customerDatabase.txt", "w")
customer_database.write(data_collector)
output_message = "PIN changed successfully."
customerMenu.printMessage_outside(output_message)
print(output_message)
def transaction(identity, amount, choice): # choice 1 for deposit; choice 2 for withdraw
customer_database = open("./database/Customer/customerDatabase.txt")
data_collector = ""
balance = 0
for line in customer_database:
if identity == line.replace("\n", ""):
data_collector += line # ID
data_collector += customer_database.readline() # PIN
balance = float(customer_database.readline().replace("\n", ""))
if choice == 2 and balance - amount < 10000: # Minimum balance 10000
return -1
else:
if choice == 1:
balance += amount
else:
balance -= amount
data_collector += str(balance) + "\n"
for index in range(9):
data_collector += customer_database.readline()
else:
data_collector += line
for index in range(11):
data_collector += customer_database.readline()
customer_database.close()
customer_database = open("./database/Customer/customerDatabase.txt", "w")
customer_database.write(data_collector)
return balance
def check_credentials(identity, password, choice,
admin_access): # checks credentials of admin/customer and returns True or False
folder_name = "./database/Admin" if (choice == 1) else "./database/Customer"
file_name = "/adminDatabase.txt" if (choice == 1) else "/customerDatabase.txt"
try:
os.makedirs(folder_name, exist_ok=True)
database = open(folder_name + file_name, "r")
except FileNotFoundError:
print("#", folder_name[2:], "database doesn't exists!\n# New", folder_name[2:],
"database created automatically.")
database = open(folder_name + file_name, "a")
if choice == 1:
database.write("admin\nadmin@123\n*\n")
else:
is_credentials_correct = False
for line in database:
id_fetched = line.replace("\n", "")
password_fetched = database.__next__().replace("\n", "")
if id_fetched == identity:
if ((password == "DO_NOT_CHECK_ADMIN" and choice == 1 and admin_access == False) or (
password == "DO_NOT_CHECK" and choice == 2 and admin_access == True) or password_fetched == password):
is_credentials_correct = True
database.close()
return True
if choice == 1: # skips unnecessary lines in admin database.
database.__next__() # skipping line
else: # skips unnecessary lines in customer database.
for index in range(10):
fetched_line = database.readline()
if fetched_line is not None:
continue
else:
break
if is_credentials_correct:
print("Success!")
else:
print("Failure!")
database.close()
return False
# Backend python functions code ends.
# Tkinter GUI code starts :
class welcomeScreen:
def __init__(self, window=None):
self.master = window
window.geometry("600x450+383+106")
window.minsize(120, 1)
window.maxsize(1370, 749)
window.resizable(0, 0)
window.title("Welcome to Techvanto Bank")
p1 = PhotoImage(file='./images/bank1.png')
window.iconphoto(True, p1)
window.configure(background="#8EE5EE")
window.configure(cursor="arrow")
self.Canvas1 = tk.Canvas(window, background="#E6E6FA", borderwidth="0", insertbackground="black",
relief="ridge",
selectbackground="blue", selectforeground="white")
self.Canvas1.place(relx=0.190, rely=0.228, relheight=0.496, relwidth=0.622)
self.Button1 = tk.Button(self.Canvas1, command=self.selectEmployee, activebackground="#ececec",
activeforeground="#000000", background="#8EE5EE", disabledforeground="#a3a3a3",
foreground="#fbfbfb", borderwidth="0", highlightbackground="#d9d9d9",
highlightcolor="black", pady="0",
text='''ADMIN''')
self.Button1.configure(font="-family {Segoe UI} -size 10 -weight bold")
self.Button1.place(relx=0.161, rely=0.583, height=24, width=87)
self.Button2 = tk.Button(self.Canvas1, command=self.selectCustomer, activebackground="#ececec",
activeforeground="#000000", background="#8EE5EE", disabledforeground="#a3a3a3",
foreground="#f9f9f9", borderwidth="0", highlightbackground="#d9d9d9",
highlightcolor="black", pady="0",
text='''CUSTOMER''')
self.Button2.configure(font="-family {Segoe UI} -size 10 -weight bold")
self.Button2.place(relx=0.617, rely=0.583, height=24, width=87)
self.Label1 = tk.Label(self.Canvas1, background="#E6E6FA", disabledforeground="#a3a3a3",
font="-family {Segoe UI} -size 13 -weight bold", foreground="#000000",
text='''Please select your role''')
self.Label1.place(relx=0.241, rely=0.224, height=31, width=194)
def selectEmployee(self):
self.master.withdraw()
adminLogin(Toplevel(self.master))
def selectCustomer(self):
self.master.withdraw()
CustomerLogin(Toplevel(self.master))
class Error:
def __init__(self, window=None):
global master
master = window
window.geometry("411x117+485+248")
window.minsize(120, 1)
window.maxsize(1370, 749)
window.resizable(0, 0)
window.title("Error")
window.configure(background="#f2f3f4")
global Label2
self.Button1 = tk.Button(window, background="#d3d8dc", borderwidth="1", disabledforeground="#a3a3a3",
font="-family {Segoe UI} -size 9", foreground="#000000", highlightbackground="#d9d9d9",
highlightcolor="black", pady="0", text='''OK''', command=self.goback)
self.Button1.place(relx=0.779, rely=0.598, height=24, width=67)
global _img0
_img0 = tk.PhotoImage(file="./images/error_image.png")
self.Label1 = tk.Label(window, background="#f2f3f4", disabledforeground="#a3a3a3", foreground="#000000",
image=_img0, text='''Label''')
self.Label1.place(relx=0.024, rely=0.0, height=81, width=84)
def setMessage(self, message_shown):
Label2 = tk.Label(master, background="#f2f3f4", disabledforeground="#a3a3a3",
font="-family {Segoe UI} -size 16", foreground="#000000", highlightcolor="#646464646464",
text=message_shown)
Label2.place(relx=0.210, rely=0.171, height=41, width=214)
def goback(self):
master.withdraw()
class adminLogin:
def __init__(self, window=None):
self.master = window
window.geometry("743x494+338+92")
window.minsize(120, 1)
window.maxsize(1370, 749)
window.resizable(0, 0)
window.title("Admin")
window.configure(background="#E6E6FA")
global Canvas1
Canvas1 = tk.Canvas(window, background="#ffffff", insertbackground="black", relief="ridge",
selectbackground="blue", selectforeground="white")
Canvas1.place(relx=0.108, rely=0.142, relheight=0.715, relwidth=0.798)
self.Label1 = tk.Label(Canvas1, background="#ffffff", disabledforeground="#a3a3a3",
font="-family {Segoe UI} -size 14 -weight bold", foreground="#00254a",
text="Admin Login")
self.Label1.place(relx=0.135, rely=0.142, height=41, width=154)
global Label2
Label2 = tk.Label(Canvas1, background="#ffffff", disabledforeground="#a3a3a3", foreground="#000000")
Label2.place(relx=0.067, rely=0.283, height=181, width=233)
global _img0
_img0 = tk.PhotoImage(file="./images/adminLogin1.png")
Label2.configure(image=_img0)
self.Entry1 = tk.Entry(Canvas1, background="#e2e2e2", borderwidth="2", disabledforeground="#a3a3a3",
font="TkFixedFont", foreground="#000000", highlightbackground="#b6b6b6",
highlightcolor="#004080", insertbackground="black")
self.Entry1.place(relx=0.607, rely=0.453, height=20, relwidth=0.26)
self.Entry1_1 = tk.Entry(Canvas1, show='*', background="#e2e2e2", borderwidth="2",
disabledforeground="#a3a3a3", font="TkFixedFont", foreground="#000000",
highlightbackground="#d9d9d9", highlightcolor="#004080", insertbackground="black",
selectbackground="blue", selectforeground="white")
self.Entry1_1.place(relx=0.607, rely=0.623, height=20, relwidth=0.26)
self.Label3 = tk.Label(Canvas1, background="#ffffff", disabledforeground="#a3a3a3", foreground="#000000")
self.Label3.place(relx=0.556, rely=0.453, height=21, width=34)
global _img1
_img1 = tk.PhotoImage(file="./images/user1.png")
self.Label3.configure(image=_img1)
self.Label4 = tk.Label(Canvas1, background="#ffffff", disabledforeground="#a3a3a3", foreground="#000000")
self.Label4.place(relx=0.556, rely=0.623, height=21, width=34)
global _img2
_img2 = tk.PhotoImage(file="./images/lock1.png")
self.Label4.configure(image=_img2)
self.Label5 = tk.Label(Canvas1, background="#ffffff", disabledforeground="#a3a3a3", foreground="#000000")
self.Label5.place(relx=0.670, rely=0.142, height=71, width=74)
global _img3
_img3 = tk.PhotoImage(file="./images/bank1.png")
self.Label5.configure(image=_img3)
self.Button = tk.Button(Canvas1, text="Login", borderwidth="0", width=10, background="#E6E6FA",
foreground="#00254a",
font="-family {Segoe UI} -size 10 -weight bold",
command=lambda: self.login(self.Entry1.get(), self.Entry1_1.get()))
self.Button.place(relx=0.765, rely=0.755)
self.Button_back = tk.Button(Canvas1, text="Back", borderwidth="0", width=10, background="#E6E6FA",
foreground="#00254a",
font="-family {Segoe UI} -size 10 -weight bold",
command=self.back)
self.Button_back.place(relx=0.545, rely=0.755)
global admin_img
admin_img = tk.PhotoImage(file="./images/adminLogin1.png")
def back(self):
self.master.withdraw()
welcomeScreen(Toplevel(self.master))
@staticmethod
def setImg():
Label2 = tk.Label(Canvas1, background="#ffffff", disabledforeground="#a3a3a3", foreground="#000000")
Label2.place(relx=0.067, rely=0.283, height=181, width=233)
Label2.configure(image=admin_img)
def login(self, admin_id, admin_password):
global admin_idNO
admin_idNO = admin_id
if check_credentials(admin_id, admin_password, 1, True):
self.master.withdraw()
adminMenu(Toplevel(self.master))
else:
Error(Toplevel(self.master))
Error.setMessage(self, message_shown="Invalid Credentials!")
self.setImg()
class CustomerLogin:
def __init__(self, window=None):
self.master = window
window.geometry("743x494+338+92")
window.minsize(120, 1)
window.maxsize(1370, 749)
window.resizable(0, 0)
window.title("Customer")
window.configure(background="#00254a")
global Canvas1
Canvas1 = tk.Canvas(window, background="#ffffff", insertbackground="black", relief="ridge",
selectbackground="blue", selectforeground="white")
Canvas1.place(relx=0.108, rely=0.142, relheight=0.715, relwidth=0.798)
Label1 = tk.Label(Canvas1, background="#ffffff", disabledforeground="#a3a3a3",
font="-family {Segoe UI} -size 14 -weight bold", foreground="#00254a",
text="Customer Login")
Label1.place(relx=0.135, rely=0.142, height=41, width=154)
global Label2
Label2 = tk.Label(Canvas1, background="#ffffff", disabledforeground="#a3a3a3", foreground="#000000")
Label2.place(relx=0.067, rely=0.283, height=181, width=233)
global _img0
_img0 = tk.PhotoImage(file="./images/customer.png")
Label2.configure(image=_img0)
self.Entry1 = tk.Entry(Canvas1, background="#e2e2e2", borderwidth="2", disabledforeground="#a3a3a3",
font="TkFixedFont", foreground="#000000", highlightbackground="#b6b6b6",
highlightcolor="#004080", insertbackground="black")
self.Entry1.place(relx=0.607, rely=0.453, height=20, relwidth=0.26)
self.Entry1_1 = tk.Entry(Canvas1, show='*', background="#e2e2e2", borderwidth="2",
disabledforeground="#a3a3a3", font="TkFixedFont", foreground="#000000",
highlightbackground="#d9d9d9", highlightcolor="#004080", insertbackground="black",
selectbackground="blue", selectforeground="white")
self.Entry1_1.place(relx=0.607, rely=0.623, height=20, relwidth=0.26)
self.Label3 = tk.Label(Canvas1, background="#ffffff", disabledforeground="#a3a3a3", foreground="#000000")
self.Label3.place(relx=0.556, rely=0.453, height=21, width=34)
global _img1
_img1 = tk.PhotoImage(file="./images/user1.png")
self.Label3.configure(image=_img1)
self.Label4 = tk.Label(Canvas1)
self.Label4.place(relx=0.556, rely=0.623, height=21, width=34)
global _img2
_img2 = tk.PhotoImage(file="./images/lock1.png")
self.Label4.configure(image=_img2, background="#ffffff")
self.Label5 = tk.Label(Canvas1, background="#ffffff", disabledforeground="#a3a3a3", foreground="#000000")
self.Label5.place(relx=0.670, rely=0.142, height=71, width=74)
global _img3
_img3 = tk.PhotoImage(file="./images/bank1.png")
self.Label5.configure(image=_img3)
self.Button = tk.Button(Canvas1, text="Login", borderwidth="0", width=10, background="#00254a",
foreground="#ffffff",
font="-family {Segoe UI} -size 10 -weight bold",
command=lambda: self.login(self.Entry1.get(), self.Entry1_1.get()))
self.Button.place(relx=0.765, rely=0.755)
self.Button_back = tk.Button(Canvas1, text="Back", borderwidth="0", width=10, background="#00254a",
foreground="#ffffff",
font="-family {Segoe UI} -size 10 -weight bold",
command=self.back)
self.Button_back.place(relx=0.545, rely=0.755)
global customer_img
customer_img = tk.PhotoImage(file="./images/customer.png")
def back(self):
self.master.withdraw()
welcomeScreen(Toplevel(self.master))
@staticmethod
def setImg():
settingIMG = tk.Label(Canvas1, background="#ffffff", disabledforeground="#a3a3a3", foreground="#000000")
settingIMG.place(relx=0.067, rely=0.283, height=181, width=233)
settingIMG.configure(image=customer_img)
def login(self, customer_account_number, customer_PIN):
if check_credentials(customer_account_number, customer_PIN, 2, False):
global customer_accNO
customer_accNO = str(customer_account_number)
self.master.withdraw()
customerMenu(Toplevel(self.master))
else:
Error(Toplevel(self.master))
Error.setMessage(self, message_shown="Invalid Credentials!")
self.setImg()
class adminMenu:
def __init__(self, window=None):
self.master = window
window.geometry("743x494+329+153")
window.minsize(120, 1)
window.maxsize(1370, 749)
window.resizable(0, 0)
window.title("Admin Section")
window.configure(background="#E6E6FA")
self.Labelframe1 = tk.LabelFrame(window, relief='groove', font="-family {Segoe UI} -size 13 -weight bold",
foreground="#001c37", text="Select your option", background="#FFE4B5")
self.Labelframe1.place(relx=0.081, rely=0.081, relheight=0.415, relwidth=0.848)
self.Button1 = tk.Button(self.Labelframe1, activebackground="#ececec", activeforeground="#000000",
background="#00254a", borderwidth="0", disabledforeground="#a3a3a3",
font="-family {Segoe UI} -size 11", foreground="#fffffe",
highlightbackground="#d9d9d9", highlightcolor="black", pady="0",
text="Close bank account", command=self.closeAccount)
self.Button1.place(relx=0.667, rely=0.195, height=34, width=181, bordermode='ignore')
self.Button2 = tk.Button(self.Labelframe1, activebackground="#ececec", activeforeground="#000000",
background="#00254a", borderwidth="0", disabledforeground="#a3a3a3",
font="-family {Segoe UI} -size 11", foreground="#fffffe",
highlightbackground="#d9d9d9", highlightcolor="black", pady="0",
text="Create bank account", command=self.createCustaccount)
self.Button2.place(relx=0.04, rely=0.195, height=34, width=181, bordermode='ignore')
self.Button3 = tk.Button(self.Labelframe1, activebackground="#ececec", activeforeground="#000000",
background="#00254a", borderwidth="0", disabledforeground="#a3a3a3",
font="-family {Segoe UI} -size 11", foreground="#fffffe",
highlightbackground="#d9d9d9", highlightcolor="black", pady="0", text="Exit",
command=self.exit)
self.Button3.place(relx=0.667, rely=0.683, height=34, width=181, bordermode='ignore')
self.Button4 = tk.Button(self.Labelframe1, activebackground="#ececec", activeforeground="#000000",
background="#00254a", borderwidth="0", disabledforeground="#a3a3a3",
font="-family {Segoe UI} -size 11", foreground="#fffffe",
highlightbackground="#d9d9d9", highlightcolor="black", pady="0",
text="Create admin account", command=self.createAdmin)
self.Button4.place(relx=0.04, rely=0.439, height=34, width=181, bordermode='ignore')
self.Button5 = tk.Button(self.Labelframe1, activebackground="#ececec", activeforeground="#000000",
background="#00254a", borderwidth="0", disabledforeground="#a3a3a3",
font="-family {Segoe UI} -size 11", foreground="#fffffe",
highlightbackground="#d9d9d9", highlightcolor="black", pady="0",
text="Close admin account", command=self.deleteAdmin)
self.Button5.place(relx=0.667, rely=0.439, height=34, width=181, bordermode='ignore')
self.Button6 = tk.Button(self.Labelframe1, activebackground="#ececec", activeforeground="#000000",
background="#00254a", foreground="#fffffe", borderwidth="0",
disabledforeground="#a3a3a3", font="-family {Segoe UI} -size 11",
highlightbackground="#d9d9d9", highlightcolor="black", pady="0",
text="Check account summary", command=self.showAccountSummary)
self.Button6.place(relx=0.04, rely=0.683, height=34, width=181, bordermode='ignore')
global Frame1
Frame1 = tk.Frame(window, relief='groove', borderwidth="2", background="#98F5FF")
Frame1.place(relx=0.081, rely=0.547, relheight=0.415, relwidth=0.848)
def closeAccount(self):
CloseAccountByAdmin(Toplevel(self.master))
def createCustaccount(self):
createCustomerAccount(Toplevel(self.master))
def createAdmin(self):
createAdmin(Toplevel(self.master))
def deleteAdmin(self):
deleteAdmin(Toplevel(self.master))
def showAccountSummary(self):
checkAccountSummary(Toplevel(self.master))
def printAccountSummary(identity):
# clearing the frame
for widget in Frame1.winfo_children():
widget.destroy()
# getting output_message and displaying it in the frame
output = display_account_summary(identity, 1)
output_message = Label(Frame1, text=output, background="#fffffe")
output_message.pack(pady=20)
def printMessage_outside(output):
# clearing the frame
for widget in Frame1.winfo_children():
widget.destroy()
# getting output_message and displaying it in the frame
output_message = Label(Frame1, text=output, background="#fffffe")
output_message.pack(pady=20)
def exit(self):
self.master.withdraw()
adminLogin(Toplevel(self.master))
class CloseAccountByAdmin:
def __init__(self, window=None):
self.master = window
window.geometry("411x117+498+261")
window.minsize(120, 1)
window.maxsize(1370, 749)
window.resizable(0, 0)
window.title("Close customer account")
window.configure(background="#f2f3f4")
self.Label1 = tk.Label(window, background="#f2f3f4", disabledforeground="#a3a3a3",
text='''Enter account number:''')
self.Label1.place(relx=0.232, rely=0.220, height=20, width=120)
self.Entry1 = tk.Entry(window, background="#cae4ff", disabledforeground="#a3a3a3", font="TkFixedFont",
foreground="#000000", insertbackground="black")
self.Entry1.place(relx=0.536, rely=0.220, height=20, relwidth=0.232)
self.Button1 = tk.Button(window, activebackground="#ececec", activeforeground="#000000", borderwidth="0",
background="#004080", disabledforeground="#a3a3a3", foreground="#ffffff",
highlightbackground="#d9d9d9", highlightcolor="black", pady="0", text="Back",
command=self.back)
self.Button1.place(relx=0.230, rely=0.598, height=24, width=67)
self.Button2 = tk.Button(window, activebackground="#ececec", activeforeground="#000000", background="#004080",
borderwidth="0", disabledforeground="#a3a3a3", foreground="#ffffff",
highlightbackground="#d9d9d9", highlightcolor="black", pady="0", text="Proceed",
command=lambda: self.submit(self.Entry1.get()))
self.Button2.place(relx=0.598, rely=0.598, height=24, width=67)
def back(self):
self.master.withdraw()
def submit(self, identity):
if not is_valid(identity):
delete_customer_account(identity, 1)
else:
Error(Toplevel(self.master))
Error.setMessage(self, message_shown="Account doesn't exist!")
return
self.master.withdraw()
class createCustomerAccount:
def __init__(self, window=None):
self.master = window
window.geometry("411x403+437+152")
window.minsize(120, 1)
window.maxsize(1370, 749)
window.resizable(0, 0)
window.title("Create account")
window.configure(background="#f2f3f4")
window.configure(highlightbackground="#d9d9d9")
window.configure(highlightcolor="black")
self.Entry1 = tk.Entry(window, background="#cae4ff", disabledforeground="#a3a3a3", font="TkFixedFont",
foreground="#000000", highlightbackground="#d9d9d9", highlightcolor="black",
insertbackground="black", selectbackground="blue", selectforeground="white")
self.Entry1.place(relx=0.511, rely=0.027, height=20, relwidth=0.302)
self.Label1 = tk.Label(window, activebackground="#f9f9f9", activeforeground="black", background="#f2f3f4",
disabledforeground="#a3a3a3", foreground="#000000", highlightbackground="#d9d9d9",
highlightcolor="black", text='''Account number:''')
self.Label1.place(relx=0.219, rely=0.025, height=26, width=120)
self.Label2 = tk.Label(window, activebackground="#f9f9f9", activeforeground="black", background="#f2f3f4",
disabledforeground="#a3a3a3", foreground="#000000", highlightbackground="#d9d9d9",
highlightcolor="black", text='''Full name:''')
self.Label2.place(relx=0.316, rely=0.099, height=27, width=75)
self.Entry2 = tk.Entry(window, background="#cae4ff", disabledforeground="#a3a3a3",
font="TkFixedFont", foreground="#000000", highlightbackground="#d9d9d9",
highlightcolor="black", insertbackground="black", selectbackground="blue",
selectforeground="white")
self.Entry2.place(relx=0.511, rely=0.099, height=20, relwidth=0.302)
self.Label3 = tk.Label(window, activebackground="#f9f9f9", activeforeground="black", background="#f2f3f4",
disabledforeground="#a3a3a3", foreground="#000000", highlightbackground="#d9d9d9",
highlightcolor="black", text='''Account type:''')
self.Label3.place(relx=0.287, rely=0.169, height=26, width=83)
global acc_type
acc_type = StringVar()
self.Radiobutton1 = tk.Radiobutton(window, activebackground="#ececec", activeforeground="#000000",
background="#f2f3f4", disabledforeground="#a3a3a3", foreground="#000000",
highlightbackground="#d9d9d9", highlightcolor="black", justify='left',
text='''Savings''', variable=acc_type, value="Savings")
self.Radiobutton1.place(relx=0.511, rely=0.174, relheight=0.057, relwidth=0.151)
self.Radiobutton1_1 = tk.Radiobutton(window, activebackground="#ececec", activeforeground="#000000",
background="#f2f3f4", disabledforeground="#a3a3a3", foreground="#000000",
highlightbackground="#d9d9d9", highlightcolor="black", justify='left',
text='''Current''', variable=acc_type, value="Current")
self.Radiobutton1_1.place(relx=0.706, rely=0.174, relheight=0.057, relwidth=0.175)
self.Radiobutton1.deselect()
self.Radiobutton1_1.deselect()
self.Label5 = tk.Label(window, activebackground="#f9f9f9", activeforeground="black", background="#f2f3f4",
disabledforeground="#a3a3a3", foreground="#000000",
highlightcolor="black", text='''Mobile number:''')
self.Label5.place(relx=0.268, rely=0.323, height=22, width=85)
self.Label4 = tk.Label(window, activebackground="#f9f9f9", activeforeground="black", background="#f2f3f4",
disabledforeground="#a3a3a3", foreground="#000000",
highlightcolor="black", text='''Birth date (DD/MM/YYYY):''')
self.Label4.place(relx=0.090, rely=0.238, height=27, width=175)
self.Entry5 = tk.Entry(window, background="#cae4ff", disabledforeground="#a3a3a3", font="TkFixedFont",
foreground="#000000", highlightbackground="#d9d9d9", highlightcolor="black",
insertbackground="black", selectbackground="blue", selectforeground="white")
self.Entry5.place(relx=0.511, rely=0.323, height=20, relwidth=0.302)
self.Entry4 = tk.Entry(window, background="#cae4ff", disabledforeground="#a3a3a3", font="TkFixedFont",
foreground="#000000", highlightbackground="#d9d9d9", highlightcolor="black",
insertbackground="black", selectbackground="blue", selectforeground="white")
self.Entry4.place(relx=0.511, rely=0.248, height=20, relwidth=0.302)
self.Label6 = tk.Label(window, activebackground="#f9f9f9", activeforeground="black", background="#f2f3f4",
disabledforeground="#a3a3a3", foreground="#000000",
highlightcolor="black", text='''Gender:''')
self.Label6.place(relx=0.345, rely=0.402, height=15, width=65)
global gender
gender = StringVar()
self.Radiobutton3 = tk.Radiobutton(window, activebackground="#ececec", activeforeground="#000000",
background="#f2f3f4", disabledforeground="#a3a3a3", foreground="#000000",
highlightcolor="black", justify='left',
text='''Male''', variable=gender, value="Male")
self.Radiobutton3.place(relx=0.481, rely=0.397, relheight=0.055, relwidth=0.175)
self.Radiobutton4 = tk.Radiobutton(window, activebackground="#ececec", activeforeground="#000000",
background="#f2f3f4", disabledforeground="#a3a3a3", foreground="#000000",
highlightbackground="#d9d9d9", highlightcolor="black", justify='left',
text='''Female''', variable=gender, value="Female")
self.Radiobutton4.place(relx=0.706, rely=0.397, relheight=0.055, relwidth=0.175)
self.Radiobutton3.deselect()
self.Radiobutton4.deselect()
self.Label7 = tk.Label(window, activebackground="#f9f9f9", activeforeground="black", background="#f2f3f4",
disabledforeground="#a3a3a3", foreground="#000000", highlightbackground="#d9d9d9",
highlightcolor="black", text='''Nationality:''')
self.Label7.place(relx=0.309, rely=0.471, height=21, width=75)
self.Entry7 = tk.Entry(window, background="#cae4ff", disabledforeground="#a3a3a3",
font="TkFixedFont", foreground="#000000", highlightbackground="#d9d9d9",
highlightcolor="black", insertbackground="black", selectbackground="blue",
selectforeground="white")
self.Entry7.place(relx=0.511, rely=0.471, height=20, relwidth=0.302)
self.Entry9 = tk.Entry(window, show="*", background="#cae4ff", disabledforeground="#a3a3a3", font="TkFixedFont",
foreground="#000000", highlightbackground="#d9d9d9", highlightcolor="black",
insertbackground="black", selectbackground="blue", selectforeground="white")
self.Entry9.place(relx=0.511, rely=0.623, height=20, relwidth=0.302)
self.Entry10 = tk.Entry(window, show="*", background="#cae4ff", disabledforeground="#a3a3a3",
font="TkFixedFont",
foreground="#000000", highlightbackground="#d9d9d9", highlightcolor="black",
insertbackground="black", selectbackground="blue", selectforeground="white")
self.Entry10.place(relx=0.511, rely=0.7, height=20, relwidth=0.302)
self.Entry11 = tk.Entry(window, background="#cae4ff", disabledforeground="#a3a3a3", font="TkFixedFont",
foreground="#000000", highlightbackground="#d9d9d9", highlightcolor="black",
insertbackground="black", selectbackground="blue", selectforeground="white")
self.Entry11.place(relx=0.511, rely=0.777, height=20, relwidth=0.302)
self.Label9 = tk.Label(window, activebackground="#f9f9f9", activeforeground="black", background="#f2f3f4",
disabledforeground="#a3a3a3", foreground="#000000", highlightbackground="#d9d9d9",
highlightcolor="black", text='''PIN:''')
self.Label9.place(relx=0.399, rely=0.62, height=21, width=35)
self.Label10 = tk.Label(window, activebackground="#f9f9f9", activeforeground="black", background="#f2f3f4",
disabledforeground="#a3a3a3", foreground="#000000", highlightbackground="#d9d9d9",
highlightcolor="black", text='''Re-enter PIN:''')
self.Label10.place(relx=0.292, rely=0.695, height=21, width=75)
self.Label11 = tk.Label(window, activebackground="#f9f9f9", activeforeground="black", background="#f2f3f4",
disabledforeground="#a3a3a3", foreground="#000000", highlightbackground="#d9d9d9",
highlightcolor="black", text='''Initial balance:''')
self.Label11.place(relx=0.292, rely=0.779, height=21, width=75)
self.Button1 = tk.Button(window, activebackground="#ececec", activeforeground="#000000", background="#004080",
borderwidth="0", disabledforeground="#a3a3a3", foreground="#ffffff",
highlightbackground="#d9d9d9", highlightcolor="black", pady="0", text='''Back''',
command=self.back)
self.Button1.place(relx=0.243, rely=0.893, height=24, width=67)
self.Button2 = tk.Button(window, activebackground="#ececec", activeforeground="#000000", background="#004080",
borderwidth="0", disabledforeground="#a3a3a3", foreground="#ffffff",
highlightbackground="#d9d9d9", highlightcolor="black", pady="0", text='''Proceed''',
command=lambda: self.create_acc(self.Entry1.get(), self.Entry2.get(), acc_type.get(),
self.Entry4.get(), self.Entry5.get(), gender.get(),
self.Entry7.get(), self.Entry8.get(),
self.Entry9.get(), self.Entry10.get(),
self.Entry11.get()))
self.Button2.place(relx=0.633, rely=0.893, height=24, width=67)
self.Label8 = tk.Label(window, background="#f2f3f4", disabledforeground="#a3a3a3", foreground="#000000",
text='''KYC document name:''')
self.Label8.place(relx=0.18, rely=0.546, height=24, width=122)
self.Entry8 = tk.Entry(window, background="#cae4ff", disabledforeground="#a3a3a3", font="TkFixedFont",
foreground="#000000", insertbackground="black")
self.Entry8.place(relx=0.511, rely=0.546, height=20, relwidth=0.302)
def back(self):
self.master.withdraw()
def create_acc(self, customer_account_number, name, account_type, date_of_birth, mobile_number, gender, nationality,
KYC_document,
PIN, confirm_PIN, initial_balance):
if is_valid(customer_account_number) and customer_account_number.isnumeric():
if name != "":
if account_type == "Savings" or account_type == "Current":
if check_date(date_of_birth):
if is_valid_mobile(mobile_number):
if gender == "Male" or gender == "Female":
if nationality.__len__() != 0:
if KYC_document.__len__() != 0:
if PIN.isnumeric() and PIN.__len__() == 4:
if confirm_PIN == PIN:
if initial_balance.isnumeric():
output_message = "Customer account created successfully!"
print(output_message)
adminMenu.printMessage_outside(output_message)
else:
Error(Toplevel(self.master))
Error.setMessage(self, message_shown="Invalid balance!")
return
else:
Error(Toplevel(self.master))
Error.setMessage(self, message_shown="PIN mismatch!")
return
else:
Error(Toplevel(self.master))
Error.setMessage(self, message_shown="Invalid PIN!")
return
else:
Error(Toplevel(self.master))
Error.setMessage(self, message_shown="Enter KYC document!")
return
else:
Error(Toplevel(self.master))
Error.setMessage(self, message_shown="Enter Nationality!")
return
else:
Error(Toplevel(self.master))
Error.setMessage(self, message_shown="Select gender!")
return
else:
Error(Toplevel(self.master))
Error.setMessage(self, message_shown="Invalid mobile number!")
return
else:
Error(Toplevel(self.master))
Error.setMessage(self, message_shown="Invalid date!")
return
else:
Error(Toplevel(self.master))
Error.setMessage(self, message_shown="Select account type!")
return
else:
Error(Toplevel(self.master))
Error.setMessage(self, message_shown="Name can't be empty!")
return
else:
Error(Toplevel(self.master))
Error.setMessage(self, message_shown="Acc-number is invalid!")
return
today = date.today() # set date of account creation
date_of_account_creation = today.strftime("%d/%m/%Y")
# adding in database
data = customer_account_number + "\n" + PIN + "\n" + initial_balance + "\n" + date_of_account_creation + "\n" + name + "\n" + account_type + "\n" + date_of_birth + "\n" + mobile_number + "\n" + gender + "\n" + nationality + "\n" + KYC_document + "\n" + "*\n"
append_data("./database/Customer/customerDatabase.txt", data)
self.master.withdraw()
class createAdmin:
def __init__(self, window=None):
self.master = window
window.geometry("411x150+512+237")
window.minsize(120, 1)
window.maxsize(1370, 749)
window.resizable(0, 0)
window.title("Create admin account")
window.configure(background="#f2f3f4")
self.Label1 = tk.Label(window, background="#f2f3f4", disabledforeground="#a3a3a3", foreground="#000000",
text='''Enter admin ID:''')
self.Label1.place(relx=0.219, rely=0.067, height=27, width=104)
self.Label2 = tk.Label(window, background="#f2f3f4", disabledforeground="#a3a3a3", foreground="#000000",
text='''Enter password:''')
self.Label2.place(relx=0.219, rely=0.267, height=27, width=104)
self.Entry1 = tk.Entry(window, background="#cae4ff", disabledforeground="#a3a3a3", font="TkFixedFont",
foreground="#000000", insertbackground="black")
self.Entry1.place(relx=0.487, rely=0.087, height=20, relwidth=0.326)
self.Entry2 = tk.Entry(window, show="*", background="#cae4ff", disabledforeground="#a3a3a3", font="TkFixedFont",
foreground="#000000", insertbackground="black")
self.Entry2.place(relx=0.487, rely=0.287, height=20, relwidth=0.326)
self.Label3 = tk.Label(window, activebackground="#f9f9f9", activeforeground="black", background="#f2f3f4",
disabledforeground="#a3a3a3", foreground="#000000", highlightbackground="#d9d9d9",
highlightcolor="black", text='''Confirm password:''')
self.Label3.place(relx=0.195, rely=0.467, height=27, width=104)
self.Entry3 = tk.Entry(window, show="*", background="#cae4ff", disabledforeground="#a3a3a3", font="TkFixedFont",
foreground="#000000", insertbackground="black")
self.Entry3.place(relx=0.487, rely=0.487, height=20, relwidth=0.326)
self.Button1 = tk.Button(window, activebackground="#ececec", activeforeground="#000000", background="#004080",
borderwidth="0", disabledforeground="#a3a3a3", foreground="#ffffff",
highlightbackground="#d9d9d9", highlightcolor="black", pady="0", text="Proceed",
command=lambda: self.create_admin_account(self.Entry1.get(), self.Entry2.get(),
self.Entry3.get()))
self.Button1.place(relx=0.598, rely=0.733, height=24, width=67)
self.Button2 = tk.Button(window, activebackground="#ececec", activeforeground="#000000", background="#004080",
borderwidth="0", disabledforeground="#a3a3a3", foreground="#ffffff",
highlightbackground="#d9d9d9", highlightcolor="black", pady="0", text="Back",
command=self.back)
self.Button2.place(relx=0.230, rely=0.733, height=24, width=67)
def back(self):
self.master.withdraw()
def create_admin_account(self, identity, password, confirm_password):
if check_credentials(identity, "DO_NOT_CHECK_ADMIN", 1, False):
Error(Toplevel(self.master))
Error.setMessage(self, message_shown="ID is unavailable!")
else:
if password == confirm_password and len(password) != 0:
create_admin_account(identity, password)
self.master.withdraw()
else:
Error(Toplevel(self.master))
if password != confirm_password:
Error.setMessage(self, message_shown="Password Mismatch!")
else:
Error.setMessage(self, message_shown="Invalid password!")
class deleteAdmin:
def __init__(self, window=None):
self.master = window
window.geometry("411x117+504+268")
window.minsize(120, 1)
window.maxsize(1370, 749)
window.resizable(0, 0)
window.title("Delete admin account")
window.configure(background="#f2f3f4")
self.Entry1 = tk.Entry(window, background="#cae4ff", disabledforeground="#a3a3a3", font="TkFixedFont",
foreground="#000000", insertbackground="black")
self.Entry1.place(relx=0.487, rely=0.092, height=20, relwidth=0.277)
self.Label1 = tk.Label(window, background="#f2f3f4", disabledforeground="#a3a3a3", foreground="#000000",
text='''Enter admin ID:''')
self.Label1.place(relx=0.219, rely=0.092, height=21, width=104)
self.Label2 = tk.Label(window, background="#f2f3f4", disabledforeground="#a3a3a3", foreground="#000000",
text='''Enter password:''')
self.Label2.place(relx=0.209, rely=0.33, height=21, width=109)
self.Entry1_1 = tk.Entry(window, show="*", background="#cae4ff", disabledforeground="#a3a3a3",
font="TkFixedFont",
foreground="#000000", highlightbackground="#d9d9d9", highlightcolor="black",