Пример #1
0
 def register_product(self):
     idd = random.randint(0, 1000000000)
     details = []
     details.append(idd)
     cls()
     print("==========================================")
     print("Enter Product Name: ", end="")
     details.append(input())
     print()
     print("Enter Product Description : ", end="")
     details.append(input())
     print()
     print("Enter Product Price : ", end="")
     details.append(input())
     print()
     details.append(Authentication.get_authenticated_user())
     details.append(-1)
     details.append(0)
     print("Enter Product Stock : ", end="")
     details.append(input())
     print()
     print("Enter Product Category : ", end="")
     details.append(input())
     print()
     Product.add_product(*details)
Пример #2
0
 def list_buys(self):
     cnt = 1
     my_purchs = Product.list_purchases()
     if len(my_purchs) == 0:
         print("No purchase records found")
     for x in my_purchs:
         current_product = Product.get_product(x[1])
         if x[2] == Authentication.get_authenticated_user():
             print("Purchase " + str(cnt) + ":")
             print("====================================")
             print("Purchase ID : " + x[0])
             print("Product Name : " + current_product.product_name)
             print("Prodcut Price : " + current_product.price)
             print("====================================\n")
             cnt += 1
     input("Enter any key to continue...")
     self.logged_in_menu()
Пример #3
0
 def viewsales(self):
     cnt = 1
     my_sales = Database.get_seller_sales(
         Authentication.get_authenticated_user())
     if len(my_sales) == 0:
         print("No sales record found")
     for x in my_sales:
         current_purchase = Database.get_purchase_info(x)
         current_product = Product.get_product(current_purchase[1])
         buyer_info = Database.get_user_details(current_purchase[2],
                                                "buyer", False)
         print("Sale " + str(cnt) + ":")
         print("====================================")
         print("Purchase ID : " + current_purchase[0])
         print("Product Name : " + current_product.product_name)
         print("Prodcut Price : " + current_product.price)
         print("Buyer Name: {0} {1}".format(buyer_info[0], buyer_info[1]))
         print("Buyer Username: {0}".format(buyer_info[2]))
         print("Buyer Address: {0}".format(buyer_info[5]))
         print("====================================\n")
         cnt += 1
     input("Enter any key to continue...")
     self.logged_in_menu()
Пример #4
0
    def logged_in_menu(self):
        acc_type = Authentication.get_acc_type()
        cls()
        print("Welcome {0}!".format(Authentication.get_authenticated_user()))
        if acc_type == "seller":
            print("""
                ==================================
                | 1. List All the Products       |
                | 2. Add a Product               |
                | 3. List My Products            |
                | 4. View My sales               |
                | 5. Exit                        |
                ==================================
            """)
            while True:
                i = Validation.get_int_input(input(), 5)
                if i == 5:
                    exit(0)
                if i == 1:
                    self.display_product()
                elif i == 2:
                    self.register_product()
                    cls()
                    print("Product Added Successfully")

                elif i == 3:
                    self.listMyProducts(
                        Authentication.get_authenticated_user())
                elif i == 4:
                    self.viewsales()
                print("""
                ==================================
                | 1. List All the Products       |
                | 2. Add a Product               |
                | 3. List My Products            |
                | 4. View My sales               |
                | 5. Exit                        |
                ==================================
                """)

        else:
            print("""
                ==================================
                | 1. List All the Products       |
                | 2. Buy Product                 |
                | 3. View Your Purchases         |
                | 4. Search and Buy Product      |
                | 5. Sort and Buy Product        |
                | 6. Exit                        |
                ==================================
            """)
            while True:
                i = Validation.get_int_input(input(), 6)
                if i == 1:
                    self.display_product()
                elif i == 2:
                    self.buy_product()
                elif i == 3:
                    self.list_buys()
                elif i == 4:
                    self.search_product()
                elif i == 5:
                    self.sort_product()
                elif i == 6:
                    exit(0)
        self.display_store()