def read_renter_list_entity_input(self):
        renterListEntity = RentingListScheme()
        renterListEntity.car_number = input("enter car number: ")
        while not CheckInput.test_car_number(renterListEntity.car_number):
            renterListEntity.car_number = input("Wrong input!\nTry again: ")

        while not CheckInput.check_car_existence(renterListEntity.car_number):
            car_entity = CarScheme()
            input_str = ""
            input_str = input("There is no such car!\nWanna add?\n(y/n): ")
            for case in switch(input_str):
                if case('y'):
                    car_entity = self.read_car_input()
                    renterListEntity.car_number = car_entity.car_number
                    db.insert_car(car_entity)
                    break
                if case('n'):
                    print("can't insert renting list entity")
                    return
                else:
                    print("____________________")
                    print("no such option, try again!")

        renterListEntity.driver_license = input("enter renter driver license: ")
        while not CheckInput.test_driver_license(renterListEntity.driver_license):
            renterListEntity.driver_license = input("Wrong input!\nTry again: ")

        while not CheckInput.check_renter_existence(renterListEntity.driver_license):
            renter_entity = RenterScheme()
            input_str = ""
            input_str = input("There is no such renter!\nWanna add?\n(y/n): ")
            for case in switch(input_str):
                if case('y'):
                    renter_entity = self.read_renter_input()
                    renterListEntity.driver_license = renter_entity.driver_license
                    db.insert_renter(renter_entity)
                    break
                if case('n'):
                    print("can't insert renting list entity")
                    return
                else:
                    print("____________________")
                    print("no such option, try again!")

        renterListEntity.date = input("enter renting date(format: year-mm-dd): ")
        while not CheckInput.test_date(renterListEntity.date):
            renterListEntity.date = input("Wrong input!\nTry again: ")

        return renterListEntity
Exemple #2
0
 def read_worker_update_input(self):
     workerEntity = WorkerScheme()
     workerEntity.name = input("enter worker name: ")
     workerEntity.id = input("enter worker id: ")
     if CheckInput.check_worker_existence(workerEntity.id):
         workerEntity.is_still_working = input(
             "enter worker is still working (True/False): ")
         while workerEntity.is_still_working != "True" and workerEntity.is_still_working != "False":
             workerEntity.is_still_working = input(
                 "Wrong input!\nTry again: ")
         workerEntity.department_id = input("enter department id: ")
         while not CheckInput.check_department_existence(
                 workerEntity.department_id):
             input_str = input(
                 "There is no such department!\nWanna add?\n(y/n): ")
             for case in switch(input_str):
                 if case('y'):
                     department_entity = self.read_department_input()
                     workerEntity.department_id = department_entity.id
                     db.insert_department(department_entity)
                     break
                 if case('n'):
                     print("can't insert worker")
                     return
                 else:
                     print("____________________")
                     print("no such option, try again!")
         return workerEntity
     else:
         print("There is no such worker in db!")
         return None
Exemple #3
0
    def read_worker_card_input(self):
        worker_card_entity = WorkerCardScheme()
        worker_card_entity.id = input("enter id: ")
        worker_card_entity.worker_id = input("enter worker_id: ")
        while not CheckInput.check_worker_existence(
                worker_card_entity.worker_id):
            input_str = input("There is no such worker!\nWanna add?\n(y/n): ")
            for case in switch(input_str):
                if case('y'):
                    worker_entity = self.read_worker_input()
                    worker_card_entity.worker_id = worker_entity.id
                    db.insert_worker(worker_entity)
                    break
                if case('n'):
                    print("can't insert worker card ")
                    return
                else:
                    print("____________________")
                    print("no such option, try again!")

        worker_card_entity.is_active = input("enter is active: ")
        while worker_card_entity.is_active != "True" and worker_card_entity.is_active != "False":
            worker_card_entity.is_active = input("Wrong input!\nTry again: ")

        return worker_card_entity
Exemple #4
0
    def read_journal_update_input(self):
        journal_entity = JournalScheme()
        journal_entity.id = input("enter id: ")
        if CheckInput.check_journal_existence(journal_entity.id):
            print("exit timestamp:")
            journal_entity.exit = self.get_date()
            print("entrance timestamp:")
            journal_entity.entrance = self.get_date()
            journal_entity.worker_id = input("worker id: ")
            while not CheckInput.check_worker_existence(
                    journal_entity.worker_id):

                input_str = input(
                    "There is no such worker!\nWanna add?\n(y/n): ")
                for case in switch(input_str):
                    if case('y'):
                        worker_entity = self.read_worker_input()
                        journal_entity.worker_id = worker_entity.id
                        db.insert_worker(worker_entity)
                        break
                    if case('n'):
                        print("can't insert journal")
                        return
                    else:
                        print("____________________")
                        print("no such option, try again!")
            return journal_entity
        else:
            print("There is no such journal in db!")
            return None
