211 lines
4.7 KiB
C#
211 lines
4.7 KiB
C#
///////////////////////////////////////////////////////////
|
|
// 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
|
|
{
|
|
/// <summary>
|
|
/// Lightweight list of <see cref="DispatchZonePickList.DispatchZonePickListInfo"/> objects representing <see cref="DispatchZone"/> objects
|
|
///
|
|
/// Includes inactive so that they can be shown on old records
|
|
/// in a consistent format
|
|
///
|
|
/// </summary>
|
|
[Serializable]
|
|
public class DispatchZonePickList : ReadOnlyCollectionBase
|
|
{
|
|
#region Data structure
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
[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
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="obj"></param>
|
|
public bool Equals(DispatchZonePickListInfo obj)
|
|
{
|
|
return this.mID.Equals(obj.mID);
|
|
}
|
|
|
|
}//end DispatchZonePickListInfo
|
|
#endregion
|
|
|
|
#region Constructor
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
protected DispatchZonePickList()
|
|
{
|
|
// 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 DispatchZonePickListInfo this[int Item]
|
|
{
|
|
|
|
get
|
|
{
|
|
return (DispatchZonePickListInfo) List[Item];
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Returns DispatchZonePickListInfo item that matches passed in itemid value
|
|
/// </summary>
|
|
/// <param name="ItemID"></param>
|
|
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
|
|
/// <summary>
|
|
/// Check if item in collection
|
|
/// </summary>
|
|
/// <param name="obj"></param>
|
|
public bool Contains(DispatchZonePickListInfo obj)
|
|
{
|
|
foreach (DispatchZonePickListInfo child in List)
|
|
{
|
|
if(child.Equals(obj)) return true;
|
|
}
|
|
return false;
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region Static methods
|
|
/// <summary>
|
|
/// Get all scheduleable users
|
|
/// </summary>
|
|
/// <returns>list of <see cref="DispatchZonePickList.DispatchZonePickListInfo"/> objects</returns>
|
|
|
|
public static DispatchZonePickList GetList(bool Regional)
|
|
{
|
|
return (DispatchZonePickList) DataPortal.Fetch(new Criteria(Regional));
|
|
}
|
|
|
|
|
|
|
|
|
|
#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(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
|
|
/// <summary>
|
|
/// Criteria for identifying existing object
|
|
/// </summary>
|
|
[Serializable]
|
|
private class Criteria
|
|
{
|
|
|
|
|
|
public bool Regional;
|
|
|
|
public Criteria(bool _Regional )
|
|
{
|
|
Regional = _Regional;
|
|
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
|
|
}//end DispatchZonePickList
|
|
|
|
}//end namespace GZTW.AyaNova.BLL |