776 lines
23 KiB
C#
776 lines
23 KiB
C#
///////////////////////////////////////////////////////////
|
|
// HeadOfficeList.cs
|
|
// Implementation of Class HeadOfficeList
|
|
// CSLA type: Read only collection
|
|
// Created on: 07-Jun-2004 8:41:14 AM
|
|
// Object design: Joyce
|
|
// Coded: Sept. 23rd 2004
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
using System;
|
|
using System.Data;
|
|
using GZTW.Data;
|
|
using CSLA.Data;
|
|
using CSLA;
|
|
using System.Threading;
|
|
using CSLA.Security;
|
|
using System.Collections.Generic;
|
|
|
|
|
|
namespace GZTW.AyaNova.BLL
|
|
{
|
|
#pragma warning disable 1591
|
|
/// <summary>
|
|
/// Lightweight read only list of <see cref="HeadOfficeList.HeadOfficeListInfo"/> objects representing <see cref="HeadOffice"/> objects
|
|
///
|
|
/// </summary>
|
|
[Serializable]
|
|
public class HeadOfficeList : ReadOnlyCollectionBase
|
|
{
|
|
|
|
|
|
#region Data structure
|
|
/// <summary>
|
|
/// Properties
|
|
/// </summary>
|
|
[Serializable]
|
|
public struct HeadOfficeListInfo
|
|
{
|
|
internal GridNameValueCellItem mHeadOffice;
|
|
internal GridNameValueCellItem mClientGroup;
|
|
internal GridNameValueCellItem mRegion;
|
|
|
|
//CONTACT FIELDS
|
|
internal string mContact;
|
|
internal string mEmail;
|
|
internal string mPhone1;
|
|
internal string mPhone2;
|
|
internal string mPhone3;
|
|
internal string mPhone4;
|
|
internal string mPhone5;
|
|
//------------------
|
|
|
|
internal string mAccountNumber;
|
|
internal string mDeliveryAddress;
|
|
internal string mCity;
|
|
internal string mStateProv;
|
|
internal string mCountry;
|
|
internal string mPostal;
|
|
|
|
internal bool mActive;
|
|
|
|
internal string mWebAddress;
|
|
|
|
internal bool mUsesBanking;
|
|
|
|
|
|
internal GridNameValueCellItem mContract;
|
|
internal SmartDate mContractExpires;
|
|
internal string mLatitude;
|
|
internal string mLongitude;
|
|
internal string mCountryCode;
|
|
internal decimal mHoursBalance;
|
|
internal decimal mIncidentsBalance;
|
|
internal decimal mCurrencyBalance;
|
|
|
|
|
|
|
|
|
|
[SqlColumnNameAttribute("aHeadOffice.aName",
|
|
"aHeadOffice.aID"),
|
|
Display(DisplayType.Button, RootObjectType = RootObjectTypes.HeadOffice)]
|
|
public GridNameValueCellItem LT_O_HeadOffice
|
|
{
|
|
get
|
|
{
|
|
return mHeadOffice;
|
|
}
|
|
}
|
|
|
|
|
|
[SqlColumnNameAttribute("aRegion.aName",
|
|
"aRegion.aID"),
|
|
Display(DisplayType.Button, RootObjectType = RootObjectTypes.Region)]
|
|
public GridNameValueCellItem LT_O_Region
|
|
{
|
|
get
|
|
{
|
|
return mRegion;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
[Display(DisplayType.Text)]
|
|
public string LT_HeadOffice_Label_AccountNumber
|
|
{
|
|
get
|
|
{
|
|
return mAccountNumber;
|
|
}
|
|
}
|
|
|
|
[SqlColumnNameAttribute("aClientGroup.aName",
|
|
"aClientGroup.aID"),
|
|
Display(DisplayType.Button, RootObjectType = RootObjectTypes.ClientGroup)]
|
|
public GridNameValueCellItem LT_O_ClientGroup
|
|
{
|
|
get
|
|
{
|
|
return mClientGroup;
|
|
}
|
|
}
|
|
|
|
|
|
[Display(DisplayType.Text)]
|
|
public string LT_Address_Label_DeliveryAddress
|
|
{
|
|
get
|
|
{
|
|
return mDeliveryAddress;
|
|
}
|
|
}
|
|
[Display(DisplayType.Text)]
|
|
public string LT_Address_Label_City
|
|
{
|
|
get
|
|
{
|
|
return mCity;
|
|
}
|
|
}
|
|
[Display(DisplayType.Text)]
|
|
public string LT_Address_Label_StateProv
|
|
{
|
|
get
|
|
{
|
|
return mStateProv;
|
|
}
|
|
}
|
|
|
|
[Display(DisplayType.Text)]
|
|
public string LT_Address_Label_Country
|
|
{
|
|
get
|
|
{
|
|
return mCountry;
|
|
}
|
|
}
|
|
|
|
[Display(DisplayType.Text)]
|
|
public string LT_Address_Label_Postal
|
|
{
|
|
get
|
|
{
|
|
return mPostal;
|
|
}
|
|
}
|
|
|
|
[Display(DisplayType.TrueFalse)]
|
|
public bool LT_HeadOffice_Label_Active
|
|
{
|
|
get
|
|
{
|
|
return mActive;
|
|
}
|
|
}
|
|
|
|
[Display(DisplayType.URL_Web)]
|
|
public string LT_HeadOffice_Label_WebAddress
|
|
{
|
|
get
|
|
{
|
|
return mWebAddress;
|
|
}
|
|
}
|
|
|
|
|
|
[Display(DisplayType.TrueFalse)]
|
|
public bool LT_HeadOffice_Label_UsesBanking
|
|
{
|
|
get
|
|
{
|
|
return mUsesBanking;
|
|
}
|
|
}
|
|
|
|
|
|
//CONTACT FIELDS
|
|
[Display(DisplayType.Text)]
|
|
public string LT_HeadOffice_Label_Contact
|
|
{ get { return mContact; } }
|
|
|
|
[Display(DisplayType.URL_Email)]
|
|
public string LT_HeadOffice_Label_Email
|
|
{ get { return mEmail; } }
|
|
|
|
[Display(DisplayType.Text)]
|
|
public string LT_HeadOffice_Label_Phone1
|
|
{ get { return mPhone1; } }
|
|
|
|
[Display(DisplayType.Text)]
|
|
public string LT_HeadOffice_Label_Phone2
|
|
{ get { return mPhone2; } }
|
|
|
|
[Display(DisplayType.Text)]
|
|
public string LT_HeadOffice_Label_Phone3
|
|
{ get { return mPhone3; } }
|
|
|
|
[Display(DisplayType.Text)]
|
|
public string LT_HeadOffice_Label_Phone4
|
|
{ get { return mPhone4; } }
|
|
|
|
[Display(DisplayType.Text)]
|
|
public string LT_HeadOffice_Label_Phone5
|
|
{ get { return mPhone5; } }
|
|
|
|
|
|
|
|
[SqlColumnNameAttribute("aContract.aName",
|
|
"aHeadOffice.aContractID"),
|
|
Display(DisplayType.Button, RootObjectType = RootObjectTypes.Contract)]
|
|
public GridNameValueCellItem LT_O_Contract
|
|
{
|
|
get
|
|
{
|
|
return mContract;
|
|
}
|
|
}
|
|
|
|
|
|
[SqlColumnNameAttribute("aHeadOffice.aContractExpires"), Display(DisplayType.DateTime)]
|
|
public object LT_HeadOffice_Label_ContractExpires
|
|
{
|
|
get
|
|
{
|
|
return mContractExpires.DBValue;
|
|
}
|
|
}
|
|
|
|
[Display(DisplayType.GeoCoordinate)]
|
|
public string LT_Address_Label_Latitude
|
|
{
|
|
get
|
|
{
|
|
return mLatitude;
|
|
}
|
|
}
|
|
|
|
[Display(DisplayType.GeoCoordinate)]
|
|
public string LT_Address_Label_Longitude
|
|
{
|
|
get
|
|
{
|
|
return mLongitude;
|
|
}
|
|
}
|
|
|
|
[Display(DisplayType.Text)]
|
|
public string LT_Address_Label_CountryCode
|
|
{
|
|
get
|
|
{
|
|
return mCountryCode;
|
|
}
|
|
}
|
|
|
|
[SqlColumnNameAttribute("HOURSBAL"), Display(DisplayType.DecimalNumber)]
|
|
public decimal LT_ServiceBank_Label_HoursBalance
|
|
{
|
|
get
|
|
{
|
|
return mHoursBalance;
|
|
}
|
|
}
|
|
|
|
[SqlColumnNameAttribute("INCIDENTSBAL"), Display(DisplayType.DecimalNumber)]
|
|
public decimal LT_ServiceBank_Label_IncidentsBalance
|
|
{
|
|
get
|
|
{
|
|
return mIncidentsBalance;
|
|
}
|
|
}
|
|
|
|
[SqlColumnNameAttribute("CURRENCYBAL"), Display(DisplayType.Currency)]
|
|
public decimal LT_ServiceBank_Label_CurrencyBalance
|
|
{
|
|
get
|
|
{
|
|
return mCurrencyBalance;
|
|
}
|
|
}
|
|
|
|
//=======================================================================
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="obj"></param>
|
|
public bool Equals(HeadOfficeListInfo obj)
|
|
{
|
|
return this.mHeadOffice.Value.Equals(obj.mHeadOffice.Value);
|
|
}
|
|
|
|
}//end HeadOfficeListInfo
|
|
#endregion
|
|
|
|
#region Constructor
|
|
|
|
protected HeadOfficeList()
|
|
{
|
|
// 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 HeadOfficeListInfo this[int Item]
|
|
{
|
|
|
|
get
|
|
{
|
|
return (HeadOfficeListInfo) List[Item];
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Returns display text that matches passed in itemid value
|
|
/// </summary>
|
|
/// <param name="ItemID"></param>
|
|
public string this[Guid ItemID]
|
|
{
|
|
|
|
get
|
|
{
|
|
foreach (HeadOfficeListInfo child in List)
|
|
{
|
|
if(child.mHeadOffice.Value==ItemID) return child.ToString();
|
|
}
|
|
return "Missing: "+ItemID.ToString();
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region contains
|
|
/// <summary>
|
|
/// Check if item in collection
|
|
/// </summary>
|
|
/// <param name="obj"></param>
|
|
public bool Contains(HeadOfficeListInfo obj)
|
|
{
|
|
foreach (HeadOfficeListInfo child in List)
|
|
{
|
|
if(child.Equals(obj)) return true;
|
|
}
|
|
return false;
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region Reporting and shared UI editor helpers
|
|
|
|
/// <summary>
|
|
/// Returns the report key which is a property of
|
|
/// reports used to link all reports that can be used
|
|
/// with a particular data source.
|
|
/// </summary>
|
|
public static string ReportKey
|
|
{
|
|
get
|
|
{
|
|
return "HeadOfficeList";
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Returns the Detailed report key
|
|
/// which is used to determine which reports and objects
|
|
/// will be used for detailed reports
|
|
///
|
|
/// If empty string then indicates there is no detailed report object or reports
|
|
/// </summary>
|
|
public static string DetailedReportKey
|
|
{
|
|
get
|
|
{
|
|
return "HeadOfficeListDetailed";
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Base object that this list is reporting on
|
|
/// used by shared UI editor to instantiate new objects
|
|
/// when user selects new in UI elements that display this list
|
|
///
|
|
/// (I.E. when user clicks on new in a read only list grid, this is the object type created)
|
|
/// </summary>
|
|
public static RootObjectTypes BaseObjectType
|
|
{
|
|
get
|
|
{
|
|
return RootObjectTypes.HeadOffice;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Locale key so that generic list editor
|
|
/// UI code knows what title to give the list in a
|
|
/// grid
|
|
/// </summary>
|
|
public string LocaleKey
|
|
{
|
|
get
|
|
{
|
|
return "HeadOffice.Label.List";
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// The Type of the struct used to store list records
|
|
/// Used to fetch the custom display attributes of the fields
|
|
/// contained within the record to modify the grid display accordingly
|
|
/// <see cref="DisplayAttribute"/>
|
|
/// </summary>
|
|
public static Type ListRecordType
|
|
{
|
|
get
|
|
{
|
|
return typeof(HeadOfficeListInfo);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// Field that contains the ID of the objects
|
|
/// that are the basis of this list.
|
|
///
|
|
/// Used for compiling an ID list for reporting from user
|
|
/// selections in a grid.
|
|
/// </summary>
|
|
public static string IDField
|
|
{
|
|
get
|
|
{
|
|
return "LT_O_HeadOffice";
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// Same as IDField but for detailed reports
|
|
/// </summary>
|
|
public static string IDFieldDetailed
|
|
{
|
|
get
|
|
{
|
|
return IDField;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region Static methods
|
|
/// <summary>
|
|
/// Internal method used by list factory
|
|
/// </summary>
|
|
internal static HeadOfficeList Get(string Filter, int MaxRecords, List<Guid> IDList)
|
|
{
|
|
return (HeadOfficeList)DataPortal.Fetch(new Criteria(Filter, IDList, MaxRecords));
|
|
}
|
|
|
|
/// <summary>
|
|
/// Takes an xml column list and where criteria
|
|
/// and returns a list filtered and sorted accordingly
|
|
/// </summary>
|
|
/// <param name="xmlCriteria">Use AyaNova UI to easily build xmlCriteria and Ctrl-Alt-g keyboard command to display it for use in your code</param>
|
|
/// <returns>list of <see cref="HeadOfficeList.HeadOfficeListInfo"/> objects</returns>
|
|
public static HeadOfficeList GetListByCriteria(string xmlCriteria)
|
|
{
|
|
return (HeadOfficeList)DataPortal.Fetch(new Criteria(xmlCriteria, null, -1));
|
|
}
|
|
|
|
/// <summary>
|
|
/// Takes a single ID and returns a "list" of one object
|
|
/// </summary>
|
|
/// <param name="HeadOfficeID">ID of HeadOffice object</param>
|
|
/// <returns>list of <see cref="HeadOfficeList.HeadOfficeListInfo"/> objects</returns>
|
|
public static HeadOfficeList GetListForSingleItem(Guid HeadOfficeID)
|
|
{
|
|
//Case 556
|
|
List<Guid> l = new List<Guid>();
|
|
l.Add(HeadOfficeID);
|
|
return GetListFromIDList(l);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Get list by items indicated in IDList
|
|
/// </summary>
|
|
/// <param name="IDList">Generic list of Guid's</param>
|
|
/// <returns>list of <see cref="HeadOfficeList.HeadOfficeListInfo"/> objects</returns>
|
|
public static HeadOfficeList GetListFromIDList(List<Guid> IDList)
|
|
{
|
|
//case 556
|
|
//Handle empty list
|
|
if (IDList.Count == 0)
|
|
return new HeadOfficeList();
|
|
return (HeadOfficeList)DataPortal.Fetch(new Criteria("", IDList, -1));
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Return an empty list
|
|
/// used for initializing grid
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public static HeadOfficeList GetEmptyList()
|
|
{
|
|
return new HeadOfficeList();
|
|
}
|
|
|
|
|
|
#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 cm = null;
|
|
if (crit.IDList != null)
|
|
{
|
|
//Case 556
|
|
System.Text.StringBuilder sbIN = new System.Text.StringBuilder();
|
|
sbIN.Append(" AND (aHeadOffice.aID in (");
|
|
foreach (Guid gItem in crit.IDList)
|
|
{
|
|
sbIN.Append("'");
|
|
sbIN.Append("{");
|
|
sbIN.Append(gItem.ToString().ToUpperInvariant());
|
|
sbIN.Append("}");
|
|
sbIN.Append("',");
|
|
}
|
|
sbIN.Length = sbIN.Length - 1;
|
|
sbIN.Append(")) ");
|
|
|
|
cm = DBUtil.DB.GetSqlStringCommandWrapper(
|
|
"SELECT aHeadOffice.aID, aHeadOffice.aName, aHeadOffice.aModified, " +
|
|
" aHeadOffice.AACTIVE, aHeadOffice.aUsesBanking, " +
|
|
" aHeadOffice.aWebAddress, " +
|
|
" aHeadOffice.aClientGroupID, " +
|
|
" (SELECT TOP 1 aSBANK.aHoursBalance " +
|
|
"FROM aServiceBank aSBANK WHERE aSBANK.AAPPLIESTOROOTOBJECTID " +
|
|
"= aHeadOffice.aID ORDER " +
|
|
"BY aSBANK.aCreated DESC) AS HOURSBAL, (SELECT TOP 1 aSBANK.aIncidentsBalance " +
|
|
"FROM aServiceBank aSBANK WHERE " +
|
|
"aSBANK.AAPPLIESTOROOTOBJECTID = aHeadOffice.aID ORDER " +
|
|
"BY aSBANK.aCreated DESC) AS INCIDENTSBAL, (SELECT " +
|
|
"TOP 1 aSBANK.aCurrencyBalance FROM aServiceBank aSBANK " +
|
|
"WHERE aSBANK.AAPPLIESTOROOTOBJECTID = aHeadOffice.aID " +
|
|
"ORDER BY aSBANK.aCreated DESC) AS CURRENCYBAL, " +
|
|
" AHEADOFFICE.ACONTACT, AHEADOFFICE.AEMAIL, AHEADOFFICE.APHONE1, AHEADOFFICE.APHONE2, AHEADOFFICE.APHONE3, AHEADOFFICE.APHONE4, AHEADOFFICE.APHONE5, " +
|
|
" aHeadOffice.AACCOUNTNUMBER, " +
|
|
" aHeadOffice.aRegionID, " +
|
|
" aRegion.aName AS aRegionName, " +
|
|
" aClientGroup.aName AS aClientGroupName, AADDRESS.aDeliveryAddress, " +
|
|
" AADDRESS.aCity, AADDRESS.aStateProv, " +
|
|
" AADDRESS.aCountry, AADDRESS.aPostal, " +
|
|
" AADDRESS.AADDRESSTYPE, AADDRESS.aLongitude, " +
|
|
" AADDRESS.aLatitude, " +
|
|
" aHeadOffice.aContractID, " +
|
|
" aContract.aName AS aContractName, aHeadOffice.aContractExpires, " +
|
|
" AADDRESS.aCountryCode " +
|
|
"FROM aHeadOffice aHeadOffice LEFT OUTER JOIN aContract " +
|
|
"ON aHeadOffice.aContractID = aContract.aID " +
|
|
"LEFT " +
|
|
"OUTER JOIN AADDRESS ON AADDRESS.aRootObjectID " +
|
|
"= aHeadOffice.aID LEFT OUTER JOIN aRegion " +
|
|
"ON aHeadOffice.aRegionID = aRegion.aID LEFT " +
|
|
"OUTER JOIN aClientGroup ON aHeadOffice.aClientGroupID " +
|
|
"= aClientGroup.aID " +
|
|
"WHERE (AADDRESS.AADDRESSTYPE IS NULL OR AADDRESS.AADDRESSTYPE = 2) "
|
|
+ sbIN.ToString() + " ORDER BY AHEADOFFICE.ANAME ");
|
|
|
|
}
|
|
else
|
|
{
|
|
string sCurrencySelect=
|
|
" (SELECT TOP 1 aSBANK.aCurrencyBalance FROM aServiceBank aSBANK " +
|
|
"WHERE aSBANK.AAPPLIESTOROOTOBJECTID = aHeadOffice.aID " +
|
|
"ORDER BY aSBANK.aCreated DESC) ";
|
|
string sIncidentsSelect=
|
|
" (SELECT TOP 1 aSBANK.aIncidentsBalance FROM aServiceBank aSBANK " +
|
|
"WHERE aSBANK.AAPPLIESTOROOTOBJECTID = aHeadOffice.aID " +
|
|
"ORDER BY aSBANK.aCreated DESC) ";
|
|
string sHoursSelect=
|
|
" (SELECT TOP 1 aSBANK.aHoursBalance FROM aServiceBank aSBANK " +
|
|
"WHERE aSBANK.AAPPLIESTOROOTOBJECTID = aHeadOffice.aID " +
|
|
"ORDER BY aSBANK.aCreated DESC) ";
|
|
|
|
string where=AyaBizUtils.GetGridColumnCriteria(crit.CriteriaXML,false);
|
|
where=where.Replace("CURRENCYBAL",sCurrencySelect);
|
|
where=where.Replace("INCIDENTSBAL",sIncidentsSelect);
|
|
where=where.Replace("HOURSBAL",sHoursSelect);
|
|
|
|
string order=AyaBizUtils.GetGridSortOrderColumns(crit.CriteriaXML);
|
|
//case 1184
|
|
//order=order.Replace("CURRENCYBAL",sCurrencySelect);
|
|
//order=order.Replace("INCIDENTSBAL",sIncidentsSelect);
|
|
//order=order.Replace("HOURSBAL",sHoursSelect);
|
|
|
|
|
|
|
|
string q = "SELECT ~MAXRECS~ aHeadOffice.aID, aHeadOffice.aName, aHeadOffice.aModified, " +
|
|
" aHeadOffice.AACTIVE, aHeadOffice.aUsesBanking, " +
|
|
" aHeadOffice.aWebAddress, " +
|
|
" aHeadOffice.aClientGroupID, " +
|
|
" (SELECT TOP 1 aSBANK.aHoursBalance " +
|
|
"FROM aServiceBank aSBANK WHERE aSBANK.AAPPLIESTOROOTOBJECTID " +
|
|
"= aHeadOffice.aID ORDER " +
|
|
"BY aSBANK.aCreated DESC) AS HOURSBAL, (SELECT TOP 1 aSBANK.aIncidentsBalance " +
|
|
"FROM aServiceBank aSBANK WHERE " +
|
|
"aSBANK.AAPPLIESTOROOTOBJECTID = aHeadOffice.aID ORDER " +
|
|
"BY aSBANK.aCreated DESC) AS INCIDENTSBAL, (SELECT " +
|
|
"TOP 1 aSBANK.aCurrencyBalance FROM aServiceBank aSBANK " +
|
|
"WHERE aSBANK.AAPPLIESTOROOTOBJECTID = aHeadOffice.aID " +
|
|
"ORDER BY aSBANK.aCreated DESC) AS CURRENCYBAL, " +
|
|
" AHEADOFFICE.ACONTACT, AHEADOFFICE.AEMAIL, AHEADOFFICE.APHONE1, AHEADOFFICE.APHONE2, AHEADOFFICE.APHONE3, AHEADOFFICE.APHONE4, AHEADOFFICE.APHONE5, " +
|
|
" aHeadOffice.AACCOUNTNUMBER, " +
|
|
" aHeadOffice.aRegionID, " +
|
|
" aRegion.aName AS aRegionName, " +
|
|
" aClientGroup.aName AS aClientGroupName, AADDRESS.aDeliveryAddress, " +
|
|
" AADDRESS.aCity, AADDRESS.aStateProv, " +
|
|
" AADDRESS.aCountry, AADDRESS.aPostal, " +
|
|
" AADDRESS.AADDRESSTYPE, AADDRESS.aLongitude, " +
|
|
" AADDRESS.aLatitude, " +
|
|
" aHeadOffice.aContractID, " +
|
|
" aContract.aName AS aContractName, aHeadOffice.aContractExpires, " +
|
|
" AADDRESS.aCountryCode " +
|
|
"FROM aHeadOffice LEFT OUTER JOIN aContract " +
|
|
"ON aHeadOffice.aContractID = aContract.aID " +
|
|
"LEFT " +
|
|
"OUTER JOIN AADDRESS ON AADDRESS.aRootObjectID " +
|
|
"= aHeadOffice.aID LEFT OUTER JOIN aRegion " +
|
|
"ON aHeadOffice.aRegionID = aRegion.aID LEFT " +
|
|
"OUTER JOIN aClientGroup ON aHeadOffice.aClientGroupID " +
|
|
"= aClientGroup.aID " +
|
|
"WHERE (AADDRESS.AADDRESSTYPE IS NULL OR AADDRESS.AADDRESSTYPE = 2) \r\n " +
|
|
where + " \r\n " +
|
|
order;
|
|
|
|
if (crit.MaxRecords > 0)
|
|
q = q.Replace("~MAXRECS~", "TOP " + crit.MaxRecords.ToString());
|
|
else
|
|
q = q.Replace("~MAXRECS~", "");
|
|
|
|
cm = DBUtil.DB.GetSqlStringCommandWrapper(q);
|
|
}
|
|
cm.AddInParameter("@TRUE",DbType.Boolean,true);
|
|
dr=new SafeDataReader(DBUtil.DB.ExecuteReader(cm));
|
|
|
|
|
|
while (dr.Read())
|
|
{
|
|
HeadOfficeListInfo info=new HeadOfficeListInfo();
|
|
|
|
info.mHeadOffice=new GridNameValueCellItem(
|
|
dr.GetGuid("aID"),
|
|
dr.GetString("aName"),
|
|
RootObjectTypes.HeadOffice);
|
|
|
|
|
|
info.mClientGroup = new GridNameValueCellItem(
|
|
dr.GetGuid("aClientGroupID"),
|
|
dr.GetString("aClientGroupName"),
|
|
RootObjectTypes.ClientGroup);
|
|
|
|
info.mRegion = new GridNameValueCellItem(
|
|
dr.GetGuid("aRegionID"),
|
|
dr.GetString("aRegionName"),
|
|
RootObjectTypes.Region);
|
|
|
|
|
|
info.mContact = dr.GetString("ACONTACT");
|
|
info.mEmail = dr.GetString("AEMAIL");
|
|
info.mPhone1 = dr.GetString("APHONE1");
|
|
info.mPhone2 = dr.GetString("APHONE2");
|
|
info.mPhone3 = dr.GetString("APHONE3");
|
|
info.mPhone4 = dr.GetString("APHONE4");
|
|
info.mPhone5 = dr.GetString("APHONE5");
|
|
|
|
info.mAccountNumber=dr.GetString("AACCOUNTNUMBER");
|
|
info.mDeliveryAddress=dr.GetString("aDeliveryAddress");
|
|
info.mCity=dr.GetString("aCity");
|
|
info.mStateProv=dr.GetString("aStateProv");
|
|
info.mCountry=dr.GetString("aCountry");
|
|
info.mPostal=dr.GetString("aPostal");
|
|
info.mActive=dr.GetBoolean("AACTIVE");
|
|
info.mWebAddress=dr.GetString("aWebAddress");
|
|
|
|
info.mUsesBanking=dr.GetBoolean("aUsesBanking");
|
|
|
|
info.mContract = new GridNameValueCellItem(
|
|
dr.GetGuid("aContractID"),
|
|
dr.GetString("aContractName"),
|
|
RootObjectTypes.Contract);
|
|
|
|
info.mContractExpires=DBUtil.ToLocal(dr.GetSmartDate("aContractExpires"));
|
|
|
|
info.mLatitude=Address.LatitudeToString(dr.GetDecimal("aLatitude"));
|
|
info.mLongitude=Address.LongitudeToString(dr.GetDecimal("aLongitude"));
|
|
info.mCountryCode=dr.GetString("aCountryCode");
|
|
info.mHoursBalance=dr.GetDecimal("HOURSBAL");
|
|
info.mIncidentsBalance=dr.GetDecimal("INCIDENTSBAL");
|
|
info.mCurrencyBalance=dr.GetDecimal("CURRENCYBAL");
|
|
|
|
|
|
|
|
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 string CriteriaXML;
|
|
public int MaxRecords;
|
|
public Criteria(string _CriteriaXML, List<Guid> _IDList, int _MaxRecords)
|
|
{
|
|
CriteriaXML = _CriteriaXML;
|
|
IDList = _IDList;
|
|
MaxRecords = _MaxRecords;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
}//end HeadOfficeList
|
|
#pragma warning restore 1591
|
|
}//end namespace GZTW.AyaNova.BLL |