def run():
    options = [
        "Store manager", "Human resources manager", "Inventory manager",
        "Accounting manager", "Sales manager",
        "Customer Relationship Management (CRM)"
    ]

    choice = None
    while choice != "0":
        terminal_view.clear()
        choice = terminal_view.get_choice("Main menu", options, "Exit Program")
        if choice == "1":
            store_controller.run()
        elif choice == "2":
            hr_controller.run()
        elif choice == "3":
            inventory_controller.run()
        elif choice == "4":
            accounting_controller.run()
        elif choice == "5":
            sales_controller.run()
        elif choice == "6":
            crm_controller.run()
        elif choice == '0':
            terminal_view.clear()
        else:
            terminal_view.print_error_message("There is no such choice.")
def fn_update(file_name, list_labels, title, function_):
   
    id_ =  terminal_view.get_string('Updates element \nID: ')
    table, title_list = common.make_table(file_name, list_labels)
    if check_exist(table, id_, 0):  #check if there is the ID to update
        inputs = terminal_view.get_inputs(list_labels, title)
        common.make_update(inputs, file_name, id_, function_)
        terminal_view.clear()
        return True
    else:
        terminal_view.print_error_message('No such ID')
        return False
def run():
    """
    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
    """


    title = "Store menu"
    list_options = ("Show", "Add", "Remove", "Update")
    exit_message = "Back do main menu"
    file_name = 'model/store/games.csv'
    title_labels = ('ID', 'Name', 'Studio', 'Elements', 'Sales')
    list_labels = ('Name:', 'Studio:', 'Elements:', 'Sales:')


    choice = None
    terminal_view.clear()
    while choice != "0":
        choice = terminal_view.get_choice("Store menu", list_options, exit_message)
        if choice == "1":
            terminal_view.clear()
            common.show_table(file_name, title_labels)
        elif choice == "2":
            terminal_view.clear()
            title = "Create record in store"
            common.show_table(file_name, title_labels)
            common.fn_add(file_name, list_labels, title, store.add)
            common.show_table(file_name, title_labels)
        elif choice == "3":
            terminal_view.clear()
            common.show_table(file_name, title_labels)
            common.remove_record_from_file(terminal_view.get_string("ID: "), store.remove, file_name, title_labels)
            common.show_table(file_name, title_labels)
        elif choice == "4":
            terminal_view.clear()
            common.show_table(file_name, title_labels)
            if common.fn_update(file_name, list_labels, 'Update', store.update):
                common.show_table(file_name, title_labels)
        else:
            terminal_view.print_error_message("There is no such choice.")
def run():
    terminal_view.clear()
    options = [
        "Store manager", "Human resources manager",
        "Customer Relationship Management (CRM)", "Sales manager"
    ]

    choice = None
    while choice != "0":
        terminal_view.clear()
        choice = terminal_view.get_choice('Main menu', options)
        if choice == "1":
            store_controller.run()
        elif choice == "2":
            hr_controller.run()
        elif choice == "3":
            crm_controller.run()
        elif choice == '4':
            sales_controller.run()
        else:
            terminal_view.print_error_message("There is no such choice.")
def run():
    """
    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
    """

    title = "Inventory Menu"
    list_options = ('List', "Add", "Remove", "Update")
    exit_message = "Back do main menu"
    file_name = 'model/inventory/inventory.csv'
    title_labels = ('ID', 'Platform', 'Producer', 'Year', 'Elements')
    list_labels = ('Platform:', 'Producer:', 'Year:', 'Elements:')

    choice = None
    terminal_view.clear()
    while choice != '0':
        choice = terminal_view.get_choice("Inventory Menu", list_options,
                                          exit_message)
        if choice == '1':
            common.show_table(file_name, title_labels)
        elif choice == '2':
            title = "Create record in inventory"
            common.fn_add(file_name, list_labels, title, inventory.add)
            common.show_table(file_name, title_labels)
        elif choice == '3':
            common.show_table(file_name, title_labels)
            common.remove_record_from_file(terminal_view.get_string("ID: "),
                                           inventory.remove, file_name,
                                           title_labels)
        elif choice == '4':
            common.show_table(file_name, title_labels)
            if common.fn_update(file_name, list_labels, 'Update',
                                inventory.update):
                common.show_table(file_name, title_labels)
        else:
            terminal_view.print_error_message("There is no such choice.")
