protected void btnXoa_Click(object sender, EventArgs e) { NXBDAO nXBDAO = new NXBDAO(); string manxb = txtMaNXB.Text; if (txtMaNXB.Text != "" && txtTenNXB.Text != "") { // Kiểm tra mã nxb này đã tồn tại trong CSDL chưa bool exist = nXBDAO.CheckNXB(manxb); if (exist) { // Thực hiện xóa từ CSDL bool result = nXBDAO.DeleteNXB(manxb); if (result) { lblMessage.Text = "Xóa thể loại thành công!"; LayDuLieuVaoGridView(); } else { lblMessage.Text = "Có lỗi. Vui lòng thử lại sau"; } } else { lblMessage.Text = "Mã loại không tồn tại"; } } else { lblMessage.Text = "Vui lòng điền đầy đủ thông tin"; } }
protected void btnThem_Click(object sender, EventArgs e) { if (txtMaNXB.Text != "" && txtTenNXB.Text != "") { // Lấy các giá trị từ giao diện NXB nXB = LayDuLieuTuForm(); NXBDAO nXBDAO = new NXBDAO(); // Kiểm tra mã nxb này đã tồn tại trong CSDL chưa bool exist = nXBDAO.CheckNXB(nXB.MaNXB); if (exist) { lblMessage.Text = "Tài khoản đã tồn tại"; } else { // Thực hiện ghi xuống CSDL bool result = nXBDAO.Insert(nXB); if (result) { lblMessage.Text = "Thêm thành công!"; LayDuLieuVaoGridView(); } else { lblMessage.Text = "Có lỗi. Vui lòng thử lại sau"; } } } else { lblMessage.Text = "Vui lòng điền đầy đủ thông tin"; } }
private void LayDuLieuVaoGridView() { NXBDAO nXBDAO = new NXBDAO(); GridView1.DataSource = nXBDAO.GetAllNXB(); GridView1.DataBind(); }
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e) { string manxb = GridView1.SelectedRow.Cells[0].Text; NXBDAO nXBDAO = new NXBDAO(); NXB nXB = nXBDAO.GetTheLoaiByMaNXB(manxb); if (nXB != null) { // Đổ dữ liệu từ đối tượng TheLoai vào các trường trên Form DoDuLieuLenForm(nXB); } }
protected void btnSua_Click(object sender, EventArgs e) { if (txtMaNXB.Text != "" && txtTenNXB.Text != "") { NXB nXB = LayDuLieuTuForm(); NXBDAO nXBDAO = new NXBDAO(); bool result = nXBDAO.UpdateNXB(nXB); if (result) { lblMessage.Text = "Cập nhật thành công"; LayDuLieuVaoGridView(); } else { lblMessage.Text = "Cập nhật không thành công, vui lòng kiểm tra lại"; } } else { lblMessage.Text = "Vui lòng điền đầy đủ thông tin"; } }
public static List <NXBDTO> GetSuppliers() { return(NXBDAO.SelecSuppliers()); }
public static int AddSupplier(string ten, string email, string sdt, string fax) { return(NXBDAO.InserSupplier(new NXBDTO(ten, email, sdt, fax))); }
public static int ChangeInfSupplier(string manxb, string ten, string email, string sdt, string fax) { return(NXBDAO.UpdatSupplier(new NXBDTO(manxb, ten, email, sdt, fax))); }
// GET: Admin/QuanLyNXB public ActionResult Index() { NXBDAO nXBDAO = new NXBDAO(); return(View(nXBDAO.dsNXB())); }