chore: 首次簽入 Thinkyu ASP.NET 專案
- 加入 Visual Studio / ASP.NET .gitignore - 排除建置輸出、IDE 設定、NuGet packages、大型 MSI 安裝檔
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
using System.Collections.Generic;
|
||||
using System.Web;
|
||||
using System.Text;
|
||||
using WebLib;
|
||||
|
||||
namespace Education.Utility
|
||||
{
|
||||
public partial class GetLookUp : FormBase
|
||||
{
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
DbCommand cmd = DAC.NewCommand();
|
||||
DbDataAdapter da = DAC.NewDataAdapter();
|
||||
cmd.Connection = conn;
|
||||
da.SelectCommand = cmd;
|
||||
|
||||
// 從 Request 中取出參數
|
||||
string lookupConfigName = Server.UrlDecode(DAC.GetString(Request["NAME"]));
|
||||
string whereKey = DAC.GetString(Request["WHERE_KEY"]);
|
||||
string langId = DAC.GetString(Request["LANGID"]);
|
||||
string addWhere = DAC.GetString(Request["ADD_WHERE"]);
|
||||
|
||||
// 從設定檔中取得SQL
|
||||
LookupList pickup = LookupList.GetInstance();
|
||||
pickup.LookupConfigName = lookupConfigName;
|
||||
string sql = pickup.GetLookupSQL();
|
||||
string[] keyFields = pickup.GetKeyFields();
|
||||
|
||||
// 將傳入的KEY代入SQL
|
||||
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(DAC.NewParameter("VALUE", whereKey + "%"));
|
||||
|
||||
// 取回資料
|
||||
DataTable table = new DataTable();
|
||||
//conn.Open();
|
||||
da.Fill(table);
|
||||
//conn.Close();
|
||||
|
||||
// 若無資料,則找尋下一個 KEY
|
||||
if (table.Rows.Count == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 輸出儲存下拉資料物件的 JSON 表示法字串
|
||||
Response.Write(pickup.GetLookupJSON(table, langId));
|
||||
Response.End();
|
||||
return;
|
||||
}
|
||||
}
|
||||
Response.End();
|
||||
}
|
||||
|
||||
protected override bool IsSetMasterPage()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user