245 lines
5.2 KiB
C#
245 lines
5.2 KiB
C#
///////////////////////////////////////////////////////////
|
|
// ScheduleableUserGroupUsersList.cs
|
|
// Implementation of Class ScheduleableUserGroupUsersList
|
|
// 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 read only list of <see cref="ScheduleableUserGroupUsersList.ScheduleableUserGroupUsersListInfo"/> objects
|
|
/// </summary>
|
|
[Serializable]
|
|
public class ScheduleableUserGroupUsersList : ReadOnlyCollectionBase
|
|
{
|
|
#region Data structure
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
[Serializable]
|
|
public struct ScheduleableUserGroupUsersListInfo
|
|
{
|
|
|
|
internal Guid mID;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// ID
|
|
/// </summary>
|
|
public Guid ID
|
|
{
|
|
get
|
|
{
|
|
return mID;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="obj"></param>
|
|
public bool Equals(ScheduleableUserGroupUsersListInfo obj)
|
|
{
|
|
return this.mID.Equals(obj.mID);
|
|
}
|
|
|
|
}//end ScheduleableUserGroupUsersListInfo
|
|
#endregion
|
|
|
|
#region Constructor
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
protected ScheduleableUserGroupUsersList()
|
|
{
|
|
// 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 ScheduleableUserGroupUsersListInfo this[int Item]
|
|
{
|
|
|
|
get
|
|
{
|
|
return (ScheduleableUserGroupUsersListInfo) List[Item];
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Returns ScheduleableUserGroupUsersListInfo item that matches passed in itemid value
|
|
/// </summary>
|
|
/// <param name="ItemID"></param>
|
|
public ScheduleableUserGroupUsersListInfo this[Guid ItemID]
|
|
{
|
|
|
|
get
|
|
{
|
|
foreach (ScheduleableUserGroupUsersListInfo child in List)
|
|
{
|
|
if(child.mID==ItemID) return child;
|
|
}
|
|
throw new ArgumentException("ScheduleableUserGroupUsersList: UserID not found:\r\n"+ItemID.ToString());
|
|
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region contains
|
|
/// <summary>
|
|
/// Check if item in collection
|
|
/// </summary>
|
|
/// <param name="obj"></param>
|
|
public bool Contains(ScheduleableUserGroupUsersListInfo obj)
|
|
{
|
|
foreach (ScheduleableUserGroupUsersListInfo child in List)
|
|
{
|
|
if(child.Equals(obj)) return true;
|
|
}
|
|
return false;
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// Check if item in collection
|
|
/// </summary>
|
|
/// <param name="UserID"></param>
|
|
public bool Contains(Guid UserID)
|
|
{
|
|
foreach (ScheduleableUserGroupUsersListInfo child in List)
|
|
{
|
|
if(child.ID.Equals(UserID)) return true;
|
|
}
|
|
return false;
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// Check if item in collection
|
|
/// </summary>
|
|
/// <param name="sUserID"></param>
|
|
public bool Contains(string sUserID)
|
|
{
|
|
foreach (ScheduleableUserGroupUsersListInfo child in List)
|
|
{
|
|
if(child.ID.ToString().Equals(sUserID)) return true;
|
|
}
|
|
return false;
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region Static methods
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// Get all Parts
|
|
/// </summary>
|
|
/// <returns>list of <see cref="ScheduleableUserGroupUsersList.ScheduleableUserGroupUsersListInfo"/> objects</returns>
|
|
public static ScheduleableUserGroupUsersList GetList(Guid ScheduleableUserGroupID)
|
|
{
|
|
return (ScheduleableUserGroupUsersList) DataPortal.Fetch(new Criteria(ScheduleableUserGroupID));
|
|
}
|
|
|
|
|
|
|
|
|
|
#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 aScheduleableUserID FROM aScheduleableUserGroupUser " +
|
|
"WHERE (aScheduleableUserGroupID = @ID)",crit.ScheduleableUserGroupID
|
|
//************************************************************
|
|
);
|
|
|
|
|
|
while(dr.Read())
|
|
{
|
|
//*******************************************
|
|
ScheduleableUserGroupUsersListInfo info=new ScheduleableUserGroupUsersListInfo();
|
|
|
|
info.mID=dr.GetGuid("aScheduleableUserID");
|
|
|
|
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 ScheduleableUserGroupID;
|
|
|
|
public Criteria( Guid _ScheduleableUserGroupID)
|
|
{
|
|
ScheduleableUserGroupID=_ScheduleableUserGroupID;
|
|
|
|
}
|
|
|
|
public Criteria()
|
|
{
|
|
ScheduleableUserGroupID=Guid.Empty;
|
|
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
|
|
}//end ScheduleableUserGroupUsersList
|
|
|
|
}//end namespace GZTW.AyaNova.BLL |