0% found this document useful (0 votes)
16 views21 pages

Cs Project File (1) Chetan

The document outlines a computer project on bank management created by a student named Chetan for Class XII. It describes a Python program that manages bank accounts, including features like account creation, transactions, and user management, utilizing MySQL for data storage. The project includes a certificate of completion, acknowledgments, and detailed system requirements along with source code and output sections.

Uploaded by

chetan2349singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views21 pages

Cs Project File (1) Chetan

The document outlines a computer project on bank management created by a student named Chetan for Class XII. It describes a Python program that manages bank accounts, including features like account creation, transactions, and user management, utilizing MySQL for data storage. The project includes a certificate of completion, acknowledgments, and detailed system requirements along with source code and output sections.

Uploaded by

chetan2349singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 21

RAJKIYA PRATHIBA VIKAS VIDYALAYA

DELHI – 110092
SESSION 2024-25

COMPUTER PROJECT ON BANK


MANAGEMENT

NAME: CHETAN
CLASS : XII A
CLASS ROLL NO : 12109
CERTIFICATE
This is to certify that Cadet PRIYANSHU CBSE Roll No:_________________

has successfully completed the project Work entitled Fitness Centre in the

subject Computer Science (083) laid down in the regulations of CBSE for the

purpose of Practical Examination in Class XII to be held in RPVV IP

Extnension Patparganj Delhi -92

(Mr.Akant Sharma)
PGT Comp Science

Signature of External Examiner


Name: _______________________
Examiner Number:_______________
ACKNOWLEDGEMENT
Apart from the efforts of me, the success of any project depends largely on
the encouragement and guidelines of many others. I take this opportunity to express
my gratitude to the people who have been instrumental in the successful completion
of this project.
I express my heartfelt gratitude to my parents for constant encouragement
while carrying out this project.

I gratefully acknowledge the contribution of the individuals who contributed in


bringing this project up to this level, who continues to look after me despite my flaws,

I express my deep sense of gratitude to the luminary The Principal, RPVV IP


Extension Delhi-92 who has been continuously motivating and extending their
helping hand to us.

My sincere thanks to Mr. Akant Sharma, Master In-charge, A guide, A Mentor


, who critically reviewed my project and helped in solving each and every problem,
occurred during implementation of the project

The guidance and support received from all the members who
contributed and who are contributing to this project, was vital for the success
of the project. I am grateful for their constant support and help.
CONTENTS

1) Introduction

2) System Requirements

3) Source code

4) Output

5) Bibliography
INTRODUCTION

This Python program provides a basic framework for


managing bank accounts, including:
 Account Creation: Allows staff to create new customer
accounts with essential details like name, address, and
initial deposit.
 Account Transactions: Enables staff to process deposits
and withdrawals for existing accounts, while maintaining
transaction records.
 Account Information: Provides options to view account
balances, customer details, and transaction histories.
 Account Updates: Allows staff to update customer
information, such as address and phone number.
 Account Closure: Enables staff to close customer
accounts.
 User Management: Includes a simple login system for
staff and administrators, with different levels of access to
system functionalities.
Key Features:
 Database Integration: Utilizes MySQL to store and
manage customer data, account information, and
transaction records.
 Data Integrity: Implements basic data validation and
checks to ensure data consistency and prevent errors.
 User-Friendly Interface: Provides a simple command-line
interface for easy interaction with the system.
This program serves as a foundational example for building a
more comprehensive bank management system. It can be
further expanded to include features like loan management,
interest calculations, reporting, and a more sophisticated user
interface.
Note: This is a simplified version and may not be suitable for
real-world banking applications, which require robust security
measures, compliance with regulations, and advanced
features.
I hope this introduction is helpful!
SYSTEM REQUIREMENTS

1.Processor : AMD® Ryzen 7 4700g with radeon


2.graphics × 16

3.Disk Space : 1GB or More

4.Operating System : :Ubuntu 20.04.4 LTS(64-


bit)

5.Python Version : Python 3.11.1

6.Mysql Version : 8.0


