chore: 首次簽入 Thinkyu ASP.NET 專案
- 加入 Visual Studio / ASP.NET .gitignore - 排除建置輸出、IDE 設定、NuGet packages、大型 MSI 安裝檔
This commit is contained in:
@@ -0,0 +1,485 @@
|
||||
//
|
||||
// 這個檔案是 課程報名 資料表的資料存取類別 檔案一
|
||||
// 請不要修改這個檔案,重新產生資料存取類別時,這個檔案會被覆蓋掉
|
||||
//
|
||||
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(string 學員編號, int 訓練課程編號)
|
||||
{
|
||||
課程報名List result = new 課程報名List();
|
||||
IDataList list = result as IDataList;
|
||||
DbCommand cmdSelect = NewCommand();
|
||||
cmdSelect.CommandText = _select + _from + _where
|
||||
+ " and 學員編號 = @學員編號 "
|
||||
+ " and 訓練課程編號 = @訓練課程編號 "
|
||||
;
|
||||
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.訓練課程編號);
|
||||
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 DB_APPNO = @original_DB_APPNO
|
||||
";
|
||||
AddParam(cmdUpdate, "報名狀態", value.報名狀態);
|
||||
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_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(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 DB_APPNO = @DB_APPNO
|
||||
";
|
||||
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.訓練課程編號);
|
||||
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 DB_APPNO = @DB_APPNO
|
||||
";
|
||||
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(string 學員編號, int 訓練課程編號)
|
||||
{
|
||||
DbCommand cmdSelect = NewCommand();
|
||||
cmdSelect.CommandText = "select count(1)" + _from + _where
|
||||
+ " and 學員編號 = @學員編號 "
|
||||
+ " and 訓練課程編號 = @訓練課程編號 "
|
||||
;
|
||||
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.GetString(reader[0]);
|
||||
newItem.訓練課程編號 = DAC.GetInt32(reader[1]);
|
||||
newItem.報名狀態 = DAC.GetString(reader[2]);
|
||||
newItem.報名日期 = DAC.GetDateTime(reader[3]);
|
||||
newItem.取消報名日期 = DAC.GetDateTime(reader[4]);
|
||||
newItem.通知發送狀態 = DAC.GetString(reader[5]);
|
||||
newItem.出席狀況 = DAC.GetString(reader[6]);
|
||||
newItem.請假事由 = DAC.GetString(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 string _學員編號;
|
||||
private int _訓練課程編號;
|
||||
private string _報名狀態;
|
||||
private DateTime _報名日期;
|
||||
private DateTime _取消報名日期;
|
||||
private string _通知發送狀態;
|
||||
private string _出席狀況;
|
||||
private string _請假事由;
|
||||
|
||||
#region 資料欄位
|
||||
///<summary>
|
||||
/// 學員編號
|
||||
///</summary>
|
||||
[DataObjectField(true, false, false, 10)]
|
||||
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>
|
||||
/// 報名狀態
|
||||
/// Y = 指定為選修,已報名
|
||||
/// S = 指定為選修,但尚未報名
|
||||
/// R = 指定為必修(並且已報名),學員不可取消報名
|
||||
/// N = 被管理員取消必修或是選修
|
||||
///</summary>
|
||||
[DataObjectField(false, false, true, 1)]
|
||||
public string 報名狀態
|
||||
{
|
||||
get
|
||||
{
|
||||
return _報名狀態;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value != _報名狀態)
|
||||
{
|
||||
_報名狀態 = value;
|
||||
OnPropertyChanged("報名狀態");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// 報名日期
|
||||
///</summary>
|
||||
[DataObjectField(false, false, true)]
|
||||
public DateTime 報名日期
|
||||
{
|
||||
get
|
||||
{
|
||||
return _報名日期;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value != _報名日期)
|
||||
{
|
||||
_報名日期 = value;
|
||||
OnPropertyChanged("報名日期");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// 取消報名日期
|
||||
///</summary>
|
||||
[DataObjectField(false, false, true)]
|
||||
public DateTime 取消報名日期
|
||||
{
|
||||
get
|
||||
{
|
||||
return _取消報名日期;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value != _取消報名日期)
|
||||
{
|
||||
_取消報名日期 = value;
|
||||
OnPropertyChanged("取消報名日期");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// 通知發送狀態
|
||||
/// Y=已發送
|
||||
///</summary>
|
||||
[DataObjectField(false, false, true, 1)]
|
||||
public string 通知發送狀態
|
||||
{
|
||||
get
|
||||
{
|
||||
return _通知發送狀態;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value != _通知發送狀態)
|
||||
{
|
||||
_通知發送狀態 = value;
|
||||
OnPropertyChanged("通知發送狀態");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// 出席狀況
|
||||
/// Y=出席
|
||||
/// N=缺席
|
||||
/// L=請假
|
||||
///</summary>
|
||||
[DataObjectField(false, false, true, 1)]
|
||||
public string 出席狀況
|
||||
{
|
||||
get
|
||||
{
|
||||
return _出席狀況;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value != _出席狀況)
|
||||
{
|
||||
_出席狀況 = value;
|
||||
OnPropertyChanged("出席狀況");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// 請假事由
|
||||
///</summary>
|
||||
[DataObjectField(false, false, true, 100)]
|
||||
public string 請假事由
|
||||
{
|
||||
get
|
||||
{
|
||||
return _請假事由;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value != _請假事由)
|
||||
{
|
||||
_請假事由 = value;
|
||||
OnPropertyChanged("請假事由");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user