156 lines
5.1 KiB
C#
156 lines
5.1 KiB
C#
|
using System;
|
|||
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Linq;
|
|||
|
using System.Text;
|
|||
|
using Ease.CoreV35.Model;
|
|||
|
using Ease.CoreV35.DataAccess;
|
|||
|
using Ease.CoreV35;
|
|||
|
using Payroll.BO;
|
|||
|
|
|||
|
namespace Payroll.Service
|
|||
|
{
|
|||
|
public class PMPValueBehaviorService : ServiceTemplate, IPMPValueBehaviorService
|
|||
|
{
|
|||
|
#region Object Mapping
|
|||
|
|
|||
|
private void MapObject(PMPValueBehavior oPMPValueBehavior, DataReader oReader)
|
|||
|
{
|
|||
|
SetObjectID(oPMPValueBehavior, oReader.GetID("PMPValueBehaviorID"));
|
|||
|
oPMPValueBehavior.Name = oReader.GetString("Name");
|
|||
|
oPMPValueBehavior.CreatedBy = oReader.GetID("CreatedBy");
|
|||
|
oPMPValueBehavior.CreatedDate = oReader.GetDateTime("CreatedDate").Value;
|
|||
|
oPMPValueBehavior.ModifiedBy = oReader.GetID("ModifiedBy") == null ? null : oReader.GetID("ModifiedBy");
|
|||
|
oPMPValueBehavior.ModifiedDate = oReader.GetDateTime("ModifiedDate") == null ? null : oReader.GetDateTime("ModifiedDate");
|
|||
|
oPMPValueBehavior.Status = (EnumStatus)oReader.GetInt32("Status").Value;
|
|||
|
oPMPValueBehavior.Sequence = oReader.GetInt32("Sequence").Value;
|
|||
|
this.SetObjectState(oPMPValueBehavior, ObjectState.Saved);
|
|||
|
}
|
|||
|
|
|||
|
protected override T CreateObject<T>(DataReader oReader)
|
|||
|
{
|
|||
|
PMPValueBehavior oPMPValueBehavior = new PMPValueBehavior();
|
|||
|
MapObject(oPMPValueBehavior, oReader);
|
|||
|
return oPMPValueBehavior as T;
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Service Implementation
|
|||
|
|
|||
|
#region Get By Status
|
|||
|
public ObjectsTemplate<PMPValueBehavior> Get(EnumStatus status)
|
|||
|
{
|
|||
|
ObjectsTemplate<PMPValueBehavior> oPMPValueBehaviors = null;
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader oreader = new DataReader(PMPValueBehaviorDA.Get(tc, status));
|
|||
|
oPMPValueBehaviors = this.CreateObjects<PMPValueBehavior>(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 oPMPValueBehaviors;
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Get By ID
|
|||
|
public PMPValueBehavior Get(ID id)
|
|||
|
{
|
|||
|
ObjectsTemplate<PMPValueBehavior> oPMPValueBehaviors = null;
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader oreader = new DataReader(PMPValueBehaviorDA.Get(tc, id));
|
|||
|
oPMPValueBehaviors = this.CreateObjects<PMPValueBehavior>(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
|
|||
|
}
|
|||
|
if (oPMPValueBehaviors.Count == 1) return oPMPValueBehaviors[0];
|
|||
|
else return null;
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
#endregion
|
|||
|
#region Save
|
|||
|
public ID Save(PMPValueBehavior item)
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
if (item.IsNew)
|
|||
|
{
|
|||
|
int id = tc.GenerateID("PMP_ValueBehavior", "PMPValueBehaviorID");
|
|||
|
int sequenceNo = tc.GenerateID("PMP_ValueBehavior", "Sequence");
|
|||
|
item.Sequence = sequenceNo;
|
|||
|
base.SetObjectID(item, ID.FromInteger(id));
|
|||
|
PMPValueBehaviorDA.Insert(tc, item);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
PMPValueBehaviorDA.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(ID id)
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
PMPValueBehaviorDA.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
|
|||
|
}
|
|||
|
}
|