//protected void DropDownList29_SelectedIndexChanged(object sender, EventArgs e) //{ // //if ((DropDownList29.SelectedValue == "workitem")) // //{ Button1.Enabled = true; } // //else // //{ Button1.Enabled = false; } //} protected void DDLLayer_SelectedIndexChanged(object sender, EventArgs e) { DDLDtUpper.Items.Clear(); DDLNext.Items.Clear(); string database = Session["DatabaseName"].ToString(); DDLDtUpper.DataSourceID = "SqlDataSource1"; //for (int i=0; i<= int.Parse(ViewState["i"].ToString()); i++) //{ //DDLLayer.SelectedValue = i.ToString(); if (Session["bid"] != null && Session["bid"].ToString() != "") { int layer = int.Parse(DDLLayer.SelectedValue); //layer = layer >= 0 ? layer - 1 : 0; //} if (layer == 1) { string MaxLayer = "Select count(SortNum) as SortNum from [NTUST].[dbo].[Bid_WBS] where BID=" + Session["BID"] + "and LayerNum=1 "; string NextNum = WebModel.SItemName(database, MaxLayer, "SortNum"); SqlDataSource1.SelectCommand = ""; DDLDtUpper.Enabled = false; for (int i = 1; i <= int.Parse(NextNum) + 1; i++) { DDLNext.Items.Add(new ListItem(i.ToString(), i.ToString())); } //ScriptManager.RegisterStartupScript((System.Web.UI.Page)HttpContext.Current.Handler, this.GetType(), "ShowMessage", "alert('無上層工項');", true); } else { DDLDtUpper.Enabled = true; SqlDataSource1.SelectCommand = "Select * from Bid_WBS where LayerNum =" + (layer - 1) + " and ItemName is not null and Bid=" + Session["Bid"].ToString() + ""; DDLDtUpper.DataTextField = "ItemName"; DDLDtUpper.DataValueField = "UID"; DDLDtUpper.AutoPostBack = true; DDLDtUpper.DataBind(); //ListItem LI1 = new ListItem(); //LI1.Text = "--"; //LI1.Value = "0"; //DDLTop.Items.Insert(0, LI1); } ListItem LI2 = new ListItem(); LI2.Text = "-請選擇-"; LI2.Value = "0"; DDLNext.Items.Insert(0, LI2); DDLDtUpper.Items.Insert(0, LI2); } else { ScriptManager.RegisterStartupScript((System.Web.UI.Page)HttpContext.Current.Handler, this.GetType(), "ShowMessage", "alert('請重新選擇標案');", true); } }
protected void DDLLayer_SelectedIndexChanged(object sender, EventArgs e) { DDLDtUpper.Items.Clear(); DDLNext.Items.Clear(); DDLDtUpper.DataSourceID = "SqlDataSource1"; //for (int i=0; i<= int.Parse(ViewState["i"].ToString()); i++) //{ //DDLLayer.SelectedValue = i.ToString(); if (Session["bid"] != null && Session["bid"].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); } else { SqlDataSource1.SelectCommand = "Select * from Bid_WBS where LayerNum =" + layer + " and ItemName is not null and Bid=" + Session["Bid"].ToString() + ""; DDLDtUpper.DataTextField = "ItemName"; DDLDtUpper.DataValueField = "UID"; DDLDtUpper.AutoPostBack = true; DDLDtUpper.DataBind(); } ListItem LI2 = new ListItem(); LI2.Text = "--"; LI2.Value = "0"; DDLDtUpper.Items.Insert(0, LI2); } else { ScriptManager.RegisterStartupScript((System.Web.UI.Page)HttpContext.Current.Handler, this.GetType(), "ShowMessage", "alert('請重新選擇標案');", true); } }
protected void Page_Load(object sender, EventArgs e) { if ((Session["UserName"] == null) || (Session["CompanyName"] == null)) { Response.Redirect("Login.aspx"); } if (Session["bid"] == null || Session["bid"] == "") { Response.Write("<script>alert('尚未選擇專案');location.href='Main.aspx';</script>"); } SqlDataSource1.ConnectionString = Utility.DBconnection.connect_string(Session["DatabaseName"].ToString()); if (!IsPostBack) { DDL_Unit.DataSource = Utility.Unitlist.UnitList(); DDL_Unit.DataBind(); LoadContent(); Session["DDLLayer"] = null; Session["DDLDtUpper"] = null; Session["DDLNext"] = null; Session["DDLKind"] = null; Session["TxItemName"] = null; Session["DDL_Unit"] = null; Session["PriceID"] = null; Session["ResourceLinkPriceID"] = null; ListItem LI2 = new ListItem(); LI2.Text = "-請選擇-"; LI2.Value = "0"; DDL_Unit.Items.Insert(0, LI2); if (UID != "") { string database = Session["DatabaseName"].ToString(); string SQLString1 = "Select * from Bid_WBS where UId=" + UID; DataTable DataTable = WebModel.LoadSetContentData(database, SQLString1); foreach (DataRow row in DataTable.Rows) { //DDLLayer.DataBind(); //DDLLayer.AutoPostBack = true; DDLLayer.SelectedValue = row["LayerNum"].ToString().Trim(); DDLLayer_SelectedIndexChanged(this, null); DDLDtUpper.AutoPostBack = true; DDLDtUpper.DataSourceID = "SqlDataSource1"; DDLDtUpper.DataBind(); DDLDtUpper.SelectedValue = row["UpperUID"].ToString(); DDLTop_SelectedIndexChanged(this, null); DDLNext.DataBind(); DDLNext.SelectedValue = row["SortNum"].ToString(); DDLKind.SelectedValue = row["ItemKind"].ToString(); TxItemName.Text = row["ItemName"].ToString(); DDL_Unit.DataBind(); DDL_Unit.SelectedValue = row["Unit"].ToString(); string PriceID = row["PriceID"].ToString(); if (PriceID != "") { string SQLSelectString = "Select * from Bid_Library where PriceID=" + PriceID; ItemName.Text = WebModel.SItemName(database, SQLSelectString, "ItemName"); } if (row["ItemKind"].ToString() == "workitem") { Button17.Enabled = true; } else { Button17.Enabled = false; } } } } //if (Session["PriceID"] != null && Session["PriceID"] != "") //{ // string PriceIDArray = Session["PriceID"].ToString(); // PriceID = PriceIDArray.Split('ξ')[0]; // Session["thisID"] = PriceID; // ItemName.Text = PriceIDArray.Split('ξ')[1]; // DDLLayer.SelectedValue = Session["DDLLayer"].ToString(); // DDLDtUpper.SelectedValue = Session["DDLDtUpper"].ToString(); // DDLNext.SelectedValue = Session["DDLNext"].ToString(); // DDLKind.SelectedValue = Session["DDLKind"].ToString(); // TxItemName.Text = Session["TxItemName"].ToString(); // DDL_Unit.SelectedValue = Session["DDL_Unit"].ToString(); // LbPriceID.Text = PriceID; // LoadContent(); // Session["DDLLayer"] = null; // Session["DDLDtUpper"] = null; // Session["DDLNext"] = null; // Session["DDLKind"] = null; // Session["TxItemName"] = null; // Session["DDL_Unit"] = null; // Session["PriceID"] = null; //} if (Session["ResourceLinkPriceID"] != null && Session["ResourceLinkPriceID"] != "") { string PriceIDArray = Session["ResourceLinkPriceID"].ToString(); string database = Session["DatabaseName"].ToString(); PriceID = PriceIDArray.Split('ξ')[0]; Session["thisID"] = PriceID; ItemName.Text = PriceIDArray.Split('ξ')[1]; DDLLayer.SelectedValue = Session["DDLLayer"].ToString(); DDLDtUpper.SelectedValue = Session["DDLDtUpper"].ToString(); DDLNext.SelectedValue = Session["DDLNext"].ToString(); DDLKind.SelectedValue = Session["DDLKind"].ToString(); TxItemName.Text = Session["TxItemName"].ToString(); DDL_Unit.SelectedValue = Session["DDL_Unit"].ToString(); LbPriceID.Text = PriceID; LoadContent(); string SQLString1 = "Select * from Bid_Library where PriceID=" + PriceID + ""; DataTable DataTableBox1 = WebModel.LoadSetContentData(database, SQLString1); if (DataTableBox1 != null && DataTableBox1.Rows.Count > 0) { foreach (DataRow row in DataTableBox1.Rows) { ItemName.Text = row["ItemName"].ToString(); } } Session["DDLLayer"] = null; Session["DDLDtUpper"] = null; Session["DDLNext"] = null; Session["DDLKind"] = null; Session["TxItemName"] = null; Session["DDL_Unit"] = null; Session["PriceID"] = null; Session["ResourceLinkPriceID"] = null; } }