-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbank[1].py
More file actions
318 lines (271 loc) · 9.01 KB
/
bank[1].py
File metadata and controls
318 lines (271 loc) · 9.01 KB
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
import random
# this function is for checking your pin number
def check():
global a19
a19 = input('ENTER YOUR PIN NUMBER')
con.execute('select PIN from bank')
a22=tuple(con.fetchall())
# this is the loop
for a20 in a22:
if a19 in a20:
con.execute("select NAME ,ACCOUNT_NO from bank where PIN='%s'"%(a19,))
a21= con.fetchall()
for i in a21:
print('YOUR NAME & ACCOUNT NO. ',i)
print(' *******************a.CASH DEPOSITE***************************')
print(' ********************b.BALANCE CHECKING*************************')
print(' ********************c.TRANSFER MONEY****************')
print(' ********************d.CASH WITHDRAWL***************************')
print(' ********************e.DELETE ACCOUNT***********-****************')
print(" ********************f.FOR CANCELLING THE TRANSACTION")
choice=input('ENTER YOUR CHOICE')
a=choice.lower()
if a=='a':
a14=input('DO YOU WANT TO DEPOSITE YOUR CASH Y/N :-')
a14=a14.lower()
if a14=="y":
cashd()
else:
check()
elif a=="b":
a15=input('DO YOU WANT TO CHECK YOUR BALANCE Y/N :-')
a15=a15.lower()
if a15=="y":
checkb()
else:
check()
elif a=="c":
a16=input('DO YOU WANT TO TRANSFER YOUR CASH TO ANOTHER ACCOUNT Y/N :-')
a16=a16.lower()
if a16=="y":
trans()
else:
check()
elif a=="d":
a16b=input('DO YOU WANT TO WITHDRAWL YOUR CASH Y/N :-')
a16b=a16b.lower()
if a16b=="y":
cashw()
else:
check()
elif a=='e':
df=input('DO YOU WANT TO DELETE YOUR ACCOUNT')
df=df.lower()
if df=='y':
dele()
else:
check()
elif a=='f':
a16a=input('DO YOU WANT TO CANCEL TRANSACTION Y/N :-')
a16a=a16a.lower()
if a16a=="y":
bank()
else:
check()
else:
check()
else:
print(' YOUR PIN NUMBER IS WORNG PLEASE ENTER CORRECT PIN NUMBER')
# calling the function check for the pin number which is given by the user
check()
# defining the function checkb for
def checkb():
q="select BALANCE from bank where PIN='%s'"%(a19,)
con.execute(q)
wq=con.fetchall()
for iq in wq:
print('**********YOUR BALANCE IS************',iq)
bank()
# this function delete is for deleting the bank account
def dele():
con.execute("delete from bank where PIN='%s'"%(a19))
db.commit()
print('*******************YOUR ACCOIUNT HAS BEEN DELETED IN THIS BANK***************')
# calling the function bank
bank()
# defining the fuction for withdrawing cash
def cashw():
a18=int(input('HOW MUCH MONEY DO YOU WANT TO WITHDRAWL MONEY :-'))
con.execute("select BALANCE from bank where PIN='%s' "%(a19,))
b7=con.fetchall()
# this loop condition
for i7 in b7:
for w7 in i7:
wcb=w7-a18
print('*****YOUR INTIAL AMOUNT IS',i7,'********')
print('*****YOUR WITHDRAWLAMOUNT IS',a18,'*******')
print('*****YOUR FINAL AMOUNT IS', wcb,'*********')
que="update bank set BALANCE=%s where PIN = '%s' "%(wcb,a19)
con.execute(que)
db.commit()
bank()
# this function is for transaction of cash from one account to the other account
def trans():
a18p=int(input('HOW MUCH MONEY DO YOU WANT TO WITHDRAWL MONEY :-'))
a19s=input('ENTER THE PIN NUMBER OF THE ACCOUNT WHERE YOU WANT TO TRANSFER YOUR MONEY')
con.execute('select PIN from bank')
q2=con.fetchall()
for abc in q2:
if a19s in abc:
nb=1
if nb==1:
con.execute("select BALANCE from bank where PIN='%s' "%(a19,))
b7p=con.fetchall()
for i7p in b7p:
for w7p in i7p:
wcbp=w7p-a18p
print('*****YOUR INTIAL AMOUNT IS',i7p,'********')
print('*****YOUR TRANSFER MONEY IS',a18p,'*******')
print('*****YOUR FINAL AMOUNT IS', wcbp,'*********')
quep="update bank set BALANCE=%s where PIN = '%s' "%(wcbp,a19)
con.execute(quep)
db.commit()
con.execute("select BALANCE from bank where PIN='%s'"%(a19s,))
wa=con.fetchall()
con.execute("select NAME from bank where PIN='%s'"%(a19s,))
wz=con.fetchall()
for rf in wz:
print("ACCOUNT NAME WHERE YOU WANT TO TRANSFER MONEY ",rf)
for wr in wa:
for wt in wr:
ts=wt+a18p
con.execute("update bank set BALANCE=%s where PIN = '%s'"%(ts,a19s))
print("*********YOUR MONEY HAS BEEN TRANSFER BY THIS ATM MACHINE ********")
bank()
else:
print("**********PLEASE WRITE CORRECT PIN NUMBER OF THE ACCOUNT WHERE YOU WANT TO TRANSFERING THE MONEY********************")
trans()
# this function is used for depositing the cash to your account
def cashd():
a18=int(input('HOW MUCH MONEY DO YOU WANT TO DEPOSITE :-'))
con.execute("select BALANCE from bank where PIN='%s' "%(a19,))
b7=con.fetchall()
for i7 in b7:
for w7 in i7:
wcb=a18+w7
print('*****YOUR INTIAL AMOUNT IS',i7,'********')
print('*****YOUR DEPOSITE AMOUNT IS',a18,'*******')
print('*****YOUR FINAL AMOUNT IS', wcb,'*********')
que="update bank set BALANCE=%s where PIN = '%s' "%(wcb,a19)
con.execute(que)
db.commit()
# calling the function bank
bank()
#opening the bank account
def open():
per=input('do you want to open your account y/n')
per=per.lower()
if per=='y':
try:
a6=input('ENTER YOUR NAME')
a7=int(input('ENTER YOUR MOBLIE NUMBER'))
a8=input("ENTER YOUR DOMINATE'S NAME ")
a9=input('ENTER YOUR F.NAME')
a10=input('ENTER YOUR ADDRESS')
a13=5
except:
print('******************PLEASE ENTER ALL YOUR NECESSARY INFORMATION*************************')
open()
a7=str(a7)
con.execute('select PIN from bank')
sx=tuple(con.fetchall())
# creating the bank account number
def acc():
fg=1
while fg==1:
ep=str(random.randint(111111111111,999999999999))
for i in ep:
if ep not in i:
return ep
fg=2
break
n=1
while n==1:
az= str(random.randint(1111,9999))
for wx in sx:
if az not in wx:
qw=acc()
tg=az
n=2
break
que="insert into bank values('%s','%s','%s','%s','%s','%s','%s','%s')"%(tg,a6,qw,a7,a9,a8,a10,a13)
con.execute(que)
db.commit()
print(' **************************&&&NOTE:-YOUR ACCOUNT HAS CREATED IN THIS BANK&&**************************')
print(' **************************&&&nNOTE:-PLEASE REMEMBER THSI PIN NUMBER ,ACCOUNT NUMBER WHENEVER YOU WANT TO DO ANY TRANSACTION*****************************ACCOUNT NUMBER IS ',qw,'AND PIN NUMBER IS',az)
print('THANKS TO MAKING YOUR ACCOUNT IN THIS BANK')
bank()
else:
bank()
# defing the function bank
def bank():
try:
con.execute('create database abhi_bank ')
con.execute('use abhi_bank')
con.execute('create table bank(PIN varchar(23) , NAME varchar(16) NOT NULL,ACCOUNT_NO varchar(19) primary key NOT NULL,MOBLIE_NUM varchar(13) NOT NULL,F_NAME varchar(20) NOT NULL, DOMINATE varchar(20) NOT NULL,ADDRESS varchar(30) NOT NULL, BALANCE int(30) NOT NULL)' )
www()
except:
def www():
con.execute('use abhi_bank')
print('***************WELCOME TO THE ABHISHEK AND SHIYA BANK********************')
print(" ********************a.OPENING ACCOUNT***************************")
print(" ********************b.FOR ANY TRANSCATION********************")
print(" ********************c.FOR EXISTING******************")
choice=input('ENTER YOUR CHOICE')
a=choice.lower()
if a=='a':
open()
elif a=='b':
mn=input('DO YOU WANT ANY TRANSACTION Y/N')
mn=mn.lower()
if mn=="y":
check()
else:
bank()
elif a=='c':
we=1
while we==1:
ab=input('DO YOU WANT TO OPEN THIS ATM MACHINE PRESS Y/N')
a1=ab.lower()
if a1=='y':
hars=int(input("Enter the Password of Atm machine to open this machine"))
if hars==98375:
bank()
break
else:
print("Please enter the correct password of ATM machine")
we=1
else:
print('****************ENTER CORRECT PASSWORD*****************')
we=1
else:
print('***********************PLEASE PRESS COPRRECT KEY*******************')
www()
# calling the function www
www()
# this is for checking that mysql is connect or not
def ab():
a=input ("enter your localhost")
b=input("enter your root")
c=input("enter your password(not atm machine password)")
try:
import mysql.connector
yj= mysql.connector.connect(host=a, user=b,passwd=c)
return yj
except:
print(" your password, localhost&root is wrong, please enter your correct password")
ab()
db=ab()
if db.is_connected:
con=db.cursor()
# calling the functio of bank for futher processing
har1=9
while(har1==9):
har = int(input("enter the password of atm machine to open it "))
if har==98375:
bank()
har1=2
else:
har1=9
else:
ab()