示例#1
0
    public bool DeleteData(object obj, string prameter)
    {
        //Page.ClientScript.RegisterStartupScript(Page.GetType(), "", "<script>if(confirm('Are you sure you want to delete?')){DeleteData1();}else{}</script>");
        bool   isSelected = false;
        string deletStr   = "select * from GlobalProductionName IgnoreFlag='False'and where PID=" + moduleTypeID;

        try
        {
            for (int i = 0; i < prductionPNList.Length; i++)
            {
                ASCXProducPNList cb = (ASCXProducPNList)PRPNList.FindControl(prductionPNList[i].ID);
                if (cb != null)
                {
                    if (cb.BeSelected == true)
                    {
                        mydt.Rows[i]["IgnoreFlag"] = true;
                        isSelected = true;
                    }
                }
                else
                {
                    Response.Write("<script>alert('can not find user control!');</script>");
                    return(false);
                }
            }
            if (isSelected == false)
            {
                //Page.ClientScript.RegisterStartupScript(Page.GetType(), "", "<script>alert('Did not choose any one!');return false;</script>");
                this.Page.RegisterStartupScript("", "<script>alert('Did not choose any one!');</script>");
                return(false);
            }
            int result = pDataIO.UpdateWithProc("GlobalProductionName", mydt, deletStr, logTracingString);
            if (result > 0)
            {
                mydt.AcceptChanges();
            }
            else
            {
                pDataIO.AlertMsgShow("Update data fail!");
            }
            Response.Redirect(Request.Url.ToString());
            return(true);
        }
        catch (System.Exception ex)
        {
            pDataIO.WriteErrorLogs(ex.ToString());
            throw ex;
        }
    }
    public bool DeleteData(object obj, string prameter)
    {
        //Page.ClientScript.RegisterStartupScript(Page.GetType(), "", "<script>if(confirm('Are you sure you want to delete?')){DeleteData1();}else{}</script>");
        bool   isSelected = false;
        string deletStr   = "select * from GlobalProductionName where IgnoreFlag='False'and PID=" + moduleTypeID;

        try
        {
            for (int i = 0; i < prductionPNList.Length; i++)
            {
                ASCXProducPNList cb = (ASCXProducPNList)PRPNList.FindControl(prductionPNList[i].ID);
                if (cb != null)
                {
                    if (cb.BeSelected == true)
                    {
                        mydt.Rows[i]["IgnoreFlag"] = true;
                        isSelected = true;
                    }
                }
                else
                {
                    Response.Write("<script>alert('can not find user control!');</script>");
                    return(false);
                }
            }
            if (isSelected == false)
            {
                //Page.ClientScript.RegisterStartupScript(Page.GetType(), "", "<script>alert('请至少选择一个!');return false;</script>");
                this.Page.RegisterStartupScript("", "<script>alert('请至少选择一个!');</script>");
                return(false);
            }

            int result = -1;
            if (Session["DB"].ToString().ToUpper() == "ATSDB")
            {
                result = pDataIO.UpdateWithProc("GlobalProductionName", mydt, deletStr, logTracingString, "ATS_V2");
            }
            else if (Session["DB"].ToString().ToUpper() == "ATSDEBUGDB")
            {
                result = pDataIO.UpdateWithProc("GlobalProductionName", mydt, deletStr, logTracingString, "ATS_VXDEBUG");
            }

            if (result > 0)
            {
                mydt.AcceptChanges();

                DataTable dt = pDataIO.GetDataTable("select newtable.num from (select ROW_NUMBER() OVER (ORDER BY GlobalProductionType.ID ASC) AS num,GlobalProductionType.ID from GlobalProductionType where GlobalProductionType.IgnoreFlag='false') as newtable where newtable.ID=" + moduleTypeID, "GlobalProductionTypeNum");
                Session["TreeNodeExpand"] = Convert.ToInt32(dt.Rows[0]["num"]) - 1;
                Session["iframe_src"]     = "WebFiles/Production_ATS/Production/ProductionPNList.aspx?uId=" + moduleTypeID;
                ScriptManager.RegisterStartupScript(this, typeof(Page), "", "window.parent.RefreshTreeNode();", true);
            }
            else
            {
                pDataIO.AlertMsgShow("数据更新失败!");
                Response.Redirect(Request.Url.ToString());
            }


            //Response.Redirect(Request.Url.ToString());
            return(true);
        }
        catch (System.Exception ex)
        {
            pDataIO.WriteErrorLogs(ex.ToString());
            throw ex;
        }
    }