This commit is contained in:
@@ -0,0 +1,244 @@
|
||||
///////////////////////////////////////////////////////////
|
||||
// PartByWarehouseInventories.cs
|
||||
// Implementation of Class PartByWarehouseInventories
|
||||
// CSLA type: Editable root collection
|
||||
// Created on: 24-Nov-2005
|
||||
// Object design: Joyce
|
||||
// Coded: 24-Nov-2005
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
using System;
|
||||
using System.Data;
|
||||
using CSLA.Data;
|
||||
using GZTW.Data;
|
||||
using CSLA;
|
||||
|
||||
|
||||
namespace GZTW.AyaNova.BLL
|
||||
{
|
||||
/// <summary>
|
||||
/// Editable root collection of <see cref="PartByWarehouseInventory"/> objects
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class PartByWarehouseInventories : BusinessCollectionBase //v8port: This is only used to feed the PartByWarehouseInventoryForm which is only used to set teh restock level and view inventory levels, it's redundant
|
||||
{
|
||||
private Guid mPartID=Guid.Empty;
|
||||
#region Constructor
|
||||
|
||||
//Private constructor prevents direction instantiation
|
||||
private PartByWarehouseInventories()
|
||||
{
|
||||
AllowSort=false;
|
||||
AllowFind=true;
|
||||
AllowEdit=true;
|
||||
AllowNew=true;
|
||||
AllowRemove=true;
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Business properties and methods
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve PartByWarehouseInventory by index
|
||||
/// </summary>
|
||||
/// <param name="Item">Index</param>
|
||||
public PartByWarehouseInventory this[int Item]
|
||||
{
|
||||
get
|
||||
{
|
||||
return (PartByWarehouseInventory) List[Item];
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Remove PartByWarehouseInventory by passing it in
|
||||
/// </summary>
|
||||
/// <param name="obj"></param>
|
||||
public void Remove(PartByWarehouseInventory obj)
|
||||
{
|
||||
List.Remove(obj);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add a new PartByWarehouseInventory to the collection
|
||||
/// </summary>
|
||||
|
||||
public PartByWarehouseInventory Add()
|
||||
{
|
||||
PartByWarehouseInventory child=PartByWarehouseInventory.NewItem();
|
||||
child.PartID=mPartID;
|
||||
List.Add(child);
|
||||
return child;
|
||||
}
|
||||
/// <summary>
|
||||
/// Add PartByWarehouseInventory by passing it in
|
||||
/// </summary>
|
||||
/// <param name="obj"></param>
|
||||
public void Add(PartByWarehouseInventory obj)
|
||||
{
|
||||
List.Add(obj);
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
protected override object OnAddNew()
|
||||
{
|
||||
PartByWarehouseInventory child=PartByWarehouseInventory.NewItem();
|
||||
List.Add(child);
|
||||
return child;
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Contains
|
||||
|
||||
/// <summary>
|
||||
/// Check if item in collection
|
||||
/// </summary>
|
||||
/// <param name="obj"></param>
|
||||
public bool Contains(PartByWarehouseInventory obj)
|
||||
{
|
||||
foreach (PartByWarehouseInventory child in List)
|
||||
{
|
||||
if(child.Equals(obj)) return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Check if item in deleted collection
|
||||
/// </summary>
|
||||
/// <param name="obj"></param>
|
||||
public bool ContainsDeleted(PartByWarehouseInventory obj)
|
||||
{
|
||||
foreach (PartByWarehouseInventory child in deletedList)
|
||||
{
|
||||
if(child.Equals(obj)) return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Static methods
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Get item collection
|
||||
/// </summary>
|
||||
///
|
||||
/// <returns></returns>
|
||||
public static PartByWarehouseInventories GetItems(Guid PartID)
|
||||
{
|
||||
|
||||
PartByWarehouseInventories col = new PartByWarehouseInventories();
|
||||
col.mPartID=PartID;
|
||||
return (PartByWarehouseInventories)DataPortal.Fetch(new Criteria(PartID));
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region DAL DATA ACCESS
|
||||
|
||||
/// <summary>
|
||||
/// Fetch children
|
||||
/// </summary>
|
||||
/// <param name="Criteria">PartID</param>
|
||||
protected override void DataPortal_Fetch(object Criteria)
|
||||
{
|
||||
Criteria crit = (Criteria)Criteria;
|
||||
SafeDataReader dr = null;
|
||||
try
|
||||
{
|
||||
dr=DBUtil.GetReaderFromSQLString("SELECT * FROM aPartByWarehouseInventory WHERE aPartID=@ID;",crit.PartID);
|
||||
while(dr.Read())
|
||||
{
|
||||
|
||||
List.Add(PartByWarehouseInventory.GetItem(dr));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
finally
|
||||
{
|
||||
if(dr!=null) dr.Close();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Editable Root Collection Update
|
||||
/// </summary>
|
||||
protected override void DataPortal_Update()
|
||||
{
|
||||
using (IDbConnection connection = DBUtil.DB.GetConnection())
|
||||
{
|
||||
connection.Open();
|
||||
IDbTransaction tr = connection.BeginTransaction();
|
||||
try
|
||||
{
|
||||
|
||||
//update (thus deleting) any deleted child objects
|
||||
foreach (PartByWarehouseInventory child in deletedList)
|
||||
{
|
||||
child.Update(tr);
|
||||
}
|
||||
|
||||
//Now that they are deleted remove them from memory
|
||||
deletedList.Clear();
|
||||
|
||||
foreach (PartByWarehouseInventory child in List)
|
||||
{
|
||||
child.Update(tr);
|
||||
|
||||
}
|
||||
|
||||
tr.Commit();
|
||||
}
|
||||
catch
|
||||
{
|
||||
tr.Rollback();
|
||||
throw;//WAS: throw(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region criteria
|
||||
/// <summary>
|
||||
/// Criteria for identifying existing object
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
private class Criteria
|
||||
{
|
||||
public Guid PartID;
|
||||
|
||||
public Criteria(Guid _PartID)
|
||||
{
|
||||
PartID=_PartID;
|
||||
}
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
}//end PartByWarehouseInventories
|
||||
|
||||
}//end namespace GZTW.AyaNova.BLL
|
||||
Reference in New Issue
Block a user