示例#1
0
def run():
    options = [
        "Add", "Remove", "Update", "Count by manufacturer",
        "Average games in stock by manufacturer"
    ]
    common_options = ["Title: ", "Manufacturer: ", "Price: ", "In stock: "]
    file = "model/store/games.csv"
    title_list = ["Id", "Title", "Manufacturer", "Price", "In stock"]
    choice = None
    terminal_clear = True
    while choice != '0':
        if terminal_clear:
            table = common.clear_instructions(file, title_list)
        choice = terminal_view.get_choice_submenu(options)
        terminal_clear = True
        if choice == '1':
            common.add(file, common_options)
        elif choice == '2':
            common.remove(file)
        elif choice == '3':
            common.update(file, common_options)
        elif choice == '4':
            msg = "Products by manufacturer:\n"
            terminal_view.print_result(
                store.get_counts_by_manufacturers(table), msg)
            terminal_clear = False
        elif choice == '5':
            manufacturer = terminal_view.get_inputs(
                ["Manufacturer: "], "Please provide manufacturer name")
            msg = "Average by " + manufacturer[0] + ":"
            value = store.get_average_by_manufacturer(table, manufacturer[0])
            terminal_view.print_result(value, msg)
            terminal_clear = False
        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
    """

    list_options = [
        "1. Add new record to table",
        "2. Remove a record with a given id from the table",
        "3. Update specified record in the table",
        "4. Which items have not exceeded their durability yet?",
        "5. What are the average durability times for each manufacturer?"
    ]

    program_works = True

    while program_works:
        table = inventory.get_table()
        title_list = [
            "ID", "NAME", "MANUFACTURER", "PURCHASE YEAR", "DURABILITY"
        ]
        terminal_view.print_table(table, title_list)

        answer = terminal_view.get_choice(list_options)

        if answer == "1":
            record = terminal_view.get_inputs([
                "ID: ", "Name: ", "Manufacturer: ", "Purchase year: ",
                "Durability: "
            ], "Please provide information: \n")
            common.add(table, record)
            inventory.save_table(table)
        elif answer == "2":
            id_ = terminal_view.get_input("Please enter id number: ")
            common.remove(table, id_)
            inventory.save_table(table)
        elif answer == "3":
            id_ = terminal_view.get_input("Please enter id number: ")
            record = terminal_view.get_inputs([
                "Enter ID: ", "Name of item: ", "Manufacturer: ",
                "Year of purchase", "Durability year"
            ], "Please provide new information")
            common.update(table, id_, record)
            inventory.save_table(table)
        elif answer == "4":
            inventory.get_oldest_person(table)
        elif answer == "5":
            inventory.get_average_durability_by_manufacturers(table)
        elif answer == "0":
            program_works = False
        else:
            terminal_view.print_error_message(
                "There is no such choice. Choose from 1 to 5")
    return
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
    """
    list_options = [
        "1. Add new record to table",
        "2. Remove a record with a given id from the table",
        "3. Update specified record in the table",
        "4. Which year has the highest profit?",
        "5. What is the average (per item) profit in a given year?"
    ]

    program_works = True
    while program_works:

        table = accounting.get_table()
        title_list = ["ID", "MONTH", "DAY", "YEAR", "TYPE", "AMOUNT"]
        terminal_view.print_table(table, title_list)

        answer = terminal_view.get_choice(list_options)

        if answer == "1":
            record = terminal_view.get_inputs([
                "ID: ", "Month of the transaction: ",
                "Day of the transaction: ", "Year of the transaction: ",
                "Type - income/outflow (in.out): ",
                "Amount of transaction in USD: "
            ], "Please provide information: \n")
            common.add(table, record)
            accounting.save_table(table)
        elif answer == "2":
            id_ = terminal_view.get_input("Please enter id number: ")
            common.remove(table, id_)
            accounting.save_table(table)
        elif answer == "3":
            id_ = terminal_view.get_input("Please enter id number: ")
            record = terminal_view.get_inputs(
                ["ID: ", "Month: ", "Day: ", "Year: ", "Type: ", "Ammount: "],
                "Please provide new information")
            common.update(table, id_, record)
            accounting.save_table(table)
        elif answer == "4":
            accounting.which_year_max(table)
        elif answer == "5":
            accounting.avg_amount(table, year)
        elif answer == "0":
            program_works = False
        else:
            terminal_view.print_error_message(
                "There is no such choice. Choose from 1 to 5")
    return
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
    """

    list_options = [
        "1. Add new record to table",
        "2. Remove a record with a given id from the table",
        "3. Update specified record in the table", "4. Which person is oldest",
        "5. Which person is closest to average"
    ]

    program_works = True

    while program_works:
        table = hr.get_table()
        title_list = ["ID", "NAME", "DATE OF BIRTH"]
        terminal_view.print_table(table, title_list)
        answer = terminal_view.get_choice(list_options)

        if answer == "1":
            record = terminal_view.get_inputs(
                ["ID: ", "Name and surname: ", "Date of birth: "],
                "Please provide your personal information")
            common.add(table, record)
            hr.save_table(table)
        elif answer == "2":
            id_ = terminal_view.get_input("Please enter id number: ")
            common.remove(table, id_)
            hr.save_table(table)
        elif answer == "3":
            id_ = terminal_view.get_input("Please enter id number: ")
            record = terminal_view.get_inputs(
                ["ID: ", "Name and surname: ", "Year of birth: "],
                "Please provide new information")
            common.update(table, id_, record)
            hr.save_table(table)
        elif answer == "4":
            print(hr.get_oldest_person(table))
            # result = hr.get_oldest_person(table)
            # terminal_view.print_result(result, "Oldest person is: ")
        elif answer == "5":
            hr.get_persons_closest_to_average(table)
        elif answer == "0":
            program_works = False
        else:
            terminal_view.print_error_message(
                "There is no such choice. Choose from 1 to 5")
    return
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
    """
    options = [
        "Add data", "Remove data", "Update data",
        "The customer ID with the Longest name", "Newsletter subscription",
        "Customer\'s name with the given ID"
    ]
    common_options = [
        "Name: ", "E-mail: ", "Newsletter subscribtion ('1'-yes or '0'-no): "
    ]
    link_for_csv = "model/crm/customers.csv"
    title_list = ["ID", "Name", "E-mail", "Newsletter subscribtion"]
    choice = None
    dont_clear = False
    while choice != '0':
        if not dont_clear:
            os.system("clear")
            table = data_manager.get_table_from_file(link_for_csv)
            terminal_view.print_table(table, title_list)
        choice = terminal_view.get_choice_submenu(options)
        dont_clear = False
        if choice == '1':
            common.add(link_for_csv, common_options)
        elif choice == '2':
            common.remove(link_for_csv)
        elif choice == '3':
            common.update(link_for_csv, common_options)
        elif choice == '4':
            terminal_view.print_result(
                crm.get_longest_name_id(table),
                'ID of the customer with the Longest name: ')
            dont_clear = True
        elif choice == '5':
            table_subscription = crm.get_subscribed_emails(table)
            terminal_view.print_result(
                table_subscription,
                'Customers who has subscribed to the newsletter: ')
            dont_clear = True
        elif choice == '6':
            ID = terminal_view.get_input("ID: ", "Please enter ID: ")
            terminal_view.print_result(
                crm.get_name_by_id_from_table(table, ID),
                "Customer\'s name by given ID: ")
            dont_clear = True
        else:
            terminal_view.print_error_message(
                "There is no such choice, please try again")
