-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
2045 lines (1775 loc) · 81 KB
/
main.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
from tkinter import *
from tkinter import messagebox
from datetime import *
from tkinter import ttk
# sql-connector
import mysql.connector as sql
db = sql.connect(
host="localhost",
user="root",
password="",
database="ATM"
)
if db.is_connected():
print("Successfully connected to", db.connection_id)
#global variables
minBalance=100
minAtmBalance=10000
atmNumber=0
cardNo=0
cardPin=0
acNumber=0
acBalance=0
custNumber=''
custPassword=''
adminNumber=''
adminPassword=''
def chkAcCred(cardNo, cardPin):
cursor = db.cursor()
selQuery = "select cd_no, pin, cd_exp from Card"
cursor.execute(selQuery)
flag = 0
records = cursor.fetchall()
dt = date.today()
for row in records:
if(str(row[0]) == cardNo and str(row[1]) == cardPin and row[2] > dt):
flag = 1
break
cursor.close()
return flag
def chkWithd(amount):
flag=0
if((acBalance-amount) > minBalance):
flag=1
return flag
def perfTransact(amount,ch,ch1,acNum):
if (ch == 1):
amount = amount * (-1)
#update Account
cursor = db.cursor()
upQuery = "update Account set ac_bal = ac_bal + %s where ac_no = %s;"
data = (amount, acNum, )
cursor.execute(upQuery, data)
db.commit()
cursor.close()
#update ATM
cursor = db.cursor()
upQuery = "update ATM set atm_bl = atm_bl + %s where atm_id = %s;"
data = (amount, atmNumber,)
cursor.execute(upQuery, data)
db.commit()
cursor.close()
cursor=db.cursor()
if(ch == 1 and ch1 == 1):
upQuery = "update ATM set avg_w = avg_w + 1 where atm_id = %s;"
elif(ch == 2 and ch1 == 2):
upQuery = "update ATM set avg_d = avg_d + 1 where atm_id = %s;"
elif(ch == 1 and ch1 == 3):
upQuery = "update ATM set avg_t = avg_t + 1 where atm_id = %s;"
elif (ch == 2 and ch1 == 3):
upQuery = "update ATM set avg_t = avg_t where atm_id = %s;"
data = (atmNumber,)
cursor.execute(upQuery, data)
db.commit()
cursor.close()
#add Transaction
cursor = db.cursor()
selQuery = "select tr_id from Withdraw order by tr_dt asc;"
cursor.execute(selQuery)
records = cursor.fetchall()
for row in records:
Tid = row[0]
cursor.close()
partid1 = int(Tid[5:])
cursor=db.cursor()
selQuery = "select tr_id from Deposit order by tr_dt asc;"
cursor.execute(selQuery)
records = cursor.fetchall()
for row in records:
Tid=row[0]
cursor.close()
partid2 = int(Tid[5:])
partid=max(partid1,partid2)
if(ch==1 and ch1 == 1):
Tid='TWSNT'+str(partid+1)
elif(ch==2 and ch1 == 2):
Tid='TDSNT'+str(partid+1)
elif(ch==1 and ch1 == 3):
Tid='TTSNT'+str(partid+1)
elif (ch == 2 and ch1 == 3):
Tid='TTSNT'+str(partid)
now = datetime.now()
dt_str = now.strftime("%Y-%m-%d %H:%M:%S")
cursor=db.cursor()
if(ch==1):
inQuery = "insert into Withdraw values(%s,%s,%s,%s,%s,%s);"
elif(ch==2):
inQuery = "insert into Deposit values(%s,%s,%s,%s,%s,%s);"
data=(Tid,ch,dt_str,amount,atmNumber,acNum,)
cursor.execute(inQuery, data)
db.commit()
cursor.close()
return Tid
def chkCCred(custNum, custPass):
cursor = db.cursor()
selQuery = "select cust_id, cust_pw from Customer"
cursor.execute(selQuery)
flag = 0
records = cursor.fetchall()
for row in records:
if (row[0] == custNum and row[1] == custPass):
flag = 1
break
cursor.close()
return flag
def chkAdCred(adminNum, adminPass):
cursor = db.cursor()
selQuery = "select ad_id, ad_pw from Admin"
cursor.execute(selQuery)
flag = 0
records = cursor.fetchall()
for row in records:
if (row[0] == adminNum and row[1] == adminPass):
flag = 1
break
cursor.close()
return flag
def chkAtCred(atmNum):
cursor = db.cursor()
selQuery = "select atm_id from ATM"
cursor.execute(selQuery)
flag = 0
records = cursor.fetchall()
for row in records:
if (row[0] == atmNum):
flag = 1
break
cursor.close()
return flag
def isRecycler(atmNum):
cursor = db.cursor()
selQuery = "select atm_tp from ATM where atm_id=%s"
data=(atmNum,)
cursor.execute(selQuery,data)
flag = 0
records = cursor.fetchone()
if (records[0] == 'Recycler'):
flag = 1
cursor.close()
return flag
def RflIsValid(atmNum, amt):
cursor = db.cursor()
selQuery = "select br_bal from ATM inner join Branch on Branch.ifsc=ATM.ifsc where atm_id=%s;"
data = (atmNum,)
cursor.execute(selQuery, data)
flag = 0
records = cursor.fetchone()
if (records[0]-amt > minAtmBalance):
flag = 1
cursor.close()
return flag
def perfRefill(atmNum, amt):
#get ifsc
cursor = db.cursor()
selQuery = "select ifsc from ATM where atm_id=%s;"
data = (atmNumber,)
cursor.execute(selQuery,data)
records=cursor.fetchone()
ifsctemp=records[0]
cursor.close()
#update ATM
cursor = db.cursor()
upQuery = "update ATM set atm_bl = atm_bl + %s where atm_id = %s;"
data = (amt, atmNum,)
cursor.execute(upQuery, data)
db.commit()
cursor.close()
#update Branch
cursor = db.cursor()
upQuery = "update Branch set br_bal = br_bal - %s where ifsc = %s;"
data = (amt, ifsctemp,)
cursor.execute(upQuery, data)
db.commit()
cursor.close()
#add refill entry
now=datetime.now()
dt_str=now.strftime("%Y-%m-%d %H:%M:%S")
cursor = db.cursor()
inQuery = "insert into refill values(%s,%s,%s,%s);"
data = (ifsctemp, atmNumber, dt_str, amt)
cursor.execute(inQuery, data)
db.commit()
cursor.close()
def secIsValid(atmNum,dt):
cursor = db.cursor()
selQuery = "select atm_id,s_dt from Security"
cursor.execute(selQuery)
flag = 0
records = cursor.fetchall()
for row in records:
# print(type(row[1]))
if (row[0] == atmNum and str(row[1]) == dt):
flag = 1
break
cursor.close()
return flag
def perfSec(atmNum,resolution):
cursor = db.cursor()
upQuery = "update Security set res = %s where atm_id = %s;"
data = (resolution, atmNum,)
cursor.execute(upQuery, data)
db.commit()
cursor.close()
def compIsValid(compNum):
cursor = db.cursor()
selQuery = "select cl_id from Complaint"
cursor.execute(selQuery)
flag = 0
records = cursor.fetchall()
for row in records:
if (row[0] == compNum):
flag = 1
break
cursor.close()
return flag
def perfComp(compNum,status):
cursor = db.cursor()
upQuery = "update Complaint set cl_stat = %s where cl_id = %s;"
data = (status,compNum,)
cursor.execute(upQuery, data)
db.commit()
cursor.close()
def vendIsValid(compName,compReview):
flag=1
if(compName=='' or compReview==''):
flag=0
return flag
if(int(compReview)<1 or int(compReview)>10):
flag=0
return flag
cursor = db.cursor()
selQuery = "select comp from Vendor"
cursor.execute(selQuery)
records = cursor.fetchall()
for row in records:
if (row[0] == compName):
flag = 0
break
cursor.close()
return flag
def perfVend(compName,compReview):
cursor = db.cursor()
inQuery = "insert into Vendor values(%s,%s,0);"
data = (compName, compReview,)
cursor.execute(inQuery, data)
db.commit()
cursor.close()
cursor = db.cursor()
inQuery = "insert into sign values(%s,%s);"
data = (adminNumber,compName,)
cursor.execute(inQuery, data)
db.commit()
cursor.close()
def perfBlock(cardNo):
cursor = db.cursor()
upQuery = "update Card set cd_exp = '2000-01-01' where cd_no=%s;"
data=(cardNo,)
cursor.execute(upQuery,data)
db.commit()
cursor.close()
def perfCompC(atmNum,descrip):
cursor = db.cursor()
selQuery = "select cl_id from Complaint order by cl_id asc;"
cursor.execute(selQuery)
records = cursor.fetchall()
for row in records:
Clid = row[0]
cursor.close()
partid = int(Clid[5:])
Clid = 'CLSNT' + str(partid + 1)
cursor = db.cursor()
inQuery = "insert into Complaint values(%s,%s,%s,%s,%s);"
data = (Clid, descrip, '', custNumber, atmNum)
cursor.execute(inQuery, data)
db.commit()
cursor.close()
return Clid
def atmChkIsValid(ifscNumber, amount):
cursor = db.cursor()
selQuery = "select ifsc from Branch"
cursor.execute(selQuery)
flag = 0
records = cursor.fetchall()
for row in records:
if (row[0] == ifscNumber and amount <=10000):
flag = 1
break
cursor.close()
return flag
def cntIsValid(atmNum,company):
flag1 = flag2 = flag3 = 0
cursor = db.cursor()
selQuery = "select atm_id from ATM"
cursor.execute(selQuery)
records = cursor.fetchall()
for row in records:
if (row[0] == atmNum):
flag1 = 1
break
cursor.close()
cursor = db.cursor()
selQuery = "select comp from Vendor"
cursor.execute(selQuery)
records = cursor.fetchall()
for row in records:
if (row[0] == company):
flag2 = 1
break
cursor.close()
if(flag1==1):
cursor = db.cursor()
selQuery = "select ct_yr, warr from Contract where atm_id=%s order by ct_yr desc;"
data=(atmNum,)
cursor.execute(selQuery, data)
records = cursor.fetchone()
yeartemp=records[0]
warrtemp=records[1]
yr= datetime.now().year
if (int(yeartemp)+int(warrtemp) < int(yr)):
flag3 = 1
cursor.close()
flag=flag1*flag2*flag3
return flag
def perfCnt(atmNum, company, amctemp, warrtemp):
#update Vendor table
cursor = db.cursor()
upQuery = "update Vendor set no_ct = no_ct + 1 where comp=%s;"
data = (company,)
cursor.execute(upQuery, data)
db.commit()
cursor.close()
#add Contract table
cursor = db.cursor()
selQuery = "select ct_id from Contract order by ct_id asc;"
cursor.execute(selQuery)
records = cursor.fetchall()
for row in records:
Cntid = row[0]
cursor.close()
partid = int(Cntid[5:])
Cntid = 'CTSNT' + str(partid + 1)
yr = datetime.now().year
cursor = db.cursor()
inQuery = "insert into Contract values(%s,%s,%s,%s,%s,%s);"
data = (Cntid, yr, amctemp, warrtemp, atmNum, company,)
cursor.execute(inQuery, data)
db.commit()
cursor.close()
return Cntid
# sql-connector
root = Tk()
root.title("Sanatan Bank")
root.wm_iconbitmap("SB_icon1.ico")
root.geometry("700x420")
def openATM():
try:
global atmNumber
atmNumber = AtmNo.get()
CredF = chkAtCred(atmNumber)
if (CredF != 1):
messagebox.showwarning("Error", "This ATM does not exist!")
return
except Exception:
pass
try:
root.destroy()
except Exception:
pass
AtmRt = Tk()
AtmRt.title("Sanatan Bank / ATM")
AtmRt.wm_iconbitmap("SB_icon1.ico")
AtmRt.geometry("700x420")
def openCAc():
try:
global cardNo, cardPin
cardNo = CdNo.get()
cardPin = pin.get()
CredF = chkAcCred(cardNo,cardPin)
if(CredF!=1):
messagebox.showwarning("Error", "Card is invalid!")
return
except Exception:
pass
try:
AtmRt.destroy()
except Exception:
pass
CAcW = Tk()
CAcW.title("Sanatan Bank / ATM / Account")
CAcW.wm_iconbitmap("SB_icon1.ico")
CAcW.geometry("700x420")
cursor = db.cursor() #sql
selQuery = "select ac_bal,Account.ac_no from Account inner join Card on Card.ac_no=Account.ac_no where cd_no = %s"
data = (cardNo,)
cursor.execute(selQuery, data)
record = cursor.fetchone()
global acBalance, acNumber
acBalance = record[0]
acNumber = record[1]
cursor.close()
def openWithdW():
try:
CAcW.destroy()
except Exception:
pass
WithdW = Tk()
WithdW.title("Sanatan Bank / ATM / Account / Withdraw")
WithdW.wm_iconbitmap("SB_icon1.ico")
WithdW.geometry("700x420")
def exeWithd():
WithdStat=chkWithd(int(WithdAmtT.get())) #sql
if(WithdStat==1):
messagebox.showinfo("Withdraw Status", "Withdraw successful!\nTransaction ID: "+perfTransact(int(WithdAmtT.get()),1,1,acNumber))
WithdW.destroy()
openCAc()
else:
messagebox.showerror("Withdraw Status", "Withdraw failed!")
SpcLabel1 = Label(WithdW, text=SpcText)
SpcLabel2 = Label(WithdW, text=SpcText)
SpcLabel3 = Label(WithdW, text=SpcText)
WithdLbl = Label(WithdW, text="Withdraw", fg="green")
WithdLbl.config(font=("Magneto Bold", 36))
WithdAmtT = Entry(WithdW, width="32", bg="green", fg="white")
WithdAmtT.insert(1, "Amount")
ConfWithdB = Button(WithdW, text="Confirm", padx=26, command=exeWithd)
SpcLabel1.grid(row=0, column=0)
WithdLbl.grid(row=1, column=1, padx=120, pady=75)
WithdAmtT.grid(row=2, column=1, pady=10)
ConfWithdB.grid(row=3, column=1, pady=10)
def openDeposW():
try:
CAcW.destroy()
except Exception:
pass
DeposW = Tk()
DeposW.title("Sanatan Bank / ATM / Account / Deposit")
DeposW.wm_iconbitmap("SB_icon1.ico")
DeposW.geometry("700x420")
def exeDepos():
DeposStat = 0
if(int(DeposAmtT.get()) >= minBalance): #sql
DeposStat=1
if(DeposStat==1):
messagebox.showinfo("Deposit Status", "Deposit successful!\nTransaction ID: "+perfTransact(int(DeposAmtT.get()),2,2,acNumber))
else:
messagebox.showerror("Deposit Status", "Deposit failed!")
DeposW.destroy()
openCAc()
SpcLabel1 = Label(DeposW, text=SpcText)
SpcLabel2 = Label(DeposW, text=SpcText)
SpcLabel3 = Label(DeposW, text=SpcText)
DeposLbl = Label(DeposW, text="Deposit", fg="green")
DeposLbl.config(font=("Magneto Bold", 36))
DeposAmtT = Entry(DeposW, width="32", bg="green", fg="white")
DeposAmtT.insert(1, "Amount")
ConfDeposB = Button(DeposW, text="Confirm", padx=26, command=exeDepos)
SpcLabel1.grid(row=0, column=0)
DeposLbl.grid(row=1, column=1, padx=120, pady=75)
DeposAmtT.grid(row=2, column=1, pady=10)
ConfDeposB.grid(row=3, column=1, pady=10)
def openTrnsfW():
try:
CAcW.destroy()
except Exception:
pass
TrnsfW = Tk()
TrnsfW.title("Sanatan Bank / ATM / Account / Transfer")
TrnsfW.wm_iconbitmap("SB_icon1.ico")
TrnsfW.geometry("700x420")
def exeTrnsf():
tgtAcNo=TrnsfAccT.get()
amttemp=TrnsfAmtT.get()
TrnsfStat = chkWithd(int(TrnsfAmtT.get()))
if(TrnsfStat==1):
temp1=perfTransact(int(amttemp),1,3,acNumber)
temp2=perfTransact(int(amttemp),2,3,tgtAcNo)
messagebox.showinfo("Transfer Status","Transfer successful!\nTransaction ID: "+temp1)
else:
messagebox.showerror("Transfer Status","Transfer failed!")
TrnsfW.destroy()
openCAc()
SpcLabel1 = Label(TrnsfW, text=SpcText)
SpcLabel2 = Label(TrnsfW, text=SpcText)
SpcLabel3 = Label(TrnsfW, text=SpcText)
TrnsfLbl = Label(TrnsfW, text="Transfer", fg="green")
TrnsfLbl.config(font=("Magneto Bold", 36))
TrnsfAccT = Entry(TrnsfW, width="32", bg="green", fg="white")
TrnsfAccT.insert(1, "Recipient's account no.")
TrnsfAmtT = Entry(TrnsfW, width="32", bg="green", fg="white")
TrnsfAmtT.insert(1, "Amount")
ConfTrnsfB = Button(TrnsfW, text="Confirm", padx=26, command=exeTrnsf)
SpcLabel1.grid(row=0, column=0)
TrnsfLbl.grid(row=1, column=1, padx=120, pady=75)
TrnsfAccT.grid(row=2, column=1, pady=10)
TrnsfAmtT.grid(row=3, column=1, pady=10)
ConfTrnsfB.grid(row=4, column=1, pady=10)
def doLogout():
try:
CAcW.destroy()
except Exception:
pass
try:
openATM()
except Exception:
pass
SpcLabel1 = Label(CAcW, text=SpcText)
SpcLabel2 = Label(CAcW, text=SpcText)
SpcLabel3 = Label(CAcW, text=SpcText)
BalLbl = Label(CAcW, text="Balance:\t" + str(acBalance), fg="green") #sql
BalLbl.config(font=("Cambria", 20, "bold"))
WithdB = Button(CAcW, text="Withdraw", padx=26, command=openWithdW)
DeposB = Button(CAcW, text="Deposit", padx=31, command=openDeposW)
TrnsfB = Button(CAcW, text="Transfer", padx=31, command=openTrnsfW)
LgoutB = Button(CAcW, text="Logout", padx=20, command=doLogout)
LgoutB.grid(row=0, column=2, padx=20, pady=10)
SpcLabel2.grid(row=1, column=0)
BalLbl.grid(row=1, column=1, padx=32, pady=75)
SpcLabel1.grid(row=2, column=0)
WithdB.grid(row=2, column=1, padx=180, pady=5)
isRecyclerF = isRecycler(atmNumber) #sql
if(isRecyclerF == 1):
DeposB.grid(row=3, column=1, pady=5)
TrnsfB.grid(row=4, column=1, pady=5)
ATMlbl1 = Label(AtmRt, text="Login to ATM", fg="green")
ATMlbl1.config(font=("Magneto Bold", 36))
CdNo = Entry(AtmRt, width="32", bg="green", fg="white")
CdNo.insert(0, "Card no.")
pin = Entry(AtmRt, width="32", bg="green", fg="white")
pin.insert(0, "ATM pin")
ATMloginB = Button(AtmRt, text="Login", padx=20, command=openCAc)
SpcLabel1 = Label(AtmRt, text=SpcText)
SpcLabel2 = Label(AtmRt, text=SpcText)
SpcLabel3 = Label(AtmRt, text=SpcText)
SpcLabel2.grid(row=1, column=0)
ATMlbl1.grid(row=1, column=1, padx=32, pady=75)
SpcLabel1.grid(row=2, column=0)
CdNo.grid(row=2, column=1, pady=10)
#SpcLabel2.grid(row=3, column=0)
pin.grid(row=3, column=1, pady=10)
ATMloginB.grid(row=4, column=1, pady=10)
def openAdmin():
try:
root.destroy()
except Exception:
pass
AdLginW = Tk()
AdLginW.title("Sanatan Bank / Admin login")
AdLginW.wm_iconbitmap("SB_icon1.ico")
AdLginW.geometry("700x420")
def openAdRt():
try:
global adminNumber, adminPassword
adminNumber=AdId.get()
adminPassword=Adpw.get()
CredF=chkAdCred(adminNumber,adminPassword)
if(CredF!=1):
messagebox.showwarning("Error","Invalid credentials!")
return
except Exception:
pass
try:
AdLginW.destroy()
except Exception:
pass
AdRtW = Tk()
AdRtW.title("Sanatan Bank / Admin login / Dashboard")
AdRtW.wm_iconbitmap("SB_icon1.ico")
AdRtW.geometry("700x420")
def doLogout():
try:
AdRtW.destroy()
except Exception:
pass
try:
openAdmin()
except Exception:
pass
def openRfl():
try:
AdRtW.destroy()
except Exception:
pass
AdRfW = Tk()
AdRfW.title("Sanatan Bank / Admin login / Dashboard / Refill")
AdRfW.wm_iconbitmap("SB_icon1.ico")
AdRfW.geometry("700x420")
def doBack():
try:
AdRfW.destroy()
except Exception:
pass
try:
openAdRt()
except Exception:
pass
def doRfl():
global atmNumber
atmNumber=Rfl_AtT.get()
amt=int(Rfl_AmT.get())
RflIsValidF = RflIsValid(atmNumber, amt)
if (RflIsValidF!=1):
messagebox.showerror("ATM Refiller", "Refill failed!")
return
perfRefill(atmNumber, amt)
messagebox.showinfo("ATM Refiller", "Refill Successful!")
doBack()
def showBalLst():
BalLstW = Tk()
BalLstW.title("Sanatan Bank - ATM Balance List")
BalLstW.wm_iconbitmap("SB_icon1.ico")
BalChart = ttk.Treeview(BalLstW)
BalChart['columns'] = ("c1", "c2", "c3")
BalChart.column("#0", width=0, stretch=NO)
BalChart.column("c1", anchor=W, width=100)
BalChart.column("c2", anchor=E, width=100)
BalChart.column("c3", anchor=W, width=100)
BalChart.heading("#0", text="", anchor=W)
BalChart.heading("c1", text="ATM ID", anchor=CENTER)
BalChart.heading("c2", text="Balance", anchor=CENTER)
BalChart.heading("c3", text="Address", anchor=CENTER)
cursor = db.cursor()
selQuery = "select atm_id, atm_bl, atm_adr from ATM order by atm_bl asc;"
cursor.execute(selQuery)
records = cursor.fetchall()
cursor.close()
for rowNum in records:
BalChart.insert(parent='', index='end', iid=rowNum, text="",
values=(rowNum[0], str(rowNum[1]), rowNum[2]))
BalChart.grid(row=4, columnspan=4, sticky='nsew')
# ACk_frm = LabelFrame(AtmCkW, "Check cash availability at ATM", padx=16, pady=16)
Rfl_backB = Button(AdRfW, text="←Back", padx=5, pady=5, command=doBack)
Rfl_Lbl = Label(AdRfW, text="Refill", fg="green")
Rfl_Lbl.config(font=("Magneto Bold", 36))
Rfl_AtT = Entry(AdRfW, width="32", bg="green", fg="white")
Rfl_AtT.insert(0, "Enter ATM no.")
Rfl_AmT = Entry(AdRfW, width="32", bg="green", fg="white")
Rfl_AmT.insert(0, "Enter refill amount")
RflDoB = Button(AdRfW, text="Refill", padx=16, command=doRfl)
BalLstB = Button(AdRfW, text="View ATM balances", padx=16, command=showBalLst)
# ACk_frm.grid(row=2, column=0, rowspan=4, padx=20, pady=30)
Rfl_backB.grid(row=0, column=0, sticky=W, padx=60, pady=5)
Rfl_Lbl.grid(row=1, column=0, columnspan=3, padx=60, pady=20)
Rfl_AtT.grid(row=2, column=0, padx=60, pady=0)
Rfl_AmT.grid(row=2, column=1, padx=0, pady=0)
RflDoB.grid(row=2, column=2, padx=60, pady=20)
BalLstB.grid(row=3, column=0, columnspan=3, padx=60, pady=20)
def openVnd():
try:
AdRtW.destroy()
except Exception:
pass
AVndW = Tk()
AVndW.title("Sanatan Bank / Admin login / Dashboard / Vendors")
AVndW.wm_iconbitmap("SB_icon1.ico")
AVndW.geometry("700x420")
def doBack():
try:
AVndW.destroy()
except Exception:
pass
try:
openAdRt()
except Exception:
pass
def openNewVnd():
try:
AVndW.destroy()
except Exception:
pass
NewVndW = Tk()
NewVndW.title("Sanatan Bank / Admin login / Dashboard / Vendors / New Vendor")
NewVndW.wm_iconbitmap("SB_icon1.ico")
NewVndW.geometry("700x420")
def doBack():
try:
NewVndW.destroy()
except Exception:
pass
try:
openVnd()
except Exception:
pass
def addVnd():
compName=NwVndCmT.get()
compReview=NwVndRvT.get()
CredF = vendIsValid(compName,compReview)
if (CredF != 1):
messagebox.showerror("New Vendor", "Addition failed!")
return
perfVend(compName,int(compReview))
messagebox.showinfo("New Vendor", "New vendor successfully added!")
doBack()
SpcLabel1 = Label(NewVndW, text=SpcText)
SpcLabel2 = Label(NewVndW, text=SpcText)
SpcLabel3 = Label(NewVndW, text=SpcText)
BackB = Button(NewVndW, text="←Back", padx=5, pady=5, command=doBack)
NwVndLbl = Label(NewVndW, text="Vendor Details", fg="green")
NwVndLbl.config(font=("Magneto Bold", 24))
# C_DtlFrm = LabelFrame(CdtlW, text="*-*-*-*-*", padx=10, pady=10)
NwVndCmL = Label(NewVndW, text="Company name: ")
NwVndRvL = Label(NewVndW, text="Review: ")
NwVndCmT = Entry(NewVndW, width="32", bg="green", fg="white")
# NwVndCmT.insert(0, "YYYY")
NwVndRvT = Entry(NewVndW, width="32", bg="green", fg="white")
NwVndRvT.insert(0, "0 to 10")
NwVndOkB = Button(NewVndW, text="Add", padx=16, command=addVnd)
# .grid(row=9, column=1, rowspan=2, sticky=E, pady=30)
# SpcLabel1.grid(row=1, column=1, rowspan=2, pady=50)
BackB.grid(row=0, column=0, padx=10, pady=10)
NwVndLbl.grid(row=1, column=1, columnspan=2, padx=145, pady=50)
NwVndCmL.grid(row=4, column=1, sticky=E)
NwVndRvL.grid(row=6, column=1, sticky=E)
NwVndCmT.grid(row=4, column=2, sticky=W)
NwVndRvT.grid(row=6, column=2, sticky=W)
NwVndOkB.grid(row=10, column=1, columnspan=2, pady=32)
def showVndLst():
VndLstW = Tk()
VndLstW.title("Sanatan Bank - Vendors List")
VndLstW.wm_iconbitmap("SB_icon1.ico")
VndChart = ttk.Treeview(VndLstW)
VndChart['columns'] = ("c1", "c2", "c3")
VndChart.column("#0", width=0, stretch=NO)
VndChart.column("c1", anchor=W, width=100)
VndChart.column("c2", anchor=E, width=100)
VndChart.column("c3", anchor=E, width=100)
VndChart.heading("#0", text="", anchor=W)
VndChart.heading("c1", text="Company", anchor=CENTER)
VndChart.heading("c2", text="Review score", anchor=CENTER)
VndChart.heading("c3", text="No. of contracts", anchor=CENTER)
cursor=db.cursor()
selQuery="select comp, rvw, no_ct from Vendor order by comp asc;"
cursor.execute(selQuery)
records = cursor.fetchall()
cursor.close()
for rowNum in records:
VndChart.insert(parent='', index='end', iid=rowNum, text="",
values=(rowNum[0], str(rowNum[1]), str(rowNum[2]))) # change
VndChart.grid(row=4, columnspan=4, sticky='nsew')
# ACk_frm = LabelFrame(AtmCkW, "Check cash availability at ATM", padx=16, pady=16)
Cnt_backB = Button(AVndW, text="←Back", padx=5, pady=5, command=doBack)
CntLbl = Label(AVndW, text="Vendors", fg="green")
CntLbl.config(font=("Magneto Bold", 36))
# Cnt_AtT = Entry(ACntW, width="32", bg="green", fg="white")
# Cnt_AtT.insert(0, "Enter ATM no.")
# Cnt_VdT = Entry(ACntW, width="32", bg="green", fg="white")
# Cnt_VdT.insert(0, "Enter vendor name")
CntAddB = Button(AVndW, text="New Vendor", padx=27, command=openNewVnd)
VndLstB = Button(AVndW, text="View Vendor List", padx=16, command=showVndLst)
# ACk_frm.grid(row=2, column=0, rowspan=4, padx=20, pady=30)
Cnt_backB.grid(row=0, column=0, sticky=W, padx=32, pady=5)
CntLbl.grid(row=1, column=0, columnspan=3, padx=250, pady=40)
# Cnt_AtT.grid(row=2, column=0, padx=60, pady=0)
# Cnt_VdT.grid(row=2, column=1, padx=0, pady=0)
CntAddB.grid(row=2, column=0, columnspan=3, padx=32, pady=8)
VndLstB.grid(row=3, column=0, columnspan=3, padx=32, pady=8)
def openACnt():
try:
AdRtW.destroy()
except Exception:
pass
ACntW = Tk()
ACntW.title("Sanatan Bank / Admin login / Dashboard / Contracts")
ACntW.wm_iconbitmap("SB_icon1.ico")
ACntW.geometry("700x420")
def doBack():
try:
ACntW.destroy()
except Exception:
pass
try:
openAdRt()
except Exception:
pass
def openNewCnt():
try:
ACntW.destroy()
except Exception:
pass
NewCntW = Tk()
NewCntW.title("Sanatan Bank / Admin login / Dashboard / Contracts / New Contract")
NewCntW.wm_iconbitmap("SB_icon1.ico")
NewCntW.geometry("700x420")
def doBack():
try:
NewCntW.destroy()
except Exception:
pass
try:
openACnt()
except Exception:
pass
def addNewCnt():
atmNum=NwCntAtT.get()
company=NwCntCoT.get()
CredF = cntIsValid(atmNum,company)
if (CredF != 1):
messagebox.showerror("New Contract", "Assignment failed!")
return
amctemp=NwCntAmcT.get()
warrtemp=NwCntWarT.get()
messagebox.showinfo("New Contract", "New contract successfully assigned!\nContract ID: "+perfCnt(atmNum, company, amctemp, warrtemp))
doBack()
SpcLabel1 = Label(NewCntW, text=SpcText)
SpcLabel2 = Label(NewCntW, text=SpcText)
SpcLabel3 = Label(NewCntW, text=SpcText)
BackB = Button(NewCntW, text="←Back", padx=5, pady=5, command=doBack)
NwCntLbl = Label(NewCntW, text="Contract Details", fg="green")
NwCntLbl.config(font=("Magneto Bold", 24))
#C_DtlFrm = LabelFrame(CdtlW, text="*-*-*-*-*", padx=10, pady=10)
#NwCntIdL = Label(NewCntW, text="Contract ID: ")
NwCntAtL = Label(NewCntW, text="Atm ID: ")
NwCntCoL = Label(NewCntW, text="Company: ")
NwCntAmcL = Label(NewCntW, text="AMC: ")
NwCntWarL = Label(NewCntW, text="Warranty: ")
#NwCntYrL = Label(NewCntW, text="Contract year: ")
#NwCntIdT = Entry(NewCntW, width="32", bg="green", fg="white")
NwCntAtT = Entry(NewCntW, width="32", bg="green", fg="white")
NwCntCoT = Entry(NewCntW, width="32", bg="green", fg="white")
NwCntAmcT = Entry(NewCntW, width="32", bg="green", fg="white")
NwCntWarT = Entry(NewCntW, width="32", bg="green", fg="white")
NwCntWarT.insert(0, "No. of years")
#NwCntYrT = Entry(NewCntW, width="32", bg="green", fg="white")
#NwCntYrT.insert(0, "YYYY")
NwCntOkB = Button(NewCntW, text="Assign", padx=16, command=addNewCnt)
#.grid(row=9, column=1, rowspan=2, sticky=E, pady=30)
#SpcLabel1.grid(row=1, column=1, rowspan=2, pady=50)
BackB.grid(row=0, column=0, padx=10, pady=10)
NwCntLbl.grid(row=1, column=1, columnspan=2, padx=135, pady=36)
#NwCntIdL.grid(row=2, column=1, sticky=E)
NwCntAtL.grid(row=3, column=1, sticky=E)
NwCntCoL.grid(row=4, column=1, sticky=E)
NwCntAmcL.grid(row=5, column=1, sticky=E)
NwCntWarL.grid(row=6, column=1, sticky=E)
#NwCntYrL.grid(row=7, column=1, sticky=E)
#NwCntIdT.grid(row=2, column=2, sticky=W)
NwCntAtT.grid(row=3, column=2, sticky=W)
NwCntCoT.grid(row=4, column=2, sticky=W)
NwCntAmcT.grid(row=5, column=2, sticky=W)
NwCntWarT.grid(row=6, column=2, sticky=W)
#NwCntYrT.grid(row=7, column=2, sticky=W)
NwCntOkB.grid(row=10, column=1, columnspan=2, pady=32)
def showCntrLst():
CntrLstW = Tk()
CntrLstW.title("Sanatan Bank - Contracts List")
CntrLstW.wm_iconbitmap("SB_icon1.ico")
VndChart = ttk.Treeview(CntrLstW)
VndChart['columns'] = ("c1", "c2", "c3", "c4", "c5")
VndChart.column("#0", width=0, stretch=NO)
VndChart.column("c1", anchor=W, width=100)
VndChart.column("c2", anchor=W, width=100)
VndChart.column("c3", anchor=CENTER, width=100)
VndChart.column("c4", anchor=E, width=100)
VndChart.column("c5", anchor=E, width=120)
VndChart.heading("#0", text="", anchor=W)
VndChart.heading("c1", text="Contract ID", anchor=CENTER)
VndChart.heading("c2", text="ATM ID", anchor=CENTER)
VndChart.heading("c3", text="Signing year", anchor=CENTER)
VndChart.heading("c4", text="Years of warranty", anchor=CENTER)
VndChart.heading("c5", text="AMC amount", anchor=CENTER)
cursor = db.cursor()
selQuery = "select ct_id, atm_id, ct_yr, warr, amc from Contract order by ct_yr desc;"
cursor.execute(selQuery)
records = cursor.fetchall()
cursor.close()