SOURCE CODE
import mysql.connector
from prettytable import PrettyTable

# Connecting to the database


mydatabase = mysql.connector.connect(host="localhost", user="root", password="0123")
mycursor = mydatabase.cursor()

# Creating database and tables


mycursor.execute("create database if not exists bank")
mycursor.execute("use bank")

# Modify the TRANSACTION table to include a unique transaction_id and prevent duplicate
transactions on the same day
mycursor.execute("""
CREATE TABLE IF NOT EXISTS COSTUMER(
name VARCHAR(40),
acc_no BIGINT PRIMARY KEY,
address VARCHAR(60),
status VARCHAR(50),
mobile_no VARCHAR(15),
deposit DECIMAL(10, 2)
)
""")

# Add a UNIQUE constraint on acc_no and TR_DATE to prevent duplicate transactions for
the same day
mycursor.execute("""
CREATE TABLE IF NOT EXISTS TRANSACTION(
transaction_id INT AUTO_INCREMENT PRIMARY KEY,
acc_no BIGINT,
DEPOSIT DECIMAL(10, 2),
WITHDRAW DECIMAL(10, 2),
TR_DATE DATE,
FOREIGN KEY (acc_no) REFERENCES COSTUMER(acc_no),
UNIQUE(acc_no, TR_DATE) -- Ensure no duplicate transactions for the same account
on the same day
)
""")

mycursor.execute("""
CREATE TABLE IF NOT EXISTS USER(
user_id VARCHAR(20) PRIMARY KEY,
password VARCHAR(255),
type VARCHAR(10)
)
""")

# TO CREATE ACCOUNT
def createAccount():
try:
accNo = int(input("Enter the account no (11 digits): "))
except ValueError:
print("Invalid account number. Please enter a numeric value.")
return

# Check if account number already exists


mycursor.execute("SELECT acc_no FROM COSTUMER WHERE acc_no=%s", (accNo,))
if mycursor.fetchone() is not None:
print("Account number already exists!")
return

name = input("Enter the account holder name: ")


address = input("Enter address: ")
mobile_no = input("Enter mobile number: ")

# Validate deposit amount


deposit = float(input("Enter the initial deposit amount: "))
if deposit <= 0:
print("Initial deposit must be greater than zero.")
return

sql_q = "insert into COSTUMER values(%s,%s,%s,'active',%s,%s)"


sql_p = (name, accNo, address, mobile_no, deposit)
mycursor.execute(sql_q, sql_p)
mydatabase.commit()
print("Your account has been successfully added.")

# Check if account exists


def wrong(acc_no):
mycursor.execute("select acc_no from COSTUMER where acc_no=%s", (acc_no,))
m = mycursor.fetchall()
if len(m) == 0:
print("Wrong account number.")
return False
return True

# TO DEPOSIT MONEY
def deposit():
acc_no = int(input("Enter account number: "))
if not wrong(acc_no): # Use the updated wrong function
return

# Check if account is closed


mycursor.execute("SELECT status FROM COSTUMER WHERE acc_no=%s", (acc_no,))
status = mycursor.fetchone()
if status[0] == 'c':
print("Account is closed. Cannot perform transactions.")
return

amount = float(input("Enter amount to deposit: "))


if amount <= 0:
print("Amount must be greater than zero.")
return

try:
mydatabase.start_transaction()
# Check if the transaction already exists for this account
mycursor.execute("""
SELECT * FROM TRANSACTION
WHERE acc_no=%s AND TR_DATE=CURRENT_DATE
""", (acc_no,))

if mycursor.fetchone():
print("A transaction has already been processed today for this account.")
return

sql = "UPDATE COSTUMER SET deposit = deposit + %s WHERE acc_no = %s"


sql_p = (amount, acc_no)
trans = "INSERT INTO TRANSACTION (acc_no, DEPOSIT, TR_DATE) VALUES
(%s, %s, CURRENT_DATE)"
p = (acc_no, amount)

mycursor.execute(trans, p)
mycursor.execute(sql, sql_p)
mydatabase.commit()
print("Amount successfully added.")
except Exception as e:
mydatabase.rollback()
print(f"Error: {e}")

