chore: 首次簽入 Thinkyu ASP.NET 專案
- 加入 Visual Studio / ASP.NET .gitignore - 排除建置輸出、IDE 設定、NuGet packages、大型 MSI 安裝檔
This commit is contained in:
@@ -0,0 +1,422 @@
|
||||
//
|
||||
// 這個檔案是 心得報告 資料表的資料存取類別 檔案一
|
||||
// 請不要修改這個檔案,重新產生資料存取類別時,這個檔案會被覆蓋掉
|
||||
//
|
||||
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 心得報告編號)
|
||||
{
|
||||
心得報告List result = new 心得報告List();
|
||||
IDataList list = result as IDataList;
|
||||
DbCommand cmdSelect = NewCommand();
|
||||
cmdSelect.CommandText = _select + _from + _where
|
||||
+ " and 心得報告編號 = @心得報告編號 "
|
||||
;
|
||||
AddParam(cmdSelect, "心得報告編號", 心得報告編號);
|
||||
Select(cmdSelect, ref list);
|
||||
return result;
|
||||
}
|
||||
|
||||
[DataObjectMethod(DataObjectMethodType.Insert)]
|
||||
public int InsertOne(心得報告 value)
|
||||
{
|
||||
using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required))
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!BeforeInsertOne(value))
|
||||
return -1;
|
||||
|
||||
DbCommand cmdInsert = NewCommand();
|
||||
cmdInsert.CommandText =
|
||||
"insert into 心得報告"
|
||||
+ " (" + _insert + ")"
|
||||
+ "values "
|
||||
+ " (" + _insertValue + ");"
|
||||
+ "select @@identity"
|
||||
;
|
||||
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);
|
||||
int newId;
|
||||
ExecuteScalar(cmdInsert, out newId);
|
||||
AfterInsertOne(value);
|
||||
ts.Complete();
|
||||
return newId;
|
||||
}
|
||||
catch (Exception error)
|
||||
{
|
||||
bool handled;
|
||||
OnInsertOneError(error, out handled);
|
||||
if(!handled)
|
||||
throw error;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[DataObjectMethod(DataObjectMethodType.Update)]
|
||||
public int UpdateOne(心得報告 value)
|
||||
{
|
||||
using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required))
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!BeforeUpdateOne(value))
|
||||
return -1;
|
||||
|
||||
心得報告List oldValues = SelectOne(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 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_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 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 DB_APPNO = @DB_APPNO
|
||||
";
|
||||
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.心得報告編號);
|
||||
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 DB_APPNO = @DB_APPNO
|
||||
";
|
||||
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 心得報告編號)
|
||||
{
|
||||
DbCommand cmdSelect = NewCommand();
|
||||
cmdSelect.CommandText = "select count(1)" + _from + _where
|
||||
+ " and 心得報告編號 = @心得報告編號 "
|
||||
;
|
||||
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.GetString(reader[3]);
|
||||
newItem.心得 = DAC.GetString(reader[4]);
|
||||
newItem.上架 = DAC.GetString(reader[5]);
|
||||
newItem.DB_APPNO = DAC.GetInt32(reader[6]);
|
||||
newItem.DB_CRDAT = DAC.GetDateTime(reader[7]);
|
||||
newItem.DB_CRUSR = DAC.GetString(reader[8]);
|
||||
newItem.DB_TRDAT = DAC.GetDateTime(reader[9]);
|
||||
newItem.DB_TRUSR = DAC.GetString(reader[10]);
|
||||
Add(newItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// 心得報告 資料紀錄類別
|
||||
///</summary>
|
||||
[Serializable]
|
||||
public partial class 心得報告 : DataItemBase
|
||||
{
|
||||
private int _心得報告編號;
|
||||
private int _訓練課程企劃編號;
|
||||
private string _學員編號;
|
||||
private string _建議;
|
||||
private string _心得;
|
||||
private string _上架;
|
||||
|
||||
#region 資料欄位
|
||||
///<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, 20)]
|
||||
public string 學員編號
|
||||
{
|
||||
get
|
||||
{
|
||||
return _學員編號;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value != _學員編號)
|
||||
{
|
||||
_學員編號 = value;
|
||||
OnPropertyChanged("學員編號");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// 建議
|
||||
///</summary>
|
||||
[DataObjectField(false, false, true, 2000)]
|
||||
public string 建議
|
||||
{
|
||||
get
|
||||
{
|
||||
return _建議;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value != _建議)
|
||||
{
|
||||
_建議 = value;
|
||||
OnPropertyChanged("建議");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// 心得
|
||||
///</summary>
|
||||
[DataObjectField(false, false, true, 2000)]
|
||||
public string 心得
|
||||
{
|
||||
get
|
||||
{
|
||||
return _心得;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value != _心得)
|
||||
{
|
||||
_心得 = value;
|
||||
OnPropertyChanged("心得");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// 上架
|
||||
///</summary>
|
||||
[DataObjectField(false, false, true, 1)]
|
||||
public string 上架
|
||||
{
|
||||
get
|
||||
{
|
||||
return _上架;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value != _上架)
|
||||
{
|
||||
_上架 = value;
|
||||
OnPropertyChanged("上架");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user