250 lines
7.1 KiB
C#
250 lines
7.1 KiB
C#
///////////////////////////////////////////////////////////
|
|
// PartWarehousePickList.cs
|
|
// Implementation of Class PartWarehousePickList
|
|
// CSLA type: Read only collection
|
|
// Created on: 22-Nov-2005
|
|
// Object design: John
|
|
// Coded: 22-Nov-2005
|
|
///////////////////////////////////////////////////////////
|
|
|
|
using System;
|
|
using System.Data;
|
|
using GZTW.Data;
|
|
using CSLA.Data;
|
|
using CSLA;
|
|
using System.Collections.Generic;
|
|
|
|
namespace GZTW.AyaNova.BLL
|
|
{
|
|
/// <summary>
|
|
/// Lightweight read only list of <see cref="PartWarehousePickList.PartWarehousePickListInfo"/> objects representing <see cref="PartWarehouse"/> objects for selection in UI and API internal usage by other business objects
|
|
/// </summary>
|
|
[Serializable]
|
|
public class PartWarehousePickList : ReadOnlyCollectionBase
|
|
{
|
|
#region Data structure
|
|
#pragma warning disable 1591
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
[Serializable]
|
|
public struct PartWarehousePickListInfo
|
|
{
|
|
|
|
internal Guid mID;
|
|
internal string mName;
|
|
internal bool mActive;
|
|
//internal string mNotes;
|
|
|
|
|
|
//Public properties
|
|
public Guid ID {get{return mID;}}
|
|
public string Name {get{return mName;}}
|
|
public bool Active {get{return mActive;}}
|
|
//public string Notes {get{return mNotes;}}
|
|
|
|
internal Guid mRegionID;//case 58
|
|
public Guid RegionID { get { return mRegionID; } }
|
|
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="obj"></param>
|
|
public bool Equals(PartWarehousePickListInfo obj)
|
|
{
|
|
return this.mID.Equals(obj.mID);
|
|
}
|
|
|
|
}//end PartWarehousePickListInfo
|
|
#pragma warning restore 1591
|
|
#endregion
|
|
|
|
#region Constructor
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
protected PartWarehousePickList()
|
|
{
|
|
// 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 PartWarehousePickListInfo this[int Item]
|
|
{
|
|
|
|
get
|
|
{
|
|
return (PartWarehousePickListInfo) List[Item];
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Returns PartWarehousePickListInfo item that matches passed in itemid value
|
|
/// </summary>
|
|
/// <param name="ItemID"></param>
|
|
public PartWarehousePickListInfo this[Guid ItemID]
|
|
{
|
|
|
|
get
|
|
{
|
|
//case 2082
|
|
if (ItemID == Guid.Empty)
|
|
return new PartWarehousePickListInfo();
|
|
|
|
foreach (PartWarehousePickListInfo child in List)
|
|
{
|
|
if(child.mID==ItemID) return child;
|
|
}
|
|
|
|
|
|
|
|
throw new ArgumentException("PartWarehousePickList: ID not found:\r\n"+ItemID.ToString());
|
|
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region contains
|
|
/// <summary>
|
|
/// Check if item in collection
|
|
/// </summary>
|
|
/// <param name="obj"></param>
|
|
public bool Contains(PartWarehousePickListInfo obj)
|
|
{
|
|
foreach (PartWarehousePickListInfo child in List)
|
|
{
|
|
if(child.Equals(obj)) return true;
|
|
}
|
|
return false;
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region Static methods
|
|
/// <summary>
|
|
/// Get all items
|
|
/// </summary>
|
|
/// <returns>list of <see cref="PartWarehousePickList.PartWarehousePickListInfo"/> objects</returns>
|
|
public static PartWarehousePickList GetList(bool Regional)
|
|
{
|
|
return (PartWarehousePickList) DataPortal.Fetch(new Criteria(null,Regional));
|
|
}
|
|
|
|
/// <summary>
|
|
/// Get list of active items only
|
|
/// except if in the passed in id list then include
|
|
/// </summary>
|
|
/// <param name="IDList">Generic list of exception Guid's</param>
|
|
/// <returns>list of <see cref="PartWarehousePickList.PartWarehousePickListInfo"/> objects</returns>
|
|
public static PartWarehousePickList GetActiveOnlyListWithExceptions(List<Guid> IDList)
|
|
{ //Added Case 640
|
|
return (PartWarehousePickList)DataPortal.Fetch(new Criteria(IDList,true));
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
#region DAL DATA ACCESS
|
|
///
|
|
/// <param name="Criteria"></param>
|
|
protected override void DataPortal_Fetch(object Criteria)
|
|
{
|
|
Criteria crit = (Criteria)Criteria;
|
|
SafeDataReader dr = null;
|
|
try
|
|
{
|
|
dr=DBUtil.GetReaderFromSQLString(
|
|
//************************************************************
|
|
"SELECT aID, AACTIVE, aName, aRegionID FROM aPartWarehouse"
|
|
//************************************************************
|
|
);
|
|
|
|
//case 1300
|
|
bool bCurrentUserIsInDefaultRegion = User.CurrentUserIsInDefaultRegion;
|
|
Guid myRegion = User.CurrentUserRegionID;
|
|
|
|
while(dr.Read())
|
|
{
|
|
//*******************************************
|
|
PartWarehousePickListInfo info=new PartWarehousePickListInfo();
|
|
info.mID=dr.GetGuid("aID");
|
|
info.mActive=dr.GetBoolean("AACTIVE");
|
|
info.mName=dr.GetString("aName");
|
|
|
|
info.mRegionID = dr.GetGuid("aRegionID");//case 58
|
|
|
|
////case 58
|
|
//if (crit.Regional)
|
|
//{
|
|
// //theory is that warehouses outside current region should just be inactive so they don't show in
|
|
// //workorders unless preselected but will then be grayed out.
|
|
// if (!AyaBizUtils.InYourRegion(info.mRegionID))
|
|
// info.mActive = false;
|
|
//}
|
|
|
|
//case 1300 same effect as above but without triggering db calls to get user region
|
|
if (crit.Regional)
|
|
if (!bCurrentUserIsInDefaultRegion)
|
|
if (info.mRegionID != Region.DefaultRegionID && info.mRegionID != myRegion)
|
|
info.mActive = false;
|
|
|
|
//Changed for case 640
|
|
if (crit.IDList == null)
|
|
InnerList.Add(info);
|
|
else
|
|
{
|
|
if (info.mActive == true)
|
|
InnerList.Add(info);
|
|
else
|
|
{
|
|
if (crit.IDList.Contains(info.mID))
|
|
InnerList.Add(info);
|
|
}
|
|
}
|
|
//*******************************************
|
|
}
|
|
}
|
|
finally
|
|
{
|
|
if(dr!=null) dr.Close();
|
|
}
|
|
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region criteria
|
|
/// <summary>
|
|
/// Criteria for identifying existing object
|
|
/// </summary>
|
|
[Serializable]
|
|
private class Criteria
|
|
{
|
|
public List<Guid> IDList;
|
|
public bool Regional;
|
|
public Criteria( List<Guid> _IDList,bool _Regional)
|
|
{
|
|
IDList = _IDList;
|
|
Regional = _Regional;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
}//end PartWarehousePickList
|
|
|
|
}//end namespace GZTW.AyaNova.BLL |