def remove():
    """
    Remove a record with a given id from the table.

    Args:
        table (list): table to remove a record from
        id_ (str): id of a record to be removed

    Returns:
        list: Table without specified record.
    """
    common.remove(sales_file)
示例#7
0
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
    """
    options = [
        'Add item', 'Edit item', 'Remove item',
        'Which items have not exceeded their durability yet',
        'What are the average durability times for each manufacturer'
    ]
    link_to_csv = 'model/inventory/inventory.csv'
    common_options = [
        'Name of item: ', 'Manufacturer: ', 'Year of purchase: ',
        'Years it can be used: '
    ]
    title_list = [
        "Id", "Name", "Manufacturer", "Year of purchase",
        "Years it can be used"
    ]
    choice = None
    dont_clear = False
    while choice != "0":
        if not dont_clear:
            os.system("clear")
            table = data_manager.get_table_from_file(link_to_csv)
            terminal_view.print_table(table, title_list)
        choice = terminal_view.get_choice_submenu(options)
        dont_clear = False
        if choice == "1":
            common.add(link_to_csv, common_options)
        elif choice == "2":
            common.update(link_to_csv, common_options)
        elif choice == "3":
            common.remove(link_to_csv)
        elif choice == "4":
            os.system("clear")
            table_to_print = inventory.get_available_items(table)
            terminal_view.print_table(table_to_print, labels)

            dont_clear = True
        elif choice == "5":
            terminal_view.print_result(
                inventory.get_average_durability_by_manufacturers(table),
                '\nWhat are the average durability times for each manufacturer: '
            )
            dont_clear = True
        else:
            terminal_view.print_error_message("There is no such choice.")
def run():
    options = ["Add", "Remove", "Update", "Lowest price item ID", "Items sold between", "Game title by ID", "All the Customer\'s IDs", "The sales of each customer", "The sales of each customer", "The number of sales of each customer", "The number of sales of each customer: "]
    common_options = ["Title: ", "Price: ", "Month: ", "Day: ", "Year: "]
    link_for_csv = "model/sales/sales.csv"
    title_list = ["ID", "Title", "Price", "Month", "Day", "Year", "Customer ID"]
    choice = None
    dont_clear = False
    while choice != '0':
        if not dont_clear:
            os.system("clear")
            table = data_manager.get_table_from_file(link_for_csv)
            terminal_view.print_table(table, title_list)
        choice = terminal_view.get_choice_submenu(options)
        dont_clear = False
        if choice == '1':
            common.add(link_for_csv, common_options)
        elif choice == '2':
            common.remove(link_for_csv)
        elif choice == '3':
            common.update(link_for_csv, common_options)
        elif choice == '4':
            lowest_price = sales.get_lowest_price_item_id(table)
            terminal_view.print_result(lowest_price, 'Lowest price game is: ')
            dont_clear = True
        elif choice == '5':
            dates_to_input = ['From month: ', 'From day: ', 'From year: ', 'To month:', 'To day: ', "To year: "]
            inputs = terminal_view.get_input(dates_to_input, "Please input appropriate data.")
            answer = sales.get_items_sold_between(table, int(inputs[0]), int(inputs[1]), int(inputs[2]), int(inputs[3]),
                                                  int(inputs[4]), int(inputs[5]))
            terminal_view.print_table(answer, title_list)
            dont_clear = True
        elif choice == '6':
            dates_to_input = 'Input ID: '
            inputs = terminal_view.get_input(dates_to_input, 'Please input appropriate data.')
            answer = sales.get_title_by_id(inputs)
            terminal_view.print_result(answer, 'Game title is: ')
            dont_clear = True
        elif choice == "7":
            terminal_view.print_result(sales.get_all_customer_ids_from_table(table), 'All the Customer\'s ID: ')
            dont_clear = True
        elif choice == "8":
            terminal_view.print_result(sales.get_all_sales_ids_for_customer_ids(), "The sales of each customer: ")
            dont_clear = True
        elif choice == "9":
            terminal_view.print_result(sales.get_all_sales_ids_for_customer_ids_form_table(table), "The sales of each customer: ")
            dont_clear = True
        elif choice == "10":
            terminal_view.print_result(sales.get_num_of_sales_per_customer_ids(), "The number of sales of each customer: ")
            dont_clear = True
        elif choice == "11":
            terminal_view.print_result(sales.get_num_of_sales_per_customer_ids_from_table(table), "The number of sales of each customer: ")
            dont_clear = True
示例#9
0
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
    """
    options = [
        "Add data", "Remove data", "Update data",
        "Year with the highest profit", "The average profit for a given year"
    ]
    common_options = [
        "Month: ", "Day: ", "Year: ",
        "Income (enter: 'in') or Outflow(enter:'out') money: ", "Amount: "
    ]
    link_for_csv = 'model/accounting/items.csv'
    title_list = [
        "ID", "Month", "Day", "Year", "Income or Outflow money", "Amount"
    ]
    choice = None
    dont_clear = False
    while choice != "0":
        if not dont_clear:
            os.system("clear")
            table = data_manager.get_table_from_file(link_for_csv)
            terminal_view.print_table(table, title_list)
        choice = terminal_view.get_choice_submenu(options)
        dont_clear = False
        if choice == "1":
            common.add(link_for_csv, common_options)
        elif choice == "2":
            common.remove(link_for_csv)
        elif choice == "3":
            common.update(link_for_csv, common_options)
        elif choice == "4":
            terminal_view.print_result(accounting.which_year_max(table),
                                       "Year with the highest profit: ")
            dont_clear = True
        elif choice == "5":
            year = int(
                terminal_view.get_input(
                    "Year: ", "Enter a year to find out an average profit: "))
            terminal_view.print_result(
                accounting.avg_amount(table, year),
                'The average profit for a given year: ')
            dont_clear = True
        else:
            terminal_view.print_error_message(
                "There is no such choice, please try again")
