246 lines
6.9 KiB
C#
246 lines
6.9 KiB
C#
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Linq;
|
|||
|
using System.Text;
|
|||
|
using Ease.CoreV35;
|
|||
|
using Ease.CoreV35.Caching;
|
|||
|
using Ease.CoreV35.DataAccess;
|
|||
|
using Ease.CoreV35.Model;
|
|||
|
using Payroll.BO;
|
|||
|
|
|||
|
|
|||
|
namespace Payroll.Service
|
|||
|
{
|
|||
|
[Serializable]
|
|||
|
public class BudgetGradeService : ServiceTemplate, IBudgetGradeService
|
|||
|
{
|
|||
|
#region Private functions and declaration
|
|||
|
Cache _cache = new Cache(typeof(BudgetGrade));
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Object Mapping
|
|||
|
|
|||
|
private void MapObject(BudgetGrade oBudgetGrade, DataReader oReader)
|
|||
|
{
|
|||
|
SetObjectID(oBudgetGrade, oReader.GetID("BudgetGradeID"));
|
|||
|
oBudgetGrade.BudgetID = oReader.GetID("BudgetID");
|
|||
|
oBudgetGrade.ChangedPercentage = oReader.GetDouble("ChangedPercentage").Value;
|
|||
|
oBudgetGrade.FixedAmount = oReader.GetDouble("FixedAmount").Value;
|
|||
|
oBudgetGrade.GradeID = oReader.GetID("GradeID");
|
|||
|
SetObjectState(oBudgetGrade, ObjectState.Saved);
|
|||
|
}
|
|||
|
|
|||
|
protected override T CreateObject<T>(DataReader dr)
|
|||
|
{
|
|||
|
BudgetGrade oBudgetGrade = new BudgetGrade();
|
|||
|
MapObject(oBudgetGrade, dr);
|
|||
|
return oBudgetGrade as T;
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Service Implementation
|
|||
|
|
|||
|
public BudgetGrade Get(ID nID)
|
|||
|
{
|
|||
|
BudgetGrade oBudgetGrade = new BudgetGrade();
|
|||
|
|
|||
|
#region Cache Header
|
|||
|
oBudgetGrade = _cache["Get", nID] as BudgetGrade;
|
|||
|
if (oBudgetGrade != null)
|
|||
|
return oBudgetGrade;
|
|||
|
#endregion
|
|||
|
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader oreader = new DataReader(BudgetGradeDA.Get(tc, nID));
|
|||
|
if (oreader.Read())
|
|||
|
{
|
|||
|
oBudgetGrade = CreateObject<BudgetGrade>(oreader);
|
|||
|
}
|
|||
|
oreader.Close();
|
|||
|
tc.End();
|
|||
|
}
|
|||
|
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
#endregion
|
|||
|
}
|
|||
|
|
|||
|
#region Cache Footer
|
|||
|
_cache.Add(oBudgetGrade, "Get", nID);
|
|||
|
#endregion
|
|||
|
|
|||
|
return oBudgetGrade;
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
public ObjectsTemplate<BudgetGrade> Get()
|
|||
|
{
|
|||
|
#region Cache Header
|
|||
|
|
|||
|
ObjectsTemplate<BudgetGrade> oBudgetGrades = _cache["Get"] as ObjectsTemplate<BudgetGrade>;
|
|||
|
if (oBudgetGrades != null)
|
|||
|
return oBudgetGrades;
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader oreader = new DataReader(BudgetGradeDA.Get(tc));
|
|||
|
// if (oreader.Read())
|
|||
|
//{
|
|||
|
oBudgetGrades = this.CreateObjects<BudgetGrade>(oreader);
|
|||
|
//}
|
|||
|
oreader.Close();
|
|||
|
tc.End();
|
|||
|
}
|
|||
|
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
#endregion
|
|||
|
}
|
|||
|
|
|||
|
#region Cache Footer
|
|||
|
|
|||
|
_cache.Add(oBudgetGrades, "Get");
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
return oBudgetGrades;
|
|||
|
}
|
|||
|
public ObjectsTemplate<BudgetGrade> Get(int nBudID)
|
|||
|
{
|
|||
|
#region Cache Header
|
|||
|
|
|||
|
ObjectsTemplate<BudgetGrade> oBudgetGrades = _cache["Get"] as ObjectsTemplate<BudgetGrade>;
|
|||
|
if (oBudgetGrades != null)
|
|||
|
return oBudgetGrades;
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader oreader = new DataReader(BudgetGradeDA.Get(tc,nBudID));
|
|||
|
// if (oreader.Read())
|
|||
|
//{
|
|||
|
oBudgetGrades = this.CreateObjects<BudgetGrade>(oreader);
|
|||
|
//}
|
|||
|
oreader.Close();
|
|||
|
tc.End();
|
|||
|
}
|
|||
|
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
#endregion
|
|||
|
}
|
|||
|
|
|||
|
#region Cache Footer
|
|||
|
|
|||
|
_cache.Add(oBudgetGrades, "Get");
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
return oBudgetGrades;
|
|||
|
}
|
|||
|
|
|||
|
public ID Save(BudgetGrade item)
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
if (item.IsNew)
|
|||
|
{
|
|||
|
int id = tc.GenerateID("BudgetGrade", "BudgetGradeID");
|
|||
|
SetObjectID(item, ID.FromInteger(id));
|
|||
|
BudgetGradeDA.Insert(tc, item);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
BudgetGradeDA.Update(tc, item);
|
|||
|
}
|
|||
|
tc.End();
|
|||
|
|
|||
|
return item.ID;
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|
|||
|
public ID Save(BudgetGrade item,TransactionContext tc)
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
int id = tc.GenerateID("BudgetGrade", "BudgetGradeID");
|
|||
|
SetObjectID(item, ID.FromInteger(id));
|
|||
|
BudgetGradeDA.Insert(tc, item);
|
|||
|
|
|||
|
return item.ID;
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void Delete(ID nID)
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
BudgetGradeDA.Delete(tc, nID);
|
|||
|
tc.End();
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|