chore: 首次簽入 Thinkyu ASP.NET 專案
- 加入 Visual Studio / ASP.NET .gitignore - 排除建置輸出、IDE 設定、NuGet packages、大型 MSI 安裝檔
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
using System.Configuration;
|
||||
using System.Collections;
|
||||
using System.Web;
|
||||
using System.Web.Security;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using System.Web.UI.WebControls.WebParts;
|
||||
using System.Web.UI.HtmlControls;
|
||||
using Wellan.Common;
|
||||
using Wellan.Data;
|
||||
using System.Text;
|
||||
|
||||
public partial class utility_GetPickUp : System.Web.UI.Page
|
||||
{
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
// 從設定檔中取得連線字串
|
||||
WConnectionString.ConnectionConfigFile = WConfig.GetConnectionConfig();
|
||||
string connName = WConfig.GetConnectionConfigName();
|
||||
string connType = WConnectionString.GetConnectionType(connName);
|
||||
string connStr = WConnectionString.GetConnectionString(connName);
|
||||
|
||||
WQuery Query = new WQuery(connType, connStr);
|
||||
DbConnection Conn = Query.NewConnection();
|
||||
DbCommand Cmd = Query.NewCommand();
|
||||
|
||||
// 從 Request 中取出參數
|
||||
string lookupConfigName = Request["NAME"];
|
||||
string whereKey = Request["WHERE_KEY"];
|
||||
string langId = Request["LANGID"];
|
||||
string addWhere = Request["ADD_WHERE"];
|
||||
|
||||
// 從設定檔中取得SQL
|
||||
WLookupList pickup = WLookupList.GetInstance();
|
||||
pickup.LookupConfigName = lookupConfigName;
|
||||
string sql = pickup.GetLookupSQL();
|
||||
string[] keyFields = pickup.GetKeyFields();
|
||||
|
||||
// 將傳入的KEY代入SQL
|
||||
try
|
||||
{
|
||||
foreach (string keyField in keyFields)
|
||||
{
|
||||
if (addWhere.Length == 0)
|
||||
Cmd.CommandText = String.Format(sql, keyField, "");
|
||||
else
|
||||
Cmd.CommandText = String.Format(sql, keyField, " AND " + addWhere);
|
||||
Cmd.Parameters.Clear();
|
||||
Cmd.Parameters.Add(Query.NewParameter("@VALUE", whereKey + "%"));
|
||||
|
||||
// 取回資料
|
||||
DataTable table = Query.Select(Conn, Cmd);
|
||||
// 若無資料,則找尋下一個 KEY
|
||||
if (table.Rows.Count == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 輸出儲存下拉資料物件的 JSON 表示法字串
|
||||
Response.Write(pickup.GetLookupJSON(table, langId));
|
||||
Response.End();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
Response.End();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user