def delete_customer(Customers): while True: Customer.show_customer_list(Customers) input = raw_input('Please enter the customer id for deletion:') customer = Customer.find_customer(Customers, input) if customer is None: print 'Invalid customer id. Please re-enter a new one!' print else: break pickle_file = customer_folder + customer.id + '.pkl' os.remove(pickle_file) Customers.remove(customer) print 'Delete customer ' + customer.id + ':' + customer.name + ' Succeed!'
def printbill(Customers): customerID = raw_input('enter customerID to search for the corresponding bill:') if customerID == 'Q' or customerID == 'q': return #if the customer id doesn't exist if len(filter(lambda customer: customer.id == customerID, Customers)) == 0: print 'Customer ID does not exist. Please try again or enter another customer ID.\n' printbill(Customers) else: customer = Customer.find_customer(Customers, customerID) print '\nThe following bill is for customerID ' + customerID + ':\n' final_sum_to_pay=0.0 for reservation in customer.reservation_list: final_sum_to_pay += float(reservation.total) print 'Reservation no. ' + reservation.rid + '\n' \ + '________________________________________________\n' \ + '\tservice ID:\t\t' + reservation.sid + '\n' \ + '\tservice name:\t\t' + reservation.name + '\n' \ + '\trecorded at:\t\t' + reservation.RMT + '\n' \ + '\tservice date:\t\t' + reservation.r_date + '\n' \ + '\tstart time:\t\t' + reservation.start_time + '\n' \ + '\tend time:\t\t' + reservation.end_time + '\n' \ + '\tservice length(min):\t' + str(reservation.time_length) + '\n' \ + '\tprice per minute:\t' + str(reservation.price) + '\n' \ + '\tsub-total price:\t' + str(reservation.total) + '\n' print 'TOTAL BILL TO PAY:\t\t' + str(final_sum_to_pay) + '\n'
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
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()