361 lines
12 KiB
C#
361 lines
12 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 編號, int 異動通知項次, string 學員編號)
|
|
{
|
|
訓練課程異動通知發送紀錄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, "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, "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 編號, int 異動通知項次, string 學員編號, 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 編號, int 異動通知項次, string 學員編號)
|
|
{
|
|
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.GetInt32(reader[1]);
|
|
newItem.學員編號 = DAC.GetString(reader[2]);
|
|
newItem.DB_APPNO = DAC.GetInt32(reader[3]);
|
|
newItem.DB_CRDAT = DAC.GetDateTime(reader[4]);
|
|
newItem.DB_CRUSR = DAC.GetString(reader[5]);
|
|
newItem.DB_TRDAT = DAC.GetDateTime(reader[6]);
|
|
newItem.DB_TRUSR = DAC.GetString(reader[7]);
|
|
Add(newItem);
|
|
}
|
|
}
|
|
}
|
|
|
|
///<summary>
|
|
/// 訓練課程異動通知發送紀錄 資料紀錄類別
|
|
///</summary>
|
|
[Serializable]
|
|
public partial class 訓練課程異動通知發送紀錄 : DataItemBase
|
|
{
|
|
private int _編號;
|
|
private int _異動通知項次;
|
|
private string _學員編號;
|
|
|
|
#region 資料欄位
|
|
///<summary>
|
|
/// 編號
|
|
///</summary>
|
|
[DataObjectField(true, false, false)]
|
|
public int 編號
|
|
{
|
|
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(true, false, false, 10)]
|
|
public string 學員編號
|
|
{
|
|
get
|
|
{
|
|
return _學員編號;
|
|
}
|
|
set
|
|
{
|
|
if (value != _學員編號)
|
|
{
|
|
_學員編號 = value;
|
|
OnPropertyChanged("學員編號");
|
|
}
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|