def remove_record_from_file(id_ , fun_, file_name, title_list):
   
    table = common.make_table(file_name)[0]
    done_table = fun_(table, id_)
    common.model_remove(file_name, done_table)
    terminal_view.clear()
def fn_add(file_name, list_labels, title, function_):
    
    table, title_list = common.make_table(file_name, list_labels)
    inputs = terminal_view.get_inputs(list_labels, title)
    common.make_record_to_add(inputs, file_name, function_)
    terminal_view.clear()
Esempio n. 8
0
def run():
    terminal_view.clear()
    options = [
        "Print list", "Add record", "Update record", "Remove record",
        "Get counts by manufacturers", "Get averege by manufacturer",
        "Get oldest game", "Get chepest game", "Get age by", "Get game by"
    ]

    file_list = "./model/store/games.csv"
    list_labels = [
        'id: ', 'title: ', 'manufacturer: ', 'price: ',
        'release_date (yyyy-mm-dd): '
    ]
    remove = ['']
    choice = None
    while choice != "0":
        choice = terminal_view.get_choice('GAMES MENU', options)
        terminal_view.clear()
        if choice == "1":
            terminal_view.print_table(
                data_manager.get_table_from_file(file_list), 'GAMES list')
        elif choice == "2":
            store.create(
                data_manager.get_table_from_file(file_list),
                terminal_view.get_inputs(list_labels,
                                         'Enter personal data here:',
                                         file_list), file_list)
        elif choice == "3":
            store.update(
                data_manager.get_table_from_file(file_list),
                terminal_view.get_inputs(
                    remove, 'Enter id, name or e-mail to update: ', ''),
                terminal_view.get_inputs(list_labels[1:],
                                         'Enter id, name or e-mail to remove',
                                         file_list), file_list)
        elif choice == "4":
            store.delete(
                data_manager.get_table_from_file(file_list),
                terminal_view.get_inputs(
                    remove, 'Enter id, name or e-mail to remove: ', ''),
                file_list)
        elif choice == "5":
            terminal_view.print_table(
                store.get_counts_by_manufacturers(
                    data_manager.get_table_from_file(file_list)),
                'The record is')
        elif choice == "6":
            terminal_view.print_result(
                store.get_average_by_manufacturer(
                    data_manager.get_table_from_file(file_list),
                    terminal_view.get_inputs(remove, 'Enter the game title',
                                             '')), 'Average by manufacturer: ')
        elif choice == "7":
            terminal_view.print_result(
                store.get_oldest_game(
                    data_manager.get_table_from_file(file_list)),
                'Get the oldest game')
        elif choice == "8":
            terminal_view.print_result(
                store.get_cheapest_game(
                    data_manager.get_table_from_file(file_list)),
                'Get the the cheapest game')
        elif choice == "9":
            terminal_view.print_result(
                store.get_age_by(
                    terminal_view.get_inputs(remove, 'Enter the game title',
                                             ''),
                    data_manager.get_table_from_file(file_list),
                    terminal_view.get_inputs(remove,
                                             'Enter the current year: ', '')),
                'The age is: ')
        elif choice == "10":
            terminal_view.print_table(
                store.get_game_by(
                    terminal_view.get_inputs(remove, 'Enter the game title',
                                             ''),
                    data_manager.get_table_from_file(file_list)),
                'The game is/are: ')
        else:
            terminal_view.print_error_message("There is no such choice.")