Untitled
unknown
plain_text
a year ago
2.4 kB
5
Indexable
# Admin - Total Revenue with Status def admin_total_revenue_with_status(): try: cur.execute("SELECT SUM(Menu.Price * Orders.Quantity) FROM Menu " "JOIN Orders ON Menu.ItemID = Orders.ItemID") total_revenue = cur.fetchone()[0] print(f"Total Revenue: ${total_revenue}") except mysql.connector.Error as err: print(f"Error: {err}") con.rollback() # Admin - Statistics with Quantity def admin_statistics_with_quantity(): try: cur.execute("SELECT Menu.Category, COUNT(*), SUM(Orders.Quantity) " "FROM Menu JOIN Orders ON Menu.ItemID = Orders.ItemID " "GROUP BY Menu.Category") statistics = cur.fetchall() table = PrettyTable(["Category", "ItemCount", "Total Quantity"]) for stat in statistics: table.add_row(stat) print(table) except mysql.connector.Error as err: print(f"Error: {err}") con.rollback() # Customer - Modify Order def customer_modify_order(customer_name): try: display_customer_orders(customer_name) order_id = int(input("Enter Order ID to modify: ")) cur.execute("SELECT OrderID FROM Orders WHERE CustomerName = %s", (customer_name,)) data = cur.fetchall() if (order_id,) in data: new_quantity = int(input("Enter the new quantity: ")) new_packaging = input("Enter 'Dine-in' or 'Take away': ").capitalize() cur.execute("UPDATE Orders SET Quantity = %s, Packaging = %s WHERE OrderID = %s", (new_quantity, new_packaging, order_id)) con.commit() print(f"Order ID {order_id} modified successfully!") else: print('Sorry, this order does not exist for the customer.') except (mysql.connector.Error, ValueError) as err: print(f"Error: {err}") con.rollback() # Customer Menu - Additional Options def customer_menu_additional_options(customer_name): while True: print("\nAdditional Options:") y = int(input(''' 1. Modify Order 2. Back to Customer Menu ''')) if y == 1: customer_modify_order(customer_name) elif y == 2: break else: print('Please enter a valid input. ')
Editor is loading...
Leave a Comment