/////////////////////////////////////////////////////////// // ScheduleableUserGroupPickList.cs // Implementation of Class ScheduleableUserGroupPickList // CSLA type: Read only collection // Created on: 29-Dec-2004 // Object design: John // Coded: 29-Dec-2004 /////////////////////////////////////////////////////////// using System; using System.Data; using GZTW.Data; using CSLA.Data; using CSLA; namespace GZTW.AyaNova.BLL { /// /// Lightweight read only list of objects representing /// objects. Used for UI selection and internal processing by business objects. /// [Serializable] public class ScheduleableUserGroupPickList : ReadOnlyCollectionBase { #region Data structure /// /// /// [Serializable] public struct ScheduleableUserGroupPickListInfo { internal Guid mID; internal string mName; internal bool mActive; //Public properties /// /// /// public Guid ID {get{return mID;}} /// /// /// public string Name {get{return mName;}} /// /// /// public bool Active {get{return mActive;}} /// /// /// /// public bool Equals(ScheduleableUserGroupPickListInfo obj) { return this.mID.Equals(obj.mID); } }//end ScheduleableUserGroupPickListInfo #endregion #region Constructor /// /// /// protected ScheduleableUserGroupPickList() { // AllowSort=false; // AllowFind=true; // AllowEdit=false; // AllowNew=false; // AllowRemove=false; } #endregion #region Business properties and methods /// /// Get item by index /// /// public ScheduleableUserGroupPickListInfo this[int Item] { get { return (ScheduleableUserGroupPickListInfo) List[Item]; } } /// /// Returns ScheduleableUserGroupPickListInfo item that matches passed in itemid value /// /// public ScheduleableUserGroupPickListInfo this[Guid ItemID] { get { foreach (ScheduleableUserGroupPickListInfo child in List) { if(child.mID==ItemID) return child; } throw new ArgumentException("ScheduleableUserGroupPickList: ID not found:\r\n"+ItemID.ToString()); } } #endregion #region contains /// /// Check if item in collection /// /// public bool Contains(ScheduleableUserGroupPickListInfo obj) { foreach (ScheduleableUserGroupPickListInfo child in List) { if(child.Equals(obj)) return true; } return false; } #endregion #region Static methods /// /// Get all scheduleable users /// /// list of objects public static ScheduleableUserGroupPickList GetList() { return (ScheduleableUserGroupPickList) DataPortal.Fetch(new Criteria()); } #endregion #region DAL DATA ACCESS /// /// protected override void DataPortal_Fetch(object Criteria) { SafeDataReader dr = null; try { dr=DBUtil.GetReaderFromSQLString( //************************************************************ "SELECT aID, AACTIVE, aName FROM aScheduleableUserGroup" //************************************************************ ); while(dr.Read()) { //******************************************* ScheduleableUserGroupPickListInfo info=new ScheduleableUserGroupPickListInfo(); info.mID=dr.GetGuid("aID"); info.mActive=dr.GetBoolean("AACTIVE"); info.mName=dr.GetString("aName"); InnerList.Add(info); //******************************************* } } finally { if(dr!=null) dr.Close(); } } #endregion #region criteria /// /// Criteria for identifying existing object /// [Serializable] private class Criteria { //public Guid VendorID; public Criteria( ) { //VendorID=_VendorID; } } #endregion }//end ScheduleableUserGroupPickList }//end namespace GZTW.AyaNova.BLL