C.S Project Presentation
C.S Project Presentation
BANGLORE EAST
NAME : P.PRANAV
CLASS : XII – K
ROLL NO : 23
1
INDEX
3
ACKNOWLEDGEMENT
4
OBJECTIVE
Hardware Requirements:
1.) Computer
2.) Storage
Software Requirements:
1.) MY SQL Database
2.) Python
3.) Python MY SQL connector module
4.) Datetime module
5.) IDLE
6.) Windows OS
5
SOURCE CODE
MYSQL:
6
create table orders(order_id int
primary key
auto_increment NOT NULL,
customer_id int, order_date
timestamp default
current_timestamp,
product_id int, quantity int,
total_price float(10,2)
foreign key(customer_id)
references
customes(customer_id)
foreign key(product_id)
references
products(product_id))
7
PYTHON:
# C.S PROJECT
import mysql.connector
from datetime import datetime
cursor = db.cursor()
def add_product():
product_name = input("Enter product name: ")
category = input("Enter product category: ")
price = float(input("Enter product price: "))
stock = int(input("Enter product stock: "))
8
# Function to update a product
def update_product():
product_id = int(input("Enter the product ID to update: "))
cursor.execute("SELECT * FROM products WHERE product_id = %s",
(product_id,))
product = cursor.fetchone()
if product:
print(f"Current Product: {product}")
product_name = input(f"Enter new product name ({product[1]}): ") or
product[1]
category = input(f"Enter new category ({product[2]}): ") or product[2]
price = input(f"Enter new price ({product[3]}): ") or product[3]
stock = input(f"Enter new stock ({product[4]}): ") or product[4]
9
# -------------------- CUSTOMER MANAGEMENT ----------------------
10
# Function to delete a customer
def delete_customer():
customer_id = int(input("Enter the customer ID to delete: "))
cursor.execute("SELECT * FROM customers WHERE
customer_id = %s", (customer_id,))
customer = cursor.fetchone()
if customer:
cursor.execute("DELETE FROM customers WHERE
customer_id = %s", (customer_id,))
db.commit()
print(f"Customer ID {customer_id} deleted successfully!")
else:
print("Customer not found!")
11
# Function to create an order
def create_order():
customer = find_customer_by_phone()
if customer is None:
print("Customer not found. Please add the customer first.")
add_customer()
customer = find_customer_by_phone()
customer_id = customer[0]
print(f"Customer ID: {customer_id}, Name: {customer[1]}")
while True:
product_id = int(input("Enter product ID (0 to finish): "))
if product_id == 0:
break
cursor.execute("SELECT * FROM products WHERE product_id
= %s", (product_id,))
product = cursor.fetchone()
if product is None:
print("Product not found.")
continue
13
# -------------------- MAIN MENU ----------------------
def menu():
while True:
print("\n******************** WELCOME TO HEAVENLY
TREAT ********************")
print("\n PRODUCT MANAGEMENT....")
print("1. Add Product")
print("2. View Products")
print("3. Update Product")
print("4. Delete Product")
print("\n CUSTOMER MANAGEMENT....")
print("5. Add Customer")
print("6. View Customers")
print("7. Update Customer")
print("8. Delete Customer")
print("\n ORDER MANAGEMENT....")
print("9. Create Order")
print("10. View Orders")
print("11. Sales Report")
print("12. Exit")
if choice == 1:
add_product()
elif choice == 2:
view_products()
elif choice == 3:
update_product()
elif choice == 4:
delete_product()
elif choice == 5:
add_customer()
14
elif choice == 6:
view_customers()
elif choice == 7:
update_customer()
elif choice == 8:
delete_customer()
elif choice == 9:
create_order()
elif choice == 10:
view_orders()
elif choice == 11:
sales_report()
elif choice == 12:
break
else:
print("Invalid choice. Try again.")
15
OUTPUT:
17
18
BIBLIOGRAPHY
• www.scribd.com
• www.slideshare.net
• https://githum.com
• www.freeprojectz.com
19