/////////////////////////////////////////////////////////// // NotifyDeliverySettingPickList.cs // Implementation of Class NotifyDeliverySettingPickList // CSLA type: Read only collection // Created on: 08-Oct-2005 // Object design: John // Coded: John 08-Oct-2005 /////////////////////////////////////////////////////////// using System; using System.Data; using GZTW.Data; using CSLA.Data; using CSLA; namespace GZTW.AyaNova.BLL { #pragma warning disable 1591 /// /// List of NotifyDeliverySettings for building pick lists /// /// /// [Serializable] public class NotifyDeliverySettingPickList : ReadOnlyCollectionBase { #region Data structure /// /// /// [Serializable] public struct NotifyDeliverySettingPickListInfo { internal Guid mID; internal string mName; //Public properties public Guid ID {get{return mID;}} public string Name {get{return mName;}} /// /// /// /// public bool Equals(NotifyDeliverySettingPickListInfo obj) { return this.mID.Equals(obj.mID); } }//end NotifyDeliverySettingPickListInfo #endregion #region Constructor /// /// /// protected NotifyDeliverySettingPickList() { // AllowSort=false; // AllowFind=true; // AllowEdit=false; // AllowNew=false; // AllowRemove=false; } #endregion #region Business properties and methods /// /// Get item by index /// /// public NotifyDeliverySettingPickListInfo this[int Item] { get { return (NotifyDeliverySettingPickListInfo) List[Item]; } } /// /// Returns NotifyDeliverySettingPickListInfo item that matches passed in itemid value /// /// public NotifyDeliverySettingPickListInfo this[Guid ItemID] { get { foreach (NotifyDeliverySettingPickListInfo child in List) { if(child.mID==ItemID) return child; } throw new ArgumentException("NotifyDeliverySettingPickList: ID not found:\r\n"+ItemID.ToString()); } } #endregion #region contains /// /// Check if item in collection /// /// public bool Contains(NotifyDeliverySettingPickListInfo obj) { foreach (NotifyDeliverySettingPickListInfo child in List) { if(child.Equals(obj)) return true; } return false; } #endregion #region Static methods /// /// Get all delivery methods for selected user /// /// public static NotifyDeliverySettingPickList GetList(Guid UserID) { return (NotifyDeliverySettingPickList) DataPortal.Fetch(new Criteria(UserID)); } #endregion #region DAL DATA ACCESS /// /// protected override void DataPortal_Fetch(object Criteria) { Criteria crit = (Criteria)Criteria; SafeDataReader dr = null; try { dr=DBUtil.GetReaderFromSQLString( //************************************************************ "SELECT aID, aName FROM aNotifyDeliverySetting WHERE aUserID=@ID", crit.UserID //************************************************************ ); while(dr.Read()) { //******************************************* NotifyDeliverySettingPickListInfo info=new NotifyDeliverySettingPickListInfo(); info.mID=dr.GetGuid("aID"); 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 UserID; public Criteria(Guid _UserID) { UserID=_UserID; } } #endregion }//end NotifyDeliverySettingPickList #pragma warning restore 1591 }//end namespace GZTW.AyaNova.BLL