chore: 首次簽入 Thinkyu ASP.NET 專案
- 加入 Visual Studio / ASP.NET .gitignore - 排除建置輸出、IDE 設定、NuGet packages、大型 MSI 安裝檔
This commit is contained in:
@@ -0,0 +1,402 @@
|
||||
//
|
||||
// 這個檔案是 課程經費 資料表的資料存取類別 檔案一
|
||||
// 請不要修改這個檔案,重新產生資料存取類別時,這個檔案會被覆蓋掉
|
||||
//
|
||||
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 單據序號)
|
||||
{
|
||||
課程經費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, "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, "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(int 訓練課程企劃編號, 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(int 訓練課程企劃編號, 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.GetInt32(reader[0]);
|
||||
newItem.單據序號 = DAC.GetInt32(reader[1]);
|
||||
newItem.收支 = DAC.GetString(reader[2]);
|
||||
newItem.金額 = DAC.GetInt32(reader[3]);
|
||||
newItem.摘要 = DAC.GetString(reader[4]);
|
||||
newItem.DB_APPNO = DAC.GetInt32(reader[5]);
|
||||
newItem.DB_CRDAT = DAC.GetDateTime(reader[6]);
|
||||
newItem.DB_CRUSR = DAC.GetString(reader[7]);
|
||||
newItem.DB_TRDAT = DAC.GetDateTime(reader[8]);
|
||||
newItem.DB_TRUSR = DAC.GetString(reader[9]);
|
||||
Add(newItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// 課程經費 資料紀錄類別
|
||||
///</summary>
|
||||
[Serializable]
|
||||
public partial class 課程經費 : DataItemBase
|
||||
{
|
||||
private int _訓練課程企劃編號;
|
||||
private int _單據序號;
|
||||
private string _收支;
|
||||
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(false, false, true, 1)]
|
||||
public string 收支
|
||||
{
|
||||
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, 500)]
|
||||
public string 摘要
|
||||
{
|
||||
get
|
||||
{
|
||||
return _摘要;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value != _摘要)
|
||||
{
|
||||
_摘要 = value;
|
||||
OnPropertyChanged("摘要");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user