コード例 #1
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     lbldirector_code = (Label)GridView1.Rows[e.RowIndex].FindControl("lbldirector_code");
            cDirector oDirector        = new cDirector();

            try
            {
                if (!oDirector.SP_DEL_DIRECTOR(lbldirector_code.Text, "N", strUpdatedBy, ref strMessage))
                {
                    lblError.Text = strMessage;
                }
            }
            catch (Exception ex)
            {
                lblError.Text = ex.Message.ToString();
            }
            finally
            {
                oDirector.Dispose();
            }
            BindGridView(0);
        }
コード例 #2
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     lbldirector_code = (Label)GridView1.Rows[e.RowIndex].FindControl("lbldirector_code");
            cDirector oDirector        = new cDirector();

            try
            {
                if (!oDirector.SP_DEL_DIRECTOR(lbldirector_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
            {
                oDirector.Dispose();
            }
            BindGridView(0);
        }