-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAtm_machine.py
More file actions
250 lines (200 loc) · 11 KB
/
Atm_machine.py
File metadata and controls
250 lines (200 loc) · 11 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
import mysql.connector as sql
conn=sql.connect(host='localhost',user='root',password='1234',database=' ATM_MACHINE')
c1=conn.cursor()
print("================================================================================")
print(" WELCOME TO OUR ATM ")
print("================================================================================")
print("1.To create account")
print("2.To login")
print("3.Exit")
print("================================================================================")
op=int(input("Enter your choice :"))
print("================================================================================")
f op==1:
c="y"
while c=="y":
m=int(input("Enter a 4 digit number as accont number:"))
cb="select * from records where ACCONT_NO={}".format(m)
c1.execute(cb)
d=c1.fetchall()
data=c1.rowcount
if data==1:
print("================================================================================")
print("This account number already exists:")
c=input("Do you want to continue y/n -")
print("================================================================================")
if c=="y":
continue
else:
print(" Thank you.")
print(" PLEASE CLOSE THIS FILE BEFORE EXITING")
print("Visit again")
print("================================================================================")
else:
name=input("Enter your name:")
passw=int(input("Enter your pass word:"))
ab="insert into records(ACCONT_NO,PASSWORD,NAME) values({},{},'{}')".format(m,passw,name)
print("================================================================================")
c1.execute(ab)
conn.commit()
print("Account sucessfully created")
print("The minimum balance is 1000 ")
print("================================================================================")
s=int(input("Enter the money to be deposited :"))
print("================================================================================")
sr="update records set CR_AMT={} where ACCONT_NO={}".format(s,m)
c1.execute(sr)
conn.commit()
ef="update records set balance=cr_amt-withdrawl where ACCONT_NO={}".format(m)
c1.execute(ef)
conn.commit()
print("sucessfully deposited")
print(" Thank you")
print(" PLEASE CLOSE THIS FILE BEFORE EXITING")
print("Visit again")
Break
if op==2:
y="y"
while y=="y":
acct=int(input("Enter your account number:"))
cb="select * from records where ACCONT_NO={}".format(acct)
c1.execute(cb)
c1.fetchall()
data=c1.rowcount
if data==1:
pas=int(input("Enter your password :"))
print("================================================================================")
e="select password from records where ACCONT_NO={}".format(acct)
c1.execute(e)
a=c1.fetchone()
d=list(a)
if pas==d[0]:
print("correct")
print("1.Depositng money")
print("2.withdrawing money")
print("3.Transfering money")
print("4.Checking balance")
print("5.Changing Account number ")
print("================================================================================")
r=int(input("Enter your choice:"))
print("================================================================================")
if r==1:
amt=int(input("Enter the money to be deposited:")) print("=============================================================================”)
sr="update records set CR_AMT=CR_AMT + {} where ACCONT_NO={}".format(amt,acct)
c1.execute(sr)
conn.commit()
ef="update records set balance=cr_amt-withdrawl where ACCONT_NO={}".format(acct)
c1.execute(ef)
conn.commit()
print("sucessfully deposited")
t=input("Do you want to continue y/n -") print("================================================================================")
if t=="y":
continue
else:
print(" Thank you")
print(" PLEASE CLOSE THIS FILE BEFORE EXITING")
if r==2:
amt=int(input("Enter the money to withdraw:”) print("================================================================================")
ah="select BALANCE from records where accont_no={}".format(acct)
c1.execute(ah)
m=c1.fetchone()
if amt >m[0]:
print("Your are having less than",amt)
print("Please try again")
print("================================================================================")
else:
sr="update records set balance=balance - {} where ACCONT_NO={}".format(amt,acct)
ed="update records set WITHDRAWL ={} where ACCONT_NO={}".format(amt,acct)
c1.execute(ed)
c1.execute(sr)
conn.commit()
print("Sucessfully updatad")
y=input("do you want to continue y/n -")
if y=="y":
continue
else:
print(" Thank you")
print(" PLEASE CLOSE THIS FILE BEFORE EXITING")
if r==3:
act=int(input("Enter the accont number to be transferrsd :"))
print("================================================================
==============")
cb="select * from records where ACCONT_NO={}".format(act)
c1.execute(cb)
c1.fetchall()
data=c1.rowcount
if data==1:
print(act ,"number exists")
m=int(input("Enter the money to be transferred :"))
print("======================================================
==========================")
ah="select BALANCE from records where accont_no={}".format(acct)
c1.execute(ah)
c=c1.fetchone()
if m > c[0]:
print("Your are having less than",m)
print("Please try again")
print("====================================================
============================")
else:
av="update records set balance=balance-{} where
ACCONT_NO={}".format(m,acct)
cv="update records set balance=balance+{} where
ACCONT_NO={}".format(m,act)
w="update records set withdrawl=withdrawl+{} where accont_no={}".format(m,acct)
t="update records set CR_AMT=CR_AMT+{} where accont_no={}".format(m,act)
c1.execute(av)
c1.execute(cv)
c1.execute(w)
c1.execute(t)
conn.commit()
print("Sucessfully transfered")
y=input("do you want to continue y/n -")
if y=="y":
continue
else:
print(" Thank you")
print(" PLEASE CLOSE THIS FILE BEFORE EXITING")
if r==4:
ma="select balance from records where accont_no={}".format(acct)
c1.execute(ma)
k=c1.fetchone()
print("Balance in your account=",k)
print("=========================================================
=======================")
y=input("do you want to continue y/n -")
if y=="y":
continue
else:
print(" Thank you")
print(" PLEASE CLOSE THIS FILE BEFORE EXITING")
if r==5:
i=int(input("Enter your new account number:"))
cb="select * from records where ACCONT_NO={}".format(i)
c1.execute(cb)
c1.fetchall()
data=c1.rowcount
if data==1:
print("This number already exists")
print("Try again")
y=input("do you want to continue y/n -")
if y=="y":
continue
else:
print(" Thank you")
print(" PLEASE CLOSE THIS FILE BEFORE EXITING")
else:
name=input("Enter your name")
ar="Update records set accont_no={} where name='{}' and password={}".format(i,name,pas)
c1.execute(ar)
conn.commit()
print("Your new account number is ",i)
else:
print("Wrong password") print("================================================================================")
y=input("do you want to continue y/n -")
else:
print("your Account does not exists")
if op==3:
print("Exiting")
print("Please close this file before exiting.")
c1.close()