#link to other classes by importing
from person import *
from account import *
#import needed libaries
import pickle
import tkinter as tk
from tkinter import messagebox
class BankSystem(object):
def __init__(self):
self.customerList = []
self.adminList = []
self.loadBankData() #used to received bank data when testing
self.save() #saves loadBankData into a file
self.load() #loads bank data from a file
def save(self):
#put customer and admin list into another list
data1 = (self.adminList, self.customerList)
#makes a file and writes bank data into it
output = open('bankData.pkl', 'wb')
pickle.dump(data1, output)
output.close()
def load(self):
#loads bank data from another file, then closes that file
pkl_file = open('bankData.pkl', 'rb')
data = pickle.load(pkl_file)
pkl_file.close()
#set the admin and customer list
self.adminList = data[0]
self.customerList = data[1]
def loadBankData(self):
#create customers and add them to the cusomterList
#create specific accounts for customers
#used to reset data when testing
customer_1 = Customer("amin", "1234", ["14", " Street2", "tabriz" , "hesabjari"])
account_no = 90455673
account_1 = hesabjari(account_no, "hesabjari", "1234", 5000)
customer_1.openAccount(account_1)
self.customerList.append(customer_1)
customer_2 = Customer("Davood", "password", ["60", "Street1", "tehran" , "hesabboland"])
account_no += 1
account_2 = hesabjari(account_no, "hesabjari", "2601", 3200)
account_no += 1
account_3 = hesabboland(account_no, "hesabboland", "2601", 600)
customer_2.openAccount(account_2)
customer_2.openAccount(account_3)
self.customerList.append(customer_2)
customer_3 = Customer("Niloo", "moonlight", ["5", "Street3", "tabriz", "hesabkotah"])
account_no += 1
account_4 = hesabkotah(account_no, "hesabkotah", "1010", 18000)
customer_3.openAccount(account_4)
self.customerList.append(customer_3)
customer_4 = Customer("Ali", "150A",["44", "nishan tashi", "istanbul", "hesabjari"])
account_no+= 1
account_5 = hesabjari(account_no, "hesabjari", "6666", 50)
customer_4.openAccount(account_5)
self.customerList.append(customer_4)
#create admins and add them to admins_list
admin_1 = Admin("ahora", "1441", True, ["12", "maqsodiye", "tehran" , ""])
self.adminList.append(admin_1)
def customerLogin(self, name, password):
#check the data inputed
foundCustomer = self.searchCustomersByName(name)
if foundCustomer == None:
return("The customer has not been found! \n")
else:
#make sure the correct password is entered
if (foundCustomer.checkPassword(password) == True):
self.runCustomerOptions(foundCustomer)
else:
return("you have input a wrong password \n")
def searchCustomersByName(self, customerName):
#finds a customer from the customers_list and compares wuth inputted data
foundCustomer = None
for a in self.customerList:
name = a.getName()
if name == customerName:
foundCustomer = a
break
if foundCustomer == None:
print("The customer %s does not exist! Try again...\n" %customerName)
#returns the found_customer to be used customer_login
return foundCustomer
def mainMenu(self):
#print the options you have
print()
print()
print ("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
print ("Welcome to the EN Simple Bank System")
print ("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
print ("1) Admin login")
print ("2) Customer login")
print ("3) Quit")
print (" ")
while True:
try:
option = int(input("\nChoose your option: "))
break
except ValueError:
print("Option not valid. Try again. \n")
return option
def runMainOption(self):
#options when code first runs
loop = 1
while loop == 1:
choice = self.mainMenu()
if choice == 1:
name = input("\nPlease input admin name: ")
password = input("\nPlease input admin password: ")
#calls admin_login to check the data inputted
msg = self.adminLogin(name, password)
print(msg)
elif choice == 2:
name = input("\nPlease input customer name: ")
password = input("\nPlease input customer password: ")
#calls customer_login to check data inputted
msg = self.customerLogin(name, password)
print(msg)
elif choice == 3:
#uses a GUI for a message box to confirm if the user wants to quit
root = tk.Tk()
if messagebox.askyesno("Quit", "Are you sure you want to quit?"):
root.destroy() #gets rid of blank GUI box the tkinter makes
self.save() #saves all changes
loop = 0 #quits
else:
print("Option not valid \n")
print ("Thank you for stopping by the bank! \n")
def customerMenu(self, customerName):
#print the options you have when logged in as a customer
print (" ")
print ("Welcome %s : Your transaction options are:" %customerName)
print ("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
print ("1) Account operations")
print ("2) Profile settings")
print ("3) Sign out")
print (" ")
while True:
try:
option = int(input("\nChoose your option: "))
break
except ValueError:
print("Option not valid. Try again.")
return option
def runCustomerOptions(self, customer):
loop = 1
while loop == 1:
choice = self.customerMenu(customer.getName())
if choice == 1:
accName = input("\nPlease input name of account: ")
account = customer.searchAccountByName(accName)
if account == None:
print ("Account could not be found \n")
else:
account.runAccountOptions(customer, self)
elif choice == 2:
customer.runProfileOptions()
elif choice == 3:
loop = 0
print ("Exit account operations \n")
def adminLogin(self, name, password):
#checks admin login same as for customers
foundAdmin = self.searchAdminByName(name)
if foundAdmin== None:
return("The admin has not been found! \n")
else:
if (foundAdmin.checkPassword(password) == True):
self.runAdminOptions(foundAdmin)
else:
return("you have input a wrong password \n")
def searchAdminByName(self, adminName):
#searchs for admins using admin list
foundAdmin = None
for a in self.adminList:
name = a.getName()
if name == adminName:
foundAdmin = a
break
if foundAdmin == None:
print("The admin %s does not exist! Try again...\n" %adminName)
return foundAdmin
def interest(self):
#allows admins to manually apply interest to all accounts
for customer in
没有合适的资源?快使用搜索试试~ 我知道了~
基于python的银行管理系统
共4个文件
py:4个
需积分: 5 9 下载量 35 浏览量
2023-06-06
19:04:40
上传
评论 3
收藏 8KB RAR 举报
温馨提示
基于python开发的一个银行管理系统 功能: 0、管理员登录、用户登录; 1、用户账户操作; 2、用户个性化界面设计; 3、管理员个性化界面设计; 4、删除用户信息; 5、打印所有用户详细信息; 6、打印所有管理员详细信息; 7、存款与利息计算; ...... 相关的功能在不断的更新...... 本银行管理系统是基于linux开发的,但是在windows环境也可以正常的运行; 本程序可以用于Python初学者的练手操作,也可以作为一个简单的课程设计。 希望对需要的人有所帮助。
资源推荐
资源详情
资源评论
收起资源包目录
bank-system-management.rar (4个子文件)
bank-system-management
bank_system.py 13KB
person.py 4KB
account.py 8KB
loan.py 3KB
共 4 条
- 1
资源评论
小禄Diary
- 粉丝: 3
- 资源: 6
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功