Files
ayanova7/source/bizobjects/AyaLib/GZTW.AyaNova.BLL/WorkorderQuoteDescriptionFetcher.cs
2018-06-29 19:47:36 +00:00

199 lines
5.3 KiB
C#

///////////////////////////////////////////////////////////
// Bool.cs
// Implementation of Class WorkorderQuoteDescriptionFetcher
// CSLA type: Read-only object
// Created on: 1-Nov-2007
// Object design: John
// Coded: John 1-Nov-2007
///////////////////////////////////////////////////////////
using System;
using System.Data;
using CSLA.Data;
using GZTW.Data;
using CSLA;
using System.Threading;
using CSLA.Security;
using System.ComponentModel;
namespace GZTW.AyaNova.BLL
{
/// <summary>
/// Used to quickly fetch descriptive information
/// for identifying a quote workorder to user
/// (Used by <see cref="NameFetcher"/>)
/// </summary>
[Serializable]
public class WorkorderQuoteDescriptionFetcher : ReadOnlyBase
{
#region Attributes
private string mWorkorderNumber = "";
private string mClientName = "";
private string mTemplateDescription = "";
#endregion
#region Constructor
/// <summary>
/// Private constructor to prevent direct instantiation
/// </summary>
private WorkorderQuoteDescriptionFetcher()
{
}
#endregion
#region Business properties
/// <summary>
///
/// </summary>
public string WorkorderNumber
{
get
{
return mWorkorderNumber;
}
}
/// <summary>
///
/// </summary>
public string ClientName
{
get
{
return mClientName;
}
}
/// <summary>
///
/// </summary>
public string TemplateDescription
{
get
{
return mTemplateDescription;
}
}
#endregion
#region Static methods
/// <summary>
/// Retrieve info by quote workorder ID
/// </summary>
/// <param name="ID"></param>
/// <returns></returns>
public static WorkorderQuoteDescriptionFetcher GetItem(Guid ID)
{
return (WorkorderQuoteDescriptionFetcher)DataPortal.Fetch(new Criteria(ID));
}
#endregion
#region DAL DATA ACCESS
///
/// <param Bool="Criteria"></param>
protected override void DataPortal_Fetch(object Criteria)
{
//case 1631
bool bFetched = false;
Criteria crit = (Criteria)Criteria;
SafeDataReader dr = null;
dr = DBUtil.GetReaderFromSQLString(
"SELECT aWorkorderQuote.aQuoteNumber, aWorkorder.ATemplateDescription, " +
"aClient.aName " +
"AS CLIENTNAME FROM aWorkorder LEFT " +
"OUTER JOIN aWorkorderQuote ON aWorkorder.aID " +
"= aWorkorderQuote.aWorkorderID LEFT OUTER " +
"JOIN aClient ON aWorkorder.aClientID = " +
"aClient.aID WHERE aWorkorderQuote.aID=@ID", crit.ID
);
if (dr.Read())
{
bFetched = true;
this.mClientName = dr.GetString("CLIENTNAME");
this.mWorkorderNumber = dr.GetInt32("aQuoteNumber").ToString();
this.mTemplateDescription = dr.GetString("atemplatedescription");
}
if (dr != null) dr.Close();
//case 1631 - Wikipage calls this through namefetcher
//and due to abolishing the workorder rootobjecttype and not really
//properly changing wikipage to the correct base object
//this is getting passed the workorder id not the quote id so try again if not retrieved before
if (!bFetched)
{
dr = DBUtil.GetReaderFromSQLString(
"SELECT aWorkorderQuote.aQuoteNumber, aWorkorder.ATemplateDescription, " +
"aClient.aName " +
"AS CLIENTNAME FROM aWorkorder LEFT " +
"OUTER JOIN aWorkorderQuote ON aWorkorder.aID " +
"= aWorkorderQuote.aWorkorderID LEFT OUTER " +
"JOIN aClient ON aWorkorder.aClientID = " +
"aClient.aID WHERE aWorkorderQuote.AWORKORDERID=@ID", crit.ID
);
if (dr.Read())
{
this.mClientName = dr.GetString("CLIENTNAME");
this.mWorkorderNumber = dr.GetInt32("aQuoteNumber").ToString();
this.mTemplateDescription = dr.GetString("atemplatedescription");
}
if (dr != null) dr.Close();
}
}
#endregion
#region criteria
/// <summary>
/// Criteria for identifying existing object
/// </summary>
[Serializable]
private class Criteria
{
public Guid ID;
public Criteria(Guid _ID)
{
ID = _ID;
}
}
#endregion
}//end Bool
}//end Boolspace GZTW.AyaNova.BLL