private void CancelBtn_Click(object sender, RoutedEventArgs e) { if (CheckInCheckOutDataGrid.SelectedItem == null) { MessageBox.Show("请选择一个订单!"); return; } else if (searchbyRooms) { IRoom rm = CheckInCheckOutDataGrid.SelectedItem as IRoom; IBooking bk = null; var book = facade.GetActiveBookings(null); foreach (IBooking bktemp in book) { if (bktemp.RoomID == rm.ID) { bk = bktemp; break; } } try { if (bk != null) { facade.CancelBooking(bk.ID); MessageBox.Show("订单已取消"); facade.Log_Cancel(bk); } } catch (Exception ex) { MessageBox.Show("取消 Room 订单错误\n" + ex); } } else if (!searchbyRooms) { IBooking bk = CheckInCheckOutDataGrid.SelectedItem as IBooking; try { facade.CancelBooking(bk.ID); MessageBox.Show("订单已取消"); } catch (Exception ex) { MessageBox.Show("取消 Booking 订单错误\n" + ex); } } }