Ejemplo n.º 1
0
def choose_service(Services):
    Service.show_service_list(Services)
    print
    while True:
        service_id = raw_input('Please select the Service ID to continue:')
        service = Service.find_service(Services, service_id)
        if service is None:
            print 'Invalid Service ID, please re-select one'
        else:
            break
    return service
Ejemplo n.º 2
0
def show_servicelist(Services):
    Service.show_service_list(Services)
    while True:
        input_sid = raw_input('Select one Service ID for the service:')
        #input_sid = '201'
        if len(filter(lambda service: service.sid == input_sid, Services)) == 0:
            print 'The Service ID is not listed on the service list!'
            continue
        else:
            break
    return input_sid
Ejemplo n.º 3
0
def delete_service(Services):
    while True:
        Service.show_service_list(Services)
        input = raw_input('Please enter the service id for deletion:')
        service = Service.find_service(Services, input)
        if service is None:
            print 'Invalid service id. Please re-enter a new one!'
            print
        else:
            break
    pickle_file = service_folder + service.name + '.pkl'
    os.remove(pickle_file)
    Services.remove(service)
    print 'Delete Service \'' + service.name + '\' Succeed!'
Ejemplo n.º 4
0
def makereservation(Customers, Services):
    """choose from a list of service, output a string"""
    choice_of_service = show_servicelist(Services)

    """enter an integer, output a string to represent ID"""
    customerID = enter_cid(Customers)

    """get customer and service object with specified id"""
    customer = Customer.find_customer(Customers, customerID)
    service = Service.find_service(Services, choice_of_service)
    """enter a date and time, output a string to represent date and time"""
    choice_of_datetime = choose_datetime(customer)
    """enter a integer, output a integer to represent the chosen length of the service"""
    choice_of_length = choose_length(service, choice_of_datetime)

    """change the data in database"""
    while True:
        print 'The time is available for making reservation'
        ans = raw_input('Do you want to make reservation?(Y or N):')
        if ans == 'Y' or ans == 'y':
            service.reserve(customer, choice_of_datetime, choice_of_length)
            break
        elif ans == 'N' or ans == 'n':
            print 'OK, now return to main screen'
            print
            break
        else:
            print 'Please type the correct key(Y or N)'
            print
Ejemplo n.º 5
0
def change_time_for_reservation(Customers, Services):
    if len(Customers) == 0:
        print 'There is no customer yet! Please add new customer first!'
    else:
        #show information of all customers
        print 'The followings are the list of Customer:'
        print '{0:15} {1:15} {2:15} {3:15}'.format('Customer ID', 'Customer Name', 'Check-in Date', 'Check-out Date')

        for customer in sorted(Customers, key=lambda customer: customer.id):
            print '{0:15} {1:15} {2:15} {3:15}'.format(customer.id, customer.name, customer.in_date, customer.out_date)

        while True:
            input = raw_input('Please choose one customer ID to continue:')
            customer = Customer.find_customer(Customers, input)
            if customer is None:
                print 'Invalid Customer ID, please re-type one!'
            else:
                break
        #show all reservations of the customer
        if customer.reservation_count == 0:
            print 'There is no any reservation for the customer ' + customer.name
            print
        else:
            customer.show_all_reservations()

            while True:
                input = raw_input('Please choose one reservation ID to continue:')
                reservation = customer.find_reservation_by_id(input)
                if reservation is None:
                    print 'Invalid reservation ID, please re-type one!'
                else:
                    break

            service = Service.find_service(Services, reservation.sid)
            choice_of_datetime = choose_datetime(customer)
            choice_of_length = choose_length(service, choice_of_datetime)

            while True:
                print 'The time is available for time modification'
                ans = raw_input('Do you want to change the time of the reservation?(Y or N):')
                if ans == 'Y' or ans == 'y':
                    service.modify_schedule(reservation, choice_of_datetime, choice_of_length)
                    break
                elif ans == 'N' or ans == 'n':
                    print 'OK, now return to main screen'
                    print
                    break
                else:
                    print 'Please type the correct key(Y or N)'
                    print

            print 'Modifying the reservation succeed!'
            print
            customer.show_all_reservations()
Ejemplo n.º 6
0
def change_price(Services):
    print 'The followings are the list of services:'
    print '{0:15} {1:10} {2:20} {3:12}'.format('Service Type', 'Service ID', 'Service Name', 'Service Price')

    for service in sorted(Services, key=lambda service: service.sid):
        print '{0:15} {1:10} {2:20} {3:12}'.format(service.type, service.sid, service.name, service.price)
    print
    while True:
        service_id = raw_input('Please select the Service ID for changing its price:')
        service = Service.find_service(Services, service_id)
        if service is None:
            print 'Invalid Service ID, please re-select one'
        else:
            break
    old_service_price = service.price
    new_service_price = get_service_price('1')
    service.price = new_service_price
    print 'Changing service ' +  service.name + ' price from ' + str(old_service_price) +\
        ' to ' + str(new_service_price) + ' succeed!'