Esempio n. 1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if ((Session["UserName"] == null) || (Session["CompanyName"] == null))
     {
         Response.Redirect("Login.aspx");
     }
     else if (Session["ProjectCode"] == null || Session["ProjectCode"] == "")
     {
         Response.Write("<script>alert('尚未選擇專案或是您的權限不足');location.href='Main.aspx';</script>");
     }
     else
     {
         //SqlDataSource3.SelectCommand = "SELECT PriceID, PriceName, Complex, AnaNumber, Price, Unit, Code, PccCode, ReferenceID, ReferenceNumber FROM PriceAnalysis";
         if (Session["ProjectCode"] != null)
         {
             SqlDataSource4.SelectCommand = Sql1;
         }
         SqlDataSource3.SelectCommand = Sql;
     }
     SqlDataSource1.ConnectionString = Utility.DBconnection.connect_string(Session["DatabaseName"].ToString());
     SqlDataSource2.ConnectionString = Utility.DBconnection.connect_string(Session["DatabaseName"].ToString());
     SqlDataSource3.ConnectionString = Utility.DBconnection.connect_string(Session["DatabaseName"].ToString());
     SqlDataSource4.ConnectionString = Utility.DBconnection.connect_string(Session["DatabaseName"].ToString());
     if (!IsPostBack)
     {
         SqlDataSource3.SelectCommand = Sql;
         GridView2.DataBind();
         DDL_Unit.DataSource = Utility.Unitlist.UnitList();
         DDL_Unit.DataBind();
         DDL_EdUnit.DataSource = Utility.Unitlist.UnitList();
         DDL_EdUnit.DataBind();
     }
 }
Esempio n. 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if ((Session["UserName"] == null) || (Session["CompanyName"] == null))
            {
                Response.Redirect("Login.aspx");
            }
            if (DropDownList3.SelectedValue != "0" && DropDownList3.SelectedValue != "")
            {
                //showid.Style.Add("style", "display:block;");
                showid.Visible = true;
            }
            else
            {
                showid.Visible = false;
            }
            SqlDataSource1.ConnectionString = Utility.DBconnection.connect_string(Session["DatabaseName"].ToString());
            SqlDataSource2.ConnectionString = Utility.DBconnection.connect_string(Session["DatabaseName"].ToString());
            SqlDataSource3.ConnectionString = Utility.DBconnection.connect_string(Session["DatabaseName"].ToString());
            if (!IsPostBack)
            {
                DDL_EdUnit.DataSource = Utility.Unitlist.UnitList();
                DDL_Unit.DataSource   = Utility.Unitlist.UnitList();
                DDL_EdUnit.DataBind();
                DDL_Unit.DataBind();
                //SqlDataSource2.SelectCommand = "select * from Bid_Library where bid=" + Session["Bid"].ToString() + "";
                if (Session["Bid"] != null)
                {
                    SqlDataSource2.SelectCommand = Sql;
                }
                DropDownList3_SelectedIndexChanged(this, null);
            }


            //SqlDataSource3.SelectCommand = "SELECT PriceID, PriceName, Complex, AnaNumber, Price, Unit, Code, PccCode, ReferenceID, ReferenceNumber FROM PriceAnalysis ";
            #region 搜尋條件
            string SelectString = "";
            string ItemName     = SystemSet.CheckMSSQLLike(SystemSet.ReplaceBlank(TxWBS.Text));
            SelectString = (DDL_WBS.SelectedValue != "0") ? "Code like '%" + DDL_WBS.SelectedValue + "%'" : "";
            if (DDL_WBS.SelectedValue != "0" && ItemName == "")
            {
                SelectString += "";
            }
            else if (DDL_WBS.SelectedValue != "0" && ItemName != "")
            {
                SelectString += DDL_Op2.SelectedValue + " ItemName like '%" + ItemName + "%'";
            }
            else if (DDL_WBS.SelectedValue == "0" && ItemName != "")
            {
                SelectString += (ItemName != "") ? " ItemName like '%" + ItemName + "%'" : "";
            }

            SelectString = (SelectString.Length > 1) ? "where " + SelectString + "" : "";

            SqlDataSource3.ConnectionString = Utility.DBconnection.connect_string(Session["DatabaseName"].ToString());
            SqlDataSource3.SelectCommand    = "SELECT PriceID, ItemName, Complex, AnaNumber, Price, Unit, Code,ItemKind FROM [PrivateResource] ";
            SqlDataSource3.SelectCommand   += SelectString + " ORDER BY PriceID ASC ";
            #endregion

            //DropDownList DDL = (DropDownList)Master.FindControl("Ddl_Project");
            //DDL.Visible = false;
            if (Session["Bid"] != null)
            {
                if (Sql != "")
                {
                    SqlDataSource2.SelectCommand = Sql;
                }
                else
                {
                    SqlDataSource2.SelectCommand = "select * from Bid_Library where bid=" + Session["Bid"].ToString() + "";
                }
            }
        }
