Files
ayanova7/source/bizobjects/AyaLib/GZTW.AyaNova.BLL/ScheduleableUserGroupPickList.cs
2018-06-29 19:47:36 +00:00

205 lines
4.7 KiB
C#

///////////////////////////////////////////////////////////
// ScheduleableUserGroupPickList.cs
// Implementation of Class ScheduleableUserGroupPickList
// CSLA type: Read only collection
// Created on: 29-Dec-2004
// Object design: John
// Coded: 29-Dec-2004
///////////////////////////////////////////////////////////
using System;
using System.Data;
using GZTW.Data;
using CSLA.Data;
using CSLA;
namespace GZTW.AyaNova.BLL
{
/// <summary>
/// Lightweight read only list of <see cref="ScheduleableUserGroupPickList.ScheduleableUserGroupPickListInfo"/> objects representing
/// <see cref="ScheduleableUserGroup"/> objects. Used for UI selection and internal processing by business objects.
/// </summary>
[Serializable]
public class ScheduleableUserGroupPickList : ReadOnlyCollectionBase
{
#region Data structure
/// <summary>
///
/// </summary>
[Serializable]
public struct ScheduleableUserGroupPickListInfo
{
internal Guid mID;
internal string mName;
internal bool mActive;
//Public properties
/// <summary>
///
/// </summary>
public Guid ID {get{return mID;}}
/// <summary>
///
/// </summary>
public string Name {get{return mName;}}
/// <summary>
///
/// </summary>
public bool Active {get{return mActive;}}
/// <summary>
///
/// </summary>
/// <param name="obj"></param>
public bool Equals(ScheduleableUserGroupPickListInfo obj)
{
return this.mID.Equals(obj.mID);
}
}//end ScheduleableUserGroupPickListInfo
#endregion
#region Constructor
/// <summary>
///
/// </summary>
protected ScheduleableUserGroupPickList()
{
// 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 ScheduleableUserGroupPickListInfo this[int Item]
{
get
{
return (ScheduleableUserGroupPickListInfo) List[Item];
}
}
/// <summary>
/// Returns ScheduleableUserGroupPickListInfo item that matches passed in itemid value
/// </summary>
/// <param name="ItemID"></param>
public ScheduleableUserGroupPickListInfo this[Guid ItemID]
{
get
{
foreach (ScheduleableUserGroupPickListInfo child in List)
{
if(child.mID==ItemID) return child;
}
throw new ArgumentException("ScheduleableUserGroupPickList: ID not found:\r\n"+ItemID.ToString());
}
}
#endregion
#region contains
/// <summary>
/// Check if item in collection
/// </summary>
/// <param name="obj"></param>
public bool Contains(ScheduleableUserGroupPickListInfo obj)
{
foreach (ScheduleableUserGroupPickListInfo 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="ScheduleableUserGroupPickList.ScheduleableUserGroupPickListInfo"/> objects</returns>
public static ScheduleableUserGroupPickList GetList()
{
return (ScheduleableUserGroupPickList) DataPortal.Fetch(new Criteria());
}
#endregion
#region DAL DATA ACCESS
///
/// <param name="Criteria"></param>
protected override void DataPortal_Fetch(object Criteria)
{
SafeDataReader dr = null;
try
{
dr=DBUtil.GetReaderFromSQLString(
//************************************************************
"SELECT aID, AACTIVE, aName FROM aScheduleableUserGroup"
//************************************************************
);
while(dr.Read())
{
//*******************************************
ScheduleableUserGroupPickListInfo info=new ScheduleableUserGroupPickListInfo();
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 Guid VendorID;
public Criteria( )
{
//VendorID=_VendorID;
}
}
#endregion
}//end ScheduleableUserGroupPickList
}//end namespace GZTW.AyaNova.BLL