Computer 1
Computer 1
………………………… …………………………
………………………… …………………………
SR NO. Contents
1. Acknowledgement
2. Introduction
i. About PYTHON
ii. About MYSQL
iii. About Bank
Management
System
3. Source Code
4. Output
5. Bibliography
ACKNOWLEDGEMENT
Garv Singh
INTRODUCTION
ABOUT PYTHON:
from datetime import date # for date of account creation when new customer account is
created.
import tkinter as tk
def is_valid(customer_account_number):
try:
customer_database = open("./database/Customer/customerDatabase.txt")
except FileNotFoundError:
os.makedirs("./database/Customer/customerDatabase.txt", exist_ok=True)
else: # if customer account number is already allocated then this will return false.
otherwise true.
return False
else:
return True
customer_database.close()
def check_leap(year):
def check_date(date):
days_in_months = ["31", "28", "31", "30", "31", "30", "31", "31", "30", "31", "30", "31"]
days_in_months_in_leap_year = ["31", "29", "31", "30", "31", "30", "31", "31", "30", "31",
"30", "31"]
if date == "":
return False
date_elements = date.split("/")
day = int(date_elements[0])
month = int(date_elements[1])
year = int(date_elements[2])
if (year > 2021 or year < 0) or (month > 12 or month < 1):
return False
else:
if check_leap(year):
numOfDays = days_in_months_in_leap_year[month - 1]
else:
numOfDays = days_in_months[month - 1]
def is_valid_mobile(mobile_number):
if mobile_number.__len__() == 10 and mobile_number.isnumeric():
return True
else:
return False
customer_database.write(data)
flag = 0
customer_database = open("./database/Customer/customerDatabase.txt")
output_message = ""
if choice == 1:
else:
flag = 1
break
else:
fetched_line = customer_database.readline()
continue
else:
break
if flag == 0:
print("\n# No account associated with the entered account number exists! #")
return output_message
def delete_customer_account(identity, choice): # choice 1 for admin, choice 2 for
customer
customer_database = open("./database/Customer/customerDatabase.txt")
data_collector = ""
flag = 0
flag = 1
else:
data_collector += line
data_collector += customer_database.readline()
customer_database.write(data_collector)
if flag == 1:
if choice == 1:
adminMenu.printMessage_outside(output_message)
print(output_message)
else:
if choice == 1:
adminMenu.printMessage_outside(output_message)
print(output_message)
def create_admin_account(identity, password):
admin_id = identity
admin_password = password
adminMenu.printMessage_outside(output_message)
print(output_message)
admin_database.close()
def delete_admin_account(identity):
admin_database = open("./database/Admin/adminDatabase.txt")
data_collector = ""
flag = 0
flag = 1
admin_database.readline()
else:
data_collector += line
data_collector += admin_database.readline()
admin_database.write(data_collector)
if flag == 1:
output_message = "Account with account id " + identity + " closed successfully!"
print(output_message)
adminMenu.printMessage_outside(output_message)
else:
adminMenu.printMessage_outside(output_message)
print(output_message)
customer_database = open("./database/Customer/customerDatabase.txt")
data_collector = ""
data_collector += line # ID
customer_database.readline()
data_collector += customer_database.readline()
else:
data_collector += line
data_collector += customer_database.readline()
customer_database.close()
customer_database.write(data_collector)
output_message = "PIN changed successfully."
customerMenu.printMessage_outside(output_message)
print(output_message)
def transaction(identity, amount, choice): # choice 1 for deposit; choice 2 for withdraw
customer_database = open("./database/Customer/customerDatabase.txt")
data_collector = ""
balance = 0
data_collector += line # ID
return -1
else:
if choice == 1:
balance += amount
else:
balance -= amount
data_collector += customer_database.readline()
else:
data_collector += line
customer_database.close()
customer_database.write(data_collector)
return balance
try:
os.makedirs(folder_name, exist_ok=True)
except FileNotFoundError:
if choice == 1:
database.write("admin\nadmin@123\n*\n")
else:
is_credentials_correct = False
is_credentials_correct = True
database.close()
return True
fetched_line = database.readline()
continue
else:
break
if is_credentials_correct:
print("Success!")
else:
print("Failure!")
database.close()
return False
class welcomeScreen:
self.master = window
window.geometry("600x450+383+106")
window.minsize(120, 1)
window.maxsize(1370, 749)
window.resizable(0, 0)
p1 = PhotoImage(file='./images/bank1.png')
window.iconphoto(True, p1)
window.configure(background="#023047")
window.configure(cursor="arrow")
relief="ridge",
selectbackground="blue", selectforeground="white")
activeforeground="#000000", background="#023047",
disabledforeground="#a3a3a3",
foreground="#fbfbfb", borderwidth="0",
highlightbackground="#d9d9d9",
highlightcolor="black", pady="0",
text='''EMPLOYEE''')
activeforeground="#000000", background="#023047",
disabledforeground="#a3a3a3",
foreground="#f9f9f9", borderwidth="0",
highlightbackground="#d9d9d9",
highlightcolor="black", pady="0",
text='''CUSTOMER''')
def selectEmployee(self):
self.master.withdraw()
adminLogin(Toplevel(self.master))
def selectCustomer(self):
self.master.withdraw()
CustomerLogin(Toplevel(self.master))
class Error:
global master
master = window
window.geometry("411x117+485+248")
window.minsize(120, 1)
window.maxsize(1370, 749)
window.resizable(0, 0)
window.title("Error")
window.configure(background="#f2f3f4")
global Label2
global _img0
_img0 = tk.PhotoImage(file="./images/error_image.png")
image=_img0, text='''Label''')
text=message_shown)
def goback(self):
master.withdraw()
class adminLogin:
self.master = window
window.geometry("743x494+338+92")
window.minsize(120, 1)
window.maxsize(1370, 749)
window.resizable(0, 0)
window.title("Admin")
window.configure(background="#ffff00")
global Canvas1
selectbackground="blue", selectforeground="white")
text="Admin Login")
global Label2
global _img0
_img0 = tk.PhotoImage(file="./images/adminLogin1.png")
Label2.configure(image=_img0)
font="TkFixedFont", foreground="#000000",
highlightbackground="#b6b6b6",
highlightcolor="#004080", insertbackground="black")
disabledforeground="#a3a3a3", font="TkFixedFont",
foreground="#000000",
highlightbackground="#d9d9d9", highlightcolor="#004080",
insertbackground="black",
selectbackground="blue", selectforeground="white")
global _img1
_img1 = tk.PhotoImage(file="./images/user1.png")
self.Label3.configure(image=_img1)
global _img2
_img2 = tk.PhotoImage(file="./images/lock1.png")
self.Label4.configure(image=_img2)
global _img3
_img3 = tk.PhotoImage(file="./images/bank1.png")
self.Label5.configure(image=_img3)
foreground="#00254a",
self.Button.place(relx=0.765, rely=0.755)
foreground="#00254a",
font="-family {Segoe UI} -size 10 -weight bold",
command=self.back)
self.Button_back.place(relx=0.545, rely=0.755)
global admin_img
admin_img = tk.PhotoImage(file="./images/adminLogin1.png")
def back(self):
self.master.withdraw()
welcomeScreen(Toplevel(self.master))
@staticmethod
def setImg():
Label2.configure(image=admin_img)
global admin_idNO
admin_idNO = admin_id
self.master.withdraw()
adminMenu(Toplevel(self.master))
else:
Error(Toplevel(self.master))
self.setImg()
class CustomerLogin:
self.master = window
window.geometry("743x494+338+92")
window.minsize(120, 1)
window.maxsize(1370, 749)
window.resizable(0, 0)
window.title("Customer")
window.configure(background="#00254a")
global Canvas1
selectbackground="blue", selectforeground="white")
text="Customer Login")
global Label2
global _img0
_img0 = tk.PhotoImage(file="./images/customer.png")
Label2.configure(image=_img0)
font="TkFixedFont", foreground="#000000",
highlightbackground="#b6b6b6",
highlightcolor="#004080", insertbackground="black")
disabledforeground="#a3a3a3", font="TkFixedFont",
foreground="#000000",
highlightbackground="#d9d9d9", highlightcolor="#004080",
insertbackground="black",
selectbackground="blue", selectforeground="white")
global _img1
_img1 = tk.PhotoImage(file="./images/user1.png")
self.Label3.configure(image=_img1)
self.Label4 = tk.Label(Canvas1)
global _img2
_img2 = tk.PhotoImage(file="./images/lock1.png")
self.Label4.configure(image=_img2, background="#ffffff")
global _img3
_img3 = tk.PhotoImage(file="./images/bank1.png")
self.Label5.configure(image=_img3)
foreground="#ffffff",
self.Button.place(relx=0.765, rely=0.755)
foreground="#ffffff",
command=self.back)
self.Button_back.place(relx=0.545, rely=0.755)
global customer_img
customer_img = tk.PhotoImage(file="./images/customer.png")
def back(self):
self.master.withdraw()
welcomeScreen(Toplevel(self.master))
@staticmethod
def setImg():
settingIMG.configure(image=customer_img)
global customer_accNO
customer_accNO = str(customer_account_number)
self.master.withdraw()
customerMenu(Toplevel(self.master))
else:
Error(Toplevel(self.master))
self.setImg()
class adminMenu:
self.master = window
window.geometry("743x494+329+153")
window.minsize(120, 1)
window.maxsize(1370, 749)
window.resizable(0, 0)
window.title("Admin Section")
window.configure(background="#ffff00")
background="#00254a", borderwidth="0",
disabledforeground="#a3a3a3",
background="#00254a", borderwidth="0",
disabledforeground="#a3a3a3",
background="#00254a", borderwidth="0",
disabledforeground="#a3a3a3",
command=self.exit)
background="#00254a", borderwidth="0",
disabledforeground="#a3a3a3",
background="#00254a", borderwidth="0",
disabledforeground="#a3a3a3",
global Frame1
def closeAccount(self):
CloseAccountByAdmin(Toplevel(self.master))
def createCustaccount(self):
createCustomerAccount(Toplevel(self.master))
def createAdmin(self):
createAdmin(Toplevel(self.master))
def deleteAdmin(self):
deleteAdmin(Toplevel(self.master))
def showAccountSummary(self):
checkAccountSummary(Toplevel(self.master))
def printAccountSummary(identity):
widget.destroy()
output = display_account_summary(identity, 1)
output_message.pack(pady=20)
def printMessage_outside(output):
widget.destroy()
output_message.pack(pady=20)
def exit(self):
self.master.withdraw()
adminLogin(Toplevel(self.master))
class CloseAccountByAdmin:
self.master = window
window.geometry("411x117+498+261")
window.minsize(120, 1)
window.maxsize(1370, 749)
window.resizable(0, 0)
window.configure(background="#f2f3f4")
foreground="#000000", insertbackground="black")
background="#004080", disabledforeground="#a3a3a3",
foreground="#ffffff",
command=self.back)
borderwidth="0", disabledforeground="#a3a3a3",
foreground="#ffffff",
def back(self):
self.master.withdraw()
if not is_valid(identity):
delete_customer_account(identity, 1)
else:
Error(Toplevel(self.master))
return
self.master.withdraw()
class createCustomerAccount:
self.master = window
window.geometry("411x403+437+152")
window.minsize(120, 1)
window.maxsize(1370, 749)
window.resizable(0, 0)
window.title("Create account")
window.configure(background="#f2f3f4")
window.configure(highlightbackground="#d9d9d9")
window.configure(highlightcolor="black")
self.Entry1 = tk.Entry(window, background="#cae4ff",
disabledforeground="#a3a3a3", font="TkFixedFont",
foreground="#000000", highlightbackground="#d9d9d9",
highlightcolor="black",
insertbackground="black", selectbackground="blue",
selectforeground="white")
disabledforeground="#a3a3a3", foreground="#000000",
highlightbackground="#d9d9d9",
disabledforeground="#a3a3a3", foreground="#000000",
highlightbackground="#d9d9d9",
font="TkFixedFont", foreground="#000000",
highlightbackground="#d9d9d9",
highlightcolor="black", insertbackground="black",
selectbackground="blue",
selectforeground="white")
disabledforeground="#a3a3a3", foreground="#000000",
highlightbackground="#d9d9d9",
global acc_type
acc_type = StringVar()
background="#f2f3f4", disabledforeground="#a3a3a3",
foreground="#000000",
highlightbackground="#d9d9d9", highlightcolor="black",
justify='left',
background="#f2f3f4", disabledforeground="#a3a3a3",
foreground="#000000",
highlightbackground="#d9d9d9", highlightcolor="black",
justify='left',
self.Radiobutton1.deselect()
self.Radiobutton1_1.deselect()
disabledforeground="#a3a3a3", foreground="#000000",
disabledforeground="#a3a3a3", foreground="#000000",
foreground="#000000", highlightbackground="#d9d9d9",
highlightcolor="black",
insertbackground="black", selectbackground="blue",
selectforeground="white")
foreground="#000000", highlightbackground="#d9d9d9",
highlightcolor="black",
insertbackground="black", selectbackground="blue",
selectforeground="white")
disabledforeground="#a3a3a3", foreground="#000000",
highlightcolor="black", text='''Gender:''')
global gender
gender = StringVar()
background="#f2f3f4", disabledforeground="#a3a3a3",
foreground="#000000",
highlightcolor="black", justify='left',
background="#f2f3f4", disabledforeground="#a3a3a3",
foreground="#000000",
highlightbackground="#d9d9d9", highlightcolor="black",
justify='left',
self.Radiobutton3.deselect()
self.Radiobutton4.deselect()
self.Label7 = tk.Label(window, activebackground="#f9f9f9",
activeforeground="black", background="#f2f3f4",
disabledforeground="#a3a3a3", foreground="#000000",
highlightbackground="#d9d9d9",
highlightcolor="black", text='''Nationality:''')
font="TkFixedFont", foreground="#000000",
highlightbackground="#d9d9d9",
highlightcolor="black", insertbackground="black",
selectbackground="blue",
selectforeground="white")
foreground="#000000", highlightbackground="#d9d9d9",
highlightcolor="black",
insertbackground="black", selectbackground="blue",
selectforeground="white")
font="TkFixedFont",
foreground="#000000", highlightbackground="#d9d9d9",
highlightcolor="black",
insertbackground="black", selectbackground="blue",
selectforeground="white")
self.Entry10.place(relx=0.511, rely=0.7, height=20, relwidth=0.302)
foreground="#000000", highlightbackground="#d9d9d9",
highlightcolor="black",
insertbackground="black", selectbackground="blue",
selectforeground="white")
disabledforeground="#a3a3a3", foreground="#000000",
highlightbackground="#d9d9d9",
highlightcolor="black", text='''PIN:''')
disabledforeground="#a3a3a3", foreground="#000000",
highlightbackground="#d9d9d9",
disabledforeground="#a3a3a3", foreground="#000000",
highlightbackground="#d9d9d9",
borderwidth="0", disabledforeground="#a3a3a3",
foreground="#ffffff",
command=self.back)
borderwidth="0", disabledforeground="#a3a3a3",
foreground="#ffffff",
self.Entry7.get(), self.Entry8.get(),
self.Entry9.get(), self.Entry10.get(),
self.Entry11.get()))
foreground="#000000", insertbackground="black")
def back(self):
self.master.withdraw()
KYC_document,
if name != "":
if check_date(date_of_birth):
if is_valid_mobile(mobile_number):
if nationality.__len__() != 0:
if KYC_document.__len__() != 0:
if confirm_PIN == PIN:
if initial_balance.isnumeric():
print(output_message)
adminMenu.printMessage_outside(output_message)
else:
Error(Toplevel(self.master))
Error.setMessage(self, message_shown="Invalid
balance!")
return
else:
Error(Toplevel(self.master))
return
else:
Error(Toplevel(self.master))
return
else:
Error(Toplevel(self.master))
return
else:
Error(Toplevel(self.master))
return
else:
Error(Toplevel(self.master))
return
else:
Error(Toplevel(self.master))
else:
Error(Toplevel(self.master))
return
else:
Error(Toplevel(self.master))
return
else:
Error(Toplevel(self.master))
return
else:
Error(Toplevel(self.master))
return
date_of_account_creation = today.strftime("%d/%m/%Y")
# adding in database
append_data("./database/Customer/customerDatabase.txt", data)
self.master.withdraw()
class createAdmin:
self.master = window
window.geometry("411x150+512+237")
window.minsize(120, 1)
window.maxsize(1370, 749)
window.resizable(0, 0)
window.configure(background="#f2f3f4")
text='''Enter password:''')
foreground="#000000", insertbackground="black")
foreground="#000000", insertbackground="black")
disabledforeground="#a3a3a3", foreground="#000000",
highlightbackground="#d9d9d9",
foreground="#000000", insertbackground="black")
borderwidth="0", disabledforeground="#a3a3a3",
foreground="#ffffff",
command=lambda: self.create_admin_account(self.Entry1.get(),
self.Entry2.get(),
self.Entry3.get()))
command=self.back)
def back(self):
self.master.withdraw()
Error(Toplevel(self.master))
else:
create_admin_account(identity, password)
self.master.withdraw()
else:
Error(Toplevel(self.master))
if password != confirm_password:
else:
class deleteAdmin:
window.geometry("411x117+504+268")
window.minsize(120, 1)
window.maxsize(1370, 749)
window.resizable(0, 0)
window.configure(background="#f2f3f4")
foreground="#000000", insertbackground="black")
text='''Enter password:''')
font="TkFixedFont",
foreground="#000000", highlightbackground="#d9d9d9",
highlightcolor="black",
insertbackground="black", selectbackground="blue",
selectforeground="white")
borderwidth="0", disabledforeground="#a3a3a3",
foreground="#ffffff",
command=self.back)
borderwidth="0", disabledforeground="#a3a3a3",
foreground="#ffffff",
command=lambda: self.delete_admin(self.Entry1.get(),
self.Entry1_1.get()))
Error(Toplevel(self.master))
return
delete_admin_account(admin_id)
self.master.withdraw()
else:
Error(Toplevel(self.master))
def back(self):
self.master.withdraw()
class customerMenu:
self.master = window
window.geometry("743x494+329+153")
window.minsize(120, 1)
window.maxsize(1370, 749)
window.resizable(0, 0)
window.title("Customer Section")
window.configure(background="#00254a")
activeforeground="#000000", background="#39a9fc",
borderwidth="0",
disabledforeground="#a3a3a3", font="-family {Segoe UI} -size 11",
foreground="#fffffe",
activeforeground="#000000", background="#39a9fc",
borderwidth="0",
activeforeground="#000000",
background="#39a9fc",
foreground="#fffffe", highlightbackground="#d9d9d9",
highlightcolor="black", pady="0",
text='''Exit''')
activeforeground="#000000", background="#39a9fc",
borderwidth="0",
text='''Close account''')
background="#39a9fc", borderwidth="0",
disabledforeground="#a3a3a3",
global Frame1_1_2
Frame1_1_2 = tk.Frame(window, relief='groove', borderwidth="2",
background="#fffffe")
def selectDeposit(self):
depositMoney(Toplevel(self.master))
def selectWithdraw(self):
withdrawMoney(Toplevel(self.master))
def selectChangePIN(self):
changePIN(Toplevel(self.master))
def selectCloseAccount(self):
self.master.withdraw()
closeAccount(Toplevel(self.master))
def exit(self):
self.master.withdraw()
CustomerLogin(Toplevel(self.master))
def checkBalance(self):
output = display_account_summary(customer_accNO, 2)
self.printMessage(output)
widget.destroy()
output_message.pack(pady=20)
def printMessage_outside(output):
widget.destroy()
output_message.pack(pady=20)
class depositMoney:
self.master = window
window.geometry("411x117+519+278")
window.minsize(120, 1)
window.maxsize(1370, 749)
window.resizable(0, 0)
window.title("Deposit money")
p1 = PhotoImage(file='./images/deposit_icon.png')
window.iconphoto(True, p1)
window.configure(borderwidth="2")
window.configure(background="#f2f3f4")
self.Label1 = tk.Label(window, background="#f2f3f4",
disabledforeground="#a3a3a3",
foreground="#000000", insertbackground="black",
selectforeground="#ffffffffffff")
disabledforeground="#a3a3a3", borderwidth="0",
foreground="#ffffff",
highlightbackground="#000000",
command=lambda: self.submit(self.Entry1.get()))
highlightbackground="#d9d9d9", borderwidth="0",
highlightcolor="black", pady="0",
text='''Back''',
command=self.back)
if amount.isnumeric():
else:
Error(Toplevel(self.master))
else:
return
else:
Error(Toplevel(self.master))
return
if output == -1:
Error(Toplevel(self.master))
return
else:
customerMenu.printMessage_outside(output)
self.master.withdraw()
def back(self):
self.master.withdraw()
class withdrawMoney:
self.master = window
window.geometry("411x117+519+278")
window.minsize(120, 1)
window.maxsize(1370, 749)
window.resizable(0, 0)
window.title("Withdraw money")
p1 = PhotoImage(file='./images/withdraw_icon.png')
window.iconphoto(True, p1)
window.configure(borderwidth="2")
window.configure(background="#f2f3f4")
foreground="#000000", insertbackground="black",
selectforeground="#ffffffffffff")
disabledforeground="#a3a3a3", borderwidth="0",
foreground="#ffffff",
highlightbackground="#000000",
command=lambda: self.submit(self.Entry1.get()))
foreground="#ffffff",
command=self.back)
if amount.isnumeric():
else:
Error(Toplevel(self.master))
else:
Error.setMessage(self, message_shown="Positive value expected!")
return
else:
Error(Toplevel(self.master))
return
if output == -1:
Error(Toplevel(self.master))
return
else:
customerMenu.printMessage_outside(output)
self.master.withdraw()
def back(self):
self.master.withdraw()
class changePIN:
self.master = window
window.geometry("411x111+505+223")
window.minsize(120, 1)
window.maxsize(1370, 749)
window.resizable(0, 0)
window.title("Change PIN")
window.configure(background="#f2f3f4")
text='''Confirm PIN:''')
foreground="#000000", insertbackground="black")
foreground="#000000", insertbackground="black")
disabledforeground="#a3a3a3", foreground="#ffffff",
borderwidth="0",
highlightbackground="#d9d9d9",
disabledforeground="#a3a3a3", foreground="#ffffff",
borderwidth="0",
highlightbackground="#d9d9d9",
change_PIN(customer_accNO, new_PIN)
self.master.withdraw()
else:
Error(Toplevel(self.master))
if new_PIN != confirm_new_PIN:
elif str(new_PIN).__len__() != 4:
else:
return
def back(self):
self.master.withdraw()
class closeAccount:
self.master = window
window.geometry("411x117+498+261")
window.minsize(120, 1)
window.maxsize(1370, 749)
window.resizable(0, 0)
window.title("Close Account")
window.configure(background="#f2f3f4")
foreground="#000000", insertbackground="black")
disabledforeground="#a3a3a3", foreground="#ffffff",
borderwidth="0",
highlightbackground="#d9d9d9",
command=lambda: self.submit(self.Entry1.get()))
disabledforeground="#a3a3a3", foreground="#ffffff",
borderwidth="0",
highlightbackground="#d9d9d9",
print("Submit pressed.")
print(customer_accNO, PIN)
print("Correct accepted.")
delete_customer_account(customer_accNO, 2)
self.master.withdraw()
CustomerLogin(Toplevel(self.master))
else:
print("Incorrect accepted.")
Error(Toplevel(self.master))
def back(self):
self.master.withdraw()
customerMenu(Toplevel(self.master))
class checkAccountSummary:
def __init__(self, window=None):
self.master = window
window.geometry("411x117+498+261")
window.minsize(120, 1)
window.maxsize(1370, 749)
window.resizable(0, 0)
window.configure(background="#f2f3f4")
text='''Enter ID :''')
foreground="#000000", insertbackground="black")
disabledforeground="#a3a3a3", foreground="#ffffff",
borderwidth="0",
highlightbackground="#d9d9d9",
command=lambda: self.submit(self.Entry1.get()))
disabledforeground="#a3a3a3", foreground="#ffffff",
borderwidth="0",
highlightbackground="#d9d9d9",
def back(self):
self.master.withdraw()
if not is_valid(identity):
adminMenu.printAccountSummary(identity)
else:
Error(Toplevel(self.master))
return
self.master.withdraw()
root = tk.Tk()
top = welcomeScreen(root)
root.mainloop()
ADMIN SECTION :-
CUSTOMER SECTION :-
To Close Customer’s Account (From Admin’s End):-
BOOKS:
SUMITA ARORA-INFORMATION PRACTICES
(PYTHON)
ARIHANT – ALL IN ONE INFORMATICS
PRACTICES (CBSE)
INTERNET:
WEBSITE: WWW.PYTHON.ORG
WEBSITE:WWW.WIKIPEDIA.ORG
WEBSITE:WWW.SCRIBD.COM