244 lines
5.2 KiB
C#
244 lines
5.2 KiB
C#
///////////////////////////////////////////////////////////
|
|
// TaskGroupTasks.cs
|
|
// Implementation of Class TaskGroupTasks
|
|
// CSLA type: Editable child collection
|
|
// Created on: 07-Jun-2004 8:41:37 AM
|
|
// Object design: John
|
|
// Coded: John 29-July-2004
|
|
///////////////////////////////////////////////////////////
|
|
|
|
using System;
|
|
using System.Data;
|
|
using CSLA.Data;
|
|
using CSLA;
|
|
|
|
namespace GZTW.AyaNova.BLL
|
|
{
|
|
/// <summary>
|
|
/// Editable child collectin of <see cref="TaskGroupTask"/> objects
|
|
/// </summary>
|
|
[Serializable]
|
|
public class TaskGroupTasks : BusinessCollectionBase {
|
|
|
|
#region Constructor
|
|
|
|
//Private constructor prevents direction instantiation
|
|
private TaskGroupTasks()
|
|
{
|
|
//Child
|
|
MarkAsChild();
|
|
AllowSort=false;
|
|
AllowFind=true;
|
|
AllowEdit=true;
|
|
AllowNew=true;
|
|
AllowRemove=true;
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Business properties and methods
|
|
/// <summary>
|
|
/// Retrieve TaskGroupTask by index
|
|
/// </summary>
|
|
/// <param name="Item">Index</param>
|
|
public TaskGroupTask this[int Item]
|
|
{
|
|
get
|
|
{
|
|
return (TaskGroupTask) List[Item];
|
|
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Retrieve TaskGroupTask by string containing Guid value
|
|
/// </summary>
|
|
public TaskGroupTask this[string TaskGroupTaskID]
|
|
{
|
|
get
|
|
{
|
|
System.Guid sid = new System.Guid(TaskGroupTaskID);
|
|
foreach (TaskGroupTask child in List)
|
|
{
|
|
if(child.ID==sid)
|
|
return child;
|
|
}
|
|
return null;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Remove TaskGroupTask by passing it in
|
|
/// </summary>
|
|
/// <param name="obj"></param>
|
|
public void Remove(TaskGroupTask obj)
|
|
{
|
|
List.Remove(obj);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Remove TaskGroupTask by string of id value
|
|
/// </summary>
|
|
/// <param name="TaskGroupTaskID"></param>
|
|
public void Remove(string TaskGroupTaskID)
|
|
{
|
|
System.Guid sid = new System.Guid(TaskGroupTaskID);
|
|
foreach (TaskGroupTask child in List)
|
|
{
|
|
if(child.ID==sid)
|
|
List.Remove(child);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Remove by Guid value of ID
|
|
/// </summary>
|
|
/// <param name="TaskGroupTaskID"></param>
|
|
public void Remove(Guid TaskGroupTaskID)
|
|
{
|
|
foreach (TaskGroupTask child in List)
|
|
{
|
|
if(child.ID==TaskGroupTaskID)
|
|
List.Remove(child);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Add a new TaskGroupTask to the collection
|
|
/// </summary>
|
|
/// <param name="obj"></param>
|
|
public TaskGroupTask Add(TaskGroup obj)
|
|
{
|
|
TaskGroupTask child=TaskGroupTask.NewItem(obj);
|
|
List.Add(child);
|
|
return child;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Contains
|
|
|
|
/// <summary>
|
|
/// Check if item in collection
|
|
/// </summary>
|
|
/// <param name="obj"></param>
|
|
public bool Contains(TaskGroupTask obj)
|
|
{
|
|
foreach (TaskGroupTask child in List)
|
|
{
|
|
if(child.Equals(obj)) return true;
|
|
}
|
|
return false;
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// Check if item in collection by string of ID value
|
|
/// </summary>
|
|
/// <param name="TaskGroupTaskID"></param>
|
|
public bool Contains(string TaskGroupTaskID)
|
|
{
|
|
System.Guid sid = new System.Guid(TaskGroupTaskID);
|
|
foreach (TaskGroupTask child in List)
|
|
{
|
|
if(child.ID==sid) return true;
|
|
}
|
|
return false;
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// Check if item in deleted collection
|
|
/// </summary>
|
|
/// <param name="obj"></param>
|
|
public bool ContainsDeleted(TaskGroupTask obj)
|
|
{
|
|
foreach (TaskGroupTask child in deletedList)
|
|
{
|
|
if(child.Equals(obj)) return true;
|
|
}
|
|
return false;
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// Check if item in deleted collection by string of ID value
|
|
/// </summary>
|
|
/// <param name="TaskGroupTaskID"></param>
|
|
public bool ContainsDeleted(string TaskGroupTaskID)
|
|
{
|
|
System.Guid sid = new System.Guid(TaskGroupTaskID);
|
|
foreach (TaskGroupTask child in deletedList)
|
|
{
|
|
if(child.ID==sid) return true;
|
|
}
|
|
return false;
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region Static methods
|
|
/// <summary>
|
|
/// NewItems
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
internal static TaskGroupTasks NewItems()
|
|
{
|
|
return new TaskGroupTasks();
|
|
}
|
|
|
|
/// <summary>
|
|
/// GetItems
|
|
/// </summary>
|
|
/// <param name="dr"></param>
|
|
/// <returns></returns>
|
|
internal static TaskGroupTasks GetItems(SafeDataReader dr)
|
|
{
|
|
TaskGroupTasks col = new TaskGroupTasks();
|
|
col.Fetch(dr);
|
|
return col;
|
|
}
|
|
#endregion
|
|
|
|
#region DAL DATA ACCESS
|
|
|
|
/// <summary>
|
|
/// Fetch children
|
|
/// </summary>
|
|
/// <param name="dr">Populated data reader</param>
|
|
private void Fetch(SafeDataReader dr)
|
|
{
|
|
while(dr.Read())
|
|
{
|
|
List.Add(TaskGroupTask.GetItem(dr));
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Update children
|
|
/// </summary>
|
|
/// <param name="obj"></param>
|
|
/// <param name="tr"></param>
|
|
internal void Update(TaskGroup obj,IDbTransaction tr)
|
|
{
|
|
//update (thus deleting) any deleted child objects
|
|
foreach (TaskGroupTask child in deletedList)
|
|
{
|
|
child.Update(obj,tr);
|
|
}
|
|
|
|
//Now that they are deleted remove them from memory
|
|
deletedList.Clear();
|
|
|
|
foreach (TaskGroupTask child in List)
|
|
{
|
|
child.Update(obj,tr);
|
|
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
}//end Tasks
|
|
|
|
}//end namespace GZTW.AyaNova.BLL |