Project_file cs
Project_file cs
COMPUTER SCIENCE
CLOTH STORE MANAGEMENT
SYSTEM
SESSION 2024-25
1|Page
Acknowledgement
2|Page
Certificate
Signature of Teacher
Date:
3|Page
Index
Page
S.no Description
numbers
5
01 Introduction & Aim
02 Future prospect 6
03 Database 7-9
04 Schemas 10-11
12-43
05 Source code
06 Output 44-48
07 Bibliography 49
4|Page
INTRODUCTION
AIM
With the help of our assigned advanced system,
which can efficiently handle and manipulate
employee and customer databases as well as
other things collectively, our project aims to
assist the managers and administrators of cloth
stores in carrying out all internal operations
successfully. This will make it easier for the
cloth retailers to manage data efficiently.
5|Page
FUTURE PROSPECT
1) Upgrade to a user-friendly and visually
appealing interface with modern web technologies
(e.g., React, Angular).
6|Page
DATABASE
1) Database:
2) Use Database:
Use clothesmanagement;
3) Customers Table
CREATE TABLE customers (
NULL
);
7|Page
4) Employees Table
CREATE TABLE employees
NULL,
);
5) Inventory Table
NULL
);
8|Page
6) Sales Table
9|Page
SCHEMAS
1) Customers
2) Employees
10 | P a g e
3) Inventory
4) Sales
11 | P a g e
SOURCE CODE
import time
import datetime
import mysql.connector as mysql
from mysql.connector import errorcode
import sys
def main():
"""
This function serves as the entry point for the program.
It typically contains the main logic and orchestrates the
flow of the program.
"""
while True:
try:
print("*"*50)
choice2 = int(input("Please enter your choice from
the above options: "))
print("*"*50)
except Exception:
12 | P a g e
print("Invalid Input. Please enter only
numeric value(1-6)")
else:
break
if choice2 == 1:
fetch_data()
elif choice2 == 2:
update_data()
fetch_data()
elif choice2 == 3:
PK = f'SELECT COLUMN_NAME FROM
INFORMATION_SCHEMA.COLUMNS WHERE
TABLE_SCHEMA = "clothesmanagement" AND
TABLE_NAME = "{dic_tables[choice1]}" AND
COLUMN_KEY = "PRI"'
cursor.execute(PK)
PK_name = cursor.fetchall()
if choice1 == 1:
print("""1) Retrieve using customer ID
2) Retrieve using Phone Number""")
while True:
try:
choice4 = int(input("Please enter
your choice(1-2): "))
if choice4 != 1 and choice4 != 2:
print("Invalid Input. Please select from
the
above options.")
13 | P a g e
else:
14 | P a g e
break
except Exception:
print("Please enter only numeric value(1-2).")
if choice4 == 1:
PK = f'SELECT COLUMN_NAME FROM
INFORMATION_SCHEMA.COLUMNS WHERE
TABLE_SCHEMA = "clothesmanagement" AND
TABLE_NAME = "{dic_tables[choice1]}" AND
COLUMN_KEY = "PRI"'
cursor.execute(PK)
PK_name = cursor.fetchall()
PK_value = int(input(f"Please enter the
{PK_name[0][0]} from which you want to get data: "))
query10 = f'SELECT * FROM {dic_tables[choice1]}
WHERE {PK_name[0][0]} = {PK_value}'
cursor.execute(query10)
fetched_data = cursor.fetchall()
if fetched_data:
for row in fetched_data:
for i in range(len(cursor.description)):
print(cursor.description[i][0] + ": " +
str(row[i]))
elif choice4 == 2:
query_PhoneNos = 'select cust_phoneno_ from
customers'
cursor.execute(query_PhoneNos)
PhoneNos = cursor.fetchall()
while True:
try:
15 | P a g e
cust_phone_no = int(input("Please enter the
customer's phone number: "))
if len(str(cust_phone_no)) != 10:
print("Please enter only 10 digit phone
number."
) else:
break
except Exception:
print("Please enter only numeric value.")
for phone_no in PhoneNos:
if phone_no[0] == cust_phone_no:
query_fetch = f'select * from customers
where cust_phoneno_ = {cust_phone_no}'
cursor.execute(query_fetch)
fetched_data = cursor.fetchall()
if fetched_data:
for row in fetched_data:
for i in range(len(cursor.description)):
print(cursor.description[i][0] + ": " +
str(row[i]))
else:
print(f"No data found for the provided
{PK_name[0][0]}.")
elif choice1 == 2:
PK_value = input(f"Please enter the
{PK_name[0][0]} from which you want to get data: ")
query10 = f'SELECT * FROM {dic_tables[choice1]}
WHERE {PK_name[0][0]} = "{PK_value}"'
cursor.execute(query10)
16 | P a g e
fetched_data = cursor.fetchall()
if fetched_data:
for row in fetched_data:
for i in range(len(cursor.description)):
print(cursor.description[i][0] + ": " +
str(row[i]))
else:
print(f"No data found for the provided
{PK_name[0][0]}.")
elif choice1 == 3:
PK_value = input(f"Please enter the
{PK_name[0][0]} from which you want to get data: ")
query10 = f'SELECT * FROM {dic_tables[choice1]}
WHERE {PK_name[0][0]} =
"{PK_value}"'
cursor.execute(query10)
fetched_data = cursor.fetchall()
if fetched_data:
for row in fetched_data:
for i in range(len(cursor.description)):
print(cursor.description[i][0] + ": " +
str(row[i]))
else:
print(f"No data found for the provided
{PK_name[0][0]}.")
elif choice1 == 4:
PK_value = int(input(f"Please enter the
{PK_name[0][0]} from which you want to get data: "))
query10 = f'SELECT * FROM {dic_tables[choice1]}
17 | P a g e
WHERE {PK_name[0][0]} = {PK_value}'
18 | P a g e
cursor.execute(query10)
fetched_data = cursor.fetchall()
if fetched_data:
for row in fetched_data:
for i in range(len(cursor.description)):
print(cursor.description[i][0] + ": " +
str(row[i]))
else:
print(f"No data found for the provided
{PK_name[0][0]}.")
elif choice2 ==
4: if choice1
== 1:
def newCustomer():
sql = ""
Info = ()
sql="Insert into customers values(%s,%s,%s,
%s,%s,%s,%s)"
Info=(cust_ID,cust_FirstName,cust_LastName,
cust_phoneno_,cust_address,cust_email,ch)
cursor.execute(sql,Info)
con.commit()
query11 = 'select cust_ID from customers'
cursor.execute(query11)
cust_IDS = cursor.fetchall()
while True:
cust_ID = int(input("Enter customer id:
")) for cust_iD in cust_IDS:
if cust_ID == cust_iD[0]:
19 | P a g e
print("Customer ID already exists. Please
enter a different customer ID.")
break
else:
break
cust_FirstName=input('Enter customers first
name:
') cust_LastName=input('Enter customers Last
20 | P a g e
try:
data_tuple = []
query4 = f"SELECT COLUMN_NAME FROM
INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME
= '{dic_tables[choice1]}' AND TABLE_SCHEMA =
'clothesmanagement' ORDER BY ORDINAL_POSITION"
cursor.execute(query4)
result = cursor.fetchall()
for col_name in result:
col_value = input(f"Please enter the new
{col_name[0]}: ")
data_tuple.append(col_value)
placeholders = ', '.join(['%s'] * len(data_tuple))
query7 = f'INSERT INTO VALUES ({placeholders})'
cursor.execute(query7,tuple(data_tuple))
con.commit()
fetch_data()
print("Successfully added new data!")
except Exception:
print("An error occured")
elif choice2 == 5:
PK = f'SELECT COLUMN_NAME FROM
INFORMATION_SCHEMA.COLUMNS WHERE
TABLE_SCHEMA = "clothesmanagement" AND
TABLE_NAME = "{dic_tables[choice1]}" AND
COLUMN_KEY = "PRI"'
cursor.execute(PK)
PK_name = cursor.fetchall()
if choice1 == 1:
21 | P a g e
while True:
query_check1 = 'select cust_ID from
customers'
cursor.execute(query_check1)
cust_ids = cursor.fetchall()
PK_value = int(input(f"Please enter the
{PK_name[0][0]} of the record to delete: "))
for cust_id in cust_ids:
if PK_value == cust_id[0]:
break
else:
print(f"{PK_value} does not exist.")
continue
query_delete = f'DELETE FROM
{dic_tables[choice1]} WHERE {PK_name[0][0]} =
{PK_value}'
cursor.execute(query_delete)
con.commit()
fetch_data()
print(f"Successfully deleted record with
{PK_name[0][0]} = {PK_value}")
break
elif choice1 == 2:
while True:
query_check2 = 'select emp_ID from
employees'
cursor.execute(query_check2)
emp_ids = cursor.fetchall()
22 | P a g e
PK_value = input(f"Please enter the
{PK_name[0][0]} of the record to delete: ")
for emp_id in emp_ids:
if PK_value == emp_id[0]:
break
else:
print(f"{PK_value} does not exist.")
continue
query_delete = f'DELETE FROM
{dic_tables[choice1]} WHERE {PK_name[0][0]} =
"{PK_value}"'
cursor.execute(query_delete)
con.commit()
fetch_data()
print(f"Successfully deleted record with
{PK_name[0][0]} = {PK_value}")
break
elif choice1 == 3:
while True:
query_check3 = 'select cloth_ID from
inventory
' cursor.execute(query_check3)
cloth_ids = cursor.fetchall()
PK_value = input(f"Please enter the
{PK_name[0][0]} of the record to delete: ")
for cloth_id in cloth_ids:
if PK_value == cloth_id[0]:
break
else:
23 | P a g e
print(f"{PK_value} does not exist.")
continue
query_delete = f'DELETE FROM
{dic_tables[choice1]} WHERE {PK_name[0][0]} =
"{PK_value}"'
cursor.execute(query_delete)
con.commit()
fetch_data()
print(f"Successfully deleted record with
{PK_name[0][0]} = {PK_value}")
break
elif choice1 == 4:
while True:
query_check4 = 'select InvoiceNo from sales'
cursor.execute(query_check4)
invoice_nos = cursor.fetchall()
PK_value = int(input(f"Please enter the
{PK_name[0][0]} of the record to delete: "))
for invoice_no in invoice_nos:
if PK_value ==
invoice_no[0]: break
else:
print(f"{PK_value} does not exist.")
continue
query_delete = f'DELETE FROM
{dic_tables[choice1]} WHERE {PK_name[0][0]} =
{PK_value}'
cursor.execute(query_delete)
con.commit()
24 | P a g e
fetch_data()
print(f"Successfully deleted record with
{PK_name[0][0]} = {PK_value}")
break
elif choice2 not in [1,2,3,4,5,6]:
print("Please choose from only the above 6 options")
def customers_options():
"""
This function seems to be a placeholder or a stub that
does not contain any implementation.
"""
25 | P a g e
This function seems to be a placeholder for a function
that would provide options related to employees.
"""
print("*" * 50)
print(f"""1) Retrieve all employees data
2) Update Data of employees
3) Retrieve data of a particular employee
4) Add a new employee
5) Delete data from employees
6) Exit""")
def inventory_options():
"""
This function does not have any code inside it. It
appears to be a placeholder for inventory options.
"""
print("*" * 50)
print(f"""1) Retrieve all data from inventory
2) Update Data of inventory
3) Retrieve data of a particular cloth item
4) Add a new Item
5) Delete data from inventory
6) Exit""")
def
sales_options():
"""
This function seems to be a placeholder or a stub.
It does not contain any code or description of what it
is supposed to do.
26 | P a g e
"""
27 | P a g e
print("*" * 50)
print(f"""1) Retrieve all data from sales
2) Update Data of sales
3) Retrieve data of a particular sale
4) Add a new sale
5) Delete data from sales
6) Exit""")
def fetch_data():
"""
This function fetches data from a data source.
"""
query3 = 'SELECT * FROM ' + dic_tables[choice1]
cursor.execute(query3)
result = cursor.fetchall()
for record in result:
print(record)
def update_data():
"""
This function updates data in a database table based on
user input.
Parameters:
None
Returns
: None
"""
28 | P a g e
dic_data = {}
if choice1 == 1:
customer_update()
elif choice1 == 2:
employee_update()
elif choice1 == 3:
inventory_update()
elif choice1 == 4:
sales_update()
29 | P a g e
for col_name in column_names:
print(col_name)
column_name = input("Please enter the column name
you want to update: ")
new_val = input("Please enter the new value: ")
query5 = f'SELECT DATA_TYPE FROM
INFORMATION_SCHEMA.COLUMNS WHERE
TABLE_SCHEMA = "clothesmanagement" AND
TABLE_NAME = "{dic_tables[choice1]}" AND
COLUMN_NAME = "{PK_name[0][0]}"'
cursor.execute(query5)
PK_data_type = cursor.fetchone()[0]
30 | P a g e
con.commit()
print("Successfully updated")
except Exception:
print("Error occured")
def column_names():
"""
This function retrieves and prints the names of all
columns in the database table
specified by the 'choice1' variable.
Parameters:
None
Returns:
None. The function prints the column names directly.
"""
query4 = f"SELECT COLUMN_NAME FROM
INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME
= '{dic_tables[choice1]}' AND TABLE_SCHEMA =
'clothesmanagement'"
cursor.execute(query4)
for column_name in cursor:
print(column_name[0])
def customer_update():
"""
This function retrieves customer data from the
'customers' table and stores it in a dictionary.
31 | P a g e
It then prints the customer IDs and their
corresponding names.
Parameters:
None
Returns:
None. The function prints the customer data directly.
"""
global dic_data
dic_data = {}
queryc = 'SELECT cust_ID, cust_FirstName,
cust_LastName FROM customers order by cust_ID ASC'
cursor.execute(queryc)
data = cursor.fetchall()
for custid, firstname, Lastname in data:
dic_data[custid] = [firstname,Lastname]
for custid, firstname, Lastname in data:
print(f'{custid}: {dic_data[custid][0]}
{dic_data[custid][1]}')
def employee_update():
"""
This function retrieves employee data from the
'employees' table and stores it in a dictionary.
It then prints the employee IDs and their corresponding
names.
Parameters:
32 | P a g e
None
Returns:
None. The function prints the employee data directly.
"""
global dic_data
dic_data = {}
querye = 'SELECT Emp_ID, EmpName FROM employees'
cursor.execute(querye)
data = cursor.fetchall()
for empid, empname in data:
dic_data[empid] = empname
print(dic_data)
def inventory_update():
"""
This function retrieves inventory data from the
'inventory' table and stores it in a dictionary.
It then prints the cloth IDs and their corresponding
names.
Parameters:
None
Returns:
None. The function prints the inventory data directly.
"""
global dic_data
dic_data = {}
33 | P a g e
queryi = 'SELECT cloth_ID, cloth_name FROM inventory'
cursor.execute(queryi)
data = cursor.fetchall()
for clothid, clothname in data:
dic_data[clothid] = clothname
print(dic_data)
def sales_update():
"""
This function retrieves sales data from the 'sales' table
and stores it in a dictionary.
It then prints the Invoice numbers and their
corresponding cloth IDs.
Parameters:
None
Returns:
None. The function prints the sales data directly.
"""
global dic_data
dic_data = {}
querys = 'SELECT InvoiceNo, cloth_ID FROM sales'
cursor.execute(querys)
data = cursor.fetchall()
for invoiceno, clothid in data:
dic_data[invoiceno] = clothid
print(dic_data)
34 | P a g e
tempadmin_name = "Ritvik"
tempadmin_ID = 1809
tempadmin_password = "admin123"
while True:
print("*" * 50,"Welcome To Cloth Store Managament
System","*"*50)
print("""Please select from the below options:
1) Admin
2) User""")
print("*" * 50)
while True:
try:
Identify = input("Please enter your choice(or enter
'q' to exit): ")
if Identify.lower() == 'q':
print("Exited from program!")
sys.exit()
Identify = int(Identify)
break
except ValueError:
print("Invalid choice Input. Please enter again")
if Identify == 1:
while True:
try:
admin_name = input("Please enter your name:
")
except Exception:
print("Please enter a valid name.")
else:
35 | P a g e
break
while True:
try:
admin_ID = int(input("Please enter you
admin_ID (only 4 numbers): "))
except Exception:
print("Please enter only numeric value.")
else:
break
while True:
try:
admin_password = input("Please Enter your
password (12 characters maximum): ")
except Exception:
print("Please create a valid password.")
else:
break
def Authentication():
"""
Authenticates the admin user by comparing the
provided credentials with the stored ones.
Parameters:
None
Returns:
bool: True if the credentials match, False
otherwise.
36 | P a g e
"""
if tempadmin_name.lower() == admin_name and
tempadmin_ID == admin_ID and
tempadmin_password.lower() ==
admin_password.lower():
return True
else:
return False
Authentication()
if Authentication() == True:
def main_menu(admin_name):
"""
This function displays the main menu for the
admin user. It allows the admin to navigate through
different
management options for customers,
employees, inventory, and sales.
Parameters:
admin_name (str): The name of the admin
user.
Returns:
None. The function displays the main menu
and handles user input.
"""
global choice1
37 | P a g e
print("Welcome Admin: ", admin_name)
while True:
print("\rPlease wait. Loading... ")
time.sleep(3)
print("Main Menu: ")
print("*" * 50)
query1 = 'SHOW TABLES'
cursor.execute(query1)
num = 1
for table in cursor:
print(str(num) + ")", table[0],
"management")
num += 1
print("*" * 50)
while True:
try:
choice1 = int(input("Please enter your
choice (Enter 8 to exit): "))
except Exception:
print("Invalid Input. Please enter only
numeric value(1-4)")
else:
break
if choice1 == 1:
customers_options()
main()
elif choice1 == 8:
break
elif choice1 == 2:
38 | P a g e
employees_options()
main()
elif choice1 == 3:
inventory_options()
main()
elif choice1 == 4:
sales_options()
main()
else:
print("Invalid table choice.")
main_menu(admin_name)
else:
print("Authentication failed. Please check your
credentials.")
elif Identify == 2:
print("Welcome To Our Cloth Store")
while True:
print('*'*50)
print("""1) Generate Bill
2) Show membership details
3) Exit """)
print('*'*50)
while True:
try:
choice3 = int(input("Please enter
your choice(1-3): "))
except Exception:
39 | P a g e
print("Invalid Input. please enter only
numeric value.(1-3)")
else:
break
if choice3 == 1:
def display_clothes():
"""
This function retrieves and displays the
available clothes from the inventory.
Parameters:
None
Returns:
None. The function prints the available clothes
directly
. """
query_display = 'select cloth_ID, cloth_name,
cloth_price from inventory'
cursor.execute(query_display)
clothes = cursor.fetchall()
print("Available Products:")
for cloth in clothes:
print(f"{cloth[0]}. {cloth[1]} : ₹{cloth[2]}")
40 | P a g e
Processes an order by adding the selected
cloth item to the shopping cart, calculating the total cost,
and updating the sales database.
Parameters:
cart (list): The current shopping cart. Each item
in the cart is a tuple containing the cloth ID, total price,
quantity, invoice number, customer ID,
employee ID, sale date, and payment mode.
cloth_ID (str): The ID of the cloth item being
ordered.
Quantity (int): The quantity of the cloth item
being ordered.
InvoiceNo (int): The invoice number for the
order.
cust_ID (int): The ID of the customer placing
the
order. emp_ID (str): The ID of the employee
processing the order.
membership (str): The membership status of
the customer ('yes' or 'no').
Returns:
float: The total cost of the order after
applying any applicable discounts.
"""
queryorder = f'SELECT cloth_name, cloth_price
FROM inventory WHERE cloth_ID = "{cloth_ID}"'
cursor.execute(queryorder)
41 | P a g e
cloth = cursor.fetchone()
if cloth:
total_price = cloth[1] * Quantity
cart.append((cloth_ID, total_price, Quantity,
InvoiceNo, cust_ID, emp_ID, datetime.datetime.now(),
PaymentMode))
print(f"Added to cart: {Quantity} {cloth[0]}(s)
- Total: ₹{total_price}")
else:
print("Cloth not found.")
Parameters:
cart (list): A list of tuples, where each tuple
represents an item in the shopping cart. Each tuple
contains the cloth ID, total price, quantity, invoice
number, customer ID, employee ID, sale date, and
payment mode.
membership (str): A string indicating whether
the customer has a membership ('yes' or 'no').
42 | P a g e
Returns:
float: The total cost of the order after
applying any applicable discounts.
"""
print("Order Summary:")
total_cost = 0
for item in cart:
print(f"{item[0]} - Quantity: {item[2]}, Total:
₹{item[1]}")
if membership == 'yes':
total_cost += item[1] * 0.9
print(f"Total Cost: ₹{total_cost} after applied
discount of 10%")
else:
total_cost += item[1]
print(f"Total Cost: ₹
{total_cost}")
return total_cost
cart = []
InvoiceNo = int(input("Enter Invoice ID: "))
cust_ID = int(input("Enter Customer ID: "))
emp_ID = input("Enter Employee ID: ")
PaymentMode= input("Please enter the
payment mode(Cash or card): ")
while True:
display_clothes()
choice = input("\nEnter the cloth ID you want
43 | P a g e
to buy (or 'q' to finish): ")
44 | P a g e
if choice.lower() == 'q':
if cart:
total_cost = generate_bill(cart, cust[3])
for item in cart:
try:
query_insert = "INSERT INTO sales
(cloth_ID, SalePrice , Quantity, InvoiceNo, cust_ID,
Emp_ID, SaleDate, PaymentMode) VALUES (%s, %s, %s,
%s, %s, %s, %s, %s)"
cursor.execute(query_insert, item)
except mysql.Error as err:
if err.errno ==
errorcode.ER_DUP_ENTRY:
print("Invoice No. already exists.")
con.commit() # Commit the transaction
print("Thank you for shopping!")
break
try:
query = 'SELECT cust_ID, cust_FirstName,
cust_LastName, membership FROM customers WHERE
cust_ID = %s'
cursor.execute(query, (cust_ID,))
cust = cursor.fetchone()
if cust:
cloth_Id = choice
Quantity = int(input("Enter the quantity:
"))
45 | P a g e
total_cost = process_order(cart, cloth_Id,
Quantity, InvoiceNo, cust[0], emp_ID, cust[3])
else:
print("Customer not found.")
except ValueError:
print("Invalid input. Please enter a valid
cloth ID and quantity.")
except mysql.Error as err:
print(f"Database error: {err}")
elif choice3 == 2:
query = 'select cust_ID, cust_FirstName,
cust_LastName, membership from customers'
cursor.execute(query)
cust =
cursor.fetchall()
customer_update()
cust_id = int(input("Please enter the customer
ID: "))
for cust_ID, cust_FirstName, cust_LastName,
membership in cust:
if cust_ID == cust_id:
print(f"customer
name:{cust_FirstName}\ncustomer Last name:
{cust_LastName}\nMembership Taken:
{membership}")
break
else:
print("Customer Id not found")
46 | P a g e
elif choice3 == 3:
47 | P a g e
break
print("Thankyou for visiting us!")
48 | P a g e
OUTPUT
1) Welcome Page:
2) Admin Menu:
3)Customers
management:
49 | P a g e
3) Customers management:
4) Employees Management
50 | P a g e
5) Inventory Management
6) Sales Management
51 | P a g e
7) User
52 | P a g e
9) User : Membership Details
53 | P a g e
BIBLIOGRAPHY
1)https://www.academia.edu/122711380/Clothes
_store_management_system_project_report
2) Website used to study about the different functions
3) https://www.slideshare.net/slideshow/clothes-
store-management-system-project-report-
pdf/270891656#9
54 | P a g e