244 lines
5.1 KiB
C#
244 lines
5.1 KiB
C#
///////////////////////////////////////////////////////////
|
|
// 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
|
|
{
|
|
/// <summary>
|
|
/// Editable child collection of <see cref="ContractRate"/> objects
|
|
/// </summary>
|
|
[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
|
|
/// <summary>
|
|
/// Retrieve ContractRate by index
|
|
/// </summary>
|
|
/// <param name="Item">Index</param>
|
|
public ContractRate this[int Item]
|
|
{
|
|
get
|
|
{
|
|
return (ContractRate) List[Item];
|
|
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Retrieve ContractRate by string containing Guid value
|
|
/// </summary>
|
|
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;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Remove ContractRate by passing it in
|
|
/// </summary>
|
|
/// <param name="obj"></param>
|
|
public void Remove(ContractRate obj)
|
|
{
|
|
List.Remove(obj);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Remove ContractRate by string of id value
|
|
/// </summary>
|
|
/// <param name="ContractRateID"></param>
|
|
public void Remove(string ContractRateID)
|
|
{
|
|
System.Guid sid = new System.Guid(ContractRateID);
|
|
foreach (ContractRate child in List)
|
|
{
|
|
if(child.ID==sid)
|
|
List.Remove(child);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Remove by Guid value of ID
|
|
/// </summary>
|
|
/// <param name="ContractRateID"></param>
|
|
public void Remove(Guid ContractRateID)
|
|
{
|
|
foreach (ContractRate child in List)
|
|
{
|
|
if(child.ID==ContractRateID)
|
|
List.Remove(child);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Add a new ContractRate to the collection
|
|
/// </summary>
|
|
/// <param name="obj"></param>
|
|
public ContractRate Add(Contract obj)
|
|
{
|
|
ContractRate child=ContractRate.NewItem(obj);
|
|
List.Add(child);
|
|
return child;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Contains
|
|
|
|
/// <summary>
|
|
/// Check if item in collection
|
|
/// </summary>
|
|
/// <param name="obj"></param>
|
|
public bool Contains(ContractRate obj)
|
|
{
|
|
foreach (ContractRate 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="ContractRateID"></param>
|
|
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;
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// Check if item in deleted collection
|
|
/// </summary>
|
|
/// <param name="obj"></param>
|
|
public bool ContainsDeleted(ContractRate obj)
|
|
{
|
|
foreach (ContractRate 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="ContractRateID"></param>
|
|
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
|
|
/// <summary>
|
|
/// NewItems
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
internal static ContractRates NewItems()
|
|
{
|
|
return new ContractRates();
|
|
}
|
|
|
|
/// <summary>
|
|
/// GetItems
|
|
/// </summary>
|
|
/// <param name="dr"></param>
|
|
/// <returns></returns>
|
|
internal static ContractRates GetItems(SafeDataReader dr)
|
|
{
|
|
ContractRates col = new ContractRates();
|
|
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(ContractRate.GetItem(dr));
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Update children
|
|
/// </summary>
|
|
/// <param name="obj"></param>
|
|
/// <param name="tr"></param>
|
|
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 |