0% found this document useful (0 votes)
29 views26 pages

IP Project 1.0

Uploaded by

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

IP Project 1.0

Uploaded by

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

INFORMATICS

PRACTICES
PROJECT FILE

SHOE STORE

DONE BY
JANYA VYAS & AALIF AZA
CLASS 12-A
INDEX

3. Acknowledgment

4. Software description – about Python and MySQL

5. Introduction

7. Output Screens

9. MySQL Tables

11. Source Code

13. Bibliography
ACKNOWLEDGMENT

First and foremost, I would like to express my deepest gratitude to my

parents. Their unwavering support, encouragement, and belief in my

abilities have been the cornerstone of my success.

I am profoundly grateful to Mr. Fariyad, my Informatics Practices teacher,

whose guidance and expertise has been invaluable. His passion and

dedication to teaching has inspired me to dive deeper into the subject. His

constructive feedback and insightful suggestions were instrumental in

refining my work.

I would also like to extend my heartfelt thanks to Mr. Rocky Miller, the

principal, for providing us with all the necessary facilities required to carry

out this project.


SOFTWARE DESCRIPTION

PYTHON
 Python is a popular programming language known for being easy to learn
and use. It’s designed to be simple and readable, which makes it easy for
beginners to get started.
 It can be used in many different areas like web development, data
analysis, artificial intelligence, and automation.
 It has a large library of built-in tools that help with things like file
management, networking, and even web scraping.
 It has a rich set of external libraries and frameworks for almost any task.
Eg: Pandas and Matplotlib for data science.
 In conclusion, Python’s simplicity, versatility, large ecosystem, and
active community make it ideal for beginners and experts.

MySQL
 MySQL is a popular, free database system that helps store and manage
data in a structured way. It uses a language called SQL (Structured Query
Language) to organize, search, and modify data.
 It is commonly used in web applications and is the database component
of the popular LAMP stack (Linux, Apache, MySQL, PHP/Python).It is
used as the back end.
 IT stores data in tables and allows you to perform various operations such
as querying, updating, and deleting data. It’s also very scalable, so it can
handle small projects or huge websites with tons of users and data.
 It is handle large amounts of data and is compatible with many
programming languages like PHP, Python, and Java.
 In conclusion, MySQL is a powerful and reliable database system that
helps manage and organize data efficiently.
INTRO AND BACKGROUND

Project on ‘SHOE STORE’

 Front end : Python

 Back end : MySQL

 Host : localhost

 User : root

 Password : 1234

 Database : Shoe store


Output screens
tables
UPDATED TABLES:
SOURCE CODE
import mysql.connector

from datetime import datetime

# Connect to the MySQL database

db = mysql.connector.connect(

host="localhost",

user="root",

password="1234",

database="shoe_store" # Name of the database we are using


)

cursor = db.cursor()

# Class to represent a shoe

class Shoe:

def __init__(self, shoe_id, name, price, size, color):

self.shoe_id = shoe_id # Unique identifier for the shoe

self.name = name # Name of the shoe

self.price = price # Price of the shoe

self.size = size # Size of the shoe

self.color = color # Color of the shoe

# Class to represent a shopping cart

class Cart:

def __init__(self):

self.items = [] # Initialize an empty list to store items in the cart

def add_shoe(self, shoe):

self.items.append(shoe) # Add a shoe to the cart

def remove_shoe(self, index):

# Remove a shoe from the cart based on its index

if 0 <= index < len(self.items):

del self.items[index] # Delete the shoe from the cart

print("Shoe removed from cart.")


else:

print("Invalid index.") # Print error if index is invalid

def view_cart(self):

total_price = 0 # Initialize total price

# Loop through each shoe in the cart and display its details

for i, shoe in enumerate(self.items):

print(f"{i + 1}. {shoe.name} - ${shoe.price:.2f} - Size: {shoe.size} - Color: {shoe.color}")

total_price += shoe.price # Add shoe price to total

print(f"Total Price: ${total_price:.2f}") # Display total price

return total_price # Return total price

# Function to display available shoes from the database

def display_shoes():

cursor.execute("SELECT * FROM shoe") # SQL command to select all shoes

shoes = cursor.fetchall() # Fetch all results

# Loop through the results and display each shoe's details

for i, (shoe_id, name, price, size, color) in enumerate(shoes):

print(f"{i + 1}. {shoe_id} - {name} - ${price:.2f} - Size: {size} - Color: {color}")

# Function to add a new shoe to the database

def add_shoe():

name = input("Enter shoe name: ")

price = float(input("Enter shoe price: "))

size = input("Enter shoe size: ")


color = input("Enter shoe color: ")

cursor.execute(

"INSERT INTO shoe (name, price, size, color) VALUES (%s, %s, %s, %s)",

(name, price, size, color)

) # Add shoe to database

db.commit() # Commit the transaction

print("Shoe added successfully.")

# Admin login function

def admin_login():

username = input("Enter admin username: ")

password = input("Enter admin password: ")

if username == "admin" and password == "12345":

print("Admin login successful!")

while True:

print("\nAdmin Options:")

print("1. Add Shoe")

print("2. Display Shoes")

print("3. View Reports")

print("4. Exit Admin")

choice = input("Enter your choice: ")

if choice == "1":
add_shoe() # Call function to add a shoe

elif choice == "2":

display_shoes() # Display available shoes

elif choice == "3":

view_reports() # Call function to view reports

elif choice == "4":

print("Exiting admin section.")

return # Exit the admin menu and return to the main menu

else:

print("Invalid choice. Please try again.")

