protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { string strMessage = string.Empty; string strCheck = string.Empty; string strScript = string.Empty; string strUpdatedBy = Session["username"].ToString(); Label lblactivity_code = (Label)GridView1.Rows[e.RowIndex].FindControl("lblactivity_code"); cActivity oactivity = new cActivity(); try { if (!oactivity.SP_DEL_ACTIVITY(lblactivity_code.Text, "N", strUpdatedBy, ref strMessage)) { lblError.Text = strMessage; } } catch (Exception ex) { if (ex.Message.Contains("REFERENCE constraint")) { MsgBox("ไม่สามารถลบข้อมูลได้เนื่องจากมีการนำไปใช้ในระบบแล้ว"); } else { lblError.Text = ex.Message.ToString(); } } finally { oactivity.Dispose(); } BindGridView(0); }
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { string strMessage = string.Empty; string strCheck = string.Empty; string strScript = string.Empty; string strUpdatedBy = Session["username"].ToString(); Label lblactivity_code = (Label)GridView1.Rows[e.RowIndex].FindControl("lblactivity_code"); cActivity oactivity = new cActivity(); try { if (!oactivity.SP_DEL_ACTIVITY(lblactivity_code.Text, "N", strUpdatedBy, ref strMessage)) { lblError.Text = strMessage; } else { string strScript1 = "RefreshMain('" + ViewState["page"].ToString() + "');"; ScriptManager.RegisterStartupScript(Page, Page.GetType(), "OpenPage", strScript1, true); } } catch (Exception ex) { lblError.Text = ex.Message.ToString(); } finally { oactivity.Dispose(); } BindGridView(); }
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { string strMessage = string.Empty; string strCheck = string.Empty; string strScript = string.Empty; string strUpdatedBy = Session["username"].ToString(); Label lblactivity_code = (Label)GridView1.Rows[e.RowIndex].FindControl("lblactivity_code"); cActivity oactivity = new cActivity(); try { if (!oactivity.SP_DEL_ACTIVITY(lblactivity_code.Text, "N", strUpdatedBy, ref strMessage)) { lblError.Text = strMessage; } } catch (Exception ex) { lblError.Text = ex.Message.ToString(); } finally { oactivity.Dispose(); } BindGridView(0); }