Ejemplo n.º 1
0
    def AddProduct(self, prod_id):
        quantity = 0
        product = Products.products_dict[prod_id]

        if prod_id in self.products_quantity_dict:
            utils.BoldPrint(
                "Product ID {0} alread exits in your cart!!\n".format(prod_id))

            curr_quantity = self.products_quantity_dict[prod_id]
            utils.BoldPrint("Current Quantity: {0}\n".format(curr_quantity))

            r = utils.YesNoGet("Change Quantity")

            if r != "y":
                return False

            self.total_price -= curr_quantity * product.price
            quantity = utils.IntegerInputGet("Enter new quantity: ")
            if quantity != 0:
                self.products_quantity_dict[prod_id] = quantity

        else:
            quantity = utils.IntegerInputGet("Enter quantity: ")
            while (quantity == 0):
                ErrorPrint("Quantity can't be 0... please try again!!\n")
                quantity = utils.IntegerInputGet("Enter quantity: ")

            self.products_quantity_dict[prod_id] = quantity

        self.total_price += self.products_quantity_dict[prod_id] * product.price
        utils.SuccessPrint(
            "Product ID {0} added to your cart!!".format(prod_id))

        self.Print()
        return True
Ejemplo n.º 2
0
    def DelProducts():
        while True:
            id = utils.IntegerInputGet("Enter product id to be deleted: ")
            print("")
            if id not in Products.products_dict:
                utils.ErrorPrint(
                    "Product ID: {0} doesn't exist!!\n".format(id))
            else:
                Products.HeadingPrint()
                print(Products.products_dict[id])
                print("")
                r = utils.YesNoGet("Delete this product")
                if (r == "y"):
                    del Products.products_dict[id]

                    with open("products.file", "wb") as products_file:
                        pickle.dump(Products.products_dict, products_file)

                    utils.SuccessPrint(
                        "Product ID: {0} deleted!!\n".format(id))
                else:
                    utils.ErrorPrint(
                        "Product ID: {0} not deleted!!\n".format(id))

            r = utils.YesNoGet("\nDelete another product")

            if r != "y":
                break
Ejemplo n.º 3
0
    def AddProducts():
        while True:
            id = utils.IntegerInputGet("Enter product id: ")
            if id in Products.products_dict:
                utils.ErrorPrint(
                    "Product ID: {0} already exists!!... try again.\n".format(
                        id))
                continue

            new_product = Products(id)

            Products.HeadingPrint()
            print(new_product)
            new_product.Modify()

            with open("products.file", "wb") as products_file:
                pickle.dump(Products.products_dict, products_file)

            utils.SuccessPrint(
                "Product ID: {0} successfully added!!\n\n".format(id))

            r = utils.YesNoGet("Add another product")

            if r != "y":
                break
Ejemplo n.º 4
0
    def Register():
        admin_num = len(Admin.admin_dict)
        if (admin_num == MAX_ADMIN_COUNT):
            utils.ErrorPrint("\nMax number of admins already created!!\n")
            return

        while (True):
            id = utils.IntegerInputGet("Enter Admin id: ")
            if id in Admin.admin_dict:
                utils.ErrorPrint(
                    "Admin ID: {0} already exist!!... please try again\n".
                    format(id))
                continue

            name = input("Enter admin name: ")
            pswd = utils.NewPasswdGet("Enter password: "******"admins.file", "wb") as admins_file:
                pickle.dump(Admin.admin_dict, admins_file)

            utils.SuccessPrint(
                "Admin ID: {0} successfully registered!!\n".format(id))
            break
Ejemplo n.º 5
0
    def AddCard(self):
        card_number = utils.IntegerInputGet("Enter Card Number: ")
        if (card_number in self.card_number_list):
            ErrorPrint("This card number is already added!!\n")
            return False

        card_type = input("Enter Card Type (Debit/Credit)? ")

        self.card_number_list.append(card_number)
        self.card_type_list.append(card_type)
        utils.SuccessPrint("New Card successfully added!!\n")
        return True
Ejemplo n.º 6
0
    def Register():
        if Guest.guest_number in Customer.customer_dict:
            utils.ErrorPrint("Guest ID {0} is already registered!!\n".format(
                Guest.guest_number))
            return

        new_customer = Customer(Guest.guest_number)

        print(new_customer)
        new_customer.Modify()

        with open("customer.file", "wb") as customer_file:
            pickle.dump(Customer.customer_dict, customer_file)

        utils.SuccessPrint("Customer ID: {0} successfully added!!\n\n".format(
            new_customer.id))
Ejemplo n.º 7
0
    def MakePayment(self):
        if self.cart.IsEmpty() == True:
            utils.ErrorPrint("Cart is Empty!!\n")
            return

        if self.payment.MakePayment() == False:
            utils.ErrorPrint("Payment Failed... please try again!!\n")
        else:
            for p in self.cart.products_quantity_dict:
                if p in self.products_bought_dict:
                    self.products_bought_dict[
                        p] += self.cart.products_quantity_dict[p]
                else:
                    self.products_bought_dict[
                        p] = self.cart.products_quantity_dict[p]

            self.cart.Clear()
            with open("customer.file", "wb") as customer_file:
                pickle.dump(Customer.customer_dict, customer_file)

            utils.SuccessPrint(
                "Payment Confirmation... Thanks for Shopping with us!!\n")
Ejemplo n.º 8
0
    def DeleteProduct(self, prod_id):
        if prod_id not in self.products_quantity_dict:
            utils.ErrorPrint(
                "Product ID {0} doesn't exist in your cart!!\n".format(
                    prod_id))
            return False

        product = Products.products_dict[prod_id]

        r = utils.YesNoGet("Delete the product completely")

        if (r != "y"):
            curr_quantity = self.products_quantity_dict[prod_id]
            utils.BoldPrint("Current Quantity: {0}\n".format(curr_quantity))

            new_quantity = utils.IntegerInputGet("Decrease the Quantity to: ")
            if (new_quantity > curr_quantity):
                utils.ErrorPrint(
                    "Use \"Add to Cart\" option to increase the quantity\n")
                return False

            if (new_quantity == curr_quantity):
                return False

            if (new_quantity != 0):
                self.products_quantity_dict[prod_id] = new_quantity
                self.total_price -= curr_quantity * product.price
                self.total_price += new_quantity * product.price

                self.Print()
                return True

        self.total_price -= self.products_quantity_dict[prod_id] * product.price
        del self.products_quantity_dict[prod_id]
        utils.SuccessPrint(
            "Product ID {0} deleted from your cart!!".format(prod_id))

        self.Print()
        return True
Ejemplo n.º 9
0
 def ConfirmDelivery():
     utils.SuccessPrint(
         "All orders have reached their destinations successfully!!\n")
Ejemplo n.º 10
0
 def MakeShipment():
     utils.SuccessPrint("All orders have been shipped!!\n")