Ejemplo n.º 1
0
 def delete_product(cls):
     print("-------- delete product --------")
     _id = input("please enter product_id for delete: ")
     if not _id:
         print("you forget enter id")
     elif Product.delete(_id):
         print(f"product with id {_id} deleted successfully ")
     else:
         print(f"product with id {_id} not found")
    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:")