Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
20 views12 pages

Kishore Project Code

The document is a Python script for a bakery management system that connects to a MySQL database. It allows an admin to manage a menu of products by adding, removing, or updating items, and enables customers to purchase items while generating a bill. The script includes functions for both admin and customer logins, along with a main menu for navigation.
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)
20 views12 pages

Kishore Project Code

The document is a Python script for a bakery management system that connects to a MySQL database. It allows an admin to manage a menu of products by adding, removing, or updating items, and enables customers to purchase items while generating a bill. The script includes functions for both admin and customer logins, along with a main menu for navigation.
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/ 12

import time

import mysql.connector

con=mysql.connector.connect(host='localhost',user='root',password='kishore720
808')

cursor=con.cursor()

cursor.execute("CREATE DATABASE IF NOT EXISTS shop")

cursor.execute("use shop")

cursor.execute("CREATE TABLE IF NOT EXISTS Menu(produt_id int,product_name


char(20),product_price int)")

query = ("SELECT * FROM Menu")

cursor.execute(query)

results = cursor.fetchall()

if results==[]:

cursor.execute("insert into Menu values(1,'Bread',50)")

cursor.execute("insert into Menu values(2,'Cake',800)")

cursor.execute("insert into Menu values(3,'Juice',40)")

cursor.execute("insert into Menu values(4,'Ice Cream',80)")

cursor.execute("insert into Menu values(5,'Milk shake',50)")


cursor.execute("insert into Menu values(6,'Biscuits',30)")

con.commit()

def display_items(cursor):

query=("SELECT * FROM Menu")

cursor.execute(query)

results=cursor.fetchall()

print("List of items: ")

print("ID","Name","Price",sep=" ")

for each in results:

print(each[0],each[1],each[2],sep=" ")

def admin_login(con,cursor):

print("=======================================================")

print(" ////Welcome! You are log in as Admin! //// ")

print("=======================================================")

print("Here are the list of choices:")

print("Choice 1: Add an item",


"Choice 2: Remove an item",

"Choice 3: Update item price",

"Choice 4: See all the items",

"Choice 5:Exit",

sep="\n")

choice = int(input("Enter your choice: "))

print()

time.sleep(0.5)

if choice==1:

print("What you like to add?")

produt_id = str(int(input("Enter the product id: ")))

product_name = input("Enter the product name: ")

product_price = input("Enter the product price: ")

try:

query=("insert into Menu values


("+produt_id+","+"'"+product_name+"'"+","+product_price+");")

cursor.execute(query)

con.commit()
print("The item has been added to the list!")

except Exception as e:

print("Error occured!")

time.sleep(1)

admin_login(con,cursor)

elif choice==2:

display_items(cursor)

print("Which item you would like to remove?")

id = str(int(input("Enter product id:")))

try:

query=("DELETE FROM Menu WHERE produt_id=("+id+")")

cursor.execute(query)

con.commit()

print("The item has been removed from the shop!")

except Exception as e:

print("Invalid item!")

time.sleep(1)

admin_login(con,cursor)

elif choice==3:
display_items(cursor)

print("Which item price you would like to update?")

id=str(int(input("Enter product ID:")))

price=str(int(input("Enter the updated price:")))

try:

query=("UPDATE Menu SET product_price=("+price+") WHERE


produt_id=("+id+")")

cursor.execute(query)

con.commit()

print("The item price has been updated!")

except Exception as e:

print("Invalid Product ID!")

time.sleep(1)

admin_login(con,cursor)

elif choice==4:

display_items(cursor)

time.sleep(1.5)

admin_login(con,cursor)

elif choice==5:

main()
else:

print("Invalid Choice!")

time.sleep(1)

admin_login(con,cursor)

def customer_login(con,cursor):

print("============================================================")

print(" //// Welcome,You are log in as a Customer! //// ")

print("============================================================")

print("Here is the list of choices:")

print("Choice 1: For Buy", "Choice 2: Exit",sep="\n")

choice = int(input("Enter your choice:"))

if(choice==1):

name = input("Enter the Name:")

phonenumber=int(input("Enter the Phone Number: "))

print("What do you want to buy ???",name)

time.sleep(0.5)

display_items(cursor)

print()
total = 0

items=[]

while 1:

id=str(int(input("Enter the product ID: ")))

quantity =int(input("Enter the quantity: "))

try:

query=("SELECT * FROM Menu WHERE produt_id =("+id+")")

cursor.execute(query)

result=cursor.fetchone()

total+= result[2]*quantity

items.append([result[1],quantity])

i=input("Anything else?Answer Y for Yes and N for No! ")

if(i=='N' or i=='n'):

break

except Exception as e:

print("Invalid Entry!")

print(e)

break

if(total!=0):
print("============================================================")

print(" //// YOUR BILL //// ")

print("============================================================")

print("Customer Name: ",name)

print("Customer Phone Number: ",phonenumber)

import mysql.connector

cnx = mysql.connector.connect(

host="localhost",

user="root",

password="kishore720808")

cur = cnx.cursor()

cur.execute("SELECT CURDATE()")

row = cur.fetchone()

print("Date: {0}".format(row[0]))
cnx.close()

print("Items Are Buyed:")

for each in items:

print(each[0],each[1],sep=":")

print("===================")

print(f"Total: {total}")

print("===================")

print()

print("============================================================")

print(" //// THANK YOU //// ")

print(" //// HAVE A NICE DAY !! //// ")

print("============================================================")

print()

time.sleep(1)

customer_login(con,cursor)

elif choice==2:

main()

else:

print("Invalid Choice!")

time.sleep(1)
customer_login(con,cursor)

def main():

inloop = 1

while inloop:

print()

print(" ===================### CS PROJECT (083)


###====================== ")

print("
================================================================= ")

print("
|.........................................................../////_WELCOME_/////...................................
.........................| ")

print(" |................................................................./////
_TO_/////.......................................................................| ")

print("
|........................................../////_BAKERY_MANAGEMENT_/////..............................
...............| ")

print(" |............................................................../////
_AND_/////......................................................................| ")

print("
|......................................................../////_SYSTEM_/////..........................................
..........................| ")
print("
================================================================= ")

print("How you want to Enter?")

print("Choice 1: Admin Login","Choice 2: Customer Login", "Choice 3:


Exit",sep="\n")

choice = input("Enter your choice:")

if choice=='1':

password = input("Enter the password: ")

if password=="1":

admin_login(con,cursor)

else:

print("Incorrect Password!")

time.sleep(1)
elif choice=='2':

customer_login(con,cursor)

elif choice=='3':

exit()

else:

print("Invalid Choice!")

main()

You might also like