EchoTex_Payroll/HRM.DA/Service/Recruitement/ErCircularDetailService.cs

212 lines
6.0 KiB
C#
Raw Normal View History

2024-10-14 10:01:49 +06:00
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 System.IO;
using System.Linq;
namespace HRM.DA
{
public class ErCircularDetailService : ServiceTemplate, IErCircularDetailService
{
#region ErCircularService Object Mapping
private void MapErCricularObject(ErCircularDetail obErCircular, DataReader oReader)
{
this.SetObjectID(obErCircular, oReader.GetInt32("ERCircularDetailID").Value);
obErCircular.ColumnType = (EnumCicularColumnType)oReader.GetInt16("Column_Type");
obErCircular.Remarks = oReader.GetString("Remarks",null);
obErCircular.Description = oReader.GetString("Description", null);
obErCircular.SequenceNo = oReader.GetInt32("SequenceNo", 0);
obErCircular.ERCircularID = oReader.GetInt32("ERCircularID", 0);
this.SetObjectState(obErCircular, ObjectState.Saved);
}
protected override T CreateObject<T>(DataReader oReader)
{
ErCircularDetail obErCircular = new ErCircularDetail();
MapErCricularObject(obErCircular, oReader);
return obErCircular as T;
}
private ErCircularDetail CreateObject(DataReader oReader)
{
ErCircularDetail obErCircular = new ErCircularDetail();
MapErCricularObject(obErCircular, oReader);
return obErCircular;
}
#endregion
#region Service Implementation
#region Insert(ErCircular erCricular)
public void Save(ErCircularDetail erCricularDetail)
{
TransactionContext tc = null;
int oID = 0;
try
{
tc = TransactionContext.Begin(true);
if (erCricularDetail.IsNew)
{
int id = tc.GenerateID("ER_CircularDetail", "ERCircularDetailID");
oID = (id);
base.SetObjectID(erCricularDetail, (id));
ErCircularDetailDA.InsertErCircularDetail(erCricularDetail, tc);
}
else
{
oID = erCricularDetail.ID;
ErCircularDetailDA.UpdateErCircularDetail(erCricularDetail, tc);
}
tc.End();
}
catch (Exception ex)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(ex);
throw new ServiceException(ex.Message, ex);
#endregion
}
}
#endregion
#region GetReferredBy(int cVID)
public List<ErCircularDetail> Get()
{
List<ErCircularDetail> allRefs = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
DataReader oreader = new DataReader(ErCircularDetailDA.Get(tc));
allRefs = this.CreateObjects<ErCircularDetail>(oreader);
oreader.Close();
tc.End();
}
catch (Exception ex)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(ex);
throw new ServiceException(ex.Message, ex);
#endregion
}
return allRefs;
}
public List<ErCircularDetail> GetByParentId(int parentId)
{
List<ErCircularDetail> allRefs = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
DataReader oreader = new DataReader(ErCircularDetailDA.GetByParentID(tc, parentId));
allRefs = this.CreateObjects<ErCircularDetail>(oreader);
oreader.Close();
tc.End();
}
catch (Exception ex)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(ex);
throw new ServiceException(ex.Message, ex);
#endregion
}
return allRefs;
}
#endregion
#region Get(int cVID)
public ErCircularDetail Get(int erCircularDetailID)
{
ErCircularDetail cv = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
DataReader oreader = new DataReader(ErCircularDetailDA.Get(tc, erCircularDetailID));
if (oreader.Read())
{
cv = this.CreateObject<ErCircularDetail>(oreader);
}
oreader.Close();
tc.End();
}
catch (Exception ex)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(ex);
throw new ServiceException(ex.Message, ex);
#endregion
}
return cv;
}
#endregion
public void Delete(ErCircularDetail oErCircularDetail)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
#region Delete ErCircular
ErCircularDetailDA.Delete(oErCircularDetail.ID, tc);
#endregion
tc.End();
}
catch (Exception ex)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(ex);
throw new ServiceException(ex.Message, ex);
#endregion
}
}
#endregion
}
}