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    lblproduce_code = (Label)GridView1.Rows[e.RowIndex].FindControl("lblproduce_code");
            cProduce oproduce        = new cProduce();

            try
            {
                if (!oproduce.SP_DEL_PRODUCE(lblproduce_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
            {
                oproduce.Dispose();
            }
            BindGridView();
        }
Example #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    lblproduce_code = (Label)GridView1.Rows[e.RowIndex].FindControl("lblproduce_code");
            cProduce oproduce        = new cProduce();

            try
            {
                if (!oproduce.SP_DEL_PRODUCE(lblproduce_code.Text, "N", strUpdatedBy, ref strMessage))
                {
                    lblError.Text = strMessage;
                }
            }
            catch (Exception ex)
            {
                lblError.Text = ex.Message.ToString();
            }
            finally
            {
                oproduce.Dispose();
            }
            BindGridView(0);
        }
Example #3
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    lblproduce_code = (Label)GridView1.Rows[e.RowIndex].FindControl("lblproduce_code");
            cProduce oproduce        = new cProduce();

            try
            {
                if (!oproduce.SP_DEL_PRODUCE(lblproduce_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
            {
                oproduce.Dispose();
            }
            BindGridView(0);
        }