204 lines
4.3 KiB
C#
204 lines
4.3 KiB
C#
///////////////////////////////////////////////////////////
|
|
// TaskPickList.cs
|
|
// Implementation of Class TaskPickList
|
|
// CSLA type: Read only collection
|
|
// Created on: 30-Dec-2004
|
|
// Object design: John
|
|
// Coded: 30-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="TaskPickList.TaskPickListInfo"/> objects representing <see cref="Task"/> objects.
|
|
/// Used for selection in UI and by API business objects internally.
|
|
/// </summary>
|
|
[Serializable]
|
|
public class TaskPickList : ReadOnlyCollectionBase
|
|
{
|
|
#region Data structure
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
[Serializable]
|
|
public struct TaskPickListInfo
|
|
{
|
|
|
|
internal Guid mID;
|
|
internal string mName;
|
|
internal bool mActive;
|
|
//internal string mNotes;
|
|
|
|
|
|
//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;}}
|
|
//public string Notes {get{return mNotes;}}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="obj"></param>
|
|
public bool Equals(TaskPickListInfo obj)
|
|
{
|
|
return this.mID.Equals(obj.mID);
|
|
}
|
|
|
|
}//end TaskPickListInfo
|
|
#endregion
|
|
|
|
#region Constructor
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
protected TaskPickList()
|
|
{
|
|
// 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 TaskPickListInfo this[int Item]
|
|
{
|
|
|
|
get
|
|
{
|
|
return (TaskPickListInfo) List[Item];
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Returns TaskPickListInfo item that matches passed in itemid value
|
|
/// </summary>
|
|
/// <param name="ItemID"></param>
|
|
public TaskPickListInfo this[Guid ItemID]
|
|
{
|
|
|
|
get
|
|
{
|
|
foreach (TaskPickListInfo child in List)
|
|
{
|
|
if(child.mID==ItemID) return child;
|
|
}
|
|
throw new ArgumentException("TaskPickList: ID not found:\r\n"+ItemID.ToString());
|
|
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region contains
|
|
/// <summary>
|
|
/// Check if item in collection
|
|
/// </summary>
|
|
/// <param name="obj"></param>
|
|
public bool Contains(TaskPickListInfo obj)
|
|
{
|
|
foreach (TaskPickListInfo child in List)
|
|
{
|
|
if(child.Equals(obj)) return true;
|
|
}
|
|
return false;
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region Static methods
|
|
/// <summary>
|
|
/// Get all tasks
|
|
/// </summary>
|
|
/// <returns>list of <see cref="TaskPickList.TaskPickListInfo"/> objects</returns>
|
|
public static TaskPickList GetList()
|
|
{
|
|
return (TaskPickList) 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 aTask"
|
|
//************************************************************
|
|
);
|
|
|
|
while(dr.Read())
|
|
{
|
|
//*******************************************
|
|
TaskPickListInfo info=new TaskPickListInfo();
|
|
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 TaskID;
|
|
|
|
public Criteria( )
|
|
{
|
|
//TaskID=_TaskID;
|
|
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
|
|
}//end TaskPickList
|
|
|
|
}//end namespace GZTW.AyaNova.BLL |