Esempio n. 1
0
        protected void Button3_Click(object sender, EventArgs e)
        {
            string[] data      = WebModel.Get_PWBS_LayerKind(Session["DatabaseName"].ToString(), Session["ProjectCode"].ToString());
            string[] LayerNum  = data[1].Split(',');
            string[] LayerKind = data[2].Split(',');
            int      num       = PlaceHolder1.Controls.Count - 1;
            int      y         = int.Parse(LayerNum.Max());

            ViewState["i"] = int.Parse(LayerNum.Max());
            string SQLDel      = "Delete from Bid_WBSLayer where Pid=" + Session["ProjectCode"].ToString() + " and LayerNum=" + y;
            string SQLDelLayer = "Delete from CBudget_WBS where Pid=" + Session["ProjectCode"].ToString() + " and LayerNum=" + y;
            bool   result      = WebModel.SQLAction(Session["DatabaseName"].ToString(), SQLDel);
            bool   result1     = WebModel.SQLAction(Session["DatabaseName"].ToString(), SQLDelLayer);

            for (int i = num; i > num - 3; i--)
            {
                PlaceHolder1.Controls.RemoveAt(i);
            }
            if (result && result1)
            {
                ScriptManager.RegisterStartupScript((System.Web.UI.Page)HttpContext.Current.Handler, this.GetType(), "ShowMessage", "alert('階層已刪除');", true);
            }
            else
            {
                ScriptManager.RegisterStartupScript((System.Web.UI.Page)HttpContext.Current.Handler, this.GetType(), "ShowMessage", "alert('階層刪除失敗');", true);
            }
        }
Esempio n. 2
0
        protected void BtnDelayer_Click(object sender, EventArgs e)
        {
            string[] data     = WebModel.Get_PWBS_LayerKind(Session["DatabaseName"].ToString(), Session["ProjectCode"].ToString());
            string[] LayerNum = new string[1];
            string[] LayerKind;
            if (data[1] != null)
            {
                LayerNum  = data[1].Split(',');
                LayerKind = data[2].Split(',');
            }
            int       num       = PlaceHolder1.Controls.Count - 1;
            int       y         = int.Parse(LayerNum.Max());
            string    SQLSelect = "Select * from CBudget_WBS where LayerNum=" + y;
            DataTable layer     = WebModel.LoadSetContentData(Session["DatabaseName"].ToString(), SQLSelect);


            if (int.Parse(ViewState["i"].ToString()) <= y)
            {
                if (layer != null && layer.Rows.Count > 0)
                {
                    Page.ClientScript.RegisterStartupScript(typeof(string), "BtnDelayer_Click", "var retValue=confirm('該階層有項目,是否刪除???');" + "if (retValue) {document.getElementById('" + Button3.ClientID + "').click();};", true);
                }
                else
                {
                    ViewState["i"] = int.Parse(LayerNum.Max());
                    //string SQLDel = "Delete from Bid_WBSLayer where Pid=" + Session["ProjectCode"].ToString() + " and LayerNum=" + y;
                    //WebModel.SQLAction(Session["DatabaseName"].ToString(), SQLDel);
                    for (int i = num; i > num - 3; i--)
                    {
                        PlaceHolder1.Controls.RemoveAt(i);
                    }
                    string SQLDel = "Delete from Bid_WBSLayer where Pid=" + Session["ProjectCode"].ToString() + " and LayerNum=" + y;

                    bool result = WebModel.SQLAction(Session["DatabaseName"].ToString(), SQLDel);
                    if (result)
                    {
                        ScriptManager.RegisterStartupScript((System.Web.UI.Page)HttpContext.Current.Handler, this.GetType(), "ShowMessage", "alert('階層已刪除');", true);
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript((System.Web.UI.Page)HttpContext.Current.Handler, this.GetType(), "ShowMessage", "alert('階層刪除失敗');", true);
                    }
                }
            }
            else
            {
                ViewState["i"] = int.Parse(LayerNum.Max());
                //string SQLDel = "Delete from Bid_WBSLayer where Pid=" + Session["ProjectCode"].ToString() + " and LayerNum=" + y;
                //WebModel.SQLAction(Session["DatabaseName"].ToString(), SQLDel);
                for (int i = num; i > num - 3; i--)
                {
                    PlaceHolder1.Controls.RemoveAt(i);
                }
                string SQLDel = "Delete from Bid_WBSLayer where Pid=" + Session["ProjectCode"].ToString() + " and LayerNum=" + y;

                bool result = WebModel.SQLAction(Session["DatabaseName"].ToString(), SQLDel);
                if (result)
                {
                    ScriptManager.RegisterStartupScript((System.Web.UI.Page)HttpContext.Current.Handler, this.GetType(), "ShowMessage", "alert('階層已刪除');", true);
                }
                else
                {
                    ScriptManager.RegisterStartupScript((System.Web.UI.Page)HttpContext.Current.Handler, this.GetType(), "ShowMessage", "alert('階層刪除失敗');", true);
                }
            }
            //Pnl_Layer.Visible = true;
        }