Esempio n. 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if ((Session["UserName"] == null) || (Session["CompanyName"] == null || Session["Bid"] == null))
            {
                Response.Redirect("Login.aspx");
            }
            SqlDataSource1.ConnectionString = Utility.DBconnection.connect_string(Session["DatabaseName"].ToString());
            SqlDataSource2.ConnectionString = Utility.DBconnection.connect_string(Session["DatabaseName"].ToString());
            SqlDataSource1.SelectCommand    = "SELECT UID,LayerCode, ItemOrder , ItemName AS FullName FROM Bid_WBS where bid=" + Session["Bid"].ToString() + " ORDER BY LayerCode";
            if (ParentID != "")
            {
                SqlDataSource2.SelectCommand = "select * from  Bid_Library where  BID=" + Session["Bid"].ToString() + " AND PriceID not in (select KidID from Bid_AnaRelation where ParentID=" + ParentID + ") and PriceID<>" + ParentID + " ORDER BY [PriceID]";
            }
            if (!IsPostBack)
            {
                string database = Session["DatabaseName"].ToString();
                DDL_EdUnit.DataSource = Utility.Unitlist.UnitList();
                DDL_EdUnit.DataBind();

                DataTable dt = WebModel.LoadSetContentData(database, SqlDataSource1.SelectCommand);
                dt.Columns.Add("FullName1", typeof(string), "ItemOrder + '-' + FullName");

                //DDLItemNmae.DataSourceID = "SqlDataSource1";
                DDLItemName.DataValueField = "UID";


                DDLItemName.DataSource    = dt;
                DDLItemName.DataTextField = "FullName1";
                DDLItemName.DataBind();
            }
            if ((Session["AddNew"].ToString() == "1"))
            {
                Pnl_WBS.Visible      = true;
                Pnl_Analysis.Visible = false;
                Pnl_Import.Visible   = false;
            }
            else if ((Session["AddNew"].ToString() == "2"))
            {
                Pnl_WBS.Visible      = false;
                Pnl_Analysis.Visible = true;
                LoadContent();
            }


            //string database = Session["DatabaseName"].ToString();
            string FdSearch = SystemSet.CheckMSSQLLike(SystemSet.ReplaceBlank(TxSearch.Text));

            if (ViewState["all"] != null && (bool)this.ViewState["all"] == true)
            {
                BtnAll_Click(this, null);
            }
            if (PriceID != "")
            {
                string SelectString = "";
                SelectString  = (Session["Bid"] != null) ? "Bid=" + Session["Bid"].ToString() + " and " : "";
                SelectString  = (DDL_WBS.SelectedValue != "0") ? "Code like '%" + DDL_WBS.SelectedValue + "%' " + DDL_Op2.SelectedValue + "" : "";
                SelectString += (FdSearch != "") ? " ItemName like '%" + FdSearch + "%' " : "";
                SelectString  = (SelectString.Length > 1) ? " and " + SelectString + " ORDER BY [PriceID]" : "";
                SqlDataSource2.SelectCommand = "select * from  Bid_Library where  BID=" + Session["Bid"].ToString() + " AND PriceID not in (select KidID from Bid_AnaRelation where ParentID=" + PriceID + ") and PriceID<>" + PriceID + "";


                SqlDataSource2.SelectCommand += SelectString;
            }
        }