Files
sryang 577060bc78 chore: 首次簽入 Thinkyu ASP.NET 專案
- 加入 Visual Studio / ASP.NET .gitignore
- 排除建置輸出、IDE 設定、NuGet packages、大型 MSI 安裝檔
2026-09-10 09:42:37 +08:00

41 lines
1.4 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using System.Data.Common;
using WebLib;
namespace 報到系統
{
/// <summary>
/// BWEX 系統設定資料存取類別
/// </summary>
public class DAC_BWEX : DAC
{
public DAC_BWEX() : base() { }
public DAC_BWEX(DbConnection conn) : base(conn) { }
/// <summary>依 KeyName 取得 KeyValue</summary>
public string GetKeyValue(string keyName)
{
DbCommand cmd = NewCommand();
cmd.CommandText = "select [BSNAM] from [BWEX] where [BSNUM] = @KeyName and [BSITM] = ' 1'";
AddParam(cmd, "KeyName", keyName);
string result;
ExecuteScalar(cmd, out result);
return result;
}
/// <summary>更新 KeyValue(若不存在則 INSERT</summary>
public void SetKeyValue(string keyName, string keyValue)
{
DbCommand cmd = NewCommand();
cmd.CommandText =
"if exists (select 1 from [BWEX] where [BSNUM] = @KeyName and [BSITM] = ' 1') " +
" update [BWEX] set [BSNAM] = @KeyValue where [BSNUM] = @KeyName and [BSITM] = ' 1'" +
"else " +
" insert into [BWEX] ([BSNUM], [BSITM], [BSNAM]) values (@KeyName, ' 1', @KeyValue)";
AddParam(cmd, "KeyName", keyName);
AddParam(cmd, "KeyValue", keyValue);
ExecuteNonQuery(cmd);
}
}
}