protected void DDLLayer_SelectedIndexChanged(object sender, EventArgs e) { DDLTop.Items.Clear(); //DDLNext.Items.Clear(); DDLTop.DataSourceID = "SqlDataSource1"; string database = Session["DatabaseName"].ToString(); if (Session["ProjectCode"] != null && Session["ProjectCode"].ToString() != "") { int layer = int.Parse(DDLLayer.SelectedValue) - 1; //} if (layer == 0) { SqlDataSource1.SelectCommand = ""; //ScriptManager.RegisterStartupScript((System.Web.UI.Page)HttpContext.Current.Handler, this.GetType(), "ShowMessage", "alert('無上層工項');", true); string SQLselect = "Select max(SortNum) as SortNum from EBudget_WBS where LayerNum =1 and pid=" + Session["ProjectCode"].ToString() + " "; string MaxSortNum = WebModel.SItemName(database, SQLselect, "SortNum") != "" ? WebModel.SItemName(database, SQLselect, "SortNum") : "0"; //LbNext.Text = (int.Parse(MaxSortNum) + int.Parse("1")).ToString(); for (int i = 0; i < int.Parse(MaxSortNum); i++) { DDLNext.Items.Insert(i, (i + 1).ToString()); } } else { SqlDataSource1.SelectCommand = "Select * from CBudget_WBS where LayerNum =" + layer + " and ItemName is not null and Pid=" + Session["ProjectCode"].ToString() + " "; DDLTop.DataTextField = "ItemName"; DDLTop.DataValueField = "CWID"; DDLTop.AutoPostBack = true; DDLTop.DataBind(); } ListItem LI2 = new ListItem(); LI2.Text = "--"; LI2.Value = "0"; DDLTop.Items.Insert(0, LI2); //DDLTop.Items.Insert(1, "1"); } else { ScriptManager.RegisterStartupScript((System.Web.UI.Page)HttpContext.Current.Handler, this.GetType(), "ShowMessage", "alert('請重新選擇標案');", true); } }
protected void DDLLayer_SelectedIndexChanged(object sender, EventArgs e) { //Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "showProgress();", true);//ajax 新增階層碼 DDLTop.Items.Clear(); DDLNext.Items.Clear(); DDLTop.DataSourceID = "SqlDataSource4"; if (Session["ProjectCode"] != null && Session["ProjectCode"].ToString() != "") { int layer = int.Parse(DDLLayer.SelectedValue) - 1; //} if (layer == 0) { SqlDataSource4.SelectCommand = ""; ScriptManager.RegisterStartupScript((System.Web.UI.Page)HttpContext.Current.Handler, this.GetType(), "ShowMessage", "alert('無上層工項');", true); } else { SqlDataSource4.SelectCommand = "Select * from EBudget_WBS where LayerNum =" + layer + " and ItemName is not null and Pid=" + Session["ProjectCode"].ToString() + ""; DDLTop.DataTextField = "ItemName"; DDLTop.DataValueField = "EWID"; DDLTop.AutoPostBack = true; DDLTop.DataBind(); } ListItem LI2 = new ListItem(); LI2.Text = "--"; LI2.Value = "0"; DDLTop.Items.Insert(0, LI2); } else { ScriptManager.RegisterStartupScript((System.Web.UI.Page)HttpContext.Current.Handler, this.GetType(), "ShowMessage", "alert('請重新選擇專案');", true); } //Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "hideProgress();", true);//ajax 新增階層碼 }
protected void Page_Load(object sender, EventArgs e) { if ((Session["UserName"] == null) || (Session["CompanyName"] == null)) { Response.Redirect("Login.aspx"); } SqlDataSource1.ConnectionString = Utility.DBconnection.connect_string(Session["DatabaseName"].ToString()); SqlDataSource1.SelectCommand = "Select * from EBudget_WBS where Pid=" + Session["ProjectCode"].ToString() + " and EEdition<>0"; SqlDataSource4.ConnectionString = Utility.DBconnection.connect_string(Session["DatabaseName"].ToString()); if (!IsPostBack) { ViewState["i"] = 0; ViewState["ADD"] = null; //Session["DDLLayer1"] = null; //Session["DDLTop1"] = null; //Session["PriceID"] = null; //Session["ItemName1"] = null; //Session["DDL_ItemKind1"] = null; //Session["DDL_Unit1"] = null; //Session["Quantity1"] =null; //Session["Notes1"] = null; //Session["DDLResponse1"] = null; //Session["DDLReason1"] = null; LoadContent(); DDL_Unit.DataSource = Utility.Unitlist.UnitList(); DDL_Unit.DataBind(); //TxItemName.Text = ""; //Session["ItemName1"] = null; } if (Session["PriceID"] != null) { string PriceIDArray = Session["PriceID"].ToString(); // var vals = valueStr.Split(',')[0]; PriceID = PriceIDArray.Split('ξ')[0]; Session["thisID"] = PriceID; ItermName = PriceIDArray.Split('ξ')[1]; LoadContent(); } if (Session["ItemName1"] != null) { TxItemName.Text = Session["ItemName1"].ToString(); } if (Session["Notes1"] != null) { TxNotes.Text = Session["Notes1"].ToString(); } if (Session["DDL_ItemKind1"] != null) { DDL_ItemKind.SelectedValue = Session["DDL_ItemKind1"].ToString(); } if (Session["DDL_Unit1"] != null) { DDL_Unit.SelectedValue = Session["DDL_Unit1"].ToString(); } if (Session["Quantity1"] != null) { TxQuantity.Text = Session["Quantity1"].ToString(); } if (Session["DDLLayer1"] != null) { DDLLayer.DataBind(); DDLLayer.SelectedValue = Session["DDLLayer1"].ToString(); } if (Session["DDLTop1"] != null) { DDLTop.DataBind(); DDLTop.SelectedValue = Session["DDLTop1"].ToString(); } if (Session["DDLResponse1"] != null) { DDLResponse.SelectedValue = Session["DDLResponse1"].ToString(); } if (Session["DDLReason1"] != null) { DDLReason.SelectedValue = Session["DDLReason1"].ToString(); } }