369 lines
13 KiB
C#
369 lines
13 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;
|
|||
|
using Payroll.Service;
|
|||
|
|
|||
|
namespace HRM.DA
|
|||
|
{
|
|||
|
public class YearEndValuesRatingService : ServiceTemplate, IYearEndValuesRatingService
|
|||
|
{
|
|||
|
#region Object Mapping
|
|||
|
|
|||
|
private void MapObject(YearEndValuesRating oYearEndValuesRating, DataReader oReader)
|
|||
|
{
|
|||
|
SetObjectID(oYearEndValuesRating, oReader.GetInt32("YearEndValuesRatingID", 0));
|
|||
|
oYearEndValuesRating.ObjectiveSetID = oReader.GetInt32("ObjectiveSetID", 0);
|
|||
|
oYearEndValuesRating.ValueID = oReader.GetInt32("ValueID", 0);
|
|||
|
oYearEndValuesRating.EmpComments = oReader.GetString("EmpComments");
|
|||
|
oYearEndValuesRating.LMComments = oReader.GetString("LMComments");
|
|||
|
oYearEndValuesRating.EmpCommentsDate = oReader.GetDateTime("EmpCommentsDate") == null
|
|||
|
? DateTime.MinValue
|
|||
|
: oReader.GetDateTime("EmpCommentsDate").Value;
|
|||
|
oYearEndValuesRating.LMCommentDate = oReader.GetDateTime("LMCommentDate") == null
|
|||
|
? DateTime.MinValue
|
|||
|
: oReader.GetDateTime("LMCommentDate").Value;
|
|||
|
oYearEndValuesRating.MYEmpComments = oReader.GetString("MYEmpComments");
|
|||
|
oYearEndValuesRating.MYLMComments = oReader.GetString("MYLMComments");
|
|||
|
oYearEndValuesRating.MYEmpCommentsDate = oReader.GetDateTime("MYEmpCommentsDate") == null
|
|||
|
? DateTime.MinValue
|
|||
|
: oReader.GetDateTime("MYEmpCommentsDate").Value;
|
|||
|
oYearEndValuesRating.MYLMCommentDate = oReader.GetDateTime("MYLMCommentDate") == null
|
|||
|
? DateTime.MinValue
|
|||
|
: oReader.GetDateTime("MYLMCommentDate").Value;
|
|||
|
oYearEndValuesRating.YEEmpComments = oReader.GetString("YEEmpComments");
|
|||
|
oYearEndValuesRating.YELMComments = oReader.GetString("YELMComments");
|
|||
|
oYearEndValuesRating.YEEmpCommentsDate = oReader.GetDateTime("YEEmpCommentsDate") == null
|
|||
|
? DateTime.MinValue
|
|||
|
: oReader.GetDateTime("YEEmpCommentsDate").Value;
|
|||
|
oYearEndValuesRating.YELMCommentDate = oReader.GetDateTime("YELMCommentDate") == null
|
|||
|
? DateTime.MinValue
|
|||
|
: oReader.GetDateTime("YELMCommentDate").Value;
|
|||
|
oYearEndValuesRating.YEEmpRating = oReader.GetInt32("YEEmpRating").Value;
|
|||
|
oYearEndValuesRating.YELMRating = (EnumObjectiveRating)oReader.GetInt32("YELMRating").Value;
|
|||
|
oYearEndValuesRating.Weightage = oReader.GetDouble("Weightage").GetValueOrDefault();
|
|||
|
oYearEndValuesRating.CompetencyLevel = oReader.GetInt32("CompetencyLevel").Value;
|
|||
|
oYearEndValuesRating.ItemType = oReader.GetInt32("ItemType").HasValue
|
|||
|
? (enumCompetency)oReader.GetInt32("ItemType")
|
|||
|
: enumCompetency.None;
|
|||
|
this.SetObjectState(oYearEndValuesRating, ObjectState.Saved);
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
protected override T CreateObject<T>(DataReader oReader)
|
|||
|
{
|
|||
|
YearEndValuesRating oYearEndValuesRating = new YearEndValuesRating();
|
|||
|
MapObject(oYearEndValuesRating, oReader);
|
|||
|
return oYearEndValuesRating as T;
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region IYearEndValuesRatingService Members
|
|||
|
|
|||
|
#region Get All
|
|||
|
|
|||
|
public List<YearEndValuesRating> Get()
|
|||
|
{
|
|||
|
List<YearEndValuesRating> oDevelopmentPlan = null;
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader oreader = new DataReader(YearEndValuesRatingDA.Get(tc));
|
|||
|
oDevelopmentPlan = this.CreateObjects<YearEndValuesRating>(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<YearEndValuesRating> GetByPMPYear(int nPMPYearID)
|
|||
|
{
|
|||
|
List<YearEndValuesRating> oObjectives = null;
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader oreader = new DataReader(YearEndValuesRatingDA.GetByPMPYear(tc, nPMPYearID));
|
|||
|
oObjectives = this.CreateObjects<YearEndValuesRating>(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<YearEndValuesRating> GetByObjectiveSetID(int ObjectiveSetID)
|
|||
|
{
|
|||
|
List<YearEndValuesRating> oDevelopmentPlan = null;
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader oreader = new DataReader(YearEndValuesRatingDA.GetByObjectiveSetID(tc, ObjectiveSetID));
|
|||
|
oDevelopmentPlan = this.CreateObjects<YearEndValuesRating>(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 YearEndValuesRating Get(int id)
|
|||
|
{
|
|||
|
YearEndValuesRating oYearEndValuesRating = null;
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader oreader = new DataReader(YearEndValuesRatingDA.Get(tc, id));
|
|||
|
oYearEndValuesRating = this.CreateObject<YearEndValuesRating>(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 oYearEndValuesRating;
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Insert
|
|||
|
|
|||
|
public int Save(YearEndValuesRating item)
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
if (item.IsNew)
|
|||
|
{
|
|||
|
int id = tc.GenerateID("YearEndValuesRating", "YearEndValuesRatingID");
|
|||
|
base.SetObjectID(item, (id));
|
|||
|
YearEndValuesRatingDA.Save(tc, item);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
YearEndValuesRatingDA.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
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void Save(List<YearEndValuesRating> oYearEndValuesRatings,
|
|||
|
List<YearEndValueDetailsRating> oYearEndValueDetailsRatings, ObjectiveSetRemarks oObjectiveSetRemark,
|
|||
|
List<Objective> oObjective, List<DevelopmentPlan> oDevelopmentPlan, YearEndRecomendation oRecomendation,
|
|||
|
ObjectiveSet oObjectiveSet)
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
foreach (YearEndValuesRating item in oYearEndValuesRatings)
|
|||
|
{
|
|||
|
if (item.IsNew)
|
|||
|
{
|
|||
|
int id = tc.GenerateID("YearEndValuesRating", "YearEndValuesRatingID");
|
|||
|
base.SetObjectID(item, (id));
|
|||
|
YearEndValuesRatingDA.Save(tc, item);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
YearEndValuesRatingDA.Update(tc, item);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
foreach (YearEndValueDetailsRating item in oYearEndValueDetailsRatings)
|
|||
|
{
|
|||
|
if (item.IsNew)
|
|||
|
{
|
|||
|
int id = tc.GenerateID("YearEndValueDetailsRating", "YearEndValueDetailsRatingID");
|
|||
|
base.SetObjectID(item, (id));
|
|||
|
YearEndValueDetailsRatingDA.Save(tc, item);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
YearEndValueDetailsRatingDA.Update(tc, item);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
foreach (Objective item in oObjective)
|
|||
|
{
|
|||
|
if (item.IsNew)
|
|||
|
{
|
|||
|
int id = tc.GenerateID("Objective", "ObjectiveID");
|
|||
|
base.SetObjectID(item, (id));
|
|||
|
ObjectiveDA.Insert(tc, item);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
ObjectiveDA.Update(tc, item);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
foreach (DevelopmentPlan item in oDevelopmentPlan)
|
|||
|
{
|
|||
|
if (item.IsNew)
|
|||
|
{
|
|||
|
int id = tc.GenerateID("DevelopmentPlan", "DevelopmentPlanID");
|
|||
|
base.SetObjectID(item, (id));
|
|||
|
//DevelopmentPlanDA.Insert(tc, item);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
//DevelopmentPlanDA.Update(tc, item);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
if (oRecomendation != null)
|
|||
|
{
|
|||
|
if (oRecomendation.IsNew)
|
|||
|
{
|
|||
|
int id = tc.GenerateID("YearEndRecomendation", "YearEndRecomendationID");
|
|||
|
base.SetObjectID(oRecomendation, (id));
|
|||
|
YearEndRecomendationDA.Insert(tc, oRecomendation);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
YearEndRecomendationDA.Update(tc, oRecomendation);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
if (oObjectiveSetRemark.IsNew)
|
|||
|
{
|
|||
|
int id = tc.GenerateID("ObjectiveSetRemarks", "ObjectiveSetRemarksID");
|
|||
|
base.SetObjectID(oObjectiveSetRemark, (id));
|
|||
|
ObjectiveSetRemarksDA.Save(tc, oObjectiveSetRemark);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
ObjectiveSetRemarksDA.Update(tc, oObjectiveSetRemark);
|
|||
|
}
|
|||
|
|
|||
|
if (oObjectiveSet.IsNew)
|
|||
|
{
|
|||
|
int id = tc.GenerateID("ObjectiveSet", "ObjectiveSetID");
|
|||
|
base.SetObjectID(oObjectiveSet, (id));
|
|||
|
ObjectiveSetDA.Save(tc, oObjectiveSet);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
ObjectiveSetDA.Update(tc, oObjectiveSet);
|
|||
|
}
|
|||
|
|
|||
|
tc.End();
|
|||
|
}
|
|||
|
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);
|
|||
|
YearEndValuesRatingDA.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
|
|||
|
}
|
|||
|
}
|