private void btnThanhToan_Click(object sender, EventArgs e) { bool success = true; BillDTO infor = LayThongTinKhachHangThanhToan(); if (BillBUS.LapHoaDon(infor)) { for (int i = 0; i < dgvHoaDon.RowCount; i++) { BillDTO inforHD = ThongTinHoaDonThanhToan(i); if (!(BillBUS.LapChiTietHoaDon(infor, inforHD))) { success = false; MessageBox.Show("Không lập được hóa đơn chi tiết thứ " + i + "", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Stop); } List <CustomerDTO> lstkh = new List <CustomerDTO>(); int?maphieuthue = inforHD.MaPhieuThue; lstkh = CustomerBUS.LayMaKhachHangCanXoa(maphieuthue); if (!(BillBUS.XoaChiTietPhieuThue(inforHD))) { success = false; MessageBox.Show("Không xóa được chi tiết phiếu thuê ", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Stop); } int dem = lstkh.Count(); for (int j = 0; j < dem; j++) { CustomerDTO id = new CustomerDTO(); id.MaKH = lstkh[j].MaKH; if (!(CustomerBUS.XoaKhachHang(id))) { success = false; MessageBox.Show("Không xóa được khách hàng ", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Stop); } } if (!(BillBUS.XoaPhieuThue(inforHD))) { success = false; MessageBox.Show("Không xóa được phiếu thuê ", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Stop); } if (!(RoomBUS.ThietLapTrangThaiPhongBanDau(inforHD))) { success = false; MessageBox.Show("Không cập nhập được tình trạng phòng ", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Stop); } if (!(OderDichVuBUS.XoaDichVuPhongDK(inforHD))) { success = false; MessageBox.Show("Không xóa được dich vụ phòng đã đăng kí ", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Stop); } } if (success == true) { success = false; MessageBox.Show("Lập hóa đơn thanh toán thành công ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); for (int k = 0; k < dgvHoaDon.RowCount; k++) { dgvHoaDon.Rows.RemoveAt(k); k = -1; numRow = 0; } frmTraPhong_Load(sender, e); DialogResult dialog = MessageBox.Show("Bạn có muốn in hóa đơn không", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (dialog == DialogResult.Yes) { ThietLapButton(false); } txtTenKhachHang.Text = ""; txtDiaChi.Text = ""; txtPhiDichVu.Text = ""; txtPhuThu.Text = ""; txtSoNgayThue.Text = ""; txtHeSo.Text = ""; txtDonGia.Text = "0"; txtTongTien.Text = "0"; cmbMaPhong.Text = ""; } } else { MessageBox.Show("Không lập hóa đơn thanh toán được ", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Stop); } ThietLapButton(false); }