protected void BtnSearch_Click(object sender, EventArgs e) { string KeyWord = SystemSet.CheckMSSQLLike(SystemSet.ReplaceBlank(TxSubBudget.Text)); #region 搜尋條件 string SelectString = ""; SelectString = (KeyWord != "") ? "SB_Name like '%" + KeyWord + "%' " : ""; if (TxDate1.Text != "") { if (KeyWord != "" && TxDate1.Text != "") { SelectString += DDL_Op1.SelectedValue; } if (DDL_date.SelectedValue == "BookInTime" && DDL_Op3.SelectedValue != "Between") { SelectString += " BookInTime " + DDL_Op3.SelectedValue + " '" + DateTime.Parse(TxDate1.Text).ToString("yyyy-MM-dd") + "'"; } else if (DDL_date.SelectedValue == "BookInTime" && DDL_Op3.SelectedValue == "Between") { SelectString += " BookInTime " + DDL_Op3.SelectedValue + "'" + DateTime.Parse(TxDate1.Text).ToString("yyyy-MM-dd") + "' and " + "'" + DateTime.Parse(TxDate2.Text).ToString("yyyy-MM-dd") + "'"; } if (DDL_date.SelectedValue == "BookContractDate" && DDL_Op3.SelectedValue != "Between") { SelectString += " BookContractDate " + DDL_Op3.SelectedValue + "'" + DateTime.Parse(TxDate1.Text).ToString("yyyy-MM-dd") + "'"; } else if (DDL_date.SelectedValue == "BookContractDate" && DDL_Op3.SelectedValue == "Between") { SelectString += " BookContractDate " + DDL_Op3.SelectedValue + "'" + DateTime.Parse(TxDate1.Text).ToString("yyyy-MM-dd") + "' and " + "'" + DateTime.Parse(TxDate2.Text).ToString("yyyy-MM-dd") + "'"; } if (DDL_date.SelectedValue == "LastContractDate" && DDL_Op3.SelectedValue != "Between") { SelectString += " LastContractDate " + DDL_Op3.SelectedValue + "'" + DateTime.Parse(TxDate1.Text).ToString("yyyy-MM-dd") + "'"; } else if (DDL_date.SelectedValue == "LastContractDate" && DDL_Op3.SelectedValue == "Between") { SelectString += " LastContractDate " + DDL_Op3.SelectedValue + "'" + DateTime.Parse(TxDate1.Text).ToString("yyyy-MM-dd") + "' and " + "'" + DateTime.Parse(TxDate2.Text).ToString("yyyy-MM-dd") + "'"; } } else { SelectString += ""; } SelectString = (SelectString.Length > 1) ? SelectString : ""; Sql_SB.SelectCommand = "SELECT SBID, PID, SB_Code, SB_Name, BookInTime, BookContractDate, LastContractDate, ContractWay, WorkManDep, WorkManName, BudgetPrice, BudgetLockNY, SC_Code FROM SubBudgetList "; Sql_SB.SelectCommand += (SelectString.Length > 1) ? "WHERE " + SelectString + " and PID = " + Session["ProjectCode"].ToString() + "" : " WHERE PID = " + Session["ProjectCode"].ToString() + ""; #endregion GV_SB.DataBind(); }
protected void BtnAll_Click(object sender, EventArgs e) { Sql_SB.SelectCommand = "SELECT SBID, PID, SB_Code, SB_Name, BookInTime, BookContractDate, LastContractDate, ContractWay, WorkManDep, WorkManName, BudgetPrice, BudgetLockNY, SC_Code FROM SubBudgetList where pid= " + Session["ProjectCode"].ToString(); GV_SB.DataBind(); }