else:

print("Invalid admin credentials.")

# Function to view reports

def view_reports():

while True:

print("\nReports Menu:")

print("1. Display List of Customers")

print("2. Display Sales for the Day")

print("3. Display Total Sales")

print("4. Exit Reports")

choice = input("Enter your choice: ")

if choice == "1":

display_customers() # Call function to display customers


elif choice == "2":

display_sales_for_day()

elif choice == "3":

display_total_sales() # Call function to display total sales

elif choice == "4":

print("Exiting reports section.")

return # Exit the reports menu

else:

print("Invalid choice. Please try again.")

# Function to display the list of customers

def display_customers():

cursor.execute("SELECT * FROM customers") # SQL command to select all customers

customers = cursor.fetchall() # Fetch all results

# Loop through the results and display each customer's details

for i, customer in enumerate(customers):

if len(customer) == 5: # Ensure there are exactly 5 fields to unpack

customer_id, name, email, phone, total_amount = customer

print(f"{i + 1}. {name} - Email: {email} - Phone: {phone} - Total Amount: ${total_amount:.2f}")

else:

print(f"{customer}")

# Function to display sales for the day

def display_sales_for_day():

today = datetime.now().date() # Get today's date


print(today)

#cursor.execute("SELECT SUM(amount) FROM purchases WHERE purchase_date = %s", (today,)) #


SQL command to sum sales for today

cursor.execute("SELECT SUM(amount) FROM purchases WHERE purchase_date like '%" +


str(today) + "%';" )

total_sales_today = cursor.fetchone()[0] # Fetch the result

print(f"Total Sales for Today: ${total_sales_today if total_sales_today else 0:.2f}")

# Function to display total sales

def display_total_sales():

cursor.execute("SELECT SUM(amount) FROM purchases") # SQL command to sum all sales

total_sales = cursor.fetchone()[0] # Fetch the result

print(f"Total Sales: ${total_sales if total_sales else 0:.2f}")

# Function to handle checkout process

def checkout(cart):

name = input("Enter your name: ")

email = input("Enter your email: ")

phone = input("Enter your phone number: ")

# Save customer information to the database

cursor.execute(

"INSERT INTO customers (name, email, phone, total_amount) VALUES (%s, %s, %s, %s)",

(name, email, phone, 0) # Initialize total_amount to 0 for new customers

)
db.commit() # Commit the transaction

# Get the customer ID of the newly added customer

customer_id = cursor.lastrowid

total_price = cart.view_cart() # View cart and get total price

purchase_date = datetime.now() # Get the current date and time

# Insert each shoe in the cart into the purchases table

for shoe in cart.items:

cursor.execute(

"INSERT INTO purchases (shoe_name, customer_id, shoe_id, purchase_date, amount) VALUES


(%s, %s, %s, %s, %s)",

(shoe.name, customer_id, shoe.shoe_id, purchase_date, shoe.price)

db.commit() # Commit the transaction

# Update the total_amount for the customer

cursor.execute(

"UPDATE customers SET total_amount = total_amount + %s WHERE id = %s",

(total_price, customer_id)

db.commit() # Commit the transaction

print(f"Purchase recorded successfully. Total amount: ${total_price:.2f}")


# Main function to run the program

def main():

print("Welcome to Kickex!") # Welcome message

cart = Cart() # Initialize the shopping cart

while True: # Start an infinite loop for user interaction

print("\nMain Menu:")

print("1. Display available shoes")

print("2. Add shoe to cart")

print("3. View cart")

print("4. Remove shoe from cart")

print("5. Checkout")

print("6. Exit")

print("7. Admin Login") # New option for admin login

choice = input("Enter your choice: ") # Get user choice

if choice == "1":

display_shoes() # Display available shoes

elif choice == "2":

shoe_index = int(input("Enter the shoe number to add to cart: ")) - 1

cursor.execute("SELECT * FROM shoe") # Fetch all shoes again

shoes = cursor.fetchall()

if 0 <= shoe_index < len(shoes):

shoe = Shoe(*shoes[shoe_index]) # Create a Shoe object


cart.add_shoe(shoe) # Add shoe to cart

print(f"{shoe.name} added to cart.")

else:

print("Invalid shoe number.")

elif choice == "3":

cart.view_cart() # View cart

elif choice == "4":

index = int(input("Enter the index of the shoe to remove from cart: ")) - 1

cart.remove_shoe(index) # Remove shoe from cart

elif choice == "5":

checkout(cart) # Call checkout function

elif choice == "6":

print("Goodbye!") # Exit message

break

elif choice == "7":

admin_login() # Call admin login function

else:

print("Invalid choice. Please try again.")

if __name__ == "__main__":

main() # Run the main function

# Close the database connection

db.close()
BIBLIOGRAPHY

 Open AI

 https://www.slideshare.net/slideshow/informatics-
practices-information-practices-project/245214767

 https://www.scribd.com/document/617802622/IP-Project
 https://engineersplanet.com/python-projects-class-xi-xii/

 https://www.slideshare.net/slideshow/social-media-site-
user-management-system-class-12th-informatics-
practices-project-report/256144984

 https://www.scribd.com/document/565971169/Vikash-
Sharma-Ip-Project-Class-12

 https://www.tutorialaicsip.com/xii-practicals-ip/ip-
project-class-12-python-2/

 https://www.academia.edu/117069120/
CBSE_class_12_informatics_practices_project_file_hosp
ital_management_

 https://www.scribd.com/document/525704032/Shoe-
Billing-Project

You might also like