// // 這個檔案是 組織人員 資料表的資料存取類別 檔案二 // 您可以修改這個檔案,加入您自訂的屬性與方法 // 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 { /// /// InsertOne 之前會執行此方法 /// 在這裡可以做一些檢查或是自動編號等動作 /// 回傳 false 會打斷 InsertOne 的執行 /// protected virtual bool BeforeInsertOne(組織人員 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 組織ID, string 人員ID, int DB_APPNO) { return true; } /// /// DeleteOne 之後會執行此方法 /// protected virtual void AfterDeleteOne(int 組織ID, string 人員ID, int DB_APPNO) { } /// /// DeleteOne 發生錯誤時會執行此方法 /// protected virtual void OnDeleteOneError(Exception error, out bool handled) { handled = false; } // 有另外加上去的屬性及方法,請加在這裡 [DataObjectMethod(DataObjectMethodType.Select)] public 組織人員List Select組織(int 組織ID) { 組織人員List result = new 組織人員List(); IDataList list = result as IDataList; DbCommand cmdSelect = NewCommand(); cmdSelect.CommandText = _select + _from + _where + " and 組織ID = @組織ID " + _order; AddParam(cmdSelect, "組織ID", 組織ID); Select(cmdSelect, ref list); return result; } [DataObjectMethod(DataObjectMethodType.Select)] public DataTable Select組織人員(int 組織ID) { DbCommand cmdSelect = NewCommand(); cmdSelect.CommandText = @"SELECT '' AS 人員ID, '(無)' AS 人員姓名 UNION ALL SELECT A.人員ID, A.人員ID + ' ' + B.BPNME AS 人員姓名 FROM 組織人員 A INNER JOIN BPSNView B ON A.人員ID=B.BPENO WHERE A.組織ID = @組織ID ORDER BY 人員ID "; AddParam(cmdSelect, "組織ID", 組織ID); return Select(cmdSelect); } [DataObjectMethod(DataObjectMethodType.Delete)] public void Delete組織人員(int 組織ID) { DbCommand cmdDelete = NewCommand(); cmdDelete.CommandText = @"DELETE FROM 組織人員 WHERE 組織ID = @組織ID"; AddParam(cmdDelete, "組織ID", 組織ID); ExecuteNonQuery(cmdDelete); } [DataObjectMethod(DataObjectMethodType.Select)] public 組織人員List Select人員所屬的組織(string 人員ID) { 組織人員List result = new 組織人員List(); IDataList list = result as IDataList; DbCommand cmdSelect = NewCommand(); cmdSelect.CommandText = _select + _from + _where + " and 人員ID = @人員ID " + _order; AddParam(cmdSelect, "人員ID", 人員ID); Select(cmdSelect, ref list); return result; } /// /// 判斷人員是否屬於某組織 /// /// 組織編號 /// 人員編號 /// public bool Is人員屬於組織(int 組織ID, string 人員ID) { return SelectOne(組織ID, 人員ID).Count > 0; } } /// /// 組織人員 資料集合類別 /// public partial class 組織人員List : List<組織人員> { // 有另外加上去的屬性及方法,請加在這裡 } /// /// 組織人員 資料紀錄類別 /// public partial class 組織人員 { // 有另外加上去的屬性及方法,請加在這裡 } }