232 lines
8.3 KiB
C#
232 lines
8.3 KiB
C#
|
using System;
|
|||
|
using System.Data;
|
|||
|
using System.Linq;
|
|||
|
using Ease.CoreV35;
|
|||
|
using Ease.CoreV35.Model;
|
|||
|
using Ease.CoreV35.DataAccess;
|
|||
|
using System.Collections.Generic;
|
|||
|
using Payroll.BO;
|
|||
|
using Ease.CoreV35.Caching;
|
|||
|
|
|||
|
namespace Payroll.Service
|
|||
|
{
|
|||
|
#region ApproveFinantialData Service
|
|||
|
[Serializable]
|
|||
|
public class ApproveFinantialDataService : ServiceTemplate, IApproveFinantialDataService
|
|||
|
{
|
|||
|
#region Private functions and declaration
|
|||
|
Cache _cache = new Cache(typeof(ApproveFinantialData));
|
|||
|
|
|||
|
#endregion
|
|||
|
public ApproveFinantialDataService() { }
|
|||
|
|
|||
|
private void MapObject(ApproveFinantialData oApproveFinantialData, DataReader oReader)
|
|||
|
{
|
|||
|
base.SetObjectID(oApproveFinantialData, oReader.GetID("ApproveID"));
|
|||
|
oApproveFinantialData.FinanatialDataType = (EnumApprovalFinancialData)oReader.GetInt32("FinanatialDataType");
|
|||
|
oApproveFinantialData.EmployeeID = oReader.GetID("EmployeeID");
|
|||
|
oApproveFinantialData.ObjectID = oReader.GetInt32("ObjectID").Value;
|
|||
|
oApproveFinantialData.SalaryMonth = oReader.GetDateTime("SalaryMonth").Value;
|
|||
|
oApproveFinantialData.Approvedby = oReader.GetInt32("Approvedby").Value;
|
|||
|
oApproveFinantialData.ApprovedDate = oReader.GetDateTime("ApprovedDate").Value;
|
|||
|
this.SetObjectState(oApproveFinantialData, Ease.CoreV35.ObjectState.Saved);
|
|||
|
}
|
|||
|
protected override T CreateObject<T>(DataReader oReader)
|
|||
|
{
|
|||
|
ApproveFinantialData oApproveFinantialData = new ApproveFinantialData();
|
|||
|
MapObject(oApproveFinantialData, oReader);
|
|||
|
return oApproveFinantialData as T;
|
|||
|
}
|
|||
|
protected ApproveFinantialData CreateObject(DataReader oReader)
|
|||
|
{
|
|||
|
ApproveFinantialData oApproveFinantialData = new ApproveFinantialData();
|
|||
|
MapObject(oApproveFinantialData, oReader);
|
|||
|
return oApproveFinantialData;
|
|||
|
}
|
|||
|
#region Service implementation
|
|||
|
|
|||
|
|
|||
|
public ApproveFinantialData Get(int EmpID, DateTime dt)
|
|||
|
{
|
|||
|
ApproveFinantialData oApproveFinantialData = new ApproveFinantialData();
|
|||
|
#region Cache Header
|
|||
|
oApproveFinantialData = _cache["Get", EmpID, dt] as ApproveFinantialData;
|
|||
|
if (oApproveFinantialData != null)
|
|||
|
return oApproveFinantialData;
|
|||
|
#endregion
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader oreader = new DataReader(ApproveFinantialDataDA.Get(tc, EmpID, dt));
|
|||
|
if (oreader.Read())
|
|||
|
{
|
|||
|
oApproveFinantialData = this.CreateObject<ApproveFinantialData>(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(oApproveFinantialData, "Get", EmpID, dt);
|
|||
|
#endregion
|
|||
|
return oApproveFinantialData;
|
|||
|
}
|
|||
|
public ObjectsTemplate<ApproveFinantialData> Get(ID id)
|
|||
|
{
|
|||
|
#region Cache Header
|
|||
|
ObjectsTemplate<ApproveFinantialData> ApproveFinantialDatas = _cache["Get",id] as ObjectsTemplate<ApproveFinantialData>;
|
|||
|
if (ApproveFinantialDatas != null)
|
|||
|
return ApproveFinantialDatas;
|
|||
|
#endregion
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader dr = new DataReader(ApproveFinantialDataDA.Get(tc,id));
|
|||
|
ApproveFinantialDatas = this.CreateObjects<ApproveFinantialData>(dr);
|
|||
|
dr.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(ApproveFinantialDatas, "Get",id);
|
|||
|
#endregion
|
|||
|
return ApproveFinantialDatas;
|
|||
|
}
|
|||
|
|
|||
|
public ObjectsTemplate<ApproveFinantialData> GetByMonth(DateTime dtStart, DateTime dtEnd)
|
|||
|
{
|
|||
|
#region Cache Header
|
|||
|
ObjectsTemplate<ApproveFinantialData> ApproveFinantialDatas = _cache["GetByMonth", dtStart,dtEnd] as ObjectsTemplate<ApproveFinantialData>;
|
|||
|
if (ApproveFinantialDatas != null)
|
|||
|
return ApproveFinantialDatas;
|
|||
|
#endregion
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader dr = new DataReader(ApproveFinantialDataDA.GetByMonth(tc, dtStart, dtEnd));
|
|||
|
ApproveFinantialDatas = this.CreateObjects<ApproveFinantialData>(dr);
|
|||
|
dr.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(ApproveFinantialDatas, "GetByMonth", dtStart, dtEnd);
|
|||
|
#endregion
|
|||
|
return ApproveFinantialDatas;
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
public ObjectsTemplate<ApproveFinantialData> Get()
|
|||
|
{
|
|||
|
#region Cache Header
|
|||
|
ObjectsTemplate<ApproveFinantialData> ApproveFinantialDatas = _cache["Get"] as ObjectsTemplate<ApproveFinantialData>;
|
|||
|
if (ApproveFinantialDatas != null)
|
|||
|
return ApproveFinantialDatas;
|
|||
|
#endregion
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader dr = new DataReader(ApproveFinantialDataDA.Get(tc));
|
|||
|
ApproveFinantialDatas = this.CreateObjects<ApproveFinantialData>(dr);
|
|||
|
dr.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(ApproveFinantialDatas, "Get");
|
|||
|
#endregion
|
|||
|
return ApproveFinantialDatas;
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
public void Save(ObjectsTemplate<ApproveFinantialData> items)
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
|
|||
|
foreach (ApproveFinantialData item in items)
|
|||
|
{
|
|||
|
int id = tc.GenerateID("ApproveFinantialData", "ApproveID");
|
|||
|
base.SetObjectID(item, ID.FromInteger(id));
|
|||
|
ApproveFinantialDataDA.Insert(tc, item);
|
|||
|
}
|
|||
|
tc.End();
|
|||
|
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
public void Delete(ApproveFinantialData item)
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
ApproveFinantialDataDA.Delete(tc, item);
|
|||
|
tc.End();
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
#endregion
|
|||
|
}
|