private void btnDongY_Click(object sender, EventArgs e) { if (hd == 1) { if (MessageBox.Show("Bạn có chắc là muốn xóa hóa đơn này chứ ?") == DialogResult.OK) { BUS.BUSCTCHIETKHAU _CTCK = new BUS.BUSCTCHIETKHAU(); foreach (DTO.DTOCTCHIETKHAU _ck in _CTCK.LayTatCaCTCHIETKHAU().Where(a => a.MAHD == LayHoaDon().MAHD)) { _CTCK.XoaCTCHIETKHAU(_ck.MACK,_ck.MAHD); } BUS.BUSCTPHUTHU _CTPT = new BUS.BUSCTPHUTHU(); foreach (DTO.DTOCTPHUTHU _pt in _CTPT.LayTatCaCTPHUTHU().Where(a => a.MAHD == LayHoaDon().MAHD)) { _CTPT.XoaCTPHUTHU(_pt.MAPT, _pt.MAHD); } HoaDon.XoaHOADON(LayHoaDon().MAHD); LoadHoaDon(); BUS.BUSPHIEUNHANPHONG _np = new BUS.BUSPHIEUNHANPHONG(); DTO.DTOPHIEUNHANPHONG _dtonp=_np.LayTheoMaPHIEUNHANPHONG(LayHoaDon().MAPHIEU)[0]; _dtonp.THANHTOAN = false; _np.CapnhatPHIEUNHANPHONG(_dtonp); DTO.DTOCheckData _cdHoadon = checkdata.LayTheoMaCheckData("PHIEUNHANPHONG").Last(); _cdHoadon.Version += 1; checkdata.CapnhatCheckData(_cdHoadon); btnXoaHD.Visible = true; btnDongY.Visible = false; btnHuy.Visible = false; hd = 0; } } }
private void LoadKhachHang() { busPhieuNhanPhong = new BUS.BUSPHIEUNHANPHONG(); busKhachHang = new BUS.BUSKHACHHANG(); busLoaiKhachHang = new BUS.BUSLOAIKH(); var _KH = (from b in busPhieuNhanPhong.LayTheoMaPHIEUNHANPHONG((int)glkvPhong.GetRowCellValue(glkvPhong.FocusedRowHandle, colMaPhieu)) join a in busKhachHang.LayTatCaKHACHHANG() on b.MAKH equals a.MAKH join c in busLoaiKhachHang.LayTatCaLOAIKH() on a.MALOAIKH equals c.MALOAIKH select new { MaKH = a.MAKH, HoTen = a.HOTEN, CMND = a.CMND, DiaChi = a.DIACHI, Email = a.EMAIL, GioiTinh = a.GIOITINH, LoaiKH = c.TENLOAIKH }).Last(); txtMaKH.Text = _KH.MaKH.ToString(); txtLKH.Text = _KH.LoaiKH; txtHoTen.Text = _KH.HoTen; txtCMND.Text = _KH.CMND; txtEmail.Text = _KH.Email; if (_KH.GioiTinh) txtGioiTinh.Text = "Nam"; else txtGioiTinh.Text = "Nữ"; }