263 lines
7.6 KiB
C#
263 lines
7.6 KiB
C#
|
using System;
|
|||
|
using Ease.Core.Model;
|
|||
|
using Ease.Core.DataAccess;
|
|||
|
using HRM.BO;
|
|||
|
using Ease.Core.Utility;
|
|||
|
using System.Collections.Generic;
|
|||
|
|
|||
|
namespace HRM.DA
|
|||
|
{
|
|||
|
public class NominationPurposeService : ServiceTemplate, INominationPurposeService
|
|||
|
{
|
|||
|
#region constructor
|
|||
|
|
|||
|
public NominationPurposeService()
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Object
|
|||
|
|
|||
|
private void MapObject(NominationPurpose oNominationPurpose, DataReader oReader)
|
|||
|
{
|
|||
|
base.SetObjectID(oNominationPurpose, oReader.GetInt32("NOMINATIONPURPOSEID").Value);
|
|||
|
oNominationPurpose.Code = oReader.GetString("CODE");
|
|||
|
oNominationPurpose.Description = oReader.GetString("DESCRIPTION");
|
|||
|
oNominationPurpose.Sequence = oReader.GetInt32("SequenceNo").Value;
|
|||
|
oNominationPurpose.Status = (EnumStatus)oReader.GetInt32("Status").Value;
|
|||
|
oNominationPurpose.CreatedBy = oReader.GetInt32("CreatedBy", 0);
|
|||
|
oNominationPurpose.CreatedDate = oReader.GetDateTime("CreationDate").Value;
|
|||
|
oNominationPurpose.ModifiedBy = oReader.GetInt32("ModifiedBy", 0);
|
|||
|
oNominationPurpose.ModifiedDate = oReader.GetDateTime("ModifiedDate");
|
|||
|
|
|||
|
this.SetObjectState(oNominationPurpose, Ease.Core.ObjectState.Saved);
|
|||
|
}
|
|||
|
|
|||
|
protected override T CreateObject<T>(DataReader oReader)
|
|||
|
{
|
|||
|
NominationPurpose oNominationPurpose = new NominationPurpose();
|
|||
|
MapObject(oNominationPurpose, oReader);
|
|||
|
return oNominationPurpose as T;
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Service implementation
|
|||
|
|
|||
|
public NominationPurpose Get(int id)
|
|||
|
{
|
|||
|
NominationPurpose oNominationPurpose = null;
|
|||
|
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader oreader = new DataReader(NominationPurposeDA.Get(tc, id));
|
|||
|
if (oreader.Read())
|
|||
|
{
|
|||
|
oNominationPurpose = this.CreateObject<NominationPurpose>(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 oNominationPurpose;
|
|||
|
}
|
|||
|
|
|||
|
public NominationPurpose Get(string sCode)
|
|||
|
{
|
|||
|
NominationPurpose oNominationPurpose = null;
|
|||
|
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader oreader = new DataReader(NominationPurposeDA.Get(tc, sCode));
|
|||
|
if (oreader.Read())
|
|||
|
{
|
|||
|
oNominationPurpose = this.CreateObject<NominationPurpose>(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 oNominationPurpose;
|
|||
|
}
|
|||
|
|
|||
|
public List<NominationPurpose> Get()
|
|||
|
{
|
|||
|
List<NominationPurpose> nominationPurposes = new List<NominationPurpose>();
|
|||
|
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
|
|||
|
DataReader dr = new DataReader(NominationPurposeDA.Get(tc));
|
|||
|
nominationPurposes = this.CreateObjects<NominationPurpose>(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 nominationPurposes;
|
|||
|
}
|
|||
|
|
|||
|
public List<NominationPurpose> Get(EnumStatus status)
|
|||
|
{
|
|||
|
List<NominationPurpose> nominationPurposes = new List<NominationPurpose>();
|
|||
|
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
|
|||
|
DataReader dr = new DataReader(NominationPurposeDA.Get(tc, status));
|
|||
|
nominationPurposes = this.CreateObjects<NominationPurpose>(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 nominationPurposes;
|
|||
|
}
|
|||
|
public List<NominationPurpose> GetListbyId(int id)
|
|||
|
{
|
|||
|
List<NominationPurpose> nominationPurposes = new List<NominationPurpose>();
|
|||
|
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
|
|||
|
DataReader dr = new DataReader(NominationPurposeDA.Get(tc, id));
|
|||
|
nominationPurposes = this.CreateObjects<NominationPurpose>(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 nominationPurposes;
|
|||
|
}
|
|||
|
|
|||
|
public int Save(NominationPurpose oNominationPurpose)
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
if (oNominationPurpose.IsNew)
|
|||
|
{
|
|||
|
int id = tc.GenerateID("NOMINATIONPURPOSE", "NOMINATIONPURPOSEID");
|
|||
|
base.SetObjectID(oNominationPurpose, id);
|
|||
|
if (oNominationPurpose.Code == "")
|
|||
|
oNominationPurpose.Code = oNominationPurpose.ID.ToString();
|
|||
|
NominationPurposeDA.Insert(tc, oNominationPurpose);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
NominationPurposeDA.Update(tc, oNominationPurpose);
|
|||
|
}
|
|||
|
|
|||
|
tc.End();
|
|||
|
return oNominationPurpose.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);
|
|||
|
NominationPurposeDA.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
|
|||
|
}
|
|||
|
}
|