# TO WITHDRAW MONEY
def withdraw():
acc_no = int(input("Enter account number: "))
if not wrong(acc_no): # Use the updated wrong function
return

# Check if account is closed


mycursor.execute("SELECT status FROM COSTUMER WHERE acc_no=%s", (acc_no,))
status = mycursor.fetchone()
if status[0] == 'c':
print("Account is closed. Cannot perform transactions.")
return
amount = float(input("Enter amount to withdraw: "))
if amount <= 0:
print("Amount must be greater than zero.")
return

# Check for sufficient funds


mycursor.execute("SELECT deposit FROM COSTUMER WHERE acc_no=%s",
(acc_no,))
balance = mycursor.fetchone()[0]
if balance < amount:
print("Insufficient funds.")
return

# Check if the transaction already exists for this account


mycursor.execute("""
SELECT * FROM TRANSACTION
WHERE acc_no=%s AND TR_DATE=CURRENT_DATE
""", (acc_no,))

if mycursor.fetchone():
print("A transaction has already been processed today for this account.")
return

sql = "UPDATE COSTUMER SET deposit = deposit - %s WHERE acc_no = %s"


sql_p = (amount, acc_no)
withdraw = "INSERT INTO TRANSACTION (acc_no, WITHDRAW, TR_DATE)
VALUES (%s, %s, CURRENT_DATE)"
p = (acc_no, amount)

mycursor.execute(withdraw, p)
mycursor.execute(sql, sql_p)
mydatabase.commit()
print("Amount successfully withdrawn.")

# TO CHECK BALANCE
def balance():
acc_no = int(input("Enter account number: "))
if not wrong(acc_no): # Use the updated wrong function
return

mycursor.execute("select deposit from COSTUMER where acc_no=%s", (acc_no,))


balance = mycursor.fetchone()
if balance is None:
print("Account not found.")
else:
print("Current balance:", balance[0])
# TO SHOW CUSTOMER DETAILS
def info():
acc_no = int(input("Enter account number: "))
if not wrong(acc_no): # Use the updated wrong function
return

mycursor.execute("select * from COSTUMER where acc_no=%s", (acc_no,))


customer = mycursor.fetchone()
if customer:
columns = ["NAME", "ACC_NO", "ADDRESS", "STATUS", "MOBILE_NO",
"DEPOSIT"]
mytable = PrettyTable(columns)
mytable.add_row(customer)
print(mytable)
else:
print("Account not found.")

# TO SHOW ALL CUSTOMER DETAILS


def allc():
sql = "select * from COSTUMER"
mycursor.execute(sql)
customers = mycursor.fetchall()

columns = ["NAME", "ACC_NO", "ADDRESS", "STATUS", "MOBILE_NO",


"DEPOSIT"]
mytable = PrettyTable(columns)
for customer in customers:
mytable.add_row(customer)
print(mytable)

# TO SHOW ALL TRANSACTIONS


def allt():
sql = "select * from TRANSACTION order by TR_DATE"
mycursor.execute(sql)
transactions = mycursor.fetchall()

columns = ["ACC_NO", "DEPOSIT", "WITHDRAW", "TR_DATE"]


mytable = PrettyTable(columns)
for transaction in transactions:
mytable.add_row(transaction)
print(mytable)

# TO UPDATE CUSTOMER INFORMATION


def update():
print("Press 1 to update name")
print("Press 2 to update address")
print("Press 3 to update mobile number")
choice = int(input("Enter your choice: "))

acc_no = int(input("Enter account number: "))


if not wrong(acc_no): # Use the updated wrong function
return

if choice == 1:
name = input("Enter new name: ")
sql = "UPDATE COSTUMER SET name=%s WHERE acc_no=%s"
sql_p = (name, acc_no)
mycursor.execute(sql, sql_p)
elif choice == 2:
address = input("Enter new address: ")
sql = "UPDATE COSTUMER SET address=%s WHERE acc_no=%s"
sql_p = (address, acc_no)
mycursor.execute(sql, sql_p)
elif choice == 3:
mobile_no = input("Enter new mobile number: ")
sql = "UPDATE COSTUMER SET mobile_no=%s WHERE acc_no=%s"
sql_p = (mobile_no, acc_no)
mycursor.execute(sql, sql_p)

mydatabase.commit()
print("Information updated successfully.")

# TO CLOSE ACCOUNT
def close():
acc_no = int(input("Enter account number: "))
if not wrong(acc_no): # Use the updated wrong function
return

sql = "UPDATE COSTUMER SET status='c' WHERE acc_no=%s"


sql_p = (acc_no,)
mycursor.execute(sql, sql_p)
mydatabase.commit()
print("Account has been closed.")

# TO SHOW TRANSACTIONS
def trans():
acc_no = int(input("Enter account number: "))
if not wrong(acc_no): # Use the updated wrong function
return

mycursor.execute("SELECT * FROM TRANSACTION WHERE acc_no=%s ORDER BY


TR_DATE", (acc_no,))
transactions = mycursor.fetchall()
columns = ["ACC_NO", "DEPOSIT", "WITHDRAW", "TR_DATE"]
mytable = PrettyTable(columns)
for transaction in transactions:
mytable.add_row(transaction)
print(mytable)

# USER MENU
def staff():
while True:
print("Press 1 to open a new account")
print("Press 2 to deposit money")
print("Press 3 to withdraw money")
print("Press 4 to check balance")
print("Press 5 to view customer details")
print("Press 6 to update customer information")
print("Press 7 to close account")
print("Press 8 to view transaction details")
print("Press 9 to exit")
choice = int(input("Enter your choice: "))

if choice == 1:
createAccount()
elif choice == 2:
deposit()
elif choice == 3:
withdraw()
elif choice == 4:
balance()
elif choice == 5:
info()
elif choice == 6:
update()
elif choice == 7:
close()
elif choice == 8:
trans()
else:
break

# ADMIN MENU
def admin():
while True:
print("Press 1 to open a new account")
print("Press 2 to deposit money")
print("Press 3 to withdraw money")
print("Press 4 to check balance")
print("Press 5 to view customer details")
print("Press 6 to update customer information")
print("Press 7 to close account")
print("Press 8 to view transaction details")
print("Press 9 to view all customer details")
print("Press 10 to view all transactions")
print("Press 11 to exit")
choice = int(input("Enter your choice: "))

if choice == 1:
createAccount()
elif choice == 2:
deposit()
elif choice == 3:
withdraw()
elif choice == 4:
balance()
elif choice == 5:
info()
elif choice == 6:
update()
elif choice == 7:
close()
elif choice == 8:
trans()
elif choice == 9:
allc()
elif choice == 10:
allt()
else:
break

# LOGIN SYSTEM
def login():
user_id = input("Enter user ID: ")
password = input("Enter password: ")
sql_q = "SELECT * FROM USER WHERE user_id=%s AND password=MD5(%s);"
sql_p = (user_id, password)
mycursor.execute(sql_q, sql_p)
user = mycursor.fetchone()

if user is None:
print("Invalid username/password.")
return
elif user[2] == 'staff':
staff()
elif user[2] == 'admin':
admin()

# SIGNUP SYSTEM
def signup():
user_id = input("Enter user ID: ")
password = input("Enter password: ")
utype = input("Enter type (admin/staff): ")
sql_q = "INSERT INTO USER VALUES (%s, MD5(%s), %s)"
sql_p = (user_id, password, utype)
mycursor.execute(sql_q, sql_p)
mydatabase.commit()

# Main Menu
while True:
print("Press 1 to login")
print("Press 2 to sign up")
print("Press 3 to exit")
choice = int(input("Enter your choice: "))

if choice == 1:
login()
elif choice == 2:
signup()
elif choice == 3:
break
else:
print("invalid choice")
OUTPUT
BIBLIOGRAPHY

Books : COMPUTER SCIENCE WITH PYTHON


PREETI ARRORA CLASS XII

Websites : chatgpt.com
Python.org

You might also like