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"; } } }
private void LayDuLieuTuGirdview() { DienDAO DienDAO = new DienDAO(); gvDien.DataSource = DienDAO.ALL(); gvDien.DataBind(); }
protected void btnSua_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 D = LayDuLieuTuForm(); DienDAO DienDAO = new DienDAO(); bool result = DienDAO.ChinhSua(D); if (result) { lblThongBao.Text = "Cập nhật thành công : " + D.NgayGhi; LayDuLieuTuGirdview(); } else { lblThongBao.Text = "Cập nhật không thành công, vui lòng kiểm tra lại"; } }
protected void tinhThanhTien() { string maCongToDien = txtMaCTD.Text; string maCongToNuoc = txtMaCTN.Text; DienDAO dienDao = new DienDAO(); long tienDien = dienDao.getThanhTien(maCongToDien); QLDNDAO nuocDao = new QLDNDAO(); long tienNuoc = nuocDao.getThanhTien(maCongToNuoc); TextBox1.Text = (tienDien + tienNuoc) + ""; }
protected void btnTim_Click1(object sender, EventArgs e) { string search = txtTim.Text; if (string.IsNullOrEmpty(search)) { lblThongBao.Text = "Bạn phải nhập từ khóa trước khi tìm"; } else { lblThongBao.Text = "Kết quả tìm kiếm"; DienDAO DienDAO = new DienDAO(); gvDien.DataSource = DienDAO.Tim(search); gvDien.DataBind(); } }
protected void btnXoa_Click(object sender, EventArgs e) { string maCongToDien = txtMacongtodien.Text; DienDAO DienDAO = new DienDAO(); bool result = DienDAO.Xoa(maCongToDien); if (result) { lblThongBao.Text = "Xóa thành công"; LayDuLieuTuGirdview(); } else { lblThongBao.Text = "Xóa không thành công, vui lòng kiểm tra lại!"; } }