/////////////////////////////////////////////////////////// // DispatchZonePickList.cs // Implementation of Class DispatchZonePickList // CSLA type: Read only collection // Created on: 09-Sept-2005 // Object design: John // Coded: 09-Sept-2005 /////////////////////////////////////////////////////////// using System; using System.Data; using GZTW.Data; using CSLA.Data; using CSLA; namespace GZTW.AyaNova.BLL { /// /// Lightweight list of objects representing objects /// /// Includes inactive so that they can be shown on old records /// in a consistent format /// /// [Serializable] public class DispatchZonePickList : ReadOnlyCollectionBase { #region Data structure /// /// /// [Serializable] public struct DispatchZonePickListInfo { internal Guid mID; internal string mName; internal bool mActive; //internal string mNotes; #pragma warning disable 1591 //Public properties public Guid ID {get{return mID;}} public string Name {get{return mName;}} public bool Active {get{return mActive;}} //public string Notes {get{return mNotes;}} #pragma warning restore 1591 /// /// /// /// public bool Equals(DispatchZonePickListInfo obj) { return this.mID.Equals(obj.mID); } }//end DispatchZonePickListInfo #endregion #region Constructor /// /// /// protected DispatchZonePickList() { // AllowSort=false; // AllowFind=true; // AllowEdit=false; // AllowNew=false; // AllowRemove=false; } #endregion #region Business properties and methods /// /// Get item by index /// /// public DispatchZonePickListInfo this[int Item] { get { return (DispatchZonePickListInfo) List[Item]; } } /// /// Returns DispatchZonePickListInfo item that matches passed in itemid value /// /// public DispatchZonePickListInfo this[Guid ItemID] { get { foreach (DispatchZonePickListInfo child in List) { if(child.mID==ItemID) return child; } throw new ArgumentException("DispatchZonePickList: ID not found:\r\n"+ItemID.ToString()); } } #endregion #region contains /// /// Check if item in collection /// /// public bool Contains(DispatchZonePickListInfo obj) { foreach (DispatchZonePickListInfo child in List) { if(child.Equals(obj)) return true; } return false; } #endregion #region Static methods /// /// Get all scheduleable users /// /// list of objects public static DispatchZonePickList GetList(bool Regional) { return (DispatchZonePickList) DataPortal.Fetch(new Criteria(Regional)); } #endregion #region DAL DATA ACCESS /// /// protected override void DataPortal_Fetch(object Criteria) { Criteria crit = (Criteria)Criteria; SafeDataReader dr = null; try { dr=DBUtil.GetReaderFromSQLString(DBUtil.AddRegionFilter( //************************************************************ "SELECT aID, AACTIVE, aName FROM aDispatchZone", "aDispatchZone", "", crit.Regional //************************************************************ )) ; while(dr.Read()) { //******************************************* DispatchZonePickListInfo info=new DispatchZonePickListInfo(); 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 bool Regional; public Criteria(bool _Regional ) { Regional = _Regional; } } #endregion }//end DispatchZonePickList }//end namespace GZTW.AyaNova.BLL