EchoTex_Payroll/HRM.DA/Service/UnAuthLeave/UnAuthorizeLeaveParameterService.cs
2024-10-14 10:01:49 +06:00

147 lines
4.6 KiB
C#

using System;
using System.Data;
using Ease.Core.Model;
using Ease.Core.DataAccess;
using Ease.Core;
using System.Collections.Generic;
using Ease.Core.Utility;
using HRM.BO;
namespace HRM.DA
{
#region UnAuthorizeLeaveParameter Service
public class UnAuthorizeLeaveParameterService : ServiceTemplate
{
public UnAuthorizeLeaveParameterService()
{
}
private void MapObject(UnAuthorizeLeaveParamDetail oUnAuthorizeLeaveParameter, DataReader oReader)
{
base.SetObjectID(oUnAuthorizeLeaveParameter, (oReader.GetInt32("ParamDetailID").Value));
oUnAuthorizeLeaveParameter.LeaveID = oReader.GetInt32("LeaveID", 0);
oUnAuthorizeLeaveParameter.AllowanceID = oReader.GetInt32("ALLOWANCEID", 0);
oUnAuthorizeLeaveParameter.UNLeaveParamID = oReader.GetInt32("UaLeaveParamID", 0);
oUnAuthorizeLeaveParameter.ValueInPercent = oReader.GetDouble("VALUEINPERCENT").Value;
oUnAuthorizeLeaveParameter.Type = (EnumSalaryComponent)oReader.GetInt32("Type").Value;
this.SetObjectState(oUnAuthorizeLeaveParameter, Ease.Core.ObjectState.Saved);
}
protected override T CreateObject<T>(DataReader oReader)
{
UnAuthorizeLeaveParamDetail oUnAuthorizeLeaveParameter = new UnAuthorizeLeaveParamDetail();
MapObject(oUnAuthorizeLeaveParameter, oReader);
return oUnAuthorizeLeaveParameter as T;
}
protected UnAuthorizeLeaveParamDetail CreateObject(DataReader oReader)
{
UnAuthorizeLeaveParamDetail oUnAuthorizeLeaveParameter = new UnAuthorizeLeaveParamDetail();
MapObject(oUnAuthorizeLeaveParameter, oReader);
return oUnAuthorizeLeaveParameter;
}
#region Service implementation
public UnAuthorizeLeaveParamDetail Get(int id)
{
UnAuthorizeLeaveParamDetail oUnAuthorizeLeaveParameter = new UnAuthorizeLeaveParamDetail();
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader oreader = new DataReader(UnAuthorizeLeaveParameterDA.Get(tc, id));
if (oreader.Read())
{
oUnAuthorizeLeaveParameter = this.CreateObject<UnAuthorizeLeaveParamDetail>(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
}
return oUnAuthorizeLeaveParameter;
}
//public List<UnAuthorizeLeaveParamDetail> Get()
//{
// List<UnAuthorizeLeaveParamDetail> unAuthorizeLeaveParameters = null;
// TransactionContext tc = null;
// try
// {
// tc = TransactionContext.Begin();
// DataReader dr = new DataReader(UnAuthorizeLeaveParameterDA.Get(tc));
// unAuthorizeLeaveParameters = this.CreateObjects<UnAuthorizeLeaveParamDetail>(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
// }
// return unAuthorizeLeaveParameters;
//}
public List<UnAuthorizeLeaveParamDetail> GetDetail(int nUnLeaveParamID)
{
List<UnAuthorizeLeaveParamDetail> unAuthorizeLeaveParameters = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(UnAuthorizeLeaveParameterDA.GetDetail(tc, nUnLeaveParamID));
unAuthorizeLeaveParameters = this.CreateObjects<UnAuthorizeLeaveParamDetail>(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
}
return unAuthorizeLeaveParameters;
}
#endregion
}
#endregion
}