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

229 lines
6.9 KiB
C#
Raw Permalink 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
{
class YearEndValueDetailsRatingService : ServiceTemplate
{
#region Object Mapping
private void MapObject(YearEndValueDetailsRating oYearEndValueDetailsRating, DataReader oReader)
{
SetObjectID(oYearEndValueDetailsRating, oReader.GetInt32("YearEndValueDetailsRatingID", 0));
oYearEndValueDetailsRating.ObjectiveSetID = oReader.GetInt32("ObjectiveSetID", 0);
oYearEndValueDetailsRating.ValueDetailID = oReader.GetInt32("ValueDetailID", 0);
oYearEndValueDetailsRating.RatingID =
oReader.GetInt32("RatingID") == null ? 0 : oReader.GetInt32("RatingID").Value;
//oYearEndValueDetailsRating.EmpComments = oReader.GetString("EmpComments");
//oYearEndValueDetailsRating.LMComments = oReader.GetString("LMComments");
// oYearEndValueDetailsRating.EmpCommentsDate = oReader.GetDateTime("EmpCommentsDate").Value;
oYearEndValueDetailsRating.LMRatingDate = oReader.GetDateTime("LMRatingDate") == null
? DateTime.MinValue
: oReader.GetDateTime("LMRatingDate").Value;
this.SetObjectState(oYearEndValueDetailsRating, ObjectState.Saved);
}
protected override T CreateObject<T>(DataReader oReader)
{
YearEndValueDetailsRating oYearEndValueDetailsRating = new YearEndValueDetailsRating();
MapObject(oYearEndValueDetailsRating, oReader);
return oYearEndValueDetailsRating as T;
}
#endregion
#region IYearEndValueDetailsRatingService Members
#region Get All
public List<YearEndValueDetailsRating> Get()
{
List<YearEndValueDetailsRating> oDevelopmentPlan = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader oreader = new DataReader(YearEndValueDetailsRatingDA.Get(tc));
oDevelopmentPlan = this.CreateObjects<YearEndValueDetailsRating>(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 oDevelopmentPlan;
}
public List<YearEndValueDetailsRating> GetByPMPYear(int nPMPYearID)
{
List<YearEndValueDetailsRating> oObjectives = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader oreader = new DataReader(YearEndValueDetailsRatingDA.GetByPMPYear(tc, nPMPYearID));
oObjectives = this.CreateObjects<YearEndValueDetailsRating>(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 oObjectives;
}
public List<YearEndValueDetailsRating> GetByObjectiveSetID(int ObjectiveSetID)
{
List<YearEndValueDetailsRating> oDevelopmentPlan = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader oreader = new DataReader(YearEndValueDetailsRatingDA.Get(tc, ObjectiveSetID));
oDevelopmentPlan = this.CreateObjects<YearEndValueDetailsRating>(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 oDevelopmentPlan;
}
#endregion
#region Get By ID
public YearEndValueDetailsRating Get(int id)
{
YearEndValueDetailsRating oYearEndValueDetailsRating = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader oreader = new DataReader(YearEndValueDetailsRatingDA.Get(tc, id));
oYearEndValueDetailsRating = this.CreateObject<YearEndValueDetailsRating>(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 oYearEndValueDetailsRating;
}
#endregion
#region Insert
public int Save(YearEndValueDetailsRating item)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
if (item.IsNew)
{
int id = tc.GenerateID("YearEndValueDetailsRating", "YearEndValueDetailsRatingID");
base.SetObjectID(item, (id));
YearEndValueDetailsRatingDA.Save(tc, item);
}
else
{
YearEndValueDetailsRatingDA.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
}
}
#endregion
#region Delete
public void Delete(int id)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
YearEndValueDetailsRatingDA.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
}
}