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 lblperson_code = (Label)GridView1.Rows[e.RowIndex].FindControl("lblperson_code"); cPerson oPerson = new cPerson(); try { if (!oPerson.SP_PERSON_DEL(lblperson_code.Text, "N", strUpdatedBy, ref strMessage)) { lblError.Text = strMessage; } } catch (Exception ex) { lblError.Text = ex.Message.ToString(); } finally { oPerson.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 lblperson_code = (Label)GridView1.Rows[e.RowIndex].FindControl("lblperson_code"); cPerson oPerson = new cPerson(); try { if (!oPerson.SP_PERSON_DEL(lblperson_code.Text, "N", strUpdatedBy, ref strMessage)) { if (strMessage.Contains("REFERENCE constraint")) { MsgBox("ไม่สามารถลบข้อมูลได้เนื่องจากมีการนำไปใช้ในระบบแล้ว"); } else { lblError.Text = strMessage; } } } catch (Exception ex) { if (ex.Message.Contains("REFERENCE constraint")) { MsgBox("ไม่สามารถลบข้อมูลได้เนื่องจากมีการนำไปใช้ในระบบแล้ว"); } else { lblError.Text = ex.Message.ToString(); } } finally { oPerson.Dispose(); } BindGridView(0); }