199 lines
5.5 KiB
C#
199 lines
5.5 KiB
C#
///////////////////////////////////////////////////////////
|
|
// FollowUpPickList.cs
|
|
// Implementation of Class FollowUpPickList
|
|
// CSLA type: Read only collection
|
|
// Created on: 19-Nov-2007
|
|
// Object design: John
|
|
// Coded: 19-Nov-2007
|
|
///////////////////////////////////////////////////////////
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using GZTW.Data;
|
|
using CSLA.Data;
|
|
using CSLA;
|
|
namespace GZTW.AyaNova.BLL
|
|
{
|
|
/// <summary>
|
|
/// Lightweight list of <see cref="FollowUpPickList.FollowUpPickListInfo"/> objects representing <see cref="ScheduleMarker"/> objects
|
|
/// that are linked to a root object.
|
|
/// </summary>
|
|
[Serializable]
|
|
public class FollowUpPickList : ReadOnlyCollectionBase
|
|
{
|
|
#region Data structure
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
[Serializable]
|
|
public struct FollowUpPickListInfo
|
|
{
|
|
|
|
internal Guid mID;
|
|
internal string mName;
|
|
|
|
|
|
|
|
//Public properties
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public Guid ID { get { return mID; } }
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public string Name { get { return mName; } }
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="obj"></param>
|
|
public bool Equals(FollowUpPickListInfo obj)
|
|
{
|
|
return this.mID.Equals(obj.mID);
|
|
}
|
|
|
|
}//end FollowUpPickListInfo
|
|
#endregion
|
|
|
|
#region Constructor
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
protected FollowUpPickList()
|
|
{
|
|
// 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 FollowUpPickListInfo this[int Item]
|
|
{
|
|
|
|
get
|
|
{
|
|
return (FollowUpPickListInfo)List[Item];
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Returns FollowUpPickListInfo item that matches passed in itemid value
|
|
/// </summary>
|
|
/// <param name="ItemID"></param>
|
|
public FollowUpPickListInfo this[Guid ItemID]
|
|
{
|
|
|
|
get
|
|
{
|
|
foreach (FollowUpPickListInfo child in List)
|
|
{
|
|
if (child.mID == ItemID) return child;
|
|
}
|
|
throw new ArgumentException("FollowUpPickList: ID not found:\r\n" + ItemID.ToString());
|
|
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region contains
|
|
/// <summary>
|
|
/// Check if item in collection
|
|
/// </summary>
|
|
/// <param name="obj"></param>
|
|
public bool Contains(FollowUpPickListInfo obj)
|
|
{
|
|
foreach (FollowUpPickListInfo child in List)
|
|
{
|
|
if (child.Equals(obj)) return true;
|
|
}
|
|
return false;
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region Static methods
|
|
/// <summary>
|
|
/// Get all follow ups for id
|
|
/// </summary>
|
|
/// <returns>list of <see cref="FollowUpPickList.FollowUpPickListInfo"/> objects</returns>
|
|
public static FollowUpPickList GetList(Guid rootObjectID)
|
|
{
|
|
if (rootObjectID == Guid.Empty)
|
|
throw new System.ApplicationException("FollowUpPickList->GetList: Error rootObjectID is empty");
|
|
return (FollowUpPickList)DataPortal.Fetch(new Criteria(rootObjectID));
|
|
}
|
|
|
|
|
|
|
|
|
|
#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 aschedulemarker " +
|
|
"WHERE AFOLLOWID = @ID ORDER BY ANAME", crit.rootObjectID
|
|
//************************************************************
|
|
);
|
|
|
|
while (dr.Read())
|
|
{
|
|
//*******************************************
|
|
FollowUpPickListInfo info = new FollowUpPickListInfo();
|
|
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 rootObjectID;
|
|
public Criteria(Guid _rootObjectID)
|
|
{
|
|
rootObjectID=_rootObjectID;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
}//end FollowUpPickList
|
|
|
|
}
|