230 lines
7.5 KiB
C#
230 lines
7.5 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
|
|
{
|
|
[Serializable]
|
|
class UnAuthorizeLeaveParamService : ServiceTemplate, IUnAuthorizeLeaveParamService
|
|
{
|
|
#region Private functions and declaration
|
|
Cache _cache = new Cache(typeof(UnAuthorizeLeaveParam));
|
|
|
|
#endregion
|
|
public UnAuthorizeLeaveParamService() { }
|
|
|
|
private void MapObject(UnAuthorizeLeaveParam oUnAuthorizeLeaveParam, DataReader oReader)
|
|
{
|
|
base.SetObjectID(oUnAuthorizeLeaveParam, oReader.GetID("UaLeaveParamID"));
|
|
oUnAuthorizeLeaveParam.UnAhuthorizeLeaveID = oReader.GetID("UaLeaveID");
|
|
this.SetObjectState(oUnAuthorizeLeaveParam, Ease.CoreV35.ObjectState.Saved);
|
|
}
|
|
protected override T CreateObject<T>(DataReader oReader)
|
|
{
|
|
UnAuthorizeLeaveParam oUnAuthorizeLeave = new UnAuthorizeLeaveParam();
|
|
MapObject(oUnAuthorizeLeave, oReader);
|
|
return oUnAuthorizeLeave as T;
|
|
}
|
|
protected UnAuthorizeLeaveParam CreateObject(DataReader oReader)
|
|
{
|
|
UnAuthorizeLeaveParam oUnAuthorizeLeave = new UnAuthorizeLeaveParam();
|
|
MapObject(oUnAuthorizeLeave, oReader);
|
|
return oUnAuthorizeLeave;
|
|
}
|
|
#region Service implementation
|
|
public UnAuthorizeLeaveParam Get(ID id)
|
|
{
|
|
UnAuthorizeLeaveParam oUnAuthorizeLeave = new UnAuthorizeLeaveParam();
|
|
#region Cache Header
|
|
oUnAuthorizeLeave = _cache["Get", id] as UnAuthorizeLeaveParam;
|
|
if (oUnAuthorizeLeave != null)
|
|
return oUnAuthorizeLeave;
|
|
#endregion
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader oreader = new DataReader(UnAuthorizeLeaveParameterDA.Get(tc, id));
|
|
if (oreader.Read())
|
|
{
|
|
oUnAuthorizeLeave = this.CreateObject<UnAuthorizeLeaveParam>(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(oUnAuthorizeLeave, "Get", id);
|
|
#endregion
|
|
return oUnAuthorizeLeave;
|
|
}
|
|
|
|
public ObjectsTemplate<UnAuthorizeLeaveParam> Get()
|
|
{
|
|
#region Cache Header
|
|
|
|
ObjectsTemplate<UnAuthorizeLeaveParam> unAuthorizeLeaves = _cache["Get"] as ObjectsTemplate<UnAuthorizeLeaveParam>;
|
|
if (unAuthorizeLeaves != null)
|
|
return unAuthorizeLeaves;
|
|
|
|
#endregion
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
|
|
DataReader dr = new DataReader(UnAuthorizeLeaveParameterDA.Get(tc));
|
|
unAuthorizeLeaves = this.CreateObjects<UnAuthorizeLeaveParam>(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(unAuthorizeLeaves, "Get");
|
|
|
|
#endregion
|
|
|
|
return unAuthorizeLeaves;
|
|
}
|
|
|
|
public ObjectsTemplate<UnAuthorizeLeaveParam> GetByLeaveID(ID nLeaveID)
|
|
{
|
|
#region Cache Header
|
|
|
|
ObjectsTemplate<UnAuthorizeLeaveParam> unAuthorizeLeaves = _cache["GetByLeaveID", nLeaveID] as ObjectsTemplate<UnAuthorizeLeaveParam>;
|
|
if (unAuthorizeLeaves != null)
|
|
return unAuthorizeLeaves;
|
|
|
|
#endregion
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
|
|
DataReader dr = new DataReader(UnAuthorizeLeaveParameterDA.GetByLeaveID(tc, nLeaveID));
|
|
unAuthorizeLeaves = this.CreateObjects<UnAuthorizeLeaveParam>(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(unAuthorizeLeaves, "GetByLeaveID", nLeaveID);
|
|
|
|
#endregion
|
|
|
|
return unAuthorizeLeaves;
|
|
}
|
|
|
|
public ID Save(UnAuthorizeLeaveParam oUnAuthorizeLeaveParam)
|
|
{
|
|
TransactionContext tc = null;
|
|
int id = 0;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
|
|
if (oUnAuthorizeLeaveParam.IsNew)
|
|
{
|
|
id = tc.GenerateID("UALeaveParam", "UaLeaveParamID");
|
|
base.SetObjectID(oUnAuthorizeLeaveParam, ID.FromInteger(id));
|
|
UnAuthorizeLeaveParameterDA.Insert(tc, oUnAuthorizeLeaveParam);
|
|
}
|
|
else
|
|
{
|
|
UnAuthorizeLeaveParameterDA.Update(tc, oUnAuthorizeLeaveParam);
|
|
UnAuthorizeLeaveParameterDA.DeleteDetail(tc, oUnAuthorizeLeaveParam.ID);
|
|
}
|
|
|
|
foreach(UnAuthorizeLeaveParamDetail detail in oUnAuthorizeLeaveParam.Details)
|
|
{
|
|
id = tc.GenerateID("LEAVESUSPENSEDEDUCT", "ParamDetailID");
|
|
base.SetObjectID(detail, ID.FromInteger(id));
|
|
detail.UNLeaveParamID = oUnAuthorizeLeaveParam.ID;
|
|
detail.LeaveID = oUnAuthorizeLeaveParam.UnAhuthorizeLeaveID;
|
|
UnAuthorizeLeaveParameterDA.Insert(tc, detail);
|
|
}
|
|
|
|
SetupDetailService sdetailService = new SetupDetailService();
|
|
sdetailService.Save(tc, EnumParameterSetup.SalaryDeduct,
|
|
oUnAuthorizeLeaveParam.SetupDetails, oUnAuthorizeLeaveParam.ID);
|
|
|
|
tc.End();
|
|
return oUnAuthorizeLeaveParam.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 id)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
UnAuthorizeLeaveParameterDA.Delete(tc, id);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
#endregion
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
}
|