コード例 #1
0
ファイル: ui.py プロジェクト: 97marcar/flask-site
def ui():
    print("1. (Re)Create Product Table")
    print("2. Add new product")
    print("3. Edit existing product")
    print("4. Delete existing product")
    print("5. Search Product")
    print("0. Exit")

    choice = input("Choose option: ")
    if choice == "1" or choice == 1:
        create_product_table.create_table(create_product_table.db_name,
                                          "Product", create_product_table.sql)
        ui()
    elif choice == "2" or choice == 2:
        inserted_name = input("Name product: ")
        inserted_price = float(input("Price: "))
        values_to_insert = (inserted_name, inserted_price)
        insert_product_data.insert_data(values_to_insert)
        ui()
    elif choice == "3" or choice == 3:
        updated_name = input("New Name: ")
        updated_price = float(input("New Price: "))
        id_where_updated = int(input("Choose which ID that will be updated: "))
        tuple_to_be_used_to_update = (updated_name, updated_price,
                                      id_where_updated)
        update_data.update_product(tuple_to_be_used_to_update)
        ui()
    elif choice == "4" or choice == 4:
        deleted_name = input("Name of Product to be deleted: ")
        delete = (deleted_name, )
        delete_data.delete_product(delete)
        ui()
    elif choice == "5" or choice == 5:
        selected_id = int(input("Enter ID of the item you wish to select: "))
        select_existing_products.select_product(selected_id)
        ui()
    else:
        print("exit.")
コード例 #2
0
ファイル: ui.py プロジェクト: 97marcar/97marcar
def ui():
    print("1. (Re)Create Product Table")
    print("2. Add new product")
    print("3. Edit existing product")
    print("4. Delete existing product")
    print("5. Search Product")
    print("0. Exit")

    choice = input("Choose option: ")
    if choice == "1" or choice == 1:
        create_product_table.create_table(create_product_table.db_name, "Product", create_product_table.sql)
        ui()
    elif choice == "2" or choice == 2:
        inserted_name = input("Name product: ")
        inserted_price = float(input("Price: "))
        values_to_insert = (inserted_name, inserted_price)
        insert_product_data.insert_data(values_to_insert)
        ui()
    elif choice == "3" or choice == 3:
        updated_name = input("New Name: ")
        updated_price = float(input("New Price: "))
        id_where_updated = int(input("Choose which ID that will be updated: "))
        tuple_to_be_used_to_update = (updated_name,updated_price,id_where_updated)
        update_data.update_product(tuple_to_be_used_to_update)
        ui()
    elif choice == "4" or choice == 4:
        deleted_name = input("Name of Product to be deleted: ")
        delete = (deleted_name,)
        delete_data.delete_product(delete)
        ui()
    elif choice == "5" or choice == 5:
        selected_id = int(input("Enter ID of the item you wish to select: "))
        select_existing_products.select_product(selected_id)
        ui()
    else:
        print("exit.")
コード例 #3
0
def gui():
    global quantity
    quantity = 0
    print("1. (Re)Create Product Table")
    print("2. Add a new product type")
    print("3. Make a new order")
    print("4. Delete something")
    print("5. Edit a product")
    print("0. Exit")
    choice = int(input("Choose option: "))

    if choice == 1:
        create.create_table_functions()
        gui()

    elif choice == 2:
        new_product_type = str(input("Name of the product type: "))
        insert.insert_product_type_data((new_product_type, ))
        gui()

    elif choice == 3:
        print("1. Returning customer")
        print("2. New customer")
        new_customer = int(input("Choose option: "))

        if new_customer == 1:
            customer_id = str(input("Enter customer id: "))

        else:
            customer_firstname = str(input("Enter first name: "))
            customer_lastname = str(input("Enter last name: "))
            customer_street = str(input("Enter street: "))
            customer_town = str(input("Enter town: "))
            customer_postcode = str(input("Enter postcode: "))
            customer_phonenumber = str(input("Enter phone number: "))
            customer_email = str(input("Enter email: "))
            print(customer_email)

            customer = (customer_firstname, customer_lastname, customer_street, \
            customer_town, customer_postcode, customer_phonenumber, customer_email)
            insert.insert_customer_data(customer)

            customer_id_temp = get_id.select_product(customer_email)
            customer_id = customer_id_temp[0]
            print(customer_id)

        product()
        insert.insert_order_customer_data(
            (a_date, a_time, customer_id, quantity))
        print("done")
        gui()

    elif choice == 4:
        print("What would you like to delete?")
        print("1. A Product ")
        print("2. A Customer")
        print("3. A Order")
        print("4. A Product Type")
        delete_choose = int(input("Choose option: "))
        if delete_choose == 1:
            data = input("ProductID of item to be deleted: ")
            delete.run_delete("product", data)
        elif delete_choose == 2:
            data = input("CustomerID of customer to be deleted: ")
            delete.run_delete("customer", data)
        elif delete_choose == 3:
            data = input("OrderID of order to be deleted: ")
            delete.run_delete("customerorder", data)
        elif delete_choose == 4:
            data = input("Name of product type to be deleted: ")
            delete.run_delete("producttype", data)
        gui()

    elif choice == 5:
        product_to_edit_id = str(input("ProductID of product to edit: "))
        product_to_edit_name = str(input("New name: "))
        product_to_edit_price = float(input("New Price: "))
        update.update_product(
            (product_to_edit_name, product_to_edit_price, product_to_edit_id))
コード例 #4
0
ファイル: gui.py プロジェクト: 97marcar/97marcar
def gui():
    global quantity
    quantity = 0
    print("1. (Re)Create Product Table")
    print("2. Add a new product type")
    print("3. Make a new order")
    print("4. Delete something")
    print("5. Edit a product")
    print("0. Exit")
    choice = int(input("Choose option: "))

    if choice == 1:
        create.create_table_functions()
        gui()

    elif choice == 2:
        new_product_type = str(input("Name of the product type: "))
        insert.insert_product_type_data((new_product_type,))
        gui()

    elif choice == 3:
        print("1. Returning customer")
        print("2. New customer")
        new_customer = int(input("Choose option: "))

        if new_customer == 1:
            customer_id = str(input("Enter customer id: "))

        else:
            customer_firstname = str(input("Enter first name: "))
            customer_lastname = str(input("Enter last name: "))
            customer_street = str(input("Enter street: "))
            customer_town = str(input("Enter town: "))
            customer_postcode = str(input("Enter postcode: "))
            customer_phonenumber = str(input("Enter phone number: "))
            customer_email  = str(input("Enter email: "))
            print(customer_email)

            customer = (customer_firstname, customer_lastname, customer_street, \
            customer_town, customer_postcode, customer_phonenumber, customer_email)
            insert.insert_customer_data(customer)

            customer_id_temp = get_id.select_product(customer_email)
            customer_id = customer_id_temp[0]
            print(customer_id)


        product()
        insert.insert_order_customer_data((a_date, a_time, customer_id, quantity))
        print("done")
        gui()

    elif choice == 4:
        print("What would you like to delete?")
        print("1. A Product ")
        print("2. A Customer")
        print("3. A Order")
        print("4. A Product Type")
        delete_choose = int(input("Choose option: "))
        if delete_choose == 1:
            data = input("ProductID of item to be deleted: ")
            delete.run_delete("product", data)
        elif delete_choose == 2:
            data = input("CustomerID of customer to be deleted: ")
            delete.run_delete("customer", data)
        elif delete_choose == 3:
            data = input("OrderID of order to be deleted: ")
            delete.run_delete("customerorder", data)
        elif delete_choose == 4:
            data = input("Name of product type to be deleted: ")
            delete.run_delete("producttype", data)
        gui()

    elif choice == 5:
        product_to_edit_id = str(input("ProductID of product to edit: "))
        product_to_edit_name = str(input("New name: "))
        product_to_edit_price = float(input("New Price: "))
        update.update_product((product_to_edit_name, product_to_edit_price, product_to_edit_id))