221 lines
6.7 KiB
C#
221 lines
6.7 KiB
C#
|
using Ease.Core.DataAccess;
|
|||
|
using Ease.Core.Model;
|
|||
|
using Ease.Core.Utility;
|
|||
|
using HRM.BO;
|
|||
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Linq;
|
|||
|
using System.Text;
|
|||
|
using System.Threading.Tasks;
|
|||
|
|
|||
|
namespace HRM.DA
|
|||
|
{
|
|||
|
public class JVSetupGradeService : ServiceTemplate, IJVSetupGradeService
|
|||
|
{
|
|||
|
#region Private functions and declaration
|
|||
|
|
|||
|
public JVSetupGradeService()
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
private void MapObject(JVSetupGrade oJVSetupGrade, DataReader oReader)
|
|||
|
{
|
|||
|
base.SetObjectID(oJVSetupGrade, oReader.GetInt32("JVSetupGradeID").Value);
|
|||
|
oJVSetupGrade.GradeID = oReader.GetString("GradeID") == null ? 0 : oReader.GetInt32("GradeID").Value;
|
|||
|
oJVSetupGrade.JVSetupID = oReader.GetString("JVSetupID") == null ? 0 : oReader.GetInt32("JVSetupID").Value;
|
|||
|
oJVSetupGrade.CreatedBy = oReader.GetString("CreatedBy") == null ? 0 : oReader.GetInt32("CreatedBy").Value;
|
|||
|
oJVSetupGrade.CreatedDate = oReader.GetDateTime("CreationDate").Value;
|
|||
|
oJVSetupGrade.ModifiedBy = oReader.GetString("ModifiedBy") == null ? 0 : oReader.GetInt32("ModifiedBy").Value;
|
|||
|
oJVSetupGrade.ModifiedDate = oReader.GetDateTime("ModifiedDate");
|
|||
|
this.SetObjectState(oJVSetupGrade, Ease.Core.ObjectState.Saved);
|
|||
|
}
|
|||
|
|
|||
|
protected override T CreateObject<T>(DataReader oReader)
|
|||
|
{
|
|||
|
JVSetupGrade oJVSetupGrade = new JVSetupGrade();
|
|||
|
MapObject(oJVSetupGrade, oReader);
|
|||
|
return oJVSetupGrade as T;
|
|||
|
}
|
|||
|
|
|||
|
protected JVSetupGrade CreateObject(DataReader oReader)
|
|||
|
{
|
|||
|
JVSetupGrade oJVSetupGrade = new JVSetupGrade();
|
|||
|
MapObject(oJVSetupGrade, oReader);
|
|||
|
return oJVSetupGrade;
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Service implementation
|
|||
|
|
|||
|
public JVSetupGrade Get(int id)
|
|||
|
{
|
|||
|
JVSetupGrade oJVSetupDetail = new JVSetupGrade();
|
|||
|
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader oreader = new DataReader(JVSetupGradeDA.Get(tc, id));
|
|||
|
if (oreader.Read())
|
|||
|
{
|
|||
|
oJVSetupDetail = this.CreateObject<JVSetupGrade>(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 oJVSetupDetail;
|
|||
|
}
|
|||
|
|
|||
|
public List<JVSetupGrade> Get()
|
|||
|
{
|
|||
|
List<JVSetupGrade> oJVSetupDetails = new List<JVSetupGrade>();
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader oreader = new DataReader(JVSetupGradeDA.Get(tc));
|
|||
|
oJVSetupDetails = this.CreateObjects<JVSetupGrade>(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 oJVSetupDetails;
|
|||
|
}
|
|||
|
public List<JVSetupGrade> GetLatestSetupByJVType(int payrolltypeid, int jvtypeid)
|
|||
|
{
|
|||
|
List<JVSetupGrade> JVSetupDetails = new List<JVSetupGrade>();
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader dr = new DataReader(JVSetupGradeDA.GetLatestSetupByJVType(tc, payrolltypeid, jvtypeid));
|
|||
|
JVSetupDetails = this.CreateObjects<JVSetupGrade>(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 JVSetupDetails;
|
|||
|
}
|
|||
|
public List<JVSetupGrade> GetByJVSetup(int JVSetupID)
|
|||
|
{
|
|||
|
List<JVSetupGrade> JVSetupDetails = new List<JVSetupGrade>();
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader dr = new DataReader(JVSetupGradeDA.GetByJVSetup(tc, JVSetupID));
|
|||
|
JVSetupDetails = this.CreateObjects<JVSetupGrade>(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 JVSetupDetails;
|
|||
|
}
|
|||
|
|
|||
|
public int Save(JVSetupGrade oJVSetupGrade)
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
if (oJVSetupGrade.IsNew)
|
|||
|
{
|
|||
|
int id = tc.GenerateID("JVSetupGrade", "JVSetupGradeID");
|
|||
|
base.SetObjectID(oJVSetupGrade, id);
|
|||
|
JVSetupGradeDA.Insert(tc, oJVSetupGrade);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
JVSetupGradeDA.Update(tc, oJVSetupGrade);
|
|||
|
}
|
|||
|
|
|||
|
tc.End();
|
|||
|
|
|||
|
return oJVSetupGrade.ID;
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException("Failed to GetJVSetupDetail", e);
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void Delete(int id)
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
JVSetupGradeDA.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
|
|||
|
}
|
|||
|
}
|