Ejemplo n.º 1
0
def start_module():
    """
    Starts this module and displays its menu.
     * User can access default special features from here.
     * User can go back to main menu from here.

    Returns:
        None
    """

    table = data_manager.get_table_from_file("sales/sales.csv")

    options = [
        "Show table",
        "Add item",
        "Remove item",
        "Update item",
        "Lowest price item ID",
        "Items ID sold between two given dates."]
    # your code


    while True:
        ui.print_menu("Sales manager", options, "Back to main menu")
        option = ui.get_inputs(
            ["Please enter a number: "],
            ""
        )

        try:
            if option == "1":
                show_table(table)
                common.go_back_in_menu()

            elif option == "2":
                table = add(table)
                data_manager.write_table_to_file("sales/sales.csv", table)

            elif option == "3":
                id_to_remove = ui.get_inputs(
                    ["Please enter the ID of the game you wish to remove: "],
                    ""
                    )
                if common.check_id_in_table(table, id_to_remove):
                    table = remove(table, id_to_remove)
                    data_manager.write_table_to_file("sales/sales.csv", table)

            elif option == "4":
                id_to_update = ui.get_inputs(
                    ["Please enter the ID of the game you wish to update: "],
                    ""
                )
                if common.check_id_in_table(table, id_to_update):
                    update(table, id_to_update)
                    data_manager.write_table_to_file("sales/sales.csv", table)

            elif option == "5":
                lowest_price = get_lowest_price_item_id(table)
                ui.print_result(lowest_price, "The lowest price games ID is: ")
                common.go_back_in_menu()

            elif option == "6":
                dates = ui.get_inputs(["Month from", "Day from", "Year from", "Month to", "Day to", "Year to"], "Please enter the dates: ")
                month_from = dates[0]
                day_from = dates[1]
                year_from = dates[2]
                month_to = dates[3]
                day_to = dates[4]
                year_to = dates[5]
                ui.print_result(get_items_sold_between(table, month_from, day_from, year_from, month_to, day_to, year_to), ["ID", "TITLE", "PRICE", "MONTH", "DAY", "YEAR"])
                common.go_back_in_menu()
                
            elif option == "0":
                break
            
            else:
                raise KeyError("There is no such option")
        
        except KeyError as err:
            ui.print_error_message(str(err))
def start_module():
    """
    Starts this module and displays its menu.
     * User can access default special features from here.
     * User can go back to main menu from here.

    Returns:
        None
    """

    table = data_manager.get_table_from_file("hr/persons.csv")

    options = [
        "Show table",
        "Add item",
        "Remove item",
        "Update item",
        "Oldest poeple",
        "People closest to birth year avg."
    ]

    while True:
        ui.print_menu("Human resources manager", options, "Back to main menu")
        option = ui.get_inputs(
            ["Please enter a number: "],
            ""
        )

        try:
            if option == "1":
                show_table(table)
                common.go_back_in_menu()

            elif option == "2":
                table = add(table)
                data_manager.write_table_to_file("hr/persons.csv", table)

            elif option == "3":
                id_to_remove = ui.get_inputs(
                    ["Please enter the ID of the person you wish to remove: "],
                    ""
                    )
                if common.check_id_in_table(table, id_to_remove):
                    table = remove(table, id_to_remove)
                    data_manager.write_table_to_file("hr/persons.csv", table)

            elif option == "4":
                id_to_update = ui.get_inputs(
                    ["Please enter the ID of the person you wish to update: "],
                    ""
                )
                if common.check_id_in_table(table, id_to_update):
                    update(table, id_to_update)
                    data_manager.write_table_to_file("hr/persons.csv", table)

            elif option == "5":
                oldest_people = get_oldest_person(table)
                ui.print_result(oldest_people, "The oldest people are: ")
                common.go_back_in_menu()

            elif option == "6":
                closes_person_avg = get_persons_closest_to_average(table)
                ui.print_result(closes_person_avg, "The people born closest to the average are: ")
                common.go_back_in_menu()

            elif option == "0":
                break
            
            else:
                raise KeyError("There is no such option")
        
        except KeyError as err:
            ui.print_error_message(str(err))
