Пример #1
0
    def read_renter_list_entity_update_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: ")

        renterListEntity.date = input("enter renting date(format: year-mm-dd): ")
        while not CheckInput.test_date(renterListEntity.date):
            renterListEntity.date = input("Wrong input!\nTry again: ")
        if CheckInput.check_renting_list_entity_existence(renterListEntity.car_number, renterListEntity.date):
            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!")
        else:
            print("There's no such renting list entity")
            return None

        return renterListEntity
Пример #2
0
def delete_entity(db_name):
    if db_name == "cars":
        car_number = user_input.get_car_number_input()

        if not CheckInput.check_car_existence(car_number):
            print("There is no such car in db!\n")
        else:
            db.delete_car(car_number)

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

        if not CheckInput.check_renter_existence(driver_license):
            print("There is no such renter in db!\n")
        else:
            db.delete_renter(driver_license)

    elif db_name == "renting_list":
        car_number = user_input.get_car_number_input()
        date = input("enter renting date(format: year-mm-dd): ")
        while not CheckInput.test_date(date):
            date = input("Wrong input!\nTry again: ")

        if not CheckInput.check_renting_list_entity_existence(
                car_number, date):
            print("There is no such renting list entity in db!\n")

        else:
            db.delete_renting_list_entity(car_number, date)
Пример #3
0
    def read_renter_input(self):
        renterEntity = RenterScheme()
        renterEntity.first_name = input("enter renter first name: ")
        renterEntity.last_name = input("enter renter last name: ")
        renterEntity.driver_license = input("enter renter driver license: ")
        while not CheckInput.test_driver_license(renterEntity.driver_license):
            renterEntity.driver_license = input("Wrong input!\nTry again: ")

        return renterEntity
Пример #4
0
 def read_renter_update_input(self):
     renterEntity = RenterScheme()
     renterEntity.driver_license = input("enter renter driver license: ")
     while not CheckInput.test_driver_license(renterEntity.driver_license):
         renterEntity.driver_license = input("Wrong input!\nTry again: ")
     if CheckInput.check_renter_existence(renterEntity.driver_license):
         renterEntity.first_name = input("enter new renter first name: ")
         renterEntity.last_name = input("enter new renter last name: ")
         return renterEntity
     else:
         print("There is no such renter in db!")
         return None