protected void grvNXB_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 = grvNXB.Rows[index];
             typemodal.Value = "NXB";
             editType.Value  = "edit"; //đoạn này
             hdId.Value      = grvNXB.DataKeys[index].Value.ToString();
             NhaXuatBan nxb = nxbbll.LayNXB(hdId.Value);
             txtTen.Text    = nxb.TenNXB;
             txtGhichu.Text = nxb.GhiChu;
         }
         else
         if (e.CommandName == "Xoa")
         {
             GridViewRow gvrow = grvNXB.Rows[index];
             string      id    = HttpUtility.HtmlDecode(gvrow.Cells[0].Text).ToString();
             editType.Value = "edit";
             idDelete.Value = id;
             Delete.Value   = "NXB";
             nxbbll.Xoa(id);
             typemodal.Value = "hide";
             LoadNXB();
         }
     }
 }
Пример #2
0
        void XoaNXB(string MaNSX)
        {
            NhaXuatBanBLL cls = new NhaXuatBanBLL(MaNSX);
            int           kq  = cls.Xoa();

            switch (kq)
            {
            case 0:
            {
                MessageBox.Show("Xóa Thành Công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                HienThiNSX();
                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ã nhà sản xuất", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtMaNXB.Focus();
                break;
            }

            case 3:
            {
                MessageBox.Show("Mã nhà xuất bản có trong bảng đầu sach", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtMaNXB.Focus();
                break;
            }
            }
        }