def update_product(cls): print("-------- update product --------") _id = input("please enter Product_id for update: ") if not _id: print("without product_id you couldn't update!") else: name = input("Enter new_name for update: ") price = input("Enter new_price for update: ") off = input("enter new_off for update: ") category = input("Enter new_category for update: ") result, msg = Product.update(_id, name, price, category, off) if result: print(f"product with id {_id} update successfully") else: print(msg)
def show(cls): print("---------- Welcome ----------") for num, title in cls.menu.items(): if num in ("5", "9", "13", "17", "0"): print("************************") print(f"{num}: {title}") print("*****************************") user_input = input("Enter your number:") while True: if user_input == "1": name = input("name: ") price = int(input("price: ")) category = input("category: ") off = float(input("off: ")) result, err = Product.save(name, price, category, off) if result: print("Successfully add product") else: print(err) if user_input == "2": print(Product.get_all_products()) if user_input == "3": products_fields = [ "id", "name", "price", "category_name", "off" ] _id, name, price, category_name, off = [ input(f"{field}:") for field in products_fields ] print(_id, name, price, category_name, off) result = Product.update(_id, name, price, category_name, off) if result: print("Successfully update product") else: print("Update err") if user_input == "4": result, err = Product.delete(input("id: ")) if result: print("Successfully delete") else: print(err) if user_input == "5": CategoryView.add_category() if user_input == "6": CategoryView.show_all() if user_input == "7": a, b = CategoryView.update_category() print(a, b) if user_input == "8": CategoryView.delete_category() if user_input == "9": RegisterView.create_customer() if user_input == "10": RegisterView.create_employee() if user_input == "16": LoginLogoutView.login() user_input = input("Enter your number:")