Exemple #5
0
def get_db_name():
    while 1:
        switchVariable = input(
            "CHOOSE DB BY ITS NUMBER\npossible are: \n\t1 - cars, \n\t2 - renters, \n\t3 - renting_list, "
            "\n\tb - go to main menu\nType here and press enter: ")
        for case in switch(switchVariable):
            if case('1'):
                return "cars"
            if case('2'):
                return "renters"
            if case('3'):
                return "renting_list"
            if case('b'):
                break
            else:
                print("____________________")
                print("no such option, try again!")
Exemple #6
0
def get_db_name():
    while 1:
        switchVariable = input(
            "CHOOSE DB BY ITS NUMBER\npossible are: \n\t1 - department, \n\t2 - worker, \n\t3 - worker_card, "
            "\n\t4 - journal,"
            "\n\tb - go to main menu\nType here and press enter: ")
        for case in switch(switchVariable):
            if case('1'):
                return "department"
            if case('2'):
                return "worker"
            if case('3'):
                return "worker_card"
            if case('4'):
                return "journal"
            if case('b'):
                break
            else:
                print("____________________")
                print("no such option, try again!")
Exemple #7
0
def get_criteria():
    while 1:
        switchVariable = input(
            "CHOOSE SEARCH CRITERIA BY ITS NUMBER\npossible are: \n\t1 - by_exit_range, \n\t2 - "
            "by_still_working, \n\t3 - by_exit_range_and_still_working, "
            "\n\t4 - by_word_not_belong (worker name), \n\t5 - by_whole_sentence (department"
            " production)\n\tb - go to main menu\nType here and press enter: ")
        for case in switch(switchVariable):
            if case('1'):
                return "by_exit_range"
            if case('2'):
                return "by_still_working"
            if case('3'):
                return "by_exit_range_and_still_working"
            if case('4'):
                return "by_word_not_belong"
            if case('5'):
                return "by_whole_sentence"
            if case('b'):
                break
            else:
                print("____________________")
                print("no such option, try again!")
Exemple #8
0
def get_criteria():
    while 1:
        switchVariable = input(
            "CHOOSE SEARCH CRITERIA BY ITS NUMBER\npossible are: \n\t1 - by_date_range, \n\t2 - "
            "by_transmission, \n\t3 - by_date_range_and_transmission, "
            "\n\t4 - by_word_not_belong (car's name), \n\t5 - by_whole_sentence (car's model)\n\tb - go to main menu\nType here and press enter: "
        )
        for case in switch(switchVariable):
            if case('1'):
                return "by_date_range"
            if case('2'):
                return "by_transmission"
            if case('3'):
                return "by_date_range_and_transmission"
            if case('4'):
                return "by_word_not_belong"
            if case('5'):
                return "by_whole_sentence"
            if case('b'):
                break
            else:
                print("____________________")
                print("no such option, try again!")
Exemple #9
0
                return "by_word_not_belong"
            if case('5'):
                return "by_whole_sentence"
            if case('b'):
                break
            else:
                print("____________________")
                print("no such option, try again!")


while 1:
    switchVariable = input(
        "CHOOSE COMMAND BY ITS NUMBER\npossible are: \n\t1 - add_entity, \n\t2 - fill_rand, \n\t3 "
        "- update_entity\n\t4 - delete_entity,\n\t5 - search_in_db, \n\tq - quit\nType here and press enter: "
    )
    for case in switch(switchVariable):
        if case('1'):
            db_name = get_db_name()
            print("Table before insertion:\n", db.get_table_string(db_name))
            add_entity(db_name)
            print("Table after insertion:\n", db.get_table_string(db_name))
            print("____________________")
            break
        if case('2'):
            db_name = get_db_name()
            print("Table before insertion:\n", db.get_table_string(db_name))
            fill_rand(db_name)
            print("Table after insertion:\n", db.get_table_string(db_name))
            print("____________________")
            break
        if case('3'):