private void btnPay_Click(object sender, RoutedEventArgs e) { List <Room> rooms = new List <Room>(); rooms.AddRange(Room.GetRoomsByCustomerID(((Customer)cbCustomerName.SelectedItem).IdCardNumber)); int flag = 0; foreach (var item in rooms) { if (RentInfo.UpdateChechoutDate(item.Name) && RoomRentalDetail.DeleteRoomRentalDetail(item.Name) && Room.UpdateRoomStatus(item.Name) && RevenueReport.InsertRevenueReport(item.Name, item.Type, RentInfo.GetDateCheckin(item.Name), DateTime.Now, totalMoney) && PaymentDetail.DeletePaymentDetailByRoomName(item.Name)) { flag += 1; } } if (flag == rooms.Count) { MessageBox.Show("Thanh toán thành công!"); } else { MessageBox.Show("Thanh toán không thành công! Vui lòng thực hiện lại thao tác!"); } this.Close(); }