def remove_flight(flight_id): result = delete_flight(flight_id) if result: message = "航班信息删除成功!" else: message = "航班信息删除失败!" return template('administrator', rows=query_flight(), message=message)
def calcul_full(flight_id, plane_type): #首先查到已预订的座位数 result0 = query_flight_seat(flight_id) tourist_reserved = result0[0] first_reserved = result0[1] #再查找总的座位数 result1 = query_plane_type("seat", plane_type) tourist_class = result1[0] first_class = result1[1] tourist_rate = tourist_reserved / tourist_class first_rate = first_reserved / first_class message = "经济舱满座率 %.2f%%\\n头等舱满座率 %.2f%%" % (tourist_rate, first_rate) return template('administrator', rows=query_flight(), message=message)
def do_reserve(flight_id, aclass): name = request.forms.get('name') pass_id = request.forms.get('pass_id') cellnumber = request.forms.get('cellnumber') #根据flight_id和aclass查询票价 price = query_flight(flight_id, aclass)[0] #在插入乘客信息之前需要先查询其信息是否已经存在,不存在才插入 if not query_passenger(pass_id): insert_passenger(pass_id, name, cellnumber) result1 = insert_ticket(pass_id, flight_id, aclass, price) #最后在flight表中更新座位信息 result2 = update_flight(flight_id, aclass) if result1 and result2: message = '机票预定成功!' else: message = '机票预定失败!' return template('passenger', message=message, rows='')
def add_flight(): flight_id = request.GET.flight_id.strip() company = request.GET.company.strip() plane_type = request.GET.plane_type.strip() departure_airport = request.GET.departure_airport.strip() arrival_airport = request.GET.arrival_airport.strip() departure_time = request.GET.departure_time.strip() arrival_time = request.GET.arrival_time.strip() tourist_reserved = request.GET.tourist_reserved.strip() first_reserved = request.GET.first_reserved.strip() tourist_price = request.GET.tourist_price.strip() first_price = request.GET.first_price.strip() result = insert_flight(flight_id, company, plane_type, departure_airport, arrival_airport, departure_time, arrival_time, tourist_reserved, first_reserved, tourist_price, first_price) if result: message = "航班信息插入成功!" else: message = "航班信息插入失败!" return template('administrator', rows=query_flight(), message=message)
def modify_flight(old_flight_id): flight_id = request.forms.get('flight_id') company = request.forms.get('company') plane_type = request.forms.get('plane_type') departure_airport = request.forms.get('departure_airport') arrival_airport = request.forms.get('arrival_airport') departure_time = request.forms.get('departure_time') arrival_time = request.forms.get('arrival_time') tourist_reserved = request.forms.get('tourist_reserved') first_reserved = request.forms.get('first_reserved') tourist_price = request.forms.get('tourist_price') first_price = request.forms.get('first_price') result = update_flight_all(old_flight_id, flight_id, company, plane_type, departure_airport, arrival_airport, departure_time, arrival_time, tourist_reserved, first_reserved, tourist_price, first_price) if result: message = "航班信息修改成功!" else: message = "航班信息修改失败!" return template('administrator', rows=query_flight(), message=message)
def administrator(): result = query_flight() return template('administrator', rows=result, message=' ')