Files
thinkyu/教育訓練系統/Web/DAC/辦訓狀況/DAC_滿意度調查講師1.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

486 lines
16 KiB
C#

//
// 這個檔案是 滿意度調查講師 資料表的資料存取類別 檔案一
// 請不要修改這個檔案,重新產生資料存取類別時,這個檔案會被覆蓋掉
//
using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using System.Data;
using System.Data.Common;
using System.Transactions;
using WebLib;
using System.Data.SqlClient;
namespace Education
{
///<summary>
/// 滿意度調查講師 資料存取類別
///</ summary>
[DataObject]
public partial class DAC_滿意度調查講師 : WebLib.DAC
{
//private string _tableName = "滿意度調查講師";
private string _select = "select 訓練課程企劃編號, 學員編號, 課程序號, 講師編號, 授課方式填答, 授課方式分數, 專業知識填答, 專業知識分數, DB_APPNO, DB_CRDAT, DB_CRUSR, DB_TRDAT, DB_TRUSR";
private string _insert = "訓練課程企劃編號, 學員編號, 課程序號, 講師編號, 授課方式填答, 授課方式分數, 專業知識填答, 專業知識分數, DB_APPNO, DB_CRDAT, DB_CRUSR, DB_TRDAT, DB_TRUSR";
private string _insertValue = "@訓練課程企劃編號, @學員編號, @課程序號, @講師編號, @授課方式填答, @授課方式分數, @專業知識填答, @專業知識分數, @DB_APPNO, @DB_CRDAT, @DB_CRUSR, @DB_TRDAT, @DB_TRUSR";
private string _from = " from 滿意度調查講師 ";
private string _where = " where 1=1 ";
private string _order = " order by 訓練課程企劃編號, 學員編號, 課程序號 ";
public DAC_滿意度調查講師()
: base()
{
}
public DAC_滿意度調查講師(DbConnection conn)
: base(conn)
{
}
[DataObjectMethod(DataObjectMethodType.Select)]
public 滿意度調查講師List SelectAll()
{
滿意度調查講師List result = new 滿意度調查講師List();
IDataList list = result as IDataList;
DbCommand cmdSelect = NewCommand();
cmdSelect.CommandText = _select + _from + _where + _order;
Select(cmdSelect, ref list);
return result;
}
[DataObjectMethod(DataObjectMethodType.Select)]
public 滿意度調查講師List SelectOne(int 訓練課程企劃編號, string 學員編號, int 課程序號)
{
滿意度調查講師List result = new 滿意度調查講師List();
IDataList list = result as IDataList;
DbCommand cmdSelect = NewCommand();
cmdSelect.CommandText = _select + _from + _where
+ " and 訓練課程企劃編號 = @訓練課程企劃編號 "
+ " and 學員編號 = @學員編號 "
+ " and 課程序號 = @課程序號 "
;
AddParam(cmdSelect, "訓練課程企劃編號", 訓練課程企劃編號);
AddParam(cmdSelect, "學員編號", 學員編號);
AddParam(cmdSelect, "課程序號", 課程序號);
Select(cmdSelect, ref list);
return result;
}
[DataObjectMethod(DataObjectMethodType.Insert)]
public void InsertOne(滿意度調查講師 value)
{
using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required))
{
try
{
if (!BeforeInsertOne(value))
return;
DbCommand cmdInsert = NewCommand();
cmdInsert.CommandText =
"insert into 滿意度調查講師"
+ " (" + _insert + ")"
+ "values "
+ " (" + _insertValue + ");"
;
AddParam(cmdInsert, "訓練課程企劃編號", value.訓練課程企劃編號);
AddParam(cmdInsert, "學員編號", value.學員編號);
AddParam(cmdInsert, "課程序號", value.課程序號);
AddParam(cmdInsert, "講師編號", value.講師編號);
AddParam(cmdInsert, "授課方式填答", value.授課方式填答);
AddParam(cmdInsert, "授課方式分數", value.授課方式分數);
AddParam(cmdInsert, "專業知識填答", value.專業知識填答);
AddParam(cmdInsert, "專業知識分數", value.專業知識分數);
AddParam(cmdInsert, "DB_APPNO", 1);
AddParam(cmdInsert, "DB_CRDAT", DateTime.UtcNow.AddHours(8));
AddParam(cmdInsert, "DB_CRUSR", CurrentUserId);
AddParam(cmdInsert, "DB_TRDAT", DBNull.Value);
AddParam(cmdInsert, "DB_TRUSR", DBNull.Value);
ExecuteNonQuery(cmdInsert);
AfterInsertOne(value);
ts.Complete();
}
catch (Exception error)
{
bool handled;
OnInsertOneError(error, out handled);
if(!handled)
throw error;
}
}
}
[DataObjectMethod(DataObjectMethodType.Update)]
public int UpdateOne(滿意度調查講師 value)
{
using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required))
{
try
{
if (!BeforeUpdateOne(value))
return -1;
滿意度調查講師List oldValues = SelectOne(value.訓練課程企劃編號, value.學員編號, value.課程序號);
if (oldValues.Count == 0 || oldValues[0].DB_APPNO != value.DB_APPNO)
{
throw new DBConcurrencyException("在更新 \"滿意度調查講師\" 資料表時發生並行例外:找不到要更新的資料列");
}
DbCommand cmdUpdate = NewCommand();
cmdUpdate.CommandText =
@"update 滿意度調查講師
set
講師編號 = @講師編號 ,
授課方式填答 = @授課方式填答 ,
授課方式分數 = @授課方式分數 ,
專業知識填答 = @專業知識填答 ,
專業知識分數 = @專業知識分數 ,
DB_APPNO = DB_APPNO + 1,
DB_TRDAT = @DB_TRDAT,
DB_TRUSR = @DB_TRUSR
where 1=1
and 訓練課程企劃編號 = @original_訓練課程企劃編號
and 學員編號 = @original_學員編號
and 課程序號 = @original_課程序號
and DB_APPNO = @original_DB_APPNO
";
AddParam(cmdUpdate, "講師編號", value.講師編號);
AddParam(cmdUpdate, "授課方式填答", value.授課方式填答);
AddParam(cmdUpdate, "授課方式分數", value.授課方式分數);
AddParam(cmdUpdate, "專業知識填答", value.專業知識填答);
AddParam(cmdUpdate, "專業知識分數", value.專業知識分數);
AddParam(cmdUpdate, "DB_TRDAT", DateTime.UtcNow.AddHours(8));
AddParam(cmdUpdate, "DB_TRUSR", CurrentUserId);
AddParam(cmdUpdate, "original_訓練課程企劃編號", value.訓練課程企劃編號);
AddParam(cmdUpdate, "original_學員編號", value.學員編號);
AddParam(cmdUpdate, "original_課程序號", value.課程序號);
AddParam(cmdUpdate, "original_DB_APPNO", value.DB_APPNO);
int rowsAffected = ExecuteNonQuery(cmdUpdate);
AfterUpdateOne(value);
ts.Complete();
return rowsAffected;
}
catch (Exception error)
{
bool handled;
OnUpdateOneError(error, out handled);
if(!handled)
throw error;
return -1;
}
}
}
[DataObjectMethod(DataObjectMethodType.Delete)]
public int DeleteOne(int 訓練課程企劃編號, string 學員編號, int 課程序號, int DB_APPNO)
{
using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required))
{
try
{
if (!BeforeDeleteOne(訓練課程企劃編號, 學員編號, 課程序號, DB_APPNO))
return -1;
滿意度調查講師List oldValues = SelectOne(訓練課程企劃編號, 學員編號, 課程序號);
if (oldValues.Count == 0 || oldValues[0].DB_APPNO != DB_APPNO)
{
throw new DBConcurrencyException("在刪除 \"滿意度調查講師\" 資料表時發生並行例外:找不到要刪除的資料列");
}
DbCommand cmdDelete = NewCommand();
cmdDelete.CommandText =
@"delete from 滿意度調查講師
where 1=1
and 訓練課程企劃編號 = @訓練課程企劃編號
and 學員編號 = @學員編號
and 課程序號 = @課程序號
and DB_APPNO = @DB_APPNO
";
AddParam(cmdDelete, "訓練課程企劃編號", 訓練課程企劃編號);
AddParam(cmdDelete, "學員編號", 學員編號);
AddParam(cmdDelete, "課程序號", 課程序號);
AddParam(cmdDelete, "DB_APPNO", DB_APPNO);
int rowsAffected = ExecuteNonQuery(cmdDelete);
AfterDeleteOne(訓練課程企劃編號, 學員編號, 課程序號, DB_APPNO);
ts.Complete();
return rowsAffected;
}
catch (Exception error)
{
bool handled;
OnDeleteOneError(error, out handled);
if(!handled)
throw error;
return -1;
}
}
}
[DataObjectMethod(DataObjectMethodType.Delete)]
public int DeleteOne(滿意度調查講師 value)
{
using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required))
{
try
{
if (!BeforeDeleteOne(value))
return -1;
滿意度調查講師List oldValues = SelectOne(value.訓練課程企劃編號, value.學員編號, value.課程序號);
if (oldValues.Count == 0 || oldValues[0].DB_APPNO != value.DB_APPNO)
{
throw new DBConcurrencyException("在刪除 \"滿意度調查講師\" 資料表時發生並行例外:找不到要刪除的資料列");
}
DbCommand cmdDelete = NewCommand();
cmdDelete.CommandText =
@"delete from 滿意度調查講師
where 1=1
and 訓練課程企劃編號 = @訓練課程企劃編號
and 學員編號 = @學員編號
and 課程序號 = @課程序號
and DB_APPNO = @DB_APPNO
";
AddParam(cmdDelete, "訓練課程企劃編號", value.訓練課程企劃編號);
AddParam(cmdDelete, "學員編號", value.學員編號);
AddParam(cmdDelete, "課程序號", value.課程序號);
AddParam(cmdDelete, "DB_APPNO", value.DB_APPNO);
int rowsAffected = ExecuteNonQuery(cmdDelete);
AfterDeleteOne(value);
ts.Complete();
return rowsAffected;
}
catch (Exception error)
{
bool handled;
OnDeleteOneError(error, out handled);
if(!handled)
throw error;
return -1;
}
}
}
public bool IsDuplicate(int 訓練課程企劃編號, string 學員編號, int 課程序號)
{
DbCommand cmdSelect = NewCommand();
cmdSelect.CommandText = "select count(1)" + _from + _where
+ " and 訓練課程企劃編號 = @訓練課程企劃編號 "
+ " and 學員編號 = @學員編號 "
+ " and 課程序號 = @課程序號 "
;
AddParam(cmdSelect, "訓練課程企劃編號", 訓練課程企劃編號);
AddParam(cmdSelect, "學員編號", 學員編號);
AddParam(cmdSelect, "課程序號", 課程序號);
int count;
ExecuteScalar(cmdSelect, out count);
return count > 0;
}
}
///<summary>
/// 滿意度調查講師 資料集合類別
///</summary>
public partial class 滿意度調查講師List : List<滿意度調查講師>, IDataList
{
public void Fill(DbDataReader reader)
{
while (reader.Read())
{
滿意度調查講師 newItem = new 滿意度調查講師();
newItem.訓練課程企劃編號 = DAC.GetInt32(reader[0]);
newItem.學員編號 = DAC.GetString(reader[1]);
newItem.課程序號 = DAC.GetInt32(reader[2]);
newItem.講師編號 = DAC.GetInt32(reader[3]);
newItem.授課方式填答 = DAC.GetInt32(reader[4]);
newItem.授課方式分數 = DAC.GetInt32(reader[5]);
newItem.專業知識填答 = DAC.GetInt32(reader[6]);
newItem.專業知識分數 = DAC.GetInt32(reader[7]);
newItem.DB_APPNO = DAC.GetInt32(reader[8]);
newItem.DB_CRDAT = DAC.GetDateTime(reader[9]);
newItem.DB_CRUSR = DAC.GetString(reader[10]);
newItem.DB_TRDAT = DAC.GetDateTime(reader[11]);
newItem.DB_TRUSR = DAC.GetString(reader[12]);
Add(newItem);
}
}
}
///<summary>
/// 滿意度調查講師 資料紀錄類別
///</summary>
[Serializable]
public partial class 滿意度調查講師 : DataItemBase
{
private int _訓練課程企劃編號;
private string _學員編號;
private int _課程序號;
private int _講師編號;
private int _授課方式填答;
private int _授課方式分數;
private int _專業知識填答;
private int _專業知識分數;
#region 資料欄位
///<summary>
/// 訓練課程企劃編號
///</summary>
[DataObjectField(true, false, false)]
public int 訓練課程企劃編號
{
get
{
return _訓練課程企劃編號;
}
set
{
if (value != _訓練課程企劃編號)
{
_訓練課程企劃編號 = value;
OnPropertyChanged("訓練課程企劃編號");
}
}
}
///<summary>
/// 學員編號
///</summary>
[DataObjectField(true, false, false, 20)]
public string 學員編號
{
get
{
return _學員編號;
}
set
{
if (value != _學員編號)
{
_學員編號 = value;
OnPropertyChanged("學員編號");
}
}
}
///<summary>
/// 課程序號
///</summary>
[DataObjectField(true, false, false)]
public int 課程序號
{
get
{
return _課程序號;
}
set
{
if (value != _課程序號)
{
_課程序號 = value;
OnPropertyChanged("課程序號");
}
}
}
///<summary>
/// 講師編號
///</summary>
[DataObjectField(false, false, true)]
public int 講師編號
{
get
{
return _講師編號;
}
set
{
if (value != _講師編號)
{
_講師編號 = value;
OnPropertyChanged("講師編號");
}
}
}
///<summary>
/// 授課方式填答
///</summary>
[DataObjectField(false, false, true)]
public int 授課方式填答
{
get
{
return _授課方式填答;
}
set
{
if (value != _授課方式填答)
{
_授課方式填答 = value;
OnPropertyChanged("授課方式填答");
}
}
}
///<summary>
/// 授課方式分數
///</summary>
[DataObjectField(false, false, true)]
public int 授課方式分數
{
get
{
return _授課方式分數;
}
set
{
if (value != _授課方式分數)
{
_授課方式分數 = value;
OnPropertyChanged("授課方式分數");
}
}
}
///<summary>
/// 專業知識填答
///</summary>
[DataObjectField(false, false, true)]
public int 專業知識填答
{
get
{
return _專業知識填答;
}
set
{
if (value != _專業知識填答)
{
_專業知識填答 = value;
OnPropertyChanged("專業知識填答");
}
}
}
///<summary>
/// 專業知識分數
///</summary>
[DataObjectField(false, false, true)]
public int 專業知識分數
{
get
{
return _專業知識分數;
}
set
{
if (value != _專業知識分數)
{
_專業知識分數 = value;
OnPropertyChanged("專業知識分數");
}
}
}
#endregion
}
}