324 lines
11 KiB
C#
324 lines
11 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
|
|
{
|
|
public class YearEndRecomendationService : ServiceTemplate
|
|
{
|
|
#region Object Mapping
|
|
|
|
private void MapObject(YearEndRecomendation oYearEndRecomendation, DataReader oReader)
|
|
{
|
|
SetObjectID(oYearEndRecomendation, oReader.GetInt32("YearEndRecomendationID", 0));
|
|
oYearEndRecomendation.ObjectiveSetID = oReader.GetInt32("ObjectiveSetID", 0);
|
|
oYearEndRecomendation.TransferLocID = oReader.GetInt32("TransferLocID", 0);
|
|
oYearEndRecomendation.PromotionLevelID = oReader.GetInt32("PromotionLevelID", 0);
|
|
oYearEndRecomendation.Confirmation = oReader.GetBoolean("Confirmation").GetValueOrDefault();
|
|
oYearEndRecomendation.PromotionLevelRemarks = oReader.GetString("PromotionLevelRemarks");
|
|
oYearEndRecomendation.TechnicalAllowance = oReader.GetDouble("TechnicalAllowance").GetValueOrDefault();
|
|
oYearEndRecomendation.PerformanceAllowance = oReader.GetDouble("PerformanceAllowance").GetValueOrDefault();
|
|
oYearEndRecomendation.SpecialAllowance = oReader.GetDouble("SpecialAllowance").GetValueOrDefault();
|
|
oYearEndRecomendation.OthersAllowance = oReader.GetDouble("OthersAllowance").GetValueOrDefault();
|
|
oYearEndRecomendation.ContractRenewalDuration = oReader.GetString("ContractRenewalDuration");
|
|
oYearEndRecomendation.OthersDetail = oReader.GetString("OthersDetail");
|
|
|
|
oYearEndRecomendation.ConfirmationLevelID = oReader.GetInt32("ConfirmationLevelID", 0);
|
|
oYearEndRecomendation.RecomendationBy = oReader.GetInt32("RecomendationBy", 0);
|
|
oYearEndRecomendation.RecomendationDate = oReader.GetDateTime("RecomendationDate").Value == null
|
|
? DateTime.MinValue
|
|
: oReader.GetDateTime("RecomendationDate").Value;
|
|
|
|
oYearEndRecomendation.RecomendationLevel =
|
|
(EnumRecomendationLevel)oReader.GetInt32("RecomendationLevel").GetValueOrDefault();
|
|
oYearEndRecomendation.RecomendationByNodeID = oReader.GetInt32("RecomendationByNodeID", 0);
|
|
oYearEndRecomendation.ConfirmationDesignationID = oReader.GetInt32("ConfirmationDesignationID", 0);
|
|
oYearEndRecomendation.PromotionDesignationID = oReader.GetInt32("PromotionDesignationID", 0);
|
|
oYearEndRecomendation.TransferLocation = oReader.GetString("TransferLocation");
|
|
oYearEndRecomendation.RecomendationType =
|
|
(EnumRecommendationType)oReader.GetInt32("RecomendationType").GetValueOrDefault();
|
|
this.SetObjectState(oYearEndRecomendation, ObjectState.Saved);
|
|
}
|
|
|
|
|
|
protected override T CreateObject<T>(DataReader oReader)
|
|
{
|
|
YearEndRecomendation oYearEndRecomendation = new YearEndRecomendation();
|
|
MapObject(oYearEndRecomendation, oReader);
|
|
return oYearEndRecomendation as T;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region IYearEndRecomendationService Members
|
|
|
|
#region Get All
|
|
|
|
public List<YearEndRecomendation> Get()
|
|
{
|
|
List<YearEndRecomendation> oYearEndRecomendation = null;
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader oreader = new DataReader(YearEndRecomendationDA.Get(tc));
|
|
oYearEndRecomendation = this.CreateObjects<YearEndRecomendation>(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 oYearEndRecomendation;
|
|
}
|
|
|
|
public List<YearEndRecomendation> Get(int PMPID, EnumRecomendationLevel recomLevel)
|
|
{
|
|
List<YearEndRecomendation> oYearEndRecomendation = null;
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader oreader = new DataReader(YearEndRecomendationDA.Get(tc, PMPID, recomLevel));
|
|
oYearEndRecomendation = this.CreateObjects<YearEndRecomendation>(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 oYearEndRecomendation;
|
|
}
|
|
|
|
public List<YearEndRecomendation> GetByObjectiveSetID(int ObjectiveSetID)
|
|
{
|
|
List<YearEndRecomendation> oYearEndRecomendation = null;
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader oreader = new DataReader(YearEndRecomendationDA.GetYearEndRecomendation(tc, ObjectiveSetID));
|
|
oYearEndRecomendation = this.CreateObjects<YearEndRecomendation>(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 oYearEndRecomendation;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Get By ID
|
|
|
|
public YearEndRecomendation Get(int id)
|
|
{
|
|
YearEndRecomendation oYearEndRecomendation = null;
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader oreader = new DataReader(YearEndRecomendationDA.Get(tc, id));
|
|
oYearEndRecomendation = this.CreateObject<YearEndRecomendation>(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 oYearEndRecomendation;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Insert
|
|
|
|
public int Save(YearEndRecomendation item)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
if (item.IsNew)
|
|
{
|
|
int id = tc.GenerateID("YearEndRecomendation", "YearEndRecomendationID");
|
|
base.SetObjectID(item, (id));
|
|
YearEndRecomendationDA.Insert(tc, item);
|
|
}
|
|
else
|
|
{
|
|
YearEndRecomendationDA.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 int Save(YearEndRecomendation item, ObjectiveSet oObjectiveSet)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
if (item.IsNew)
|
|
{
|
|
int id = tc.GenerateID("YearEndRecomendation", "YearEndRecomendationID");
|
|
base.SetObjectID(item, (id));
|
|
YearEndRecomendationDA.Insert(tc, item);
|
|
}
|
|
else
|
|
{
|
|
YearEndRecomendationDA.Update(tc, item);
|
|
}
|
|
|
|
if (oObjectiveSet.IsNew)
|
|
{
|
|
int id = tc.GenerateID("ObjectiveSet", "ObjectiveSetID");
|
|
base.SetObjectID(oObjectiveSet, (id));
|
|
ObjectiveSetDA.Save(tc, oObjectiveSet);
|
|
}
|
|
else
|
|
{
|
|
ObjectiveSetDA.Update(tc, oObjectiveSet);
|
|
}
|
|
|
|
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<YearEndRecomendation> oItems)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
foreach (YearEndRecomendation item in oItems)
|
|
{
|
|
if (item.ID != 0)
|
|
{
|
|
int id = tc.GenerateID("YearEndRecomendation", "YearEndRecomendationID");
|
|
base.SetObjectID(item, (id));
|
|
YearEndRecomendationDA.Insert(tc, item);
|
|
}
|
|
else
|
|
{
|
|
YearEndRecomendationDA.Update(tc, item);
|
|
}
|
|
}
|
|
|
|
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);
|
|
YearEndRecomendationDA.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
|
|
}
|
|
} |