EchoTex_Payroll/HRM.DA/Service/PMP/AssignProxyObjectiveSettingService.cs

211 lines
6.9 KiB
C#
Raw Normal View History

2024-10-14 10:01:49 +06:00
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 AssignProxyObjectiveSetting Service
public class AssignProxyObjectiveSettingService : ServiceTemplate, IAssignProxyObjectiveSettingService
{
public AssignProxyObjectiveSettingService()
{
}
private void MapObject(AssignProxyObjectiveSetting oAssignProxyObjectiveSetting, DataReader oReader)
{
base.SetObjectID(oAssignProxyObjectiveSetting, oReader.GetInt32("AssignProxyObjectiveSettingID", 0));
oAssignProxyObjectiveSetting.RequestedEmployeeID = oReader.GetInt32("RequestedEmployeeID", 0);
oAssignProxyObjectiveSetting.AssignedForEmployeeID = oReader.GetInt32("AssignedForEmployeeID", 0);
oAssignProxyObjectiveSetting.AssignedToEmployeeID = oReader.GetInt32("AssignedToEmployeeID", 0);
oAssignProxyObjectiveSetting.PMPYearID = oReader.GetInt32("PMPYearID", 0);
oAssignProxyObjectiveSetting.GeadeID = oReader.GetInt32("GeadeID", 0);
oAssignProxyObjectiveSetting.IsApproved = oReader.GetBoolean("IsApproved").Value;
oAssignProxyObjectiveSetting.ApprovalDate = oReader.GetDateTime("ApprovalDate");
oAssignProxyObjectiveSetting.ApprovedBy = oReader.GetInt32("ApprovedBy", 0);
oAssignProxyObjectiveSetting.AuthorizedType =
(EnumPMPAutorizedType)oReader.GetInt32("AuthorizedType").Value;
//oAssignProxyObjectiveSetting.Status = (((EnumStatus)))oReader.GetInt32("Status").Value;
this.SetObjectState(oAssignProxyObjectiveSetting, Ease.Core.ObjectState.Saved);
}
protected override T CreateObject<T>(DataReader oReader)
{
AssignProxyObjectiveSetting oAssignProxyObjectiveSetting = new AssignProxyObjectiveSetting();
MapObject(oAssignProxyObjectiveSetting, oReader);
return oAssignProxyObjectiveSetting as T;
}
protected AssignProxyObjectiveSetting CreateObject(DataReader oReader)
{
AssignProxyObjectiveSetting oAssignProxyObjectiveSetting = new AssignProxyObjectiveSetting();
MapObject(oAssignProxyObjectiveSetting, oReader);
return oAssignProxyObjectiveSetting;
}
#region Service implementation
public List<AssignProxyObjectiveSetting> Get()
{
List<AssignProxyObjectiveSetting> AssignProxyObjectiveSettings = new List<AssignProxyObjectiveSetting>();
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(AssignProxyObjectiveSettingDA.Get(tc));
AssignProxyObjectiveSettings = this.CreateObjects<AssignProxyObjectiveSetting>(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 AssignProxyObjectiveSettings;
}
public List<AssignProxyObjectiveSetting> Get(int nPMPYearID)
{
List<AssignProxyObjectiveSetting> AssignProxyObjectiveSettings = new List<AssignProxyObjectiveSetting>();
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(AssignProxyObjectiveSettingDA.Get(tc, nPMPYearID));
AssignProxyObjectiveSettings = this.CreateObjects<AssignProxyObjectiveSetting>(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 AssignProxyObjectiveSettings;
}
public List<AssignProxyObjectiveSetting> Get(int nPMPYearID, int nEmpID)
{
List<AssignProxyObjectiveSetting> AssignProxyObjectiveSettings = new List<AssignProxyObjectiveSetting>();
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(AssignProxyObjectiveSettingDA.Get(tc, nPMPYearID, nEmpID));
AssignProxyObjectiveSettings = this.CreateObjects<AssignProxyObjectiveSetting>(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 AssignProxyObjectiveSettings;
}
public int Save(AssignProxyObjectiveSetting oAssignProxyObjectiveSetting)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
if (oAssignProxyObjectiveSetting.IsNew)
{
int id = tc.GenerateID("AssignProxyObjectiveSetting", "AssignProxyObjectiveSettingID");
base.SetObjectID(oAssignProxyObjectiveSetting, (id));
AssignProxyObjectiveSettingDA.Insert(tc, oAssignProxyObjectiveSetting);
}
else
{
AssignProxyObjectiveSettingDA.Update(tc, oAssignProxyObjectiveSetting);
}
tc.End();
return oAssignProxyObjectiveSetting.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(int id)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
AssignProxyObjectiveSettingDA.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
}
#endregion
}