This commit is contained in:
191
source/bizobjects/AyaLib/GZTW.AyaNova.BLL/ClientNoteList.cs
Normal file
191
source/bizobjects/AyaLib/GZTW.AyaNova.BLL/ClientNoteList.cs
Normal file
@@ -0,0 +1,191 @@
|
||||
///////////////////////////////////////////////////////////
|
||||
// ClientNoteList.cs
|
||||
// Implementation of Class ClientNoteList
|
||||
// CSLA type: Read only collection
|
||||
// Created on: 18-FEB-2015
|
||||
// Object design: John
|
||||
// Coded: 18-FEB-2015
|
||||
///////////////////////////////////////////////////////////
|
||||
//created for case 1975
|
||||
|
||||
using System;
|
||||
using System.Data;
|
||||
using GZTW.Data;
|
||||
using CSLA.Data;
|
||||
using CSLA;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace GZTW.AyaNova.BLL
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
/// <summary>
|
||||
/// Read only list of <see cref="ClientNoteList.ClientNoteListInfo"/> objects representing <see cref="ClientNote"/> objects.
|
||||
/// Used for display in responsive interface (AyaNova RI)
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class ClientNoteList : ReadOnlyCollectionBase
|
||||
{
|
||||
|
||||
#region Data structure
|
||||
/// <summary>
|
||||
/// Properties
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public struct ClientNoteListInfo
|
||||
{
|
||||
internal string mCreator;
|
||||
internal string mNoteDate;
|
||||
internal string mNotes;
|
||||
internal string mClientNoteType;
|
||||
internal decimal mTotal;
|
||||
internal Guid mId;
|
||||
|
||||
public string Creator
|
||||
{ get { return mCreator; } }
|
||||
|
||||
public string NoteDate
|
||||
{ get { return mNoteDate; } }
|
||||
|
||||
public string Notes
|
||||
{ get { return mNotes; } }
|
||||
|
||||
public string ClientNoteType
|
||||
{ get { return mClientNoteType; } }
|
||||
|
||||
public decimal Total
|
||||
{ get { return mTotal; } }
|
||||
|
||||
public Guid Id
|
||||
{ get { return mId; } }
|
||||
|
||||
|
||||
|
||||
}//end ClientNoteListInfo
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
|
||||
protected ClientNoteList()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Business properties and methods
|
||||
|
||||
///// <summary>
|
||||
///// Get item by index
|
||||
///// </summary>
|
||||
///// <param name="Item"></param>
|
||||
//public ClientNoteListInfo this[int Item]
|
||||
//{
|
||||
// get
|
||||
// {
|
||||
// return (ClientNoteListInfo)List[Item];
|
||||
// }
|
||||
//}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region Static methods
|
||||
|
||||
//case 1975
|
||||
/// <summary>
|
||||
/// Get MaxRecords Client notes for specified client (-1 for all)
|
||||
/// </summary>
|
||||
public static ClientNoteList GetList(Guid ClientID, int MaxRecords)
|
||||
{
|
||||
return (ClientNoteList)DataPortal.Fetch(new Criteria(ClientID, MaxRecords));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region DAL DATA ACCESS
|
||||
///
|
||||
/// <param name="Criteria"></param>
|
||||
protected override void DataPortal_Fetch(object Criteria)
|
||||
{
|
||||
|
||||
Criteria crit = (Criteria)Criteria;
|
||||
|
||||
|
||||
SafeDataReader dr = null;
|
||||
try
|
||||
{
|
||||
|
||||
|
||||
decimal dTotal=DBUtil.ScalarToDecimal(DBUtil.GetScalarFromSQLString("SELECT COUNT(AID) FROM ACLIENTNOTE WHERE ACLIENTNOTE.ACLIENTID=@ID", crit.ClientID));
|
||||
|
||||
string q = "SELECT ~MAXRECS~ ACLIENTNOTE.AID AS ACLIENTNOTEID, ACLIENTNOTE.ANOTEDATE, ACLIENTNOTE.ANOTES, " +
|
||||
" AUSER.AFIRSTNAME, AUSER.ALASTNAME, " +
|
||||
" AUSER.AINITIALS, AUSER.AEMPLOYEENUMBER, " +
|
||||
" ACLIENTNOTETYPE.ANAME AS ACLIENTNOTETYPENAME " +
|
||||
" FROM ACLIENTNOTE " +
|
||||
" INNER JOIN AUSER ON (ACLIENTNOTE.ACREATOR = AUSER.AID)" +
|
||||
" LEFT OUTER JOIN ACLIENTNOTETYPE ON (ACLIENTNOTE.ACLIENTNOTETYPEID=ACLIENTNOTETYPE.AID) " +
|
||||
" WHERE ACLIENTNOTE.ACLIENTID=@ID " +
|
||||
" ORDER BY ANOTEDATE DESC";
|
||||
|
||||
if (crit.MaxRecords > 0)
|
||||
q = q.Replace("~MAXRECS~", "TOP " + crit.MaxRecords.ToString());
|
||||
else
|
||||
q = q.Replace("~MAXRECS~", "");
|
||||
|
||||
dr = DBUtil.GetReaderFromSQLString(q, crit.ClientID);
|
||||
|
||||
//************************************************************
|
||||
|
||||
bool bFirst = true;
|
||||
while (dr.Read())
|
||||
{
|
||||
//*******************************************
|
||||
ClientNoteListInfo info = new ClientNoteListInfo();
|
||||
info.mId = dr.GetGuid("ACLIENTNOTEID");
|
||||
info.mCreator = User.NameFormatter(dr.GetString("aFirstName"), dr.GetString("aLastName"),
|
||||
dr.GetString("aInitials"), dr.GetString("aEmployeeNumber"), "",
|
||||
AyaBizUtils.GlobalSettings.DefaultScheduleableUserNameDisplayFormat);
|
||||
|
||||
info.mClientNoteType = dr.GetString("ACLIENTNOTETYPENAME");
|
||||
info.mNoteDate = DBUtil.ToLocal(dr.GetSmartDate("ANOTEDATE")).ToString();
|
||||
info.mNotes = dr.GetString("ANOTES");
|
||||
if (bFirst)
|
||||
{
|
||||
info.mTotal = dTotal;
|
||||
bFirst = false;
|
||||
}
|
||||
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 int MaxRecords;
|
||||
public Criteria(Guid _ClientID, int _MaxRecords)
|
||||
{
|
||||
ClientID = _ClientID;
|
||||
MaxRecords = _MaxRecords;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
}//end ClientNoteList
|
||||
#pragma warning restore 1591
|
||||
}//end namespace GZTW.AyaNova.BLL
|
||||
Reference in New Issue
Block a user