protected void btnLuu_Click(object sender, EventArgs e) { DTOCongNoBanHang dto = new DTOCongNoBanHang(); dto.MaDH = lbMaDH.Text; dto.MaKH = int.Parse(lbMaKH.Text); dto.MaNV = int.Parse(txtMaNV.Text); dto.NgayTraNo = Convert.ToDateTime(lbNgayTra.Text); dto.TienTT = int.Parse(txtTienTT.Text); DAO_Entity dao = new DAO_Entity(); dao.ThemCongNoBH(dto); DTODonDatHang dtodh = new DTODonDatHang(); dtodh.MaDH = lbMaDH.Text; int tong = int.Parse(lbTienTra.Text); int no = int.Parse(txtTienTT.Text); dtodh.CongNoDH = tong - no; dao.CapNhatCongNo(dtodh); if (dtodh.CongNoDH == 0) { dao.CapNhatTrangThaisauThanhToan(dtodh); } Response.Redirect("~/QLBoPhan_ThanhPham/QuanLyQuanNo_BH/DanhSachCongNo_BH.aspx"); }