// // 這個檔案是 課程經費 資料表的資料存取類別 檔案二 // 您可以修改這個檔案,加入您自訂的屬性與方法 // using System; using System.Collections.Generic; using System.Text; using System.ComponentModel; using System.Data; using System.Data.Common; using WebLib; using System.Data.SqlClient; namespace Education { /// /// 課程經費 資料存取類別 /// public partial class DAC_課程經費 : WebLib.DAC { #region 自動產生的資料存取方法 /// /// InsertOne 之前會執行此方法 /// 在這裡可以做一些檢查或是自動編號等動作 /// 回傳 false 會打斷 InsertOne 的執行 /// protected virtual bool BeforeInsertOne(課程經費 value) { value.單據序號 = Next單據序號(value.訓練課程企劃編號); return true; } /// /// InsertOne 之後會執行此方法 /// protected virtual void AfterInsertOne(課程經費 value) { } /// /// InsertOne 發生錯誤時會執行此方法 /// ///錯誤是否已經處理妥當 protected virtual void OnInsertOneError(Exception error, out bool handled) { handled = false; } /// /// UpdateOne 之前會執行此方法 /// 在這裡可以做一些檢查 /// 回傳 false 會打斷 UpdateOne 的執行 /// protected virtual bool BeforeUpdateOne(課程經費 value) { return true; } /// /// UpdateOne 之後會執行此方法 /// protected virtual void AfterUpdateOne(課程經費 value) { } /// /// UpdateOne 發生錯誤時會執行此方法 /// ///錯誤是否已經處理妥當 protected virtual void OnUpdateOneError(Exception error, out bool handled) { handled = false; } /// /// DeleteOne 之前會執行此方法 /// 在這裡可以做一些檢查 /// 回傳 false 會打斷 DeleteOne 的執行 /// protected virtual bool BeforeDeleteOne(課程經費 value) { return true; } /// /// DeleteOne 之後會執行此方法 /// protected virtual void AfterDeleteOne(課程經費 value) { } /// /// DeleteOne 之前會執行此方法 /// 在這裡可以做一些檢查 /// 回傳 false 會打斷 DeleteOne 的執行 /// protected virtual bool BeforeDeleteOne(int 訓練課程企劃編號, int 單據序號, int DB_APPNO) { return true; } /// /// DeleteOne 之後會執行此方法 /// protected virtual void AfterDeleteOne(int 訓練課程企劃編號, int 單據序號, int DB_APPNO) { } /// /// DeleteOne 發生錯誤時會執行此方法 /// ///錯誤是否已經處理妥當 protected virtual void OnDeleteOneError(Exception error, out bool handled) { handled = false; } #endregion // 有另外加上去的屬性及方法,請加在這裡 [DataObjectMethod(DataObjectMethodType.Select)] public 課程經費List Select(int 訓練課程企劃編號) { 課程經費List result = new 課程經費List(); IDataList list = result as IDataList; DbCommand cmdSelect = NewCommand(); cmdSelect.CommandText = _select + _from + _where + " and 訓練課程企劃編號 = @訓練課程企劃編號 " + " order by 單據序號" ; AddParam(cmdSelect, "訓練課程企劃編號", 訓練課程企劃編號); Select(cmdSelect, ref list); return result; } [DataObjectMethod(DataObjectMethodType.Select)] public int Get經費合計(int 訓練課程企劃編號) { DbCommand cmdSelect = NewCommand(); cmdSelect.CommandText = @"select isnull(sum(金額), 0) from 課程經費 where 訓練課程企劃編號 = @訓練課程企劃編號 and 收支='支'"; // @"select // (select isnull(sum(金額), 0) from 課程經費 where 訓練課程企劃編號 = @訓練課程企劃編號 and 收支='支') // - // (select isnull(sum(金額), 0) from 課程經費 where 訓練課程企劃編號 = @訓練課程企劃編號 and 收支='收')"; AddParam(cmdSelect, "訓練課程企劃編號", 訓練課程企劃編號); int i; ExecuteScalar(cmdSelect, out i); return i; } private int Next單據序號(int 訓練課程企劃編號) { DbCommand cmdSelect = NewCommand(@"select isnull(max(單據序號), 0) + 1 from " + _tableName + " where 訓練課程企劃編號 = @訓練課程企劃編號"); AddParam(cmdSelect, "訓練課程企劃編號", 訓練課程企劃編號); int i; ExecuteScalar(cmdSelect, out i); return i; } } /// /// 課程經費 資料集合類別 /// public partial class 課程經費List : List<課程經費> { // 有另外加上去的屬性及方法,請加在這裡 } /// /// 課程經費 資料紀錄類別 /// public partial class 課程經費 { // 有另外加上去的屬性及方法,請加在這裡 } }