protected void grvTheLoai_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName != "Page") { GridViewRow gvr; gvr = (GridViewRow)(((LinkButton)e.CommandSource).NamingContainer); int index = gvr.RowIndex; if (e.CommandName == "Sua") { GridViewRow gvrow = grvTheLoai.Rows[index]; typemodal.Value = "TL"; editType.Value = "edit"; hdId.Value = grvTheLoai.DataKeys[index].Value.ToString(); TheLoai tl = tlbll.LayTL(hdId.Value); txtTen.Text = tl.TenTheLoai; txtMoTa.Text = tl.MoTa; } else if (e.CommandName == "Xoa") { GridViewRow gvrow = grvTheLoai.Rows[index]; string id = HttpUtility.HtmlDecode(gvrow.Cells[0].Text).ToString(); editType.Value = "edit"; idDelete.Value = id; Delete.Value = "TL"; tlbll.Xoa(id); typemodal.Value = "hide"; LoadTL(); } } }
void XoaTheLoai(string MaTheLoai) { TheLoaiBLL cls = new TheLoaiBLL(MaTheLoai); int kq = cls.Xoa(); switch (kq) { case 0: { MessageBox.Show("Xóa Thành Công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); HienThiThongTheLoai(); break; } case 1: { MessageBox.Show("Xóa Thất Bại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); break; } case 2: { MessageBox.Show("Không Tồn Tại Mã thể loại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtMaTheLoai.Focus(); break; } case 3: { MessageBox.Show("Không thể xóa.Mã thể loại này c1 trong bảng tựa sách", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtMaTheLoai.Focus(); break; } } }