861 lines
31 KiB
C#
861 lines
31 KiB
C#
//
|
|
// 這個檔案是 Classes 資料表的資料存取類別 檔案一
|
|
// 請不要修改這個檔案,重新產生資料存取類別時,這個檔案會被覆蓋掉
|
|
//
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Data.Common;
|
|
using System.Linq;
|
|
using System.Transactions;
|
|
using WebLib;
|
|
using System.Data.SqlClient;
|
|
|
|
namespace 報到系統
|
|
{
|
|
///<summary>
|
|
/// Classes 資料存取類別
|
|
///</ summary>
|
|
[DataObject]
|
|
public partial class DAC_Classes : WebLib.DAC
|
|
{
|
|
private const string _tableName = "[Classes]";
|
|
private const string _allFields = "[ID], [CourseCode], [CourseName], [CourseDate], [CourseLocation], [NotificationTitle], [NotificationTemplate], [Closed], [ProjectID], [StartTime], [EndTime], [Teacher], [AgreedTerms], [DB_APPNO], [DB_CRDAT], [DB_CRUSR], [DB_TRDAT], [DB_TRUSR]";
|
|
private string _orderBy = "[ID]";
|
|
private string _select = "select " + _allFields;
|
|
private string _insert = "[CourseCode], [CourseName], [CourseDate], [CourseLocation], [NotificationTitle], [NotificationTemplate], [Closed], [ProjectID], [StartTime], [EndTime], [Teacher], [AgreedTerms], [DB_APPNO], [DB_CRDAT], [DB_CRUSR], [DB_TRDAT], [DB_TRUSR]";
|
|
private string _insertBak = "[ID], [CourseCode], [CourseName], [CourseDate], [CourseLocation], [NotificationTitle], [NotificationTemplate], [Closed], [ProjectID], [StartTime], [EndTime], [Teacher], [AgreedTerms], [DB_APPNO], [DB_CRDAT], [DB_CRUSR], [DB_TRDAT], [DB_TRUSR], [DB_TRMOD]";
|
|
private string _insertValue = "@CourseCode, @CourseName, @CourseDate, @CourseLocation, @NotificationTitle, @NotificationTemplate, @Closed, @ProjectID, @StartTime, @EndTime, @Teacher, @AgreedTerms, @DB_APPNO, @DB_CRDAT, @DB_CRUSR, @DB_TRDAT, @DB_TRUSR";
|
|
private string _insertBakValue = "@ID, @CourseCode, @CourseName, @CourseDate, @CourseLocation, @NotificationTitle, @NotificationTemplate, @Closed, @ProjectID, @StartTime, @EndTime, @Teacher, @AgreedTerms, @DB_APPNO, @DB_CRDAT, @DB_CRUSR, @DB_TRDAT, @DB_TRUSR, @DB_TRMOD";
|
|
private string _from = " from " + _tableName + " ";
|
|
private string _where = " where 1=1 ";
|
|
private string _order = " order by [ID] ";
|
|
|
|
public const string OrderBy_2 = "[CourseCode]";
|
|
public const string OrderBy_1 = "[CourseDate]";
|
|
|
|
public DAC_Classes()
|
|
: base()
|
|
{
|
|
}
|
|
|
|
public DAC_Classes(DbConnection conn)
|
|
: base(conn)
|
|
{
|
|
}
|
|
|
|
[DataObjectMethod(DataObjectMethodType.Select)]
|
|
public ClassesList SelectAll(string orderBy = "")
|
|
{
|
|
ClassesList result = new ClassesList();
|
|
IDataList list = result as IDataList;
|
|
DbCommand cmdSelect = NewCommand();
|
|
cmdSelect.CommandText = _select + _from + _where + (orderBy == null || orderBy.Length == 0 ? _order : " order by " + orderBy);
|
|
Select(cmdSelect, ref list);
|
|
return result;
|
|
}
|
|
|
|
public int SelectAllCount()
|
|
{
|
|
DbCommand cmdSelect = NewCommand();
|
|
cmdSelect.CommandText = "select count(1) " + _from;
|
|
int i;
|
|
ExecuteScalar(cmdSelect, out i);
|
|
return i;
|
|
}
|
|
|
|
[DataObjectMethod(DataObjectMethodType.Select)]
|
|
public ClassesList SelectAllPage(int startRowIndex, int maximumRows, string orderBy = "")
|
|
{
|
|
ClassesList result = new ClassesList();
|
|
IDataList list = result as IDataList;
|
|
DbCommand cmdSelect = NewCommand();
|
|
cmdSelect.CommandText =
|
|
String.Format("select top {0} * from (", maximumRows)
|
|
+ "select " + _allFields
|
|
+ ", row_number() over (order by " + (orderBy == null || orderBy.Length == 0 ? _orderBy : orderBy) + ") as rowid "
|
|
+ _from + _where
|
|
+ ") as TMP1 where rowid > @startRowIndex ";
|
|
AddParam(cmdSelect, "startRowIndex", startRowIndex);
|
|
Select(cmdSelect, ref list);
|
|
return result;
|
|
}
|
|
|
|
[DataObjectMethod(DataObjectMethodType.Select)]
|
|
public ClassesList SelectOne(int ID)
|
|
{
|
|
ClassesList result = new ClassesList();
|
|
IDataList list = result as IDataList;
|
|
DbCommand cmdSelect = NewCommand();
|
|
cmdSelect.CommandText = _select + _from + _where
|
|
+ " and ID = @ID "
|
|
;
|
|
AddParam(cmdSelect, "ID", ID);
|
|
Select(cmdSelect, ref list);
|
|
return result;
|
|
}
|
|
|
|
///<summary>
|
|
/// 給查詢畫面用的增加 Where 條件的方法
|
|
///</summary>
|
|
private void AddWhere(DbCommand cmdSelect, ref bool noInput, string CourseCode, string CourseName, DateTime? CourseDate_1, DateTime? CourseDate_2, string CourseLocation, bool? Closed, string ProjectID)
|
|
{
|
|
if (CourseCode != null && CourseCode.Length > 0)
|
|
{
|
|
noInput = false;
|
|
cmdSelect.CommandText += " and CourseCode like @CourseCode ";
|
|
AddParam(cmdSelect, "CourseCode", "%" + CourseCode + "%");
|
|
}
|
|
|
|
if (CourseName != null && CourseName.Length > 0)
|
|
{
|
|
noInput = false;
|
|
cmdSelect.CommandText += " and CourseName like @CourseName ";
|
|
AddParam(cmdSelect, "CourseName", "%" + CourseName + "%");
|
|
}
|
|
|
|
if (CourseDate_1.HasValue && CourseDate_2.HasValue)
|
|
{
|
|
noInput = false;
|
|
cmdSelect.CommandText += " and CourseDate >= @CourseDate_1 and CourseDate < @CourseDate_2 ";
|
|
AddParam(cmdSelect, "CourseDate_1", CourseDate_1);
|
|
AddParam(cmdSelect, "CourseDate_2", CourseDate_2.Value.AddDays(1));
|
|
}
|
|
else if (CourseDate_1.HasValue && !CourseDate_2.HasValue)
|
|
{
|
|
noInput = false;
|
|
cmdSelect.CommandText += " and CourseDate >= @CourseDate_1 ";
|
|
AddParam(cmdSelect, "CourseDate_1", CourseDate_1);
|
|
}
|
|
else if (!CourseDate_1.HasValue && CourseDate_2.HasValue)
|
|
{
|
|
noInput = false;
|
|
cmdSelect.CommandText += " and CourseDate < @CourseDate_2 ";
|
|
AddParam(cmdSelect, "CourseDate_2", CourseDate_2.Value.AddDays(1));
|
|
}
|
|
if (CourseLocation != null && CourseLocation.Length > 0)
|
|
{
|
|
noInput = false;
|
|
cmdSelect.CommandText += " and CourseLocation like @CourseLocation ";
|
|
AddParam(cmdSelect, "CourseLocation", "%" + CourseLocation + "%");
|
|
}
|
|
|
|
if (Closed != null)
|
|
{
|
|
noInput = false;
|
|
cmdSelect.CommandText += " and Closed = @Closed ";
|
|
AddParam(cmdSelect, "Closed", Closed);
|
|
}
|
|
|
|
if (ProjectID != null && ProjectID.Length > 0)
|
|
{
|
|
noInput = false;
|
|
cmdSelect.CommandText += " and ProjectID like @ProjectID ";
|
|
AddParam(cmdSelect, "ProjectID", "%" + ProjectID + "%");
|
|
}
|
|
|
|
}
|
|
|
|
///<summary>
|
|
/// 給查詢畫面用的 Select 方法
|
|
///</summary>
|
|
[DataObjectMethod(DataObjectMethodType.Select)]
|
|
public ClassesList Select(bool noInputReturnAll, string CourseCode, string CourseName, DateTime? CourseDate_1, DateTime? CourseDate_2, string CourseLocation, bool? Closed, string ProjectID, string orderBy = "")
|
|
{
|
|
ClassesList result = new ClassesList();
|
|
bool noInput = true;
|
|
IDataList list = result as IDataList;
|
|
DbCommand cmdSelect = NewCommand();
|
|
cmdSelect.CommandText = _select + _from + _where;
|
|
AddWhere(cmdSelect, ref noInput, CourseCode, CourseName, CourseDate_1, CourseDate_2, CourseLocation, Closed, ProjectID);
|
|
cmdSelect.CommandText += (orderBy == null || orderBy.Length == 0 ? _order : " order by " + orderBy);
|
|
|
|
if (!noInputReturnAll && noInput)
|
|
return result;
|
|
|
|
Select(cmdSelect, ref list);
|
|
return result;
|
|
}
|
|
|
|
///<summary>
|
|
/// 給查詢畫面用的 SelectCount 方法
|
|
///</summary>
|
|
[DataObjectMethod(DataObjectMethodType.Select)]
|
|
public int SelectCount(bool noInputReturnAll, string CourseCode, string CourseName, DateTime? CourseDate_1, DateTime? CourseDate_2, string CourseLocation, bool? Closed, string ProjectID, string orderBy = "")
|
|
{
|
|
bool noInput = true;
|
|
DbCommand cmdSelect = NewCommand();
|
|
cmdSelect.CommandText = "select count(1) " + _from + _where;
|
|
AddWhere(cmdSelect, ref noInput, CourseCode, CourseName, CourseDate_1, CourseDate_2, CourseLocation, Closed, ProjectID);
|
|
|
|
if (!noInputReturnAll && noInput)
|
|
return 0;
|
|
|
|
int i;
|
|
ExecuteScalar(cmdSelect, out i);
|
|
return i;
|
|
}
|
|
|
|
///<summary>
|
|
/// 給查詢畫面用的 SelectPage 方法
|
|
///</summary>
|
|
[DataObjectMethod(DataObjectMethodType.Select)]
|
|
public ClassesList SelectPage(bool noInputReturnAll, int startRowIndex, int maximumRows, string CourseCode, string CourseName, DateTime? CourseDate_1, DateTime? CourseDate_2, string CourseLocation, bool? Closed, string ProjectID, string orderBy = "")
|
|
{
|
|
ClassesList result = new ClassesList();
|
|
bool noInput = true;
|
|
IDataList list = result as IDataList;
|
|
DbCommand cmdSelect = NewCommand();
|
|
|
|
cmdSelect.CommandText =
|
|
String.Format("select top {0} * from (", maximumRows)
|
|
+ "select " + _allFields
|
|
+ ", row_number() over (order by " + (orderBy == null || orderBy.Length == 0 ? _orderBy : orderBy) + ") as rowid "
|
|
+ _from + _where;
|
|
AddWhere(cmdSelect, ref noInput, CourseCode, CourseName, CourseDate_1, CourseDate_2, CourseLocation, Closed, ProjectID);
|
|
cmdSelect.CommandText += ") as TMP1 where rowid > @startRowIndex ";
|
|
AddParam(cmdSelect, "startRowIndex", startRowIndex);
|
|
|
|
if (!noInputReturnAll && noInput)
|
|
return result;
|
|
|
|
Select(cmdSelect, ref list);
|
|
return result;
|
|
}
|
|
|
|
[DataObjectMethod(DataObjectMethodType.Insert)]
|
|
public ClassesItem InsertOne(ClassesItem value)
|
|
{
|
|
using (TransactionScope ts = DAC.NewTransactionScope())
|
|
{
|
|
try
|
|
{
|
|
if (!BeforeInsertOne(value))
|
|
return value;
|
|
DbCommand cmdInsert = NewCommand();
|
|
cmdInsert.CommandText =
|
|
"insert into [Classes]"
|
|
+ " (" + _insert + ")"
|
|
+ "values "
|
|
+ " (" + _insertValue + ");" + "select @@identity"
|
|
;
|
|
AddParam(cmdInsert, "CourseCode", value.CourseCode);
|
|
AddParam(cmdInsert, "CourseName", value.CourseName);
|
|
AddParam(cmdInsert, "CourseDate", value.CourseDate);
|
|
AddParam(cmdInsert, "CourseLocation", value.CourseLocation);
|
|
AddParam(cmdInsert, "NotificationTitle", value.NotificationTitle);
|
|
AddParam(cmdInsert, "NotificationTemplate", value.NotificationTemplate);
|
|
AddParam(cmdInsert, "Closed", value.Closed);
|
|
AddParam(cmdInsert, "ProjectID", value.ProjectID);
|
|
AddParam(cmdInsert, "StartTime", value.StartTime);
|
|
AddParam(cmdInsert, "EndTime", value.EndTime);
|
|
AddParam(cmdInsert, "Teacher", value.Teacher);
|
|
AddParam(cmdInsert, "AgreedTerms", value.AgreedTerms);
|
|
AddParam(cmdInsert, "DB_APPNO", 1);
|
|
AddParam(cmdInsert, "DB_CRDAT", DateTime.Now);
|
|
AddParam(cmdInsert, "DB_CRUSR", CurrentUserId);
|
|
AddParam(cmdInsert, "DB_TRDAT", DBNull.Value);
|
|
AddParam(cmdInsert, "DB_TRUSR", DBNull.Value);
|
|
int newId;
|
|
ExecuteScalar(cmdInsert, out newId);
|
|
value.ID = newId;
|
|
AfterInsertOne(value);
|
|
ts.Complete();
|
|
}
|
|
catch (Exception error)
|
|
{
|
|
bool handled;
|
|
OnInsertOneError(error, out handled);
|
|
if(!handled)
|
|
throw error;
|
|
}
|
|
return value;
|
|
}
|
|
}
|
|
|
|
[DataObjectMethod(DataObjectMethodType.Update)]
|
|
public ClassesItem UpdateOne(ClassesItem value)
|
|
{
|
|
using (TransactionScope ts = DAC.NewTransactionScope())
|
|
{
|
|
try
|
|
{
|
|
if (!BeforeUpdateOne(value))
|
|
return value;
|
|
|
|
ClassesList oldValues = SelectOne(value.ID);
|
|
if (oldValues.Count == 0 || oldValues[0].DB_APPNO != value.DB_APPNO)
|
|
{
|
|
throw new DBConcurrencyException("在更新 \"Classes\" 資料表時發生並行例外:找不到要更新的資料列");
|
|
}
|
|
else
|
|
{
|
|
DoBackup(oldValues[0], "UPDATE");
|
|
}
|
|
|
|
DbCommand cmdUpdate = NewCommand();
|
|
cmdUpdate.CommandText =
|
|
@"update [Classes]
|
|
set
|
|
[CourseCode] = @CourseCode ,
|
|
[CourseName] = @CourseName ,
|
|
[CourseDate] = @CourseDate ,
|
|
[CourseLocation] = @CourseLocation ,
|
|
[NotificationTitle] = @NotificationTitle ,
|
|
[NotificationTemplate] = @NotificationTemplate ,
|
|
[Closed] = @Closed ,
|
|
[ProjectID] = @ProjectID ,
|
|
[StartTime] = @StartTime ,
|
|
[EndTime] = @EndTime ,
|
|
[Teacher] = @Teacher ,
|
|
[AgreedTerms] = @AgreedTerms ,
|
|
DB_APPNO = DB_APPNO + 1,
|
|
DB_TRDAT = @DB_TRDAT,
|
|
DB_TRUSR = @DB_TRUSR
|
|
where 1=1
|
|
and [ID] = @original_ID
|
|
and DB_APPNO = @original_DB_APPNO
|
|
";
|
|
AddParam(cmdUpdate, "CourseCode", value.CourseCode);
|
|
AddParam(cmdUpdate, "CourseName", value.CourseName);
|
|
AddParam(cmdUpdate, "CourseDate", value.CourseDate);
|
|
AddParam(cmdUpdate, "CourseLocation", value.CourseLocation);
|
|
AddParam(cmdUpdate, "NotificationTitle", value.NotificationTitle);
|
|
AddParam(cmdUpdate, "NotificationTemplate", value.NotificationTemplate);
|
|
AddParam(cmdUpdate, "Closed", value.Closed);
|
|
AddParam(cmdUpdate, "ProjectID", value.ProjectID);
|
|
AddParam(cmdUpdate, "StartTime", value.StartTime);
|
|
AddParam(cmdUpdate, "EndTime", value.EndTime);
|
|
AddParam(cmdUpdate, "Teacher", value.Teacher);
|
|
AddParam(cmdUpdate, "AgreedTerms", value.AgreedTerms);
|
|
AddParam(cmdUpdate, "DB_TRDAT", DateTime.Now);
|
|
AddParam(cmdUpdate, "DB_TRUSR", CurrentUserId);
|
|
AddParam(cmdUpdate, "original_ID", value.ID);
|
|
AddParam(cmdUpdate, "original_DB_APPNO", value.DB_APPNO);
|
|
ExecuteNonQuery(cmdUpdate);
|
|
AfterUpdateOne(value);
|
|
ts.Complete();
|
|
return value;
|
|
}
|
|
catch (Exception error)
|
|
{
|
|
bool handled;
|
|
OnUpdateOneError(error, out handled);
|
|
if(!handled)
|
|
throw error;
|
|
return value;
|
|
}
|
|
}
|
|
}
|
|
|
|
[DataObjectMethod(DataObjectMethodType.Update)]
|
|
public ClassesItem UpdateOne(ClassesItem value, ClassesItem original_value)
|
|
{
|
|
using (TransactionScope ts = DAC.NewTransactionScope())
|
|
{
|
|
try
|
|
{
|
|
if (!BeforeUpdateOne(value, original_value))
|
|
return value;
|
|
|
|
ClassesList oldValues = SelectOne(original_value.ID);
|
|
if (oldValues.Count == 0 || oldValues[0].DB_APPNO != value.DB_APPNO)
|
|
{
|
|
throw new DBConcurrencyException("在更新 \"Classes\" 資料表時發生並行例外:找不到要更新的資料列");
|
|
}
|
|
else
|
|
{
|
|
DoBackup(oldValues[0], "UPDATE");
|
|
}
|
|
|
|
DbCommand cmdUpdate = NewCommand();
|
|
cmdUpdate.CommandText =
|
|
@"update [Classes]
|
|
set
|
|
[CourseCode] = @CourseCode ,
|
|
[CourseName] = @CourseName ,
|
|
[CourseDate] = @CourseDate ,
|
|
[CourseLocation] = @CourseLocation ,
|
|
[NotificationTitle] = @NotificationTitle ,
|
|
[NotificationTemplate] = @NotificationTemplate ,
|
|
[Closed] = @Closed ,
|
|
[ProjectID] = @ProjectID ,
|
|
[StartTime] = @StartTime ,
|
|
[EndTime] = @EndTime ,
|
|
[Teacher] = @Teacher ,
|
|
[AgreedTerms] = @AgreedTerms ,
|
|
DB_APPNO = DB_APPNO + 1,
|
|
DB_TRDAT = @DB_TRDAT,
|
|
DB_TRUSR = @DB_TRUSR
|
|
where 1=1
|
|
and [ID] = @original_ID
|
|
and DB_APPNO = @original_DB_APPNO
|
|
";
|
|
AddParam(cmdUpdate, "CourseCode", value.CourseCode);
|
|
AddParam(cmdUpdate, "CourseName", value.CourseName);
|
|
AddParam(cmdUpdate, "CourseDate", value.CourseDate);
|
|
AddParam(cmdUpdate, "CourseLocation", value.CourseLocation);
|
|
AddParam(cmdUpdate, "NotificationTitle", value.NotificationTitle);
|
|
AddParam(cmdUpdate, "NotificationTemplate", value.NotificationTemplate);
|
|
AddParam(cmdUpdate, "Closed", value.Closed);
|
|
AddParam(cmdUpdate, "ProjectID", value.ProjectID);
|
|
AddParam(cmdUpdate, "StartTime", value.StartTime);
|
|
AddParam(cmdUpdate, "EndTime", value.EndTime);
|
|
AddParam(cmdUpdate, "Teacher", value.Teacher);
|
|
AddParam(cmdUpdate, "AgreedTerms", value.AgreedTerms);
|
|
AddParam(cmdUpdate, "DB_TRDAT", DateTime.Now);
|
|
AddParam(cmdUpdate, "DB_TRUSR", CurrentUserId);
|
|
AddParam(cmdUpdate, "original_ID", original_value.ID);
|
|
AddParam(cmdUpdate, "original_DB_APPNO", original_value.DB_APPNO);
|
|
ExecuteNonQuery(cmdUpdate);
|
|
AfterUpdateOne(value, original_value);
|
|
ts.Complete();
|
|
return value;
|
|
}
|
|
catch (Exception error)
|
|
{
|
|
bool handled;
|
|
OnUpdateOneError(error, out handled);
|
|
if(!handled)
|
|
throw error;
|
|
return value;
|
|
}
|
|
}
|
|
}
|
|
|
|
[DataObjectMethod(DataObjectMethodType.Delete)]
|
|
public int DeleteOne(int ID, int DB_APPNO)
|
|
{
|
|
using (TransactionScope ts = DAC.NewTransactionScope())
|
|
{
|
|
try
|
|
{
|
|
if (!BeforeDeleteOne(ID, DB_APPNO))
|
|
return -1;
|
|
|
|
ClassesList oldValues = SelectOne(ID);
|
|
if (oldValues.Count == 0 || oldValues[0].DB_APPNO != DB_APPNO)
|
|
{
|
|
throw new DBConcurrencyException("在刪除 \"Classes\" 資料表時發生並行例外:找不到要刪除的資料列");
|
|
}
|
|
else
|
|
{
|
|
DoBackup(oldValues[0], "DELETE");
|
|
}
|
|
|
|
DbCommand cmdDelete = NewCommand();
|
|
cmdDelete.CommandText =
|
|
@"delete from [Classes]
|
|
where 1=1
|
|
and ID = @ID
|
|
and DB_APPNO = @DB_APPNO
|
|
";
|
|
AddParam(cmdDelete, "ID", ID);
|
|
AddParam(cmdDelete, "DB_APPNO", DB_APPNO);
|
|
int rowsAffected = ExecuteNonQuery(cmdDelete);
|
|
AfterDeleteOne(ID, 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(ClassesItem value)
|
|
{
|
|
using (TransactionScope ts = DAC.NewTransactionScope())
|
|
{
|
|
try
|
|
{
|
|
if (!BeforeDeleteOne(value))
|
|
return -1;
|
|
|
|
ClassesList oldValues = SelectOne(value.ID);
|
|
if (oldValues.Count == 0 || oldValues[0].DB_APPNO != value.DB_APPNO)
|
|
{
|
|
throw new DBConcurrencyException("在刪除 \"Classes\" 資料表時發生並行例外:找不到要刪除的資料列");
|
|
}
|
|
else
|
|
{
|
|
DoBackup(oldValues[0], "DELETE");
|
|
}
|
|
|
|
DbCommand cmdDelete = NewCommand();
|
|
cmdDelete.CommandText =
|
|
@"delete from [Classes]
|
|
where 1=1
|
|
and ID = @ID
|
|
and DB_APPNO = @DB_APPNO
|
|
";
|
|
AddParam(cmdDelete, "ID", value.ID);
|
|
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 ID)
|
|
{
|
|
DbCommand cmdSelect = NewCommand();
|
|
cmdSelect.CommandText = "select count(1)" + _from + _where
|
|
+ " and ID = @ID "
|
|
;
|
|
AddParam(cmdSelect, "ID", ID);
|
|
int count;
|
|
ExecuteScalar(cmdSelect, out count);
|
|
return count > 0;
|
|
}
|
|
|
|
public void DoBackup(ClassesItem value, string updateMode)
|
|
{
|
|
DbCommand cmdBak = NewCommand();
|
|
cmdBak.CommandText =
|
|
"insert into [Classes_BAK]"
|
|
+ " (" + _insertBak + ")"
|
|
+ "values "
|
|
+ " (" + _insertBakValue + ");"
|
|
;
|
|
AddParam(cmdBak, "ID", value.ID);
|
|
AddParam(cmdBak, "CourseCode", value.CourseCode);
|
|
AddParam(cmdBak, "CourseName", value.CourseName);
|
|
AddParam(cmdBak, "CourseDate", value.CourseDate);
|
|
AddParam(cmdBak, "CourseLocation", value.CourseLocation);
|
|
AddParam(cmdBak, "NotificationTitle", value.NotificationTitle);
|
|
AddParam(cmdBak, "NotificationTemplate", value.NotificationTemplate);
|
|
AddParam(cmdBak, "Closed", value.Closed);
|
|
AddParam(cmdBak, "ProjectID", value.ProjectID);
|
|
AddParam(cmdBak, "StartTime", value.StartTime);
|
|
AddParam(cmdBak, "EndTime", value.EndTime);
|
|
AddParam(cmdBak, "Teacher", value.Teacher);
|
|
AddParam(cmdBak, "AgreedTerms", value.AgreedTerms);
|
|
AddParam(cmdBak, "DB_APPNO", value.DB_APPNO);
|
|
AddParam(cmdBak, "DB_CRDAT", value.DB_CRDAT);
|
|
AddParam(cmdBak, "DB_CRUSR", value.DB_CRUSR);
|
|
AddParam(cmdBak, "DB_TRDAT", DateTime.Now);
|
|
AddParam(cmdBak, "DB_TRUSR", CurrentUserId);
|
|
AddParam(cmdBak, "DB_TRMOD", updateMode);
|
|
ExecuteNonQuery(cmdBak);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
///<summary>
|
|
///Classes 資料集合類別
|
|
///</summary>
|
|
[Serializable]
|
|
public partial class ClassesList : List<ClassesItem>, IDataList
|
|
{
|
|
public void Fill(DbDataReader reader)
|
|
{
|
|
DAC.FillData<ClassesItem>(reader, this);
|
|
}
|
|
}
|
|
|
|
|
|
///<summary>
|
|
/// Classes 資料紀錄類別
|
|
///</summary>
|
|
[Serializable]
|
|
public partial class ClassesItem : DataItemBase
|
|
{
|
|
private int _ID;
|
|
private string _CourseCode;
|
|
private string _CourseName;
|
|
private DateTime _CourseDate;
|
|
private string _CourseLocation;
|
|
private string _NotificationTitle;
|
|
private string _NotificationTemplate;
|
|
private bool _Closed;
|
|
private string _ProjectID;
|
|
private string _StartTime;
|
|
private string _EndTime;
|
|
private string _Teacher;
|
|
private string _AgreedTerms;
|
|
|
|
#region 資料欄位
|
|
///<summary>
|
|
/// 流水號
|
|
///</summary>
|
|
[DataObjectField(true, false, false)]
|
|
public int ID
|
|
{
|
|
get
|
|
{
|
|
return _ID;
|
|
}
|
|
set
|
|
{
|
|
if (value != _ID)
|
|
{
|
|
_ID = value;
|
|
OnPropertyChanged("ID");
|
|
}
|
|
}
|
|
}
|
|
|
|
///<summary>
|
|
/// 課程編號
|
|
///</summary>
|
|
[DataObjectField(false, false, false, 20)]
|
|
public string CourseCode
|
|
{
|
|
get
|
|
{
|
|
return _CourseCode;
|
|
}
|
|
set
|
|
{
|
|
if (value != _CourseCode)
|
|
{
|
|
_CourseCode = value;
|
|
OnPropertyChanged("CourseCode");
|
|
}
|
|
}
|
|
}
|
|
|
|
///<summary>
|
|
/// 課程名稱
|
|
///</summary>
|
|
[DataObjectField(false, false, false, 100)]
|
|
public string CourseName
|
|
{
|
|
get
|
|
{
|
|
return _CourseName;
|
|
}
|
|
set
|
|
{
|
|
if (value != _CourseName)
|
|
{
|
|
_CourseName = value;
|
|
OnPropertyChanged("CourseName");
|
|
}
|
|
}
|
|
}
|
|
|
|
///<summary>
|
|
/// 課程日期
|
|
///</summary>
|
|
[DataObjectField(false, false, false)]
|
|
public DateTime CourseDate
|
|
{
|
|
get
|
|
{
|
|
return _CourseDate;
|
|
}
|
|
set
|
|
{
|
|
if (value != _CourseDate)
|
|
{
|
|
_CourseDate = value;
|
|
OnPropertyChanged("CourseDate");
|
|
}
|
|
}
|
|
}
|
|
|
|
///<summary>
|
|
/// 課程地點
|
|
///</summary>
|
|
[DataObjectField(false, false, false, 100)]
|
|
public string CourseLocation
|
|
{
|
|
get
|
|
{
|
|
return _CourseLocation;
|
|
}
|
|
set
|
|
{
|
|
if (value != _CourseLocation)
|
|
{
|
|
_CourseLocation = value;
|
|
OnPropertyChanged("CourseLocation");
|
|
}
|
|
}
|
|
}
|
|
|
|
///<summary>
|
|
/// 通知標題
|
|
///</summary>
|
|
[DataObjectField(false, false, true, 100)]
|
|
public string NotificationTitle
|
|
{
|
|
get
|
|
{
|
|
return _NotificationTitle;
|
|
}
|
|
set
|
|
{
|
|
if (value != _NotificationTitle)
|
|
{
|
|
_NotificationTitle = value;
|
|
OnPropertyChanged("NotificationTitle");
|
|
}
|
|
}
|
|
}
|
|
|
|
///<summary>
|
|
/// 通知模板
|
|
///</summary>
|
|
[DataObjectField(false, false, true, 500)]
|
|
public string NotificationTemplate
|
|
{
|
|
get
|
|
{
|
|
return _NotificationTemplate;
|
|
}
|
|
set
|
|
{
|
|
if (value != _NotificationTemplate)
|
|
{
|
|
_NotificationTemplate = value;
|
|
OnPropertyChanged("NotificationTemplate");
|
|
}
|
|
}
|
|
}
|
|
|
|
///<summary>
|
|
/// 結案
|
|
///</summary>
|
|
[DataObjectField(false, false, false)]
|
|
public bool Closed
|
|
{
|
|
get
|
|
{
|
|
return _Closed;
|
|
}
|
|
set
|
|
{
|
|
if (value != _Closed)
|
|
{
|
|
_Closed = value;
|
|
OnPropertyChanged("Closed");
|
|
}
|
|
}
|
|
}
|
|
|
|
///<summary>
|
|
/// 計畫代號
|
|
///</summary>
|
|
[DataObjectField(false, false, true, 20)]
|
|
public string ProjectID
|
|
{
|
|
get
|
|
{
|
|
return _ProjectID;
|
|
}
|
|
set
|
|
{
|
|
if (value != _ProjectID)
|
|
{
|
|
_ProjectID = value;
|
|
OnPropertyChanged("ProjectID");
|
|
}
|
|
}
|
|
}
|
|
|
|
///<summary>
|
|
/// 課程開始時間
|
|
///</summary>
|
|
[DataObjectField(false, false, true, 5)]
|
|
public string StartTime
|
|
{
|
|
get
|
|
{
|
|
return _StartTime;
|
|
}
|
|
set
|
|
{
|
|
if (value != _StartTime)
|
|
{
|
|
_StartTime = value;
|
|
OnPropertyChanged("StartTime");
|
|
}
|
|
}
|
|
}
|
|
|
|
///<summary>
|
|
/// 課程結束時間
|
|
///</summary>
|
|
[DataObjectField(false, false, true, 5)]
|
|
public string EndTime
|
|
{
|
|
get
|
|
{
|
|
return _EndTime;
|
|
}
|
|
set
|
|
{
|
|
if (value != _EndTime)
|
|
{
|
|
_EndTime = value;
|
|
OnPropertyChanged("EndTime");
|
|
}
|
|
}
|
|
}
|
|
|
|
///<summary>
|
|
/// 老師
|
|
///</summary>
|
|
[DataObjectField(false, false, true, 50)]
|
|
public string Teacher
|
|
{
|
|
get
|
|
{
|
|
return _Teacher;
|
|
}
|
|
set
|
|
{
|
|
if (value != _Teacher)
|
|
{
|
|
_Teacher = value;
|
|
OnPropertyChanged("Teacher");
|
|
}
|
|
}
|
|
}
|
|
|
|
///<summary>
|
|
/// 同意確認事項
|
|
///</summary>
|
|
[DataObjectField(false, false, true, 100)]
|
|
public string AgreedTerms
|
|
{
|
|
get
|
|
{
|
|
return _AgreedTerms;
|
|
}
|
|
set
|
|
{
|
|
if (value != _AgreedTerms)
|
|
{
|
|
_AgreedTerms = value;
|
|
OnPropertyChanged("AgreedTerms");
|
|
}
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|