protected void grvTacGiaa_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 = grvTacGia.Rows[index]; typemodal.Value = "TG"; editType.Value = "edit"; //đoạn này hdId.Value = grvTacGia.DataKeys[index].Value.ToString(); TacGia tg = tgbll.LayTacGia(hdId.Value); txtTen.Text = tg.HoTenTacGia; txtMoTa.Text = tg.MoTa; } else if (e.CommandName == "Xoa") { GridViewRow gvrow = grvTacGia.Rows[index]; string id = HttpUtility.HtmlDecode(gvrow.Cells[0].Text).ToString(); editType.Value = "edit"; idDelete.Value = id; Delete.Value = "TG"; LoadTG(); tgbll.Xoa(id); typemodal.Value = "hide"; LoadTG(); } } }
void XoaTacGia(string MaTacGia) { TacGiaBLL cls = new TacGiaBLL(MaTacGia); int kq = cls.Xoa(); switch (kq) { case 0: { MessageBox.Show("Xóa Thành Công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); HienThiTacGia(); 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ã tác giả", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtMaNXB.Focus(); break; } case 3: { MessageBox.Show("Mã tác giả có trong bảng tựa sách", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtMaNXB.Focus(); break; } } }