Untitled

 avatar
unknown
plain_text
a year ago
829 B
5
Indexable
def admin_change_order_status():
    try:
        admin_view_orders_with_status()
        order_id = int(input("Enter Order ID to change status: "))
        cur.execute("SELECT OrderID FROM Customer_Orders_Admin")
        data = cur.fetchall()

        if (order_id,) in data:
            new_status = input("Enter 'Pending' or 'Delivered': ").capitalize()

            cur.execute("UPDATE Customer_Orders_Admin SET Status = %s WHERE OrderID = %s",
                        (new_status, order_id))
            con.commit()
            print(f"Order ID {order_id} status changed to {new_status} successfully!")
        else:
            print('Sorry, this order does not exist in the admin records.')

    except (mysql.connector.Error, ValueError) as err:
        print(f"Error: {err}")
        con.rollback()
Editor is loading...
Leave a Comment