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