203 lines
4.3 KiB
C#
203 lines
4.3 KiB
C#
///////////////////////////////////////////////////////////
|
|
// 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
|
|
|
|
/// <summary>
|
|
/// List of NotifyDeliverySettings for building pick lists
|
|
///
|
|
///
|
|
/// </summary>
|
|
[Serializable]
|
|
public class NotifyDeliverySettingPickList : ReadOnlyCollectionBase
|
|
{
|
|
#region Data structure
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
[Serializable]
|
|
public struct NotifyDeliverySettingPickListInfo
|
|
{
|
|
|
|
internal Guid mID;
|
|
internal string mName;
|
|
|
|
|
|
|
|
//Public properties
|
|
public Guid ID {get{return mID;}}
|
|
public string Name {get{return mName;}}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="obj"></param>
|
|
public bool Equals(NotifyDeliverySettingPickListInfo obj)
|
|
{
|
|
return this.mID.Equals(obj.mID);
|
|
}
|
|
|
|
}//end NotifyDeliverySettingPickListInfo
|
|
#endregion
|
|
|
|
#region Constructor
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
protected NotifyDeliverySettingPickList()
|
|
{
|
|
// AllowSort=false;
|
|
// AllowFind=true;
|
|
// AllowEdit=false;
|
|
// AllowNew=false;
|
|
// AllowRemove=false;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Business properties and methods
|
|
|
|
/// <summary>
|
|
/// Get item by index
|
|
/// </summary>
|
|
/// <param name="Item"></param>
|
|
public NotifyDeliverySettingPickListInfo this[int Item]
|
|
{
|
|
|
|
get
|
|
{
|
|
return (NotifyDeliverySettingPickListInfo) List[Item];
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Returns NotifyDeliverySettingPickListInfo item that matches passed in itemid value
|
|
/// </summary>
|
|
/// <param name="ItemID"></param>
|
|
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
|
|
/// <summary>
|
|
/// Check if item in collection
|
|
/// </summary>
|
|
/// <param name="obj"></param>
|
|
public bool Contains(NotifyDeliverySettingPickListInfo obj)
|
|
{
|
|
foreach (NotifyDeliverySettingPickListInfo child in List)
|
|
{
|
|
if(child.Equals(obj)) return true;
|
|
}
|
|
return false;
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region Static methods
|
|
/// <summary>
|
|
/// Get all delivery methods for selected user
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
|
|
public static NotifyDeliverySettingPickList GetList(Guid UserID)
|
|
{
|
|
return (NotifyDeliverySettingPickList) DataPortal.Fetch(new Criteria(UserID));
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
#region DAL DATA ACCESS
|
|
///
|
|
/// <param name="Criteria"></param>
|
|
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
|
|
/// <summary>
|
|
/// Criteria for identifying existing object
|
|
/// </summary>
|
|
[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 |