parent
f0896ffd43
commit
086f9ad4d3
@ -0,0 +1,3 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
@ -0,0 +1 @@
|
||||
银行系统.py
|
@ -0,0 +1,6 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<settings>
|
||||
<option name="USE_PROJECT_PROFILE" value="false" />
|
||||
<version value="1.0" />
|
||||
</settings>
|
||||
</component>
|
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Black">
|
||||
<option name="sdkName" value="Python 3.12 (银行系统v1.0) (2)" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.12 (银行系统v1.0) (2)" project-jdk-type="Python SDK" />
|
||||
</project>
|
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/银行系统v1.0.iml" filepath="$PROJECT_DIR$/.idea/银行系统v1.0.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="PYTHON_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<excludeFolder url="file://$MODULE_DIR$/.venv" />
|
||||
</content>
|
||||
<orderEntry type="jdk" jdkName="Python 3.12 (银行系统v1.0) (2)" jdkType="Python SDK" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,21 @@
|
||||
class Admin:
|
||||
adminU = '丑陋的妖怪' # 管理员的账号
|
||||
adpwd = '1' # 管理员的密码
|
||||
def printAdminView(self):
|
||||
print("*** 欢迎登录银行系统 ***")
|
||||
def printsysFunctionView(self):
|
||||
print("1.开户(1)\n 2.查询(2) ")
|
||||
print(" 3.取款(3)\n 4.存款(4) ")
|
||||
print(" 5.转账(5)\n 6.锁定(6) \n7.解锁(7)\n退出(8)")
|
||||
def adminOption(self):
|
||||
adminInput = input("请输入管理员账户:")
|
||||
if self.adminU != adminInput:
|
||||
print("管理员账户输入错误......")
|
||||
return -1
|
||||
passwordInput = input("请输入密码:")
|
||||
if self.adpwd != passwordInput:
|
||||
print("输入密码有误......")
|
||||
return -1
|
||||
else:
|
||||
print("操作成功,请稍后......")
|
||||
return 0
|
@ -0,0 +1,6 @@
|
||||
class Card:
|
||||
def __init__(self, cardId, cardPwd, money):
|
||||
self.cardId = cardId
|
||||
self.cardPwd = cardPwd
|
||||
self.money = money
|
||||
self.cardLock = False
|
@ -0,0 +1,6 @@
|
||||
class User:
|
||||
def __init__(self, name, id, phone, card):
|
||||
self.name = name
|
||||
self.id = id
|
||||
self.phone = phone
|
||||
self.card = card
|
@ -0,0 +1,167 @@
|
||||
import tkinter as tk
|
||||
from tkinter import messagebox
|
||||
from PIL import Image, ImageTk
|
||||
|
||||
|
||||
class BankSystem:
|
||||
def __init__(self):
|
||||
self.accounts = {}
|
||||
self.current_id = 0
|
||||
|
||||
def create_account(self, name, amount):
|
||||
if name in self.accounts:
|
||||
messagebox.showerror('错误', '帐户已存在.')
|
||||
else:
|
||||
self.current_id += 1
|
||||
self.accounts[name] = [self.current_id, float(amount)]
|
||||
|
||||
def deposit(self, name, amount):
|
||||
if name not in self.accounts:
|
||||
messagebox.showerror('错误', '找不到帐户.')
|
||||
else:
|
||||
self.accounts[name][1] += float(amount)
|
||||
messagebox.showinfo('成功', f'{amount} 元人民币存入帐户 {name}')
|
||||
|
||||
def withdraw(self, name, amount):
|
||||
if name not in self.accounts:
|
||||
messagebox.showerror('错误', '找不到帐户..')
|
||||
else:
|
||||
if self.accounts[name][1] < float(amount):
|
||||
messagebox.showerror('错误', '余额不足')
|
||||
else:
|
||||
self.accounts[name][1] -= float(amount)
|
||||
messagebox.showinfo('成功', f'{amount} 元人民币从帐户中取出 {name}')
|
||||
|
||||
def transfer(self, sender_name, receiver_name, amount):
|
||||
if sender_name not in self.accounts or receiver_name not in self.accounts:
|
||||
messagebox.showerror('错误', '账号不存在')
|
||||
else:
|
||||
if self.accounts[sender_name][1] < float(amount):
|
||||
messagebox.showerror('错误', '余额不足')
|
||||
else:
|
||||
self.accounts[sender_name][1] -= float(amount)
|
||||
self.accounts[receiver_name][1] += float(amount)
|
||||
messagebox.showinfo('成功', f'{amount} 元人民币从帐户 {sender_name} 转出到帐户 {receiver_name}')
|
||||
|
||||
def check_balance(self, name):
|
||||
if name not in self.accounts:
|
||||
messagebox.showerror('错误', '找不到帐户..')
|
||||
else:
|
||||
balance = self.accounts[name][1]
|
||||
balance = int(balance)
|
||||
messagebox.showinfo('Balance', f'账户 {name} 余额为 {balance} 元')
|
||||
|
||||
|
||||
class BankGUI:
|
||||
def __init__(self):
|
||||
self.bank = BankSystem()
|
||||
self.root = tk.Tk()
|
||||
self.root.title('银行管理系统')
|
||||
self.root.geometry('900x800')
|
||||
|
||||
# 设置背景图片
|
||||
self.background_image = Image.open('background.jpg')
|
||||
self.background_photo = ImageTk.PhotoImage(self.background_image)
|
||||
self.background_label = tk.Label(self.root, image=self.background_photo)
|
||||
self.background_label.place(x=0, y=0, relwidth=1, relheight=1)
|
||||
|
||||
# 创建账户
|
||||
self.create_label = tk.Label(self.root, text='创建账户', font=('Arial', 16, 'bold'))
|
||||
self.create_label.place(x=100, y=100)
|
||||
self.name_label = tk.Label(self.root, text='账户名:')
|
||||
self.name_label.place(x=100, y=150)
|
||||
self.name_entry = tk.Entry(self.root)
|
||||
self.name_entry.place(x=200, y=150)
|
||||
self.amount_label = tk.Label(self.root, text='初始金额:')
|
||||
self.amount_label.place(x=100, y=200)
|
||||
self.amount_entry = tk.Entry(self.root)
|
||||
self.amount_entry.place(x=200, y=200)
|
||||
self.create_button = tk.Button(self.root, text='创建', command=self.create_account)
|
||||
self.create_button.place(x=200, y=250)
|
||||
|
||||
# 存款
|
||||
self.deposit_label = tk.Label(self.root, text='存款', font=('Arial', 16, 'bold'))
|
||||
self.deposit_label.place(x=400, y=100)
|
||||
self.deposit_name_label = tk.Label(self.root, text='账户名:')
|
||||
self.deposit_name_label.place(x=400, y=150)
|
||||
self.deposit_name_entry = tk.Entry(self.root)
|
||||
self.deposit_name_entry.place(x=500, y=150)
|
||||
self.deposit_amount_label = tk.Label(self.root, text='存款金额:')
|
||||
self.deposit_amount_label.place(x=400, y=200)
|
||||
self.deposit_amount_entry = tk.Entry(self.root)
|
||||
self.deposit_amount_entry.place(x=500, y=200)
|
||||
self.deposit_button = tk.Button(self.root, text='存款', command=self.deposit)
|
||||
self.deposit_button.place(x=500, y=250)
|
||||
|
||||
# 取款
|
||||
self.withdraw_label = tk.Label(self.root, text='取款', font=('Arial', 16, 'bold'))
|
||||
self.withdraw_label.place(x=100, y=350)
|
||||
self.withdraw_name_label = tk.Label(self.root, text='账户名:')
|
||||
self.withdraw_name_label.place(x=100, y=400)
|
||||
self.withdraw_name_entry = tk.Entry(self.root)
|
||||
self.withdraw_name_entry.place(x=200, y=400)
|
||||
self.withdraw_amount_label = tk.Label(self.root, text='取款金额:')
|
||||
self.withdraw_amount_label.place(x=100, y=450)
|
||||
self.withdraw_amount_entry = tk.Entry(self.root)
|
||||
self.withdraw_amount_entry.place(x=200, y=450)
|
||||
self.withdraw_button = tk.Button(self.root, text='取款', command=self.withdraw)
|
||||
self.withdraw_button.place(x=200, y=500)
|
||||
# 转账
|
||||
self.transfer_label = tk.Label(self.root, text='转账', font=('Arial', 16, 'bold'))
|
||||
self.transfer_label.place(x=400, y=350)
|
||||
self.transfer_sender_label = tk.Label(self.root, text='转出账户:')
|
||||
self.transfer_sender_label.place(x=400, y=400)
|
||||
self.transfer_sender_entry = tk.Entry(self.root)
|
||||
self.transfer_sender_entry.place(x=500, y=400)
|
||||
self.transfer_receiver_label = tk.Label(self.root, text='转入账户:')
|
||||
self.transfer_receiver_label.place(x=400, y=450)
|
||||
self.transfer_receiver_entry = tk.Entry(self.root)
|
||||
self.transfer_receiver_entry.place(x=500, y=450)
|
||||
self.transfer_amount_label = tk.Label(self.root, text='转账金额:')
|
||||
self.transfer_amount_label.place(x=400, y=500)
|
||||
self.transfer_amount_entry = tk.Entry(self.root)
|
||||
self.transfer_amount_entry.place(x=500, y=500)
|
||||
self.transfer_button = tk.Button(self.root, text='转账', command=self.transfer)
|
||||
self.transfer_button.place(x=500, y=550)
|
||||
|
||||
# 查询余额
|
||||
self.balance_label = tk.Label(self.root, text='查询余额', font=('Arial', 16, 'bold'))
|
||||
self.balance_label.place(x=100, y=600)
|
||||
self.balance_name_label = tk.Label(self.root, text='账户名:')
|
||||
self.balance_name_label.place(x=100, y=650)
|
||||
self.balance_name_entry = tk.Entry(self.root)
|
||||
self.balance_name_entry.place(x=200, y=650)
|
||||
self.balance_button = tk.Button(self.root, text='查询', command=self.check_balance)
|
||||
self.balance_button.place(x=200, y=700)
|
||||
|
||||
self.root.mainloop()
|
||||
|
||||
def create_account(self):
|
||||
name = self.name_entry.get()
|
||||
amount = self.amount_entry.get()
|
||||
self.bank.create_account(name, amount)
|
||||
messagebox.showinfo('Success', f'创建成功 账号:{name} 账号余额:{amount}')
|
||||
|
||||
def deposit(self):
|
||||
name = self.deposit_name_entry.get()
|
||||
amount = self.deposit_amount_entry.get()
|
||||
self.bank.deposit(name, amount)
|
||||
|
||||
def withdraw(self):
|
||||
name = self.withdraw_name_entry.get()
|
||||
amount = self.withdraw_amount_entry.get()
|
||||
self.bank.withdraw(name, amount)
|
||||
|
||||
def transfer(self):
|
||||
sender = self.transfer_sender_entry.get()
|
||||
receiver = self.transfer_receiver_entry.get()
|
||||
amount = self.transfer_amount_entry.get()
|
||||
self.bank.transfer(sender, receiver, amount)
|
||||
|
||||
def check_balance(self):
|
||||
name = self.balance_name_entry.get()
|
||||
balance = self.bank.check_balance(name)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
bank_gui = BankGUI()
|
@ -0,0 +1,43 @@
|
||||
from admin import Admin
|
||||
from atm import ATM
|
||||
import time
|
||||
class HomePage:
|
||||
def __init__(self):
|
||||
self.allUserD = {} # 使用字典存储数据
|
||||
self.atm = ATM(self.allUserD)
|
||||
self.admin = Admin() # 管理员开机界面
|
||||
def saveUser(self):
|
||||
self.allUserD.update(self.atm.alluser)
|
||||
print("数据存盘成功")
|
||||
def main(self):
|
||||
self.admin.printAdminView()
|
||||
resL = self.admin.adminOption()
|
||||
if not resL:
|
||||
while True:
|
||||
self.admin.printsysFunctionView()
|
||||
option = input("请输入您的操作:")
|
||||
if option not in ("1", "2", "3", "4", "5", "6", "7", "S", "Q"):
|
||||
print("输入操作项有误,请仔细确认!")
|
||||
time.sleep(1)
|
||||
if option == "1": # 开户
|
||||
self.atm.creatUser()
|
||||
elif option == "2": # 查询
|
||||
self.atm.searchUser()
|
||||
elif option == "3": # 取款
|
||||
self.atm.getMoney()
|
||||
elif option == "4": # 存储
|
||||
self.atm.saveMoney()
|
||||
elif option == "5": # 转账
|
||||
self.atm.transferMoney()
|
||||
elif option == "6": # 锁定
|
||||
self.atm.lockCard()
|
||||
elif option == "7": # 解锁
|
||||
self.atm.unlockCard()
|
||||
elif option.upper() == "8":
|
||||
if not (self.admin.adminOption()):
|
||||
self.saveUser()
|
||||
print('退出系统')
|
||||
return -1
|
||||
if __name__ == "__main__":
|
||||
homepage = HomePage()
|
||||
homepage.main()
|
Loading…
Reference in new issue