示例#10
0
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
    """
    list_options = [
        "1. Add new record to table",
        "2. Remove a record with a given id from the table",
        "3. Update specified record in the table",
        "4. What is the id of the customer with the longest name?",
        "5. Which customers has subscribed to the newsletter?"
    ]

    program_works = True
    while program_works:
        table = crm.get_table()
        title_list = [
            "ID",
            "NAME",
            "EMAIL",
            "SUBSCRIBED? y/n",
        ]
        terminal_view.print_table(table, title_list)
        answer = terminal_view.get_choice(list_options)

        if answer == "1":
            record = terminal_view.get_inputs(
                ["ID: ", "Name: ", "E-mail: ", "Subscription? Yes/ No"],
                "Please provide information: \n")
            common.add(table, record)
            crm.save_table(table)
        elif answer == "2":
            id_ = terminal_view.get_input("Please enter id number: ")
            common.remove(table, id_)
            crm.save_table(table)
        elif answer == "3":
            common.update(table, id_, record)
        elif answer == "4":
            crm.get_longest_name_id(table)
        elif answer == "5":
            crm.get_subscribed_emails(table)
        elif answer == "0":
            program_works = False
        else:
            terminal_view.print_error_message(
                "There is no such choice. Choose from 1 to 5")
    return
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
    """


    list_options = ["1. Add new record to table", 
                    "2. Remove a record with a given id from the table", 
                    "3. Update specified record in the table", 
                    "4. How many different kinds of game are available of each manufacturer?", 
                    "5. What is the average amount of games in stock of a given manufacturer?"]

    
    program_works = True

    while program_works:
        table = store.get_table()
        title_list = ["ID", "TITLE", "MANUFACTURER", "PRICE (in $)", "IN STOCK"]
        terminal_view.print_table(table, title_list)
        
        answer = terminal_view.get_choice(list_options)

        if answer == "1":
            record = terminal_view.get_inputs(["ID: ","Title of the game: ","Manufacturer: ","Price in dollars: ","In stock (number): "],"Please provide information: \n")
            common.add(table, record)
            store.save_table(table)
        elif answer == "2":
            id_ = terminal_view.get_input("Please enter id number: ")
            common.remove(table, id_)
            store.save_table(table)
        elif answer == "3":
            id_ = terminal_view.get_input("Please enter id number: ")
            record = terminal_view.get_inputs(["ID: ","Title of the game: ","Manufacturer: ","Price in dollars: ","In stock (number): "],"Please provide information: \n")
            common.update(table, id_, record)
            store.save_table(table)
        elif answer =="4":
            store.get_counts_by_manufacturers(table)
        elif answer == "5":
            store.get_average_by_manufacturer(table, manufacturer)
        elif answer == "0":
            program_works = False
        else:
            terminal_view.print_error_message("There is no such choice. Choose from 1 to 5")
    return 
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
    """

    list_options = ["1. Add new record to table", 
                    "2. Remove a record with a given id from the table", 
                    "3. Update specified record in the table", 
                    "4. What is the id of the item that was sold for the lowest price?", 
                    "5. Which items are sold between two given dates?"]
    
    program_works = True

    while program_works:
        table = sales.get_table()  
        title_list = ["ID", "TITLE", "PRICE","MONTH","DAY","YEAR"]
        terminal_view.print_table(table, title_list)

        answer = terminal_view.get_choice(list_options)

        if answer == "1":
            record = terminal_view.get_inputs(["ID: ","Title of the game sold: ","The actual sale price in USD: ","Month of the sale: ","Day of the sale: ","Year of the sale: "],"Please provide information: \n")
            common.add(table, record)
            sales.save_table(table)
        elif answer == "2":
            id_ = terminal_view.get_input("Please enter id number: ")
            common.remove(table, id_)
            sales.save_table(table)
        elif answer == "3":
            id_ = terminal_view.get_input("Please enter id number: ")
            record = terminal_view.get_inputs(["ID: ","Title of the game sold: ","The actual sale price in USD: ","Month of the sale: ","Day of the sale: ","Year of the sale: "],"Please provide information: \n")
            common.update(table, id_, record)
            sales.save_table(table)
        elif answer == "4":
            sales.get_oldest_person(table)
        elif answer == "5":
            sales.get_items_sold_between(table, month_from, day_from, year_from, month_to, day_to, year_to)
        elif answer == "0":
            program_works = False
        else:
            terminal_view.print_error_message("There is no such choice. Choose from 1 to 5")
    return 
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
    """
    options = ["Add", "Remove", "Update", "Oldest person", "Persons closest to average"]
    common_options = ["Name: ", "Year: "]
    file = "model/hr/persons.csv"
    title_list = ["Id", "Name", "Year"]
    choice = None
    dont_clear = False
    while choice != '0':
        if not dont_clear:
            os.system("clear")
            table = data_manager.get_table_from_file(file)
            terminal_view.print_table(table, title_list)
        choice = terminal_view.get_choice_submenu(options)
        dont_clear = False
        if choice == '1':
            common.add(file, common_options)
        elif choice == '2':
            common.remove(file)
        elif choice == '3':
            common.update(file, common_options)
        elif choice == '4':
            terminal_view.print_result(hr.get_oldest_person(table), "Oldest persons:\n")
            dont_clear = True
        elif choice == '5':
            msg = "Persons with age closest to average:\n"
            terminal_view.print_result(hr.get_persons_closest_to_average(table), msg)
            dont_clear = True
        else:
            terminal_view.print_error_message("There is no such choice.")