246 lines
6.6 KiB
C#
246 lines
6.6 KiB
C#
///////////////////////////////////////////////////////////
|
|
// WorkorderPickList.cs
|
|
// Implementation of Class WorkorderPickList
|
|
// CSLA type: Read only collection
|
|
// Created on: 11-Feb-2005
|
|
// Object design: John
|
|
// Coded: 11-Feb-2005
|
|
///////////////////////////////////////////////////////////
|
|
|
|
using System;
|
|
using System.Data;
|
|
using GZTW.Data;
|
|
using CSLA.Data;
|
|
using CSLA;
|
|
|
|
namespace GZTW.AyaNova.BLL
|
|
{
|
|
/// <summary>
|
|
/// Lightweight read only list of <see cref="WorkorderPickList.WorkorderPickListInfo"/> objects representing <see cref="Workorder"/> objects.
|
|
/// Fetched by client for selection in UI.
|
|
/// </summary>
|
|
[Serializable]
|
|
public class WorkorderPickList : ReadOnlyCollectionBase
|
|
{
|
|
#region Data structure
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
[Serializable]
|
|
public struct WorkorderPickListInfo
|
|
{
|
|
|
|
internal Guid mID;
|
|
internal string mServiceNumber;
|
|
internal DateTime mServiceDate;
|
|
internal string mSummary;
|
|
|
|
|
|
|
|
//Public properties
|
|
/// <summary>
|
|
/// <see cref="Workorder"/> object ID
|
|
/// </summary>
|
|
public Guid ID {get{return mID;}}
|
|
|
|
/// <summary>
|
|
/// <see cref="Workorder"/> object's <see cref="WorkorderService"/> number
|
|
/// </summary>
|
|
public string ServiceNumber {get{return mServiceNumber;}}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public string Summary {get{return mSummary;}}
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public DateTime ServiceDate {get{return mServiceDate;}}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="obj"></param>
|
|
public bool Equals(WorkorderPickListInfo obj)
|
|
{
|
|
return this.mID.Equals(obj.mID);
|
|
}
|
|
|
|
}//end WorkorderPickListInfo
|
|
#endregion
|
|
|
|
#region Constructor
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
protected WorkorderPickList()
|
|
{
|
|
// 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 WorkorderPickListInfo this[int Item]
|
|
{
|
|
|
|
get
|
|
{
|
|
return (WorkorderPickListInfo) List[Item];
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Returns WorkorderPickListInfo item that matches passed in itemid value
|
|
/// </summary>
|
|
/// <param name="ItemID"></param>
|
|
public WorkorderPickListInfo this[Guid ItemID]
|
|
{
|
|
|
|
get
|
|
{
|
|
foreach (WorkorderPickListInfo child in List)
|
|
{
|
|
if(child.mID==ItemID) return child;
|
|
}
|
|
throw new ArgumentException("WorkorderPickList: ID not found:\r\n"+ItemID.ToString());
|
|
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region contains
|
|
/// <summary>
|
|
/// Check if item in collection
|
|
/// </summary>
|
|
/// <param name="obj"></param>
|
|
public bool Contains(WorkorderPickListInfo obj)
|
|
{
|
|
foreach (WorkorderPickListInfo child in List)
|
|
{
|
|
if(child.Equals(obj)) return true;
|
|
}
|
|
return false;
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region Static methods
|
|
/// <summary>
|
|
/// Get all Workorders owned by client specified
|
|
/// </summary>
|
|
/// <param name="ClientID">Client owning Workorders</param>
|
|
/// <returns>list of <see cref="WorkorderPickList.WorkorderPickListInfo"/> objects</returns>
|
|
public static WorkorderPickList GetListByClient(Guid ClientID)
|
|
{
|
|
return (WorkorderPickList) DataPortal.Fetch(new Criteria(ClientID, Guid.Empty));
|
|
}
|
|
|
|
/// <summary>
|
|
/// Get all Workorders owned by client specified
|
|
/// except one specified in workorder id parameter
|
|
/// </summary>
|
|
/// <param name="ClientID">Client owning Workorders</param>
|
|
/// <param name="WorkorderId">Guid of workorder that should not be included in return list</param>
|
|
/// <returns>list of <see cref="WorkorderPickList.WorkorderPickListInfo"/> objects</returns>
|
|
public static WorkorderPickList GetListByClient(Guid ClientID, Guid WorkorderId)
|
|
{
|
|
return (WorkorderPickList)DataPortal.Fetch(new Criteria(ClientID, WorkorderId));
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
#region DAL DATA ACCESS
|
|
///
|
|
/// <param name="Criteria"></param>
|
|
protected override void DataPortal_Fetch(object Criteria)
|
|
{
|
|
Criteria crit = (Criteria)Criteria;
|
|
|
|
SafeDataReader dr = null;
|
|
try
|
|
{
|
|
DBCommandWrapper dbCommandWrapper = DBUtil.DB.GetSqlStringCommandWrapper(
|
|
//************************************************************
|
|
"SELECT aWorkorder.aID, aWorkorderService.aServiceNumber, " +
|
|
" aWorkorderService.aServiceDate, aWorkorder.aSummary " +
|
|
"FROM aWorkorder INNER JOIN aWorkorderService " +
|
|
"ON aWorkorder.aID = aWorkorderService.aWorkorderID " +
|
|
"WHERE(aWorkorder.aClientID " +
|
|
"= @ClientID) AND (aWorkorder.aClosed = @aFalse) AND " +
|
|
"(aWorkorder.aServiceCompleted = @aFalse) AND (aWorkorder.aWorkorderType " +
|
|
"= @WorkorderType) ORDER BY AWORKORDERSERVICE.ASERVICENUMBER DESC "
|
|
//************************************************************
|
|
);
|
|
dbCommandWrapper.AddInParameter("@ClientID",DbType.Guid,crit.ClientID);
|
|
dbCommandWrapper.AddInParameter("@aFalse",DbType.Boolean,false);
|
|
dbCommandWrapper.AddInParameter("@WorkorderType",DbType.Int16,(int)WorkorderTypes.Service);
|
|
dr = new SafeDataReader(DBUtil.DB.ExecuteReader(dbCommandWrapper));
|
|
|
|
|
|
while(dr.Read())
|
|
{
|
|
//*******************************************
|
|
WorkorderPickListInfo info=new WorkorderPickListInfo();
|
|
info.mID=dr.GetGuid("aID");
|
|
if (info.mID == crit.WorkorderID)
|
|
continue;//case 1975
|
|
info.mServiceNumber=dr.GetInt32("aServiceNumber").ToString();
|
|
info.mSummary=dr.GetString("aSummary");
|
|
info.mServiceDate=DBUtil.ToLocal(dr.GetDateTime("aServiceDate"));
|
|
InnerList.Add(info);
|
|
//*******************************************
|
|
}
|
|
}
|
|
finally
|
|
{
|
|
if(dr!=null) dr.Close();
|
|
}
|
|
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region criteria
|
|
/// <summary>
|
|
/// Criteria for identifying existing object
|
|
/// </summary>
|
|
[Serializable]
|
|
private class Criteria
|
|
{
|
|
|
|
|
|
public Guid ClientID;
|
|
public Guid WorkorderID;
|
|
|
|
public Criteria(Guid _ClientID, Guid _WorkorderID )
|
|
{
|
|
ClientID=_ClientID;
|
|
WorkorderID = _WorkorderID;
|
|
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
|
|
}//end WorkorderPickList
|
|
|
|
}//end namespace GZTW.AyaNova.BLL |