Ejemplo n.º 3
0
def start_module():
    """
    Starts this module and displays its menu.
     * User can access default special features from here.
     * User can go back to main menu from here.

    Returns:
        None
    """

    table = data_manager.get_table_from_file("inventory/inventory.csv")

    options = [
        "Show table",
        "Add item",
        "Remove item",
        "Update item",
        "Available items",
        "Average durability by manufacturer"
    ]

    while True:
        ui.print_menu("Inventory manager", options, "Back to Main menu")
        option = ui.get_inputs(
            ["Please enter a number: "],
            ""
        )

        try:
            if option == "1":
                show_table(table)
                common.go_back_in_menu()

            elif option == "2":
                table = add(table)
                data_manager.write_table_to_file("inventory/inventory.csv", table)
            
            elif option == "3":
                id_to_remove = ui.get_inputs(
                    ["Please enter the ID of the title you wish to remove: "],
                    ""
                )
                if common.check_id_in_table(table, id_to_remove):    
                    table = remove(table, id_to_remove)
                    data_manager.write_table_to_file("inventory/inventory.csv", table)

            elif option == "4":
                id_to_update = ui.get_inputs(
                    ["Please enter the Id of the item you wish to update: "],
                    ""
                )
                if common.check_id_in_table(table, id_to_update):
                    update(table, id_to_update)
                    data_manager.write_table_to_file("inventory/inventory.csv", table)

            elif option == "5":
                ui.print_result(get_available_items(table), "The available items are: ")
                common.go_back_in_menu()
            
            elif option == "6":
                ui.print_result(get_average_durability_by_manufacturers(table), ["MANUFACTURER", "AVG. DURABILITY"])
                common.go_back_in_menu()

            elif option == "0":
                break

            else:
                raise KeyError("Theres no such option")
            
        except KeyError as err:
            ui.print_error_message(str(err))
def start_module():
    """
    Starts this module and displays its menu.
     * User can access default special features from here.
     * User can go back to main menu from here.

    Returns:
        None
    """

    # you code
    table = data_manager.get_table_from_file("accounting/items.csv")

    options = [
        "Show table",
        "Add item",
        "Remove item",
        "Update item",
        "Most profitable year",
        "Avg. profit / item in a given year"]

    while True:
        ui.print_menu("- Accounting -", options, "Back to Main menu")
        option = ui.get_inputs(["Please enter a number: "], "")

        try:
            if option == "1":
                show_table(table)
                common.go_back_in_menu()

            elif option == "2":
                table = add(table) 
                data_manager.write_table_to_file("accounting/items.csv", table)

            elif option == "3":
                id_to_remove = ui.get_inputs(
                    ["Please enter the ID of the title you wish to remove: "], ""
                )
                if common.check_id_in_table(table, id_to_remove):
                    table = remove(table, id_to_remove)
                    data_manager.write_table_to_file("accounting/items.csv", table)

            elif option == "4":
                id_to_update = ui.get_inputs(
                    ["Please enter the ID of the title you wish to update: "],
                    ""
                )
                if common.check_id_in_table(table, id_to_update):
                    update(table, id_to_update)
                    data_manager.write_table_to_file("accounting/items.csv", table)

            elif option == "5":
                ui.print_result(which_year_max(table), "\nThe most profitable year was: ")
                common.go_back_in_menu()

            elif option == "6":
                which_year = ui.get_inputs(
                    ["Please enter a year: "],
                    ""
                )
                ui.print_result(avg_amount(table, which_year), "The average amount by given year is: ")
                common.go_back_in_menu()

            elif option == "0":
                break

            else:
                raise KeyError("There is no such option")

        except KeyError as err:
            ui.print_error_message(str(err))
def start_module():
    """
    Starts this module and displays its menu.
     * User can access default special features from here.
     * User can go back to main menu from here.

    Returns:
        None
    """
    table = data_manager.get_table_from_file("store/games.csv")

    options = [
        "Show table",
        "Add item",
        "Remove item",
        "Update item",
        "Games per manufacturer",
        "Average stock by manufacturer"]

    while True:
        ui.print_menu("- Store manager -", options, "Back to Main menu")
        option = ui.get_inputs(["Please enter a number: "], "")

        try:
            if option == "1":
                show_table(table) 
                common.go_back_in_menu()

            elif option == "2":
                table = add(table) 
                data_manager.write_table_to_file("store/games.csv", table)

            elif option == "3":
                id_to_remove = ui.get_inputs(
                    ["Please enter the ID of the title you wish to remove: "], ""
                )
                if common.check_id_in_table(table, id_to_remove):
                    table = remove(table, id_to_remove)
                    data_manager.write_table_to_file("store/games.csv", table)

            elif option == "4":
                id_to_update = ui.get_inputs(
                    ["Please enter the ID of the title you wish to update: "],
                    ""
                )
                if common.check_id_in_table(table, id_to_update): 
                    update(table, id_to_update)
                    data_manager.write_table_to_file("store/games.csv", table)

            elif option == "5":
                count_by_manufacturer = get_counts_by_manufacturers(table)
                ui.print_result(count_by_manufacturer, ["MANUFACTURER", "GAMES"])
                common.go_back_in_menu()
                
            elif option == "6":
                which_manuf = ui.get_inputs(
                    ["Please enter which manufacturer: "],
                    ""
                )
                try:
                    average_stock_by_manufacturer = get_average_by_manufacturer(table, which_manuf)
                except ZeroDivisionError:
                    continue

                ui.print_result(average_stock_by_manufacturer,"The avarege stock by the manufacturer is ")
                common.go_back_in_menu()

            elif option == "0":
                break

            else:
                raise KeyError("There is no such option")

        except KeyError as err:
            ui.print_error_message(str(err))
Ejemplo n.º 6
0
def start_module():
    """
    Starts this module and displays its menu.
     * User can access default special features from here.
     * User can go back to main menu from here.

    Returns:
        None
    """

    table = data_manager.get_table_from_file("crm/customers.csv")

    options = [
        "Show table",
        "Add item",
        "Remove item",
        "Update item",
        "ID of the longest name",
        "Customers subscribed to newsletter"
    ]

    while True:
        ui.print_menu("- CRM manager -", options, "Back to Main menu")
        option = ui.get_inputs(["Please enter a number: "], "")

        try:
            if option == "1":
                show_table(table)
                common.go_back_in_menu()

            elif option == "2":
                table = add(table)
                data_manager.write_table_to_file("crm/customer.csv", table)

            elif option == "3":
                id_to_remove = ui.get_inputs(
                    ["Please enter the ID of the person you wish to remove: "],
                    ""
                )
                if common.check_id_in_table(table, id_to_remove):
                    table = remove(table, id_to_remove)
                    data_manager.write_table_to_file("crm/customers.csv", table)

            elif option == "4":
                id_to_update = ui.get_inputs(
                    ["Please enter the ID of the person you wish to update: "],
                    ""
                )
                if common.check_id_in_table(table, id_to_update):
                    update(table, id_to_update)
                    data_manager.write_table_to_file("crm/customers.csv", table)

            elif option == "5":
                ui.print_result(get_longest_name_id(table), "\nThe ID of the longest name is: ")
                common.go_back_in_menu()
            
            elif option == "6":
                ui.print_result(get_subscribed_emails(table), "")
                common.go_back_in_menu()
            elif option == "0":
                break

            else:
                raise KeyError("There is no such option")

        except KeyError as err:
            ui.print_error_message(str(err))