Esempio n. 3
0
        protected void AddLayer()
        {
            if (Session["ProjectCode"].ToString() != "")
            {
                PlaceHolder1.Controls.Clear();  //先清除所有子控制項
                string[] data      = WebModel.Get_PWBS_LayerKind(Session["DatabaseName"].ToString(), Session["ProjectCode"].ToString());
                string[] LayerNum  = new string[1];
                string[] LayerKind = new string[1];
                if (data[1] != null && data[2] != null)
                {
                    LayerNum  = data[1].Split(',');
                    LayerKind = data[2].Split(',');

                    if (ViewState["ADD"] == null)
                    {
                        //Section1_Click(this, null);

                        if (LayerNum[0] != null)
                        {
                            ViewState["i"] = int.Parse(LayerNum.Max());
                        }
                        for (int i = 0; i < int.Parse(ViewState["i"].ToString()); i++)
                        {
                            DropDownList ddl = new DropDownList();
                            ddl.ID = i.ToString();

                            ddl.DataSourceID   = "SqlDataSource1";
                            ddl.DataTextField  = "OrderName";
                            ddl.DataValueField = "Kind";
                            //ddl.DataBind();
                            y = i + 1;
                            ddl.AutoPostBack          = true;
                            ddl.SelectedIndexChanged += itemselect_indexchange;

                            PlaceHolder1.Controls.Add(new LiteralControl("<tr><td class=\"auto-style13\">第 " + y + " 階</td><td class=\"auto-style14\">"));

                            PlaceHolder1.Controls.Add(ddl);

                            //ddl.Items.Insert(0, new ListItem("-請選擇-", "0"));
                            PlaceHolder1.Controls.Add(new LiteralControl("</td></tr>"));
                            ViewState["layer"] = y;
                            Session["layer"]   = y;
                        }
                        if (LayerNum[0] != null)
                        {
                            for (int i = 0; i < int.Parse(LayerNum.Max()); i++)
                            {
                                DropDownList DDL = (DropDownList)PlaceHolder1.FindControl(i.ToString());
                                if (DDL != null)
                                {
                                    DDL.SelectedValue = LayerKind[i];
                                }
                            }
                        }
                    }
                    else
                    {
                        for (int i = 0; i < int.Parse(ViewState["i"].ToString()); i++)
                        {
                            DropDownList ddl = new DropDownList();
                            ddl.ID = i.ToString();

                            ddl.DataSourceID   = "SqlDataSource1";
                            ddl.DataTextField  = "OrderName";
                            ddl.DataValueField = "Kind";
                            //ddl.DataBind();
                            int y = i + 1;
                            // ddl.AutoPostBack = true;
                            ddl.SelectedIndexChanged += itemselect_indexchange;

                            PlaceHolder1.Controls.Add(new LiteralControl("<tr><td class=\"auto-style13\">第 " + y + " 階</td><td class=\"auto-style14\">"));

                            PlaceHolder1.Controls.Add(ddl);

                            //ddl.Items.Insert(0, new ListItem("-請選擇-", "0"));
                            PlaceHolder1.Controls.Add(new LiteralControl("</td></tr>"));

                            this.ViewState["ADD"] = true;
                            //Pnl_Layer.Visible = true;
                            ViewState["layer"] = y;
                            Session["layer"]   = y;
                        }

                        for (int i = 0; i < int.Parse(LayerNum.Max()); i++)
                        {
                            DropDownList DDL = (DropDownList)PlaceHolder1.FindControl(i.ToString());
                            if (DDL != null)
                            {
                                DDL.SelectedValue = LayerKind[i];
                            }
                        }
                    }
                    //ViewState["layer"] = y;
                    //Session["layer"] = y;
                }
                else
                {
                    if (LayerNum[0] == null)
                    {
                        LayerNum = new string[1] {
                            "1"
                        };
                        LayerKind = new string[1] {
                            "1"
                        };
                    }
                    for (int i = 0; i < int.Parse(ViewState["i"].ToString()); i++)
                    {
                        DropDownList ddl = new DropDownList();
                        ddl.ID = i.ToString();

                        ddl.DataSourceID   = "SqlDataSource1";
                        ddl.DataTextField  = "OrderName";
                        ddl.DataValueField = "Kind";
                        //ddl.DataBind();
                        int y = i + 1;
                        // ddl.AutoPostBack = true;
                        ddl.SelectedIndexChanged += itemselect_indexchange;

                        PlaceHolder1.Controls.Add(new LiteralControl("<tr><td class=\"auto-style13\">第 " + y + " 階</td><td class=\"auto-style14\">"));

                        PlaceHolder1.Controls.Add(ddl);

                        //ddl.Items.Insert(0, new ListItem("-請選擇-", "0"));
                        PlaceHolder1.Controls.Add(new LiteralControl("</td></tr>"));

                        this.ViewState["ADD"] = true;

                        ViewState["layer"] = y;
                        Session["layer"]   = y;
                    }



                    for (int i = 0; i < int.Parse(LayerNum.Max()); i++)
                    {
                        DropDownList DDL = (DropDownList)PlaceHolder1.FindControl(i.ToString());
                        if (DDL != null)
                        {
                            DDL.SelectedValue = LayerKind[i];
                        }
                    }
                }
            }
            else
            {
                ScriptManager.RegisterStartupScript((System.Web.UI.Page)HttpContext.Current.Handler, this.GetType(), "ShowMessage", "alert('請先選擇專案');", true);
            }
        }