def order(self): self.msg = messagebox.askyesno("asking", "do you went to place this order ?") if self.msg: with connection_pool.getconn() as connection: with connection.cursor() as cursor: cursor.execute( "insert into public.order(first_name, last_name, total_price) values(%s, %s, %s)", ("Sad", "Eamin", self.total_price)) connection.commit() cursor.close() messagebox.showinfo(title="success", message="successfully") with connection_pool.getconn() as connection: with connection.cursor() as cursor1: cursor1.execute( "select id from public.order order by id DESC limit 1 ;" ) self.order_id = tuple(cursor1) for i in self.treeview_order_2.get_children(): print(self.order_id, self.treeview_order_2.item(i)) with connection_pool.getconn() as connection: with connection.cursor() as cursor1: cursor1.execute( "insert into order_items(no, name, quantity, price, order_id) values(%s, %s, %s, %s, %s);", (self.treeview_order_2.item(i)["text"], self.treeview_order_2.item(i)["values"] [0], self.treeview_order_2.item( i)["values"][1], self.treeview_order_2.item(i)["values"] [2], str(self.order_id[0][0])))
def delete(self): self.ci_2 = self.treeview.focus() self.table_value_2 = self.treeview.item(self.ci_2) print(self.table_value_2, self.table_value_2["text"][0]) with connection_pool.getconn() as connection: with connection.cursor() as cursor1: cursor1.execute("delete from public.order Where id = %s;", (self.table_value_2["text"], ))
def refresh(self): self.tv.delete(*self.tv.get_children()) with connection_pool.getconn() as connection: with connection.cursor() as cursor: cursor.execute( "select id as total, frist_name, last_name from users order by total asc" ) for item in list(cursor): self.tv.insert('', "end", text=f"{item[0]}", values=(f'{item[1]}', f'{item[2]}'))
def Update(self): popup = messagebox.askyesno(title="asking", message="Do you went to update this order") if popup: with connection_pool.getconn() as connection: with connection.cursor() as cursor: cursor.execute( "Update public.order set total_price=%s Where id=%s", (self.total_price, self.table_value_4["text"])) connection.commit() cursor.close() messagebox.showinfo(title="success", message="successfully")
def delete(self): ci = self.tv.focus() table_value = self.tv.item(ci) if len(table_value["text"]) == 0 or len(table_value["values"]) == 0: messagebox.showerror( "please select something", "Select the user which one should you went to delete") else: popup = messagebox.askyesno( title="asking", message="Do you went to delete this user") if popup: with connection_pool.getconn() as connection: with connection.cursor() as cursor: cursor.execute("delete from users Where id=%s", (table_value['text'], ))
def delete(): ci = tv.focus() table_value = tv.item(ci) if len(table_value["text"]) == 0 or len(table_value["values"]) == 0: messagebox.showerror( "warning", "Select any item which one should you went to edit") else: popup = messagebox.askyesno( title="asking", message="Do you went to delete this item") if popup: with connection_pool.getconn() as connection: with connection.cursor() as cursor: cursor.execute("delete from menu Where id=%s", (table_value['text'], ))
def refresh(self): self.treeview.delete(*self.treeview.get_children()) with connection_pool.getconn() as connection: with connection.cursor() as cursor: cursor.execute( "select id as total, first_name, last_name, total_price from public.order order by total asc" ) for item in list(cursor): self.treeview.insert('', "end", text=f"{item[0]}", values=(f'{item[1]}', f'{item[2]}', f'{item[3]}')) self.treeview.column("#0", anchor="center") self.treeview.column("first_name", anchor="center") self.treeview.column("last_name", anchor="center") self.treeview.column("total_price", anchor="center")
def main(): tv.delete(*tv.get_children()) with connection_pool.getconn() as connection: with connection.cursor() as cursor: cursor.execute( "select id as total, name, price, type from menu Where type = 'Main' order by total" ) for item in list(cursor): tv.insert('', "end", text=f"{item[0]}", values=(f'{item[1]}', f'{item[2]}', f'{item[3]}')) tv.column("#0", anchor="center") tv.column("name", anchor="center") tv.column("price", anchor="center") tv.column("type", anchor="center")
def Save(self): if len(self.entry_id.get()) == 0 or \ len(self.entry_first_name.get()) == 0 or \ len(self.entry_last_name.get()) == 0 or len(self.entry_password.get()) == 0: messagebox.showerror( "warning", "Those entry fields are empty please fill it.") else: with connection_pool.getconn() as connection: with connection.cursor() as cursor: qu = f"insert into users(id, frist_name, last_name, password) values('{self.strvar1.get()}', '{self.strvar2.get()}', '{self.strvar3.get()}', '{self.strvar4.get()}')" print(qu.strip()) cursor.execute(qu) connection.commit() cursor.close() messagebox.showinfo(title="success", message="successfully")
def all(self): self.treeview_items.delete(*self.treeview_items.get_children()) with connection_pool.getconn() as connection: with connection.cursor() as cursor: cursor.execute( "select id as total, name, price, type from menu order by total" ) for item in list(cursor): self.treeview_items.insert('', "end", text=f"{item[0]}", values=(f'{item[1]}', f'{item[2]}', f'{item[3]}')) self.treeview_items.column("#0", anchor="center") self.treeview_items.column("name", anchor="center") self.treeview_items.column("price", anchor="center") self.treeview_items.column("type", anchor="center")
def Save(): if len(entry_id.get()) == 0 or \ len(entry_name.get()) == 0 or \ len(entry_price.get()) == 0 or len(combobox_type.get()) == 0 or type(entry_price) == "<class 'float'>": messagebox.showerror("warning", "Id id empty please fill it.") else: with connection_pool.getconn() as connection: with connection.cursor() as cursor: cursor.execute( "insert into menu(id, name, price, type) " "values(%s, %s, %s, %s)", (entry_id.get(), entry_name.get(), entry_price.get(), combobox_type.get())) connection.commit() cursor.close() messagebox.showinfo(title="success", message="successfully")
def Update(): popup = messagebox.askyesno( title="asking", message="Do you went to update this item") if popup: if len(entry_id.get()) == 0 or \ len(entry_name.get()) == 0 or \ len(entry_price.get()) == 0 or len(combobox_type.get()) == 0: messagebox.showerror("warning", "text boxes empty please fill it.") else: with connection_pool.getconn() as connection: with connection.cursor() as cursor: cursor.execute( "Update menu set name=%s, price=%s, type=%s Where id=%s", (entry_name.get(), entry_price.get(), combobox_type.get(), entry_id.get())) connection.commit() cursor.close() messagebox.showinfo(title="success", message="successfully")
def Update(self): popup = messagebox.askyesno(title="asking", message="Do you went to update this user") if popup: if len(self.entry_id_one.get()) == 0 or \ len(self.entry_last_name_one.get()) == 0 or \ len(self.entry_last_name_one.get()) == 0: messagebox.showerror("warning", "text boxes empty please fill it.") else: with connection_pool.getconn() as connection: with connection.cursor() as cursor: cursor.execute( "Update users set frist_name=%s, last_name=%s Where id=%s", (self.entry_first_name_one.get(), self.entry_last_name_one.get(), self.entry_id_one.get())) connection.commit() cursor.close() messagebox.showinfo(title="success", message="successfully")
def Manage_menu_window(): top = Toplevel() top.title("Manage Menu") top.geometry("1301x820+250+130") top.resizable(False, False) main_heading = ttk.Label(top, text="Restaurant Management System", foreground="red", font=("arial", 30, "bold italic")) main_heading.pack(padx=300) tv = ttk.Treeview(top, height=32) tv.pack() tv["columns"] = ("name", "price", "type") tv.heading("#0", text="Id") tv.heading("name", text="Name") tv.heading("price", text="Price") tv.heading("type", text="Type") tv.column("#0", width=310) tv.column("name", width=310) tv.column("price", width=310) tv.column("type", width=310) with connection_pool.getconn() as connection: with connection.cursor() as cursor: cursor.execute( "select id as total, name, price, type from menu order by total asc" ) for item in list(cursor): tv.insert('', "end", text=f"{item[0]}", values=(f'{item[1]}', f'{item[2]}', f'{item[3]}')) tv.column("#0", anchor="center") tv.column("name", anchor="center") tv.column("price", anchor="center") tv.column("type", anchor="center") frame_buttons = ttk.Frame(top) frame_buttons.configure(width=1301, height=75) frame_buttons.pack(side="bottom", pady=10) def edit(): ci = tv.focus() table_value = tv.item(ci) if len(table_value["text"]) == 0 or len(table_value["values"]) == 0: messagebox.showerror( "warning", "Select any item which one should you went to edit") else: top_1 = Toplevel() top_1.title("Add New Menu Item") top_1.geometry("620x495+550+230") top_1.resizable(False, False) label_id = ttk.Label( top_1, text="Menu Item Id : " " ", font=("arial", 15)) label_id.pack(pady=5) strvar1 = StringVar() entry_id = Entry(top_1, width=50, font=("arial", 15), textvariable=strvar1) entry_id.pack(pady=20) entry_id.insert(0, table_value['text']) entry_id.config(state="disable") # entry_id.state(["disabled"]) label_id = ttk.Label( top_1, text= "Menu Item Name : ", font=("arial", 15)) label_id.pack(pady=5) strvar2 = StringVar() entry_name = Entry(top_1, width=50, font=("arial", 15), textvariable=strvar2) entry_name.insert(0, table_value['values'][0]) entry_name.pack(pady=20) label_id = ttk.Label( top_1, text= "Menu Item Price : ", font=("arial", 15)) label_id.pack(pady=5) strvar3 = StringVar() entry_price = Entry(top_1, width=50, font=("arial", 15), textvariable=strvar3) entry_price.insert(0, table_value['values'][1]) entry_price.pack(pady=20) label_id = ttk.Label( top_1, text= "type : " " " " ", font=("arial", 15)) label_id.pack(pady=5) combobox_type = ttk.Combobox(top_1, width=48, font=("arial", 15)) combobox_type.config(value=["Main", "Drink", "Alcohol", "Dessert"]) combobox_type.insert(0, table_value['values'][2]) combobox_type.state(["readonly"]) combobox_type.pack(pady=15) style = ttk.Style() style.configure(style="frame.TFrame") frame_buttons_1 = ttk.Frame(top_1) frame_buttons_1.configure(width=550, height=60) frame_buttons_1.pack() def Update(): popup = messagebox.askyesno( title="asking", message="Do you went to update this item") if popup: if len(entry_id.get()) == 0 or \ len(entry_name.get()) == 0 or \ len(entry_price.get()) == 0 or len(combobox_type.get()) == 0: messagebox.showerror("warning", "text boxes empty please fill it.") else: with connection_pool.getconn() as connection: with connection.cursor() as cursor: cursor.execute( "Update menu set name=%s, price=%s, type=%s Where id=%s", (entry_name.get(), entry_price.get(), combobox_type.get(), entry_id.get())) connection.commit() cursor.close() messagebox.showinfo(title="success", message="successfully") def cancel(): top_1.destroy() button_save1 = Button(frame_buttons_1, text="Save", bg="blue", fg="#FFD5C6", height=3, width=15, command=Update) button_save1.grid(row=0, column=0, padx=40, ipadx=20, ipady=10) button_cancel = Button(frame_buttons_1, text="Cancel", bg="blue", fg="#FFD5C6", height=3, width=15, command=cancel) button_cancel.grid(row=0, column=1, padx=40, ipadx=20, ipady=10) def refresh(): tv.delete(*tv.get_children()) with connection_pool.getconn() as connection: with connection.cursor() as cursor: cursor.execute( "select id as total, name, price, type from menu order by total asc" ) for item in list(cursor): tv.insert('', "end", text=f"{item[0]}", values=(f'{item[1]}', f'{item[2]}', f'{item[3]}')) tv.column("#0", anchor="center") tv.column("name", anchor="center") tv.column("price", anchor="center") tv.column("type", anchor="center") def delete(): ci = tv.focus() table_value = tv.item(ci) if len(table_value["text"]) == 0 or len(table_value["values"]) == 0: messagebox.showerror( "warning", "Select any item which one should you went to edit") else: popup = messagebox.askyesno( title="asking", message="Do you went to delete this item") if popup: with connection_pool.getconn() as connection: with connection.cursor() as cursor: cursor.execute("delete from menu Where id=%s", (table_value['text'], )) def Add_new_item(): top_1 = Toplevel() top_1.title("Edit New Menu Item") top_1.geometry("620x495+550+230") top_1.resizable(False, False) label_id = ttk.Label( top_1, text= "Menu Item Id : ", font=("arial", 15)) label_id.pack(pady=5) strvar1 = StringVar() entry_id = ttk.Entry(top_1, width=50, font=("arial", 15), textvariable=strvar1) entry_id.pack(pady=20) label_id = ttk.Label( top_1, text= "Menu Item Name : ", font=("arial", 15)) label_id.pack(pady=5) strvar2 = StringVar() entry_name = ttk.Entry(top_1, width=50, font=("arial", 15), textvariable=strvar2) entry_name.pack(pady=20) label_id = ttk.Label( top_1, text= "Menu Item Price : ", font=("arial", 15)) label_id.pack(pady=5) strvar3 = StringVar() entry_price = ttk.Entry(top_1, width=50, font=("arial", 15), textvariable=strvar3) entry_price.pack(pady=20) label_id = ttk.Label( top_1, text= "type : " " " " ", font=("arial", 15)) label_id.pack(pady=5) combobox_type = ttk.Combobox(top_1, width=48, font=("arial", 15)) combobox_type.config(value=["Main", "Drink", "Alcohol", "Dessert"]) combobox_type.state(["readonly"]) combobox_type.pack(pady=15) frame_buttons_1 = ttk.Frame(top_1) frame_buttons_1.configure(width=550, height=60) frame_buttons_1.pack() def Save(): if len(entry_id.get()) == 0 or \ len(entry_name.get()) == 0 or \ len(entry_price.get()) == 0 or len(combobox_type.get()) == 0 or type(entry_price) == "<class 'float'>": messagebox.showerror("warning", "Id id empty please fill it.") else: with connection_pool.getconn() as connection: with connection.cursor() as cursor: cursor.execute( "insert into menu(id, name, price, type) " "values(%s, %s, %s, %s)", (entry_id.get(), entry_name.get(), entry_price.get(), combobox_type.get())) connection.commit() cursor.close() messagebox.showinfo(title="success", message="successfully") def New(): entry_id.delete(0, "end") entry_name.delete(0, "end") entry_price.delete(0, "end") combobox_type.set("") def cancel(): top_1.destroy() button_save = Button(frame_buttons_1, text="Save", command=Save, bg="blue", fg="#FFD5C6", height=3, width=15) button_new = Button(frame_buttons_1, text="New", command=New, bg="blue", fg="#FFD5C6", height=3, width=15) button_cancel = Button(frame_buttons_1, text="Cancel", command=cancel, bg="blue", fg="#FFD5C6", height=3, width=15) button_save.grid(row=0, column=0, padx=5, ipadx=10) button_new.grid(row=0, column=1, padx=5, ipadx=10) button_cancel.grid(row=0, column=2, padx=5, ipadx=10) button_add_item = Button(frame_buttons, text="Add New menu item", command=Add_new_item, bg="blue", fg="white") button_add_item.grid(ipadx=30, ipady=20, padx=10) button_edit_item = Button(frame_buttons, text="Edit New menu item", bg="blue", fg="white", command=edit) button_edit_item.grid(ipadx=30, ipady=20, row=0, column=1, padx=10) button_delete_item = Button(frame_buttons, text="Delete New menu item", bg="blue", fg="white", command=delete) button_delete_item.grid(ipadx=30, ipady=20, row=0, column=2, padx=10) button_refresh = Button(frame_buttons, text=" Refresh ", bg="blue", fg="white", command=refresh) button_refresh.grid(ipadx=30, ipady=20, row=0, column=3, padx=10)
def __init__(self): self.top = Toplevel() self.top.title("Manage Employees") self.top.geometry("1301x820+250+130") self.top.resizable(False, False) main_heading = ttk.Label(self.top, text="Staff Management", foreground="red", font=("arial", 30, "bold italic")) main_heading.pack(padx=300) self.tv = ttk.Treeview(self.top, height=32) self.tv.pack() self.tv["columns"] = ("first_name", "last_name") self.tv.heading("#0", text="Id") self.tv.heading("first_name", text="First Name") self.tv.heading("last_name", text="Last Name") self.tv.column("#0", width=410) self.tv.column("first_name", width=410) self.tv.column("last_name", width=410) with connection_pool.getconn() as connection: with connection.cursor() as cursor: cursor.execute( "select id as total, frist_name, last_name from users order by total asc" ) for item in list(cursor): self.tv.insert('', "end", text=f"{item[0]}", values=(f'{item[1]}', f'{item[2]}')) self.tv.column("#0", anchor="center") self.tv.column("first_name", anchor="center") self.tv.column("last_name", anchor="center") style = ttk.Style() style.configure(style="frame.TFrame") self.frame_buttons = ttk.Frame(self.top) self.frame_buttons.configure(width=1301, height=75) self.frame_buttons.pack(side="bottom", pady=10) self.button_add_staff = Button(self.frame_buttons, text="Add New Staff", command=self.Add_new_employee, bg="blue", fg="white") self.button_add_staff.grid(ipadx=30, ipady=20, padx=10) self.button_edit_staff = Button(self.frame_buttons, text="Edit Staff", bg="blue", fg="white", command=self.edit) self.button_edit_staff.grid(ipadx=30, ipady=20, row=0, column=1, padx=10) self.button_delete_staff = Button(self.frame_buttons, text="Delete Staff", bg="blue", fg="white", command=self.delete) self.button_delete_staff.grid(ipadx=30, ipady=20, row=0, column=2, padx=10) self.button_refresh = Button(self.frame_buttons, text=" Refresh ", bg="blue", fg="white", command=self.refresh) self.button_refresh.grid(ipadx=30, ipady=20, row=0, column=3, padx=10)
def __init__(self): self.top_order = Toplevel() self.top_order.title("Order Management") self.top_order.geometry("1301x820+250+130") self.top_order.resizable(False, False) self.heading = ttk.Label(self.top_order, text="Order Management", foreground="red", font=("arial", 30, "bold italic")) self.heading.pack(padx=300) self.treeview = ttk.Treeview(self.top_order, height=32) self.treeview.pack() self.treeview["columns"] = ("first_name", "last_name", "total_price") self.treeview.heading("#0", text="Order Id") self.treeview.heading("first_name", text="Staff First Name") self.treeview.heading("last_name", text="Staff Last Name") self.treeview.heading("total_price", text="Total Price") self.treeview.column("#0", width=310) self.treeview.column("first_name", width=310) self.treeview.column("last_name", width=310) self.treeview.column("total_price", width=310) with connection_pool.getconn() as connection: with connection.cursor() as cursor: cursor.execute( "select id as total, first_name, last_name, total_price from public.order order by total asc" ) for item in list(cursor): self.treeview.insert('', "end", text=f"{item[0]}", values=(f'{item[1]}', f'{item[2]}', f'{item[3]}')) self.treeview.column("#0", anchor="center") self.treeview.column("first_name", anchor="center") self.treeview.column("last_name", anchor="center") self.treeview.column("total_price", anchor="center") self.frame_buttons_order = ttk.Frame(self.top_order) self.frame_buttons_order.configure(width=1301, height=75) self.frame_buttons_order.pack(side="bottom", pady=10) self.button_add_order = Button(self.frame_buttons_order, text="Add New Order", bg="blue", fg="white", command=self.Add_new_order) self.button_add_order.grid(ipadx=30, ipady=20, padx=10) self.button_edit_order = Button(self.frame_buttons_order, text="Edit Order", bg="blue", fg="white", command=self.edit_order) self.button_edit_order.grid(ipadx=30, ipady=20, row=0, column=1, padx=10) self.button_delete_order = Button(self.frame_buttons_order, text="Delete Order", bg="blue", fg="white", command=self.delete) self.button_delete_order.grid(ipadx=30, ipady=20, row=0, column=2, padx=10) self.button_refresh = Button(self.frame_buttons_order, text=" Refresh ", bg="blue", fg="white", command=self.refresh) self.button_refresh.grid(ipadx=30, ipady=20, row=0, column=3, padx=10)
def Add_new_order(self): self.top_add_new_order = Toplevel() self.top_add_new_order.geometry("1301x820+250+130") self.top_add_new_order.title("Add New Order") self.top_add_new_order.resizable(False, False) self.style = ttk.Style() self.style.configure("frame.TFrame", background="blue") self.style1 = ttk.Style() self.style1.configure("frame1.TFrame", background="yellow") self.heading = ttk.Label(self.top_add_new_order, text="New Order", foreground="red", font=("arial", 30, "bold italic")) self.heading.pack(padx=300) self.frame_treeview = ttk.Frame(self.top_add_new_order) self.frame_treeview.configure(height=760, width=660) self.frame_treeview.pack(side=RIGHT) self.treeview_items = ttk.Treeview(self.frame_treeview, height=32) self.treeview_items.pack() self.treeview_items["columns"] = ("name", "price", "type") self.treeview_items.heading("#0", text="Id") self.treeview_items.heading("name", text="Name") self.treeview_items.heading("price", text="Price") self.treeview_items.heading("type", text="Type") with connection_pool.getconn() as connection: with connection.cursor() as cursor: cursor.execute( "select id as total, name, price, type from menu order by total" ) for item in list(cursor): self.treeview_items.insert('', "end", text=f"{item[0]}", values=(f'{item[1]}', f'{item[2]}', f'{item[3]}')) self.treeview_items.column("#0", width=200) self.treeview_items.column("name", width=200) self.treeview_items.column("price", width=200) self.treeview_items.column("type", width=200) self.treeview_items.column("#0", anchor="center") self.treeview_items.column("name", anchor="center") self.treeview_items.column("price", anchor="center") self.treeview_items.column("type", anchor="center") self.frame_button_a = ttk.Frame(self.frame_treeview) self.frame_button_a.configure(height=55, width=660) self.frame_button_a.pack() self.button_all = Button(self.frame_button_a, bg="blue", text="All", fg="white", command=self.all) self.button_all.grid(row=0, column=0, ipady=15, pady=7, padx=10, ipadx=30) self.button_main = Button(self.frame_button_a, bg="blue", text="Main", fg="white", command=self.main) self.button_main.grid(row=0, column=1, ipady=15, pady=7, padx=10, ipadx=30) self.button_drink = Button(self.frame_button_a, bg="blue", text="Drink", fg="white", command=self.drink) self.button_drink.grid(row=0, column=2, ipady=15, pady=7, padx=10, ipadx=30) self.button_alcohol = Button(self.frame_button_a, bg="blue", text="Alcohol", fg="white", command=self.alcohol) self.button_alcohol.grid(row=0, column=3, ipady=15, pady=7, padx=10, ipadx=30) self.button_desert = Button(self.frame_button_a, bg="blue", text="Desert", fg="white", command=self.dessert) self.button_desert.grid(row=0, column=4, ipady=15, pady=7, padx=10, ipadx=30) self.frame_treeview_tow = ttk.Frame(self.top_add_new_order) self.frame_treeview_tow.configure(height=760, width=660) self.frame_treeview_tow.pack(side=TOP, pady=16) self.treeview_order_2 = ttk.Treeview(self.frame_treeview_tow, height=26) self.treeview_order_2.pack() self.treeview_order_2["columns"] = ("name", "quantity", "price") self.treeview_order_2.heading("#0", text="No") self.treeview_order_2.heading("name", text="Name") self.treeview_order_2.heading("quantity", text="Quantity") self.treeview_order_2.heading("price", text="Price") self.treeview_order_2.column("#0", width=120) self.treeview_order_2.column("name", width=120) self.treeview_order_2.column("quantity", width=120) self.treeview_order_2.column("price", width=120) self.treeview_order_2.column("#0", anchor="center") self.treeview_order_2.column("name", anchor="center") self.treeview_order_2.column("quantity", anchor="center") self.treeview_order_2.column("price", anchor="center") self.frame_button_b = ttk.Frame(self.frame_treeview_tow) self.frame_button_b.configure(height=210, width=630) self.frame_button_b.pack(padx=18, ipadx=5) self.frame_price = ttk.Frame(self.frame_button_b) self.frame_price.configure(height=100, width=630) self.frame_price.grid(row=0, column=0, pady=10, ipadx=90) self.label_total = ttk.Label(self.frame_price, width=20, text="Total price : ", font=("arial", 12)) self.label_total.grid(row=0, column=0, sticky=SW) # self.total_price_add = ttk.Label(self.frame_price, width=20, text='1111', font=("arial", 12)) # self.total_price_add.grid(row=0, column=1) self.label_staff = ttk.Label(self.frame_price, text="Staff name :", font=("arial", 12)) self.label_staff.grid(row=1, column=0, pady=10, sticky=SW) self.label_name = ttk.Label(self.frame_price, text="Sad eamin", font=("arial", 12)) self.label_name.grid(row=1, column=1, pady=10, sticky=SW) self.frame_button_c = ttk.Frame(self.frame_button_b) self.frame_button_c.configure(height=55, width=660) self.frame_button_c.grid(row=4, column=0, pady=42) self.strvar = StringVar() self.entry_quantity = ttk.Entry(self.frame_button_c, font=(12), width=10, textvariable=self.strvar) self.entry_quantity.grid(row=0, column=0, ipady=20, ipadx=10, padx=10) self.button_add = Button(self.frame_button_c, text="Add", bg="blue", fg="white", command=self.Add) self.button_add.grid(row=0, column=1, ipady=20, ipadx=25, padx=10) self.button_Delete = Button(self.frame_button_c, text="Delete", bg="blue", fg="white", command=self.Delete_order) self.button_Delete.grid(row=0, column=2, ipady=20, ipadx=25, padx=10) self.button_Order = Button(self.frame_button_c, text="Order", bg="blue", fg="white", command=self.order) self.button_Order.grid(row=0, column=3, ipady=20, ipadx=25, padx=10) self.entry_quantity.insert(0, "1") self.total_price = 0
def Menu_window(): top = Toplevel() top.title("Show Menu") top.geometry("1301x840+250+130") top.resizable(False, False) main_heading = ttk.Label(top, text="Restaurant Management System", foreground="red", font=("arial", 30, "bold italic")) main_heading.pack(padx=60, pady=30) # creating the treeview tv = ttk.Treeview(top, height=30) tv.pack() tv["columns"] = ("name", "price", "type") tv.heading("#0", text="Id") tv.heading("name", text="Name") tv.heading("price", text="Price") tv.heading("type", text="Type") tv.column("#0", width=310) tv.column("name", width=310) tv.column("price", width=310) tv.column("type", width=310) with connection_pool.getconn() as connection: with connection.cursor() as cursor: cursor.execute( "select id as total, name, price, type from menu order by total" ) for item in list(cursor): tv.insert('', "end", text=f"{item[0]}", values=(f'{item[1]}', f'{item[2]}', f'{item[3]}')) tv.column("#0", anchor="center") tv.column("name", anchor="center") tv.column("price", anchor="center") tv.column("type", anchor="center") style = ttk.Style() style.configure("1.TFrame") frame_buttons = ttk.Frame(top) frame_buttons.configure(width=700, height=80, style="1.TFrame") frame_buttons.pack(pady=20) def all(): tv.delete(*tv.get_children()) with connection_pool.getconn() as connection: with connection.cursor() as cursor: cursor.execute( "select id as total, name, price, type from menu order by total" ) for item in list(cursor): tv.insert('', "end", text=f"{item[0]}", values=(f'{item[1]}', f'{item[2]}', f'{item[3]}')) tv.column("#0", anchor="center") tv.column("name", anchor="center") tv.column("price", anchor="center") tv.column("type", anchor="center") def main(): tv.delete(*tv.get_children()) with connection_pool.getconn() as connection: with connection.cursor() as cursor: cursor.execute( "select id as total, name, price, type from menu Where type = 'Main' order by total" ) for item in list(cursor): tv.insert('', "end", text=f"{item[0]}", values=(f'{item[1]}', f'{item[2]}', f'{item[3]}')) tv.column("#0", anchor="center") tv.column("name", anchor="center") tv.column("price", anchor="center") tv.column("type", anchor="center") def drink(): tv.delete(*tv.get_children()) with connection_pool.getconn() as connection: with connection.cursor() as cursor: cursor.execute( "select id as total, name, price, type from menu Where type = 'Drink' order by total" ) for item in list(cursor): tv.insert('', "end", text=f"{item[0]}", values=(f'{item[1]}', f'{item[2]}', f'{item[3]}')) tv.column("#0", anchor="center") tv.column("name", anchor="center") tv.column("price", anchor="center") tv.column("type", anchor="center") def alcohol(): tv.delete(*tv.get_children()) with connection_pool.getconn() as connection: with connection.cursor() as cursor: cursor.execute( "select id as total, name, price, type from menu Where type = 'Alcohol' order by total" ) for item in list(cursor): tv.insert('', "end", text=f"{item[0]}", values=(f'{item[1]}', f'{item[2]}', f'{item[3]}')) tv.column("#0", anchor="center") tv.column("name", anchor="center") tv.column("price", anchor="center") tv.column("type", anchor="center") def dessert(): tv.delete(*tv.get_children()) with connection_pool.getconn() as connection: with connection.cursor() as cursor: cursor.execute( "select id as total, name, price, type from menu Where type = 'Dessert' order by total" ) for item in list(cursor): tv.insert('', "end", text=f"{item[0]}", values=(f'{item[1]}', f'{item[2]}', f'{item[3]}')) tv.column("#0", anchor="center") tv.column("name", anchor="center") tv.column("price", anchor="center") tv.column("type", anchor="center") button_all = Button(frame_buttons, text="All", bg="blue", fg="#FFD5C6", height=3, width=15, command=all) button_main = Button(frame_buttons, text="Main", bg="blue", fg="#FFD5C6", height=3, width=15, command=main) button_drink = Button(frame_buttons, text="Drink", bg="blue", fg="#FFD5C6", height=3, width=15, command=drink) button_alcohol = Button(frame_buttons, text="Alcohol", bg="blue", fg="#FFD5C6", height=3, width=15, command=alcohol) button_dessert = Button(frame_buttons, text="Dessert", bg="blue", fg="#FFD5C6", height=3, width=15, command=dessert) button_all.grid(row=0, column=0, padx=10, ipadx=10) button_main.grid(row=0, column=1, padx=10, ipadx=10) button_drink.grid(row=0, column=2, padx=10, ipadx=10) button_alcohol.grid(row=0, column=3, padx=10, ipadx=10) button_dessert.grid(row=0, column=4, padx=10, ipadx=10)