Cs Project File (1) Chetan
Cs Project File (1) Chetan
DELHI – 110092
SESSION 2024-25
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
(Mr.Akant Sharma)
PGT Comp Science
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
# 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
# TO DEPOSIT MONEY
def deposit():
acc_no = int(input("Enter account number: "))
if not wrong(acc_no): # Use the updated wrong function
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
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
if mycursor.fetchone():
print("A transaction has already been processed today for this account.")
return
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
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
# TO SHOW TRANSACTIONS
def trans():
acc_no = int(input("Enter account number: "))
if not wrong(acc_no): # Use the updated wrong function
return
# 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
Websites : chatgpt.com
Python.org