Files
thinkyu/branches/1150807/DAC/辦訓狀況/DAC_心得報告2.cs
T
sryang 577060bc78 chore: 首次簽入 Thinkyu ASP.NET 專案
- 加入 Visual Studio / ASP.NET .gitignore
- 排除建置輸出、IDE 設定、NuGet packages、大型 MSI 安裝檔
2026-09-10 09:42:37 +08:00

251 lines
7.2 KiB
C#

//
// 這個檔案是 心得報告 資料表的資料存取類別 檔案二
// 您可以修改這個檔案,加入您自訂的屬性與方法
//
using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using System.Data;
using System.Data.Common;
using WebLib;
using System.Data.SqlClient;
namespace Education
{
///<summary>
/// 心得報告 資料存取類別
///</summary>
public partial class DAC_心得報告 : WebLib.DAC
{
#region 自動產生的資料存取方法
///<summary>
/// 給查詢畫面用的 Select 方法
///</summary>
[DataObjectMethod(DataObjectMethodType.Select)]
public 心得報告List Select(bool noInputReturnAll, int 訓練課程企劃編號, string 學員編號)
{
心得報告List result = new 心得報告List();
bool noInput = true;
IDataList list = result as IDataList;
DbCommand cmdSelect = NewCommand();
cmdSelect.CommandText = _select + _from + _where;
if (訓練課程企劃編號 > 0)
{
noInput = false;
cmdSelect.CommandText += " and 訓練課程企劃編號 = @訓練課程企劃編號 ";
AddParam(cmdSelect, "訓練課程企劃編號", 訓練課程企劃編號);
}
if (學員編號 != null && 學員編號.Length > 0)
{
noInput = false;
cmdSelect.CommandText += " and 學員編號 like @學員編號 ";
AddParam(cmdSelect, "學員編號", 學員編號 + "%");
}
cmdSelect.CommandText += _order;
if (!noInputReturnAll && noInput)
return result;
Select(cmdSelect, ref list);
return result;
}
///<summary>
/// InsertOne 之前會執行此方法
/// 在這裡可以做一些檢查或是自動編號等動作
/// 回傳 false 會打斷 InsertOne 的執行
///</summary>
protected virtual bool BeforeInsertOne(心得報告 value)
{
value.上架 = "N";
return true;
}
///<summary>
/// InsertOne 之後會執行此方法
///</summary>
protected virtual void AfterInsertOne(心得報告 value)
{
}
///<summary>
/// InsertOne 發生錯誤時會執行此方法
///</summary>
///<param name="handled">錯誤是否已經處理妥當</param>
protected virtual void OnInsertOneError(Exception error, out bool handled)
{
handled = false;
}
///<summary>
/// UpdateOne 之前會執行此方法
/// 在這裡可以做一些檢查
/// 回傳 false 會打斷 UpdateOne 的執行
///</summary>
protected virtual bool BeforeUpdateOne(心得報告 value)
{
return true;
}
///<summary>
/// UpdateOne 之後會執行此方法
///</summary>
protected virtual void AfterUpdateOne(心得報告 value)
{
}
///<summary>
/// UpdateOne 發生錯誤時會執行此方法
///</summary>
///<param name="handled">錯誤是否已經處理妥當</param>
protected virtual void OnUpdateOneError(Exception error, out bool handled)
{
handled = false;
}
///<summary>
/// DeleteOne 之前會執行此方法
/// 在這裡可以做一些檢查
/// 回傳 false 會打斷 DeleteOne 的執行
///</summary>
protected virtual bool BeforeDeleteOne(心得報告 value)
{
return true;
}
///<summary>
/// DeleteOne 之後會執行此方法
///</summary>
protected virtual void AfterDeleteOne(心得報告 value)
{
}
///<summary>
/// DeleteOne 之前會執行此方法
/// 在這裡可以做一些檢查
/// 回傳 false 會打斷 DeleteOne 的執行
///</summary>
protected virtual bool BeforeDeleteOne(int 心得報告編號, int DB_APPNO)
{
return true;
}
///<summary>
/// DeleteOne 之後會執行此方法
///</summary>
protected virtual void AfterDeleteOne(int 心得報告編號, int DB_APPNO)
{
}
///<summary>
/// DeleteOne 發生錯誤時會執行此方法
///</summary>
///<param name="handled">錯誤是否已經處理妥當</param>
protected virtual void OnDeleteOneError(Exception error, out bool handled)
{
handled = false;
}
#endregion
// 有另外加上去的屬性及方法,請加在這裡
public void Update(int 訓練課程企劃編號, string 學員編號, string 建議, string 心得, string UserId)
{
心得報告List d = Select(false, 訓練課程企劃編號, 學員編號);
if (d.Count == 0)
{
心得報告 newValue = new 心得報告();
newValue.訓練課程企劃編號 = 訓練課程企劃編號;
newValue.學員編號 = 學員編號;
newValue.建議 = 建議;
newValue.心得 = 心得;
newValue.DB_CRUSR = UserId;
InsertOne(newValue);
}
else
{
d[0].建議 = 建議;
d[0].心得 = 心得;
d[0].DB_TRUSR = UserId;
UpdateOne(d[0]);
}
}
public void 上架(int 心得報告編號, string UserId)
{
心得報告List d = SelectOne(心得報告編號);
if (d.Count > 0)
{
d[0].上架 = "Y";
d[0].DB_TRUSR = UserId;
UpdateOne(d[0]);
}
}
public void 下架(int 心得報告編號, string UserId)
{
心得報告List d = SelectOne(心得報告編號);
if (d.Count > 0)
{
d[0].上架 = "N";
d[0].DB_TRUSR = UserId;
UpdateOne(d[0]);
}
}
[DataObjectMethod(DataObjectMethodType.Select)]
public DataTable Select上架()
{
DbCommand cmdSelect = NewCommand();
cmdSelect.CommandText =
@"SELECT A.心得報告編號, A.訓練課程企劃編號, A.學員編號, A.心得,
B.訓練名稱, B.訓練日期, B.訓練日期迄, C.BPNME AS 學員姓名,
( SELECT COUNT(1)
FROM 心得報告討論 D
WHERE A.心得報告編號=D.心得報告編號
AND (D.下架 IS NULL OR D.下架 = '' OR D.下架 = 'N') ) AS 討論人數
FROM 心得報告 A
INNER JOIN 訓練課程企劃 B ON A.訓練課程企劃編號 = B.編號
INNER JOIN BPSNView C ON A.學員編號 = C.BPENO
WHERE A.上架='Y'
ORDER BY A.心得報告編號 DESC";
return Select(cmdSelect);
}
[DataObjectMethod(DataObjectMethodType.Select)]
public 心得報告List Select建議(int 訓練課程企劃編號)
{
心得報告List result = new 心得報告List();
IDataList list = result as IDataList;
DbCommand cmdSelect = NewCommand();
cmdSelect.CommandText = _select + _from + _where
+ " and 訓練課程企劃編號 = @訓練課程企劃編號 "
+ " and 建議 is not null "
+ " and 建議 <> '' "
;
AddParam(cmdSelect, "訓練課程企劃編號", 訓練課程企劃編號);
Select(cmdSelect, ref list);
return result;
}
}
///<summary>
/// 心得報告 資料集合類別
///</summary>
public partial class 心得報告List : List<心得報告>
{
// 有另外加上去的屬性及方法,請加在這裡
}
///<summary>
/// 心得報告 資料紀錄類別
///</summary>
public partial class 心得報告
{
// 有另外加上去的屬性及方法,請加在這裡
}
}