Restaurant Management Coding

Download as pdf or txt
Download as pdf or txt
You are on page 1of 12

from os import sys

import mysql.connector as con

password=''

def login():

global password

print('='*15+'welcome to login'+'='*15)

password=input('enter password:')

login()

try:

mycon=con.connect(host='127.0.0.1',
user='root',passwd=password)

cursor=mycon.cursor()

except:

print('='*15+'invalid password'+'='*15,'\n')

login()

mycon=con.connect(host='127.0.0.1',
user='root',passwd=password)

cursor=mycon.cursor()

def create():

cursor.execute("create database if not exists


resturant_managment")

cursor.execute("use resturant_managment")

cursor.execute("create table if not exists staff(staff_no


varchar(50) primary Key, name varchar(255), contact
varchar(32), age varchar(32), gender varchar(32), post
varchar(32), salary varchar(32))")

cursor.execute("create table if not exists inventory(item_no


varchar(50) primary Key, item varchar(32) , quantity
varchar(32), rate int)")

cursor.execute("create table if not exists bill(bill_no


varchar(50) primary Key, name varchar(255), contact
varchar(15), total_bill int)")

mycon.commit()

def menu():

print('='*15+'main menu'+'='*15)

print('1.staff details')

print('2.inventory details')

print('3.bill details')

print('4.exit')

menu_input=int(input('enter your choice:'))

if menu_input==1:

staff()

elif menu_input==2:

inventory()

elif menu_input==3:

bill()

elif menu_input==4:

exitt()

else:

print('please enter valid choice!')

menu()

def staff():
print('='*15+'staff menu'+'='*15)

print('1.add staff member')

print('2.update staff member')

print('3.remove staff member ')

print('4.show staff details')

print('5.bacK to menu')

staff_input=int(input('enter your choice:'))

if staff_input==1:

add_staff()

elif staff_input==2:

update_staff()

elif staff_input==3:

remove_staff()

elif staff_input==4:

show_staff()

else:

menu()

def add_staff():

dic=['n','n','no','no','no']

ans=''

while ans not in dic:

print('='*15+'enter staff details'+'='*15)

staff_no=input('enter staff id::')

staff_name=str(input('enter staff name::'))

staff_contact=input('enter staff contact info::')

staff_age=input('enter staff age::')

staff_gender=input('enter staff gender::')


staff_post=input('enter staff designation::')

staff_salary=input('enter staff salary::')

cursor=mycon.cursor()

cursor.execute(f"insert into staff


values({staff_no},'{staff_name}',{staff_contact},{staff_age},'{staff
_gender}','{staff_post}',{staff_salary})")

mycon.commit()

ans=input('do you want to add more details(y/n):')

staff()

def update_staff():

print('='*15+'update staff details'+'='*15)

print('1.update name')

print('2.update contact')

print('3.update age')

print('4.update post')

print('5.update salary')

print('bacK')

update_input=int(input('enter your choice:'))

if update_input==1:

update_staff_name()

elif update_input==2:

update_staff_contact()

elif update_input==3:

update_staff_age()

elif update_input==4:

update_staff_post()

elif update_input==5:
update_staff_salary()

else:

staff()

def update_staff_name():

update_staff_id=input('enter id no. of the staff:')

update_staff_name_input= input('enter new name of the


staff:')

cursor.execute("update staff set name='{}' where


staff_no={}".format(update_staff_name_input, update_staff_id))

mycon.commit()

update_staff()

def update_staff_contact():

update_staff_id=input('enter id no. of the staff:')

update_staff_contact_input= input('enter new contact of


the staff:')

cursor.execute("update staff set contact={} where


staff_no={}".format(update_staff_contact_input,
update_staff_id))

mycon.commit()

update_staff()

def update_staff_age():

update_staff_id=input('enter id no. of the staff:')

update_staff_age_input= input('enter new age of the staff:')

cursor.execute("update staff set age={} where


staff_no={}".format(update_staff_age_input, update_staff_id))

mycon.commit()

update_staff()
def update_staff_post():

update_staff_id=input('enter id no. of the staff:')

update_staff_post_input= input('enter new post of the


staff:')

cursor.execute("update staff set post='{}' where


staff_no={}".format(update_staff_post_input, update_staff_id))

mycon.commit()

update_staff()

def update_staff_salary():

update_staff_id=input('enter id no. of the staff:')

update_staff_salary_input= input('enter new salart of the


staff:')

cursor.execute("update staff set salary={} where


staff_no={}".format(update_staff_salary_input, update_staff_id))

mycon.commit()

update_staff()

def remove_staff():

print('='*15+'remove staff details'+'='*15)

remove_input=input('enter id no. of staff to remove:')

cursor=mycon.cursor()

cursor.execute("delete from staff where


staff_no={}".format(remove_input))

mycon.commit()

print(f'staff no. {remove_input} is removed successfully!!')

staff()
def show_staff():

print('='*15+'all staff details'+'='*15)

cursor.execute("select * from staff")

detail=cursor.fetchall()

print('staff no. | name | contact | age | post | salary\n')

for row in detail:

print(row)

staff()

def inventory():

print('='*15+'inventory menu'+'='*15)

print('1.add item')

print('2.update item')

print('3.remove item')

print('4.show item')

print('bacK to menu')

inventory_input=int(input('enter your choice:'))

if inventory_input==1:

add_item()

elif inventory_input==2:

update_item()

elif inventory_input==3:

remove_item()

elif inventory_input==4:

show_item()

else:

menu()

def add_item():
dic=['n','n','no','no','no']

ans=''

while ans not in dic:

print('='*15+'enter item details'+'='*15)

item_no=input('enter item no. ::')

item_name=str(input('enter item name::'))

item_quantity=int(input('enter item quantity::'))

item_rate=int(input('enter item rate::'))

cursor=mycon.cursor()

cursor.execute(f"insert into inventory


values({item_no},'{item_name}',{item_quantity},{item_rate})")

mycon.commit()

ans=input('do you want to add more details(y/n):')

inventory()

def update_item():

print('='*15+'update item details'+'='*15)

print('1.update name')

print('2.update quantity')

print('3.update rate')

print('bacK')

update_input=int(input('enter your choice:'))

if update_input==1:

update_item_name()

elif update_input==2:

update_item_quantity()

elif update_input==3:

update_input_rate()
else:

inventory()

def update_item_name():

update_item_no=input('enter item no. :')

update_item_name_input= input('enter new name of the


item:')

cursor.execute("update inventory set name='{}' where


item_no={}".format(update_item_name_input, update_item_no))

mycon.commit()

update_item()

def update_item_quantity():

update_item_no=input('enter item no. :')

update_item_quantity_input= input('enter new quantity


of the item:')

cursor.execute("update inventory set quantity={} where


item_no={}".format(update_item_quantity_input,
update_item_no))

mycon.commit()

update_item()

def update_staff_age():

update_item_no=input('enter item no. :')

update_item_rate_input= input('enter new rate of the item:')

cursor.execute("update inventory set rate={} where


item_no={}".format(update_item_rate_input, update_item_no))

mycon.commit()

update_item()
def remove_item():

print('='*15+'remove item details'+'='*15)

remove_input=input('enter item no. to remove:')

cursor=mycon.cursor()

cursor.execute("delete from inventory where


item_no={}".format(remove_input))

mycon.commit()

print(f'item no. {remove_input} is removed successfully!!')

inventory()

def show_item():

print('='*15+'all item details'+'='*15)

cursor.execute("select * from inventory")

detail=cursor.fetchall()

print('item no. | item name | quantity | rate\n')

for row in detail:

print(row)

inventory()

def bill():

print('='*15+'bill menu'+'='*15)

print('1.add bill')

print('2.remove bill')

print('3.show bill')

print('bacK to menu')

bill_input=int(input('enter your choice:'))

if bill_input==1:
add_bill()

elif bill_input==2:

remove_bill()

elif bill_input==3:

show_bill()

else:

bill()

def add_bill():

dic=['n','n','no','no','no']

ans=''

while ans not in dic:

print('='*15+'enter bill details'+'='*15)

bill_no=input('enter bill no. ::')

bill_name=str(input('enter customer name::'))

bill_contact=int(input('enter customer contact::'))

bill_amount=int(input('enter total amount::'))

cursor=mycon.cursor()

cursor.execute(f"insert into bill


values({bill_no},'{bill_name}',{bill_contact},{bill_amount})")

mycon.commit()

ans=input('do you want to add more details(y/n):')

bill()

def remove_bill():

print('='*15+'remove bill details'+'='*15)

remove_input=input('enter bill no. to remove:')

cursor=mycon.cursor()
cursor.execute("delete from bill where
bill_no={}".format(remove_input))

mycon.commit()

print(f'bill no. {remove_input} is removed successfully!!')

bill()

def show_bill():

print('='*15+'all bill details'+'='*15)

cursor.execute("select * from bill")

detail=cursor.fetchall()

print('bill no. | customer name | contact | total amount\n')

for row in detail:

print(row)

bill()

def exitt():

print('='*15+'exit'+'='*15)

sys.exit(0)

if __name__=='__main__':

create()

menu()

You might also like