def main(self): product = Products() self.clear() print(" ***** Manage Products *****\n\n") print(" 1- Add a new product") print(" 2- Edit existing product") print(" 3- Remove existing product\n") productOperation = input("Please choose your option [1-3] >>") if productOperation[:1] == '1': category = Categories() self.clear() # Retrive real state data from database print("Options:") print( "\n\n1- Choose a category from the existing categories to add your product to") print("\n2- Add a new category to connect your product to") option = input("\nPlease make a selection [1-2] >>") if category.ValidateUserInputAsNumber(option): option = int(option) if(option == 1 or option == 2): if(option == 1): self.clear() SQLStatment = category.selectStatment( "*", "categories", "") cursor = self.executeSQLStatment(SQLStatment) rows = cursor.fetchall() cursor.close() print( "-------------------------------------------------------------:") print( "---------------------- Categories List ----------------------") #ProductCategory = Category() if(rows): counter = 0 for row in rows: print(f"{counter+1} - {row[1]} ") counter += 1 categoryNo = input( "\n\nPlease enter a valid category from the list above>>") if category.ValidateUserInputAsNumber(categoryNo): categoryNo = int(categoryNo) if(categoryNo > 0 and categoryNo <= counter and categoryNo is not None): rowIndex = int(categoryNo)-1 category_id = int(rows[rowIndex][0]) print("\n\n ***New Product Information:***") productName = input( "Please enter the product name >> ") productDescription = input( "Please enter the product description >> ") productPrice = input( "Please enter the product price >> ") self.addNewProduct( category_id, productName, productDescription, productPrice) else: categoryName = input( "Please enter the Category name that you want to add >>") rows = category.addNewCategory(categoryName) category_id = rows.fetchone()[0] print("\n\n ***New Product Information:***") productName = input( "Please enter the product name >> ") productDescription = input( "Please enter the product description >> ") productPrice = input( "Please enter the product price >> ") self.addNewProduct( category_id, productName, productDescription, productPrice) else: print("invalid option") elif productOperation[:1] == '2': # self.EditProduct("Edit") # self.editExistingProduct( print("\n\n- Search Products by Name -") productName = input( "Please enter a keyword to search for Product Name >> ") whereStatment = f"LOWER(product_name) like '%{productName}%' " self.editExistingProduct(whereStatment) elif productOperation[:1] == '3': self.searchMainMenu("Delete") else: print("Invalid entry\n")