protected void btnThem_Click(object sender, EventArgs e) { int csd; int csc; int dg; csd = Convert.ToInt16(txtChisocdau.Text); csc = Convert.ToInt16(txtChisocuoi.Text); dg = Convert.ToInt16(txtDongia.Text); int tthu; tthu = (csc - csd); txtTieuthu.Text = tthu.ToString(); Dien DN = LayDuLieuTuForm(); DienDAO DienDAO = new DienDAO(); bool exist = DienDAO.checkmact(DN.Macongtodien); if (exist) { lblThongBao.Text = "Mã công tơ nước đã tồn tại"; } else { bool result = DienDAO.Them(DN); if (result) { lblThongBao.Text = "Tính thành công"; LayDuLieuTuGirdview(); } else { lblThongBao.Text = "Lỗi"; } } }