-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathBankManagementSystemissue.py
78 lines (76 loc) · 3.19 KB
/
BankManagementSystemissue.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
import mysql.connector as c
con=c.connect(host='localhost',
user='root',
password='1234',
database='hospital')
cursor=con.cursor()
if con.is_connected():
print("Welcome To ABC Bank")
while True:
condition=input("Please press 1 for OPEN ACCOUNT \n Please press 2 for CASH DEPOSIT \n Please press 3 for CASH WITHDRAWL \n Please press 4 for ACCOUNT DETAILS \n Please press 5 for EXIT\n")
#OpenAccount
if condition=="1":
name=input("Please enter your full name ")
query="select count('{}') from user where name='{}'".format(name, name)
cursor.execute(query)
name_count=cursor.fetchone()
name_count = str(name_count).replace("(", "")
name_count = name_count.replace(")", "")
name_count = name_count.replace(",", "")
if(float(name_count)>0):
print("Name already exists")
break;
age=int(input("Please enter your age "))
address=input("Please enter your address ")
mobile=int(input("Please enter your mobile number "))
amount=int(input("Please enter the amount to open bank account "))
query="insert into user values('{}',{},'{}',{},{})".format(name,age,address,mobile,amount)
cursor.execute(query)
con.commit()
print("Account open Sucessfully")
#CashDeposit
elif condition=="2":
name=input("Please enter your full name ")
amount=int(input("Enter the amount you want to deposit "))
query = "select amount from user where name='{}'".format(name)
cursor.execute(query)
old_amount = cursor.fetchone()
old_amount = str(old_amount).replace("(", "")
old_amount = old_amount.replace(")", "")
old_amount = old_amount.replace(",", "")
amount = amount + float(old_amount)
query = "update user set amount={} where name='{}'".format(amount,name)
cursor.execute(query)
con.commit()
print("Total amount in your BankAccount ",amount)
#CashWithdrawl
elif condition=="3":
name = input("Please enter your full name ")
amount = int(input("Enter the amount you want to withdraw "))
query="select amount from user where name='{}'".format(name)
cursor.execute(query)
old_amount = cursor.fetchone()
old_amount = str(old_amount).replace("(", "")
old_amount = old_amount.replace(")", "")
old_amount = old_amount.replace(",", "")
if (float(old_amount) < amount):
print("Insuffcient balance for this transaction\nPlease check your balance")
else:
amount = float(old_amount) - amount
print(amount)
query = "update user set amount={} where name='{}'".format(amount, name)
cursor.execute(query)
con.commit()
print("Your current balance is",old_amount)
#AccountDetails
elif condition=="4":
name = input("Please enter your full name ")
query="select * from user where name='{}'".format(name)
cursor.execute(query)
account_info=cursor.fetchone()
print(account_info)
con.commit()
#Exit
elif condition=="5":
print("Exit")
break;