/////////////////////////////////////////////////////////// // Bool.cs // Implementation of Class WorkorderPMDescriptionFetcher // 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 { /// /// Used to quickly fetch descriptive information /// for identifying a quote workorder to user /// (Used by ) /// [Serializable] public class WorkorderPMDescriptionFetcher : ReadOnlyBase { #region Attributes private string mWorkorderNumber = ""; private string mClientName = ""; private string mTemplateDescription = ""; #endregion #region Constructor /// /// Private constructor to prevent direct instantiation /// private WorkorderPMDescriptionFetcher() { } #endregion #region Business properties /// /// /// public string WorkorderNumber { get { return mWorkorderNumber; } } /// /// /// public string ClientName { get { return mClientName; } } /// /// /// public string TemplateDescription { get { return mTemplateDescription; } } #endregion #region Static methods /// /// Fetch description by ID of workorder for PM /// /// /// public static WorkorderPMDescriptionFetcher GetItem(Guid ID) { return (WorkorderPMDescriptionFetcher)DataPortal.Fetch(new Criteria(ID)); } #endregion #region DAL DATA ACCESS /// /// protected override void DataPortal_Fetch(object Criteria) { Criteria crit = (Criteria)Criteria; SafeDataReader dr = null; //case 1631 bool bFetched = false; dr = DBUtil.GetReaderFromSQLString( "SELECT AWORKORDERPREVENTIVEMAINTENANCE.APREVENTIVEMAINTENANCENUMBER, aWorkorder.ATemplateDescription, " + "aClient.aName " + "AS CLIENTNAME FROM aWorkorder LEFT " + "OUTER JOIN AWORKORDERPREVENTIVEMAINTENANCE ON aWorkorder.aID " + "= AWORKORDERPREVENTIVEMAINTENANCE.aWorkorderID LEFT OUTER " + "JOIN aClient ON aWorkorder.aClientID = " + "aClient.aID WHERE AWORKORDERPREVENTIVEMAINTENANCE.aID=@ID", crit.ID ); if (dr.Read()) { bFetched = true; this.mClientName = dr.GetString("CLIENTNAME"); this.mWorkorderNumber = dr.GetInt32("APREVENTIVEMAINTENANCENUMBER").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 pm id so try again if not retrieved before if (!bFetched) { dr = DBUtil.GetReaderFromSQLString( "SELECT AWORKORDERPREVENTIVEMAINTENANCE.APREVENTIVEMAINTENANCENUMBER, aWorkorder.ATemplateDescription, " + "aClient.aName " + "AS CLIENTNAME FROM aWorkorder LEFT " + "OUTER JOIN AWORKORDERPREVENTIVEMAINTENANCE ON aWorkorder.aID " + "= AWORKORDERPREVENTIVEMAINTENANCE.aWorkorderID LEFT OUTER " + "JOIN aClient ON aWorkorder.aClientID = " + "aClient.aID WHERE AWORKORDERPREVENTIVEMAINTENANCE.AWORKORDERID=@ID", crit.ID ); if (dr.Read()) { bFetched = true; this.mClientName = dr.GetString("CLIENTNAME"); this.mWorkorderNumber = dr.GetInt32("APREVENTIVEMAINTENANCENUMBER").ToString(); this.mTemplateDescription = dr.GetString("atemplatedescription"); } if (dr != null) dr.Close(); } } #endregion #region criteria /// /// Criteria for identifying existing object /// [Serializable] private class Criteria { public Guid ID; public Criteria(Guid _ID) { ID = _ID; } } #endregion }//end Bool }//end Boolspace GZTW.AyaNova.BLL