EchoTex_Payroll/HRM.DA/Service/Recruitement/ErCircularSurveyService.cs
2024-10-14 10:01:49 +06:00

266 lines
7.4 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;
using System.IO;
using System.Linq;
namespace HRM.DA
{
public class ErCircularSurveyService : ServiceTemplate, IErCircularSurveyService
{
#region ErCircularService Object Mapping
private void MapErCricularObject(ErCircularSurvey obErCircular, DataReader oReader)
{
this.SetObjectID(obErCircular, oReader.GetInt32("ERSurveyCircularID").Value);
obErCircular.SurveyID = oReader.GetInt32("SurveyID", 0);
obErCircular.ERCircularID = oReader.GetInt32("ERCircularID", 0);
this.SetObjectState(obErCircular, ObjectState.Saved);
}
protected override T CreateObject<T>(DataReader oReader)
{
ErCircularSurvey obErCircular = new ErCircularSurvey();
MapErCricularObject(obErCircular, oReader);
return obErCircular as T;
}
private ErCircularSurvey CreateObject(DataReader oReader)
{
ErCircularSurvey obErCircular = new ErCircularSurvey();
MapErCricularObject(obErCircular, oReader);
return obErCircular;
}
#endregion
#region Service Implementation
#region Insert(ErCircular erCricular)
public void Save(ErCircularSurvey erCricularDetail)
{
TransactionContext tc = null;
int oID = 0;
try
{
tc = TransactionContext.Begin(true);
if (erCricularDetail.IsNew)
{
int id = tc.GenerateID("ER_CircularSurvey", "ERSurveyCircularID");
oID = (id);
base.SetObjectID(erCricularDetail, (id));
ErCircularSurveyDA.InsertErCircularSurvey(erCricularDetail, tc);
}
else
{
oID = erCricularDetail.ID;
ErCircularSurveyDA.UpdateErCircularSurvey(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<ErCircularSurvey> Get()
{
List<ErCircularSurvey> allRefs = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
DataReader oreader = new DataReader(ErCircularSurveyDA.Get(tc));
allRefs = this.CreateObjects<ErCircularSurvey>(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<ErCircularSurvey> GetByParentId(int parentId)
{
List<ErCircularSurvey> allRefs = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
DataReader oreader = new DataReader(ErCircularSurveyDA.GetBySurveyID(tc, parentId));
allRefs = this.CreateObjects<ErCircularSurvey>(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<ErCircularSurvey> GetByCircularID(int erCricularID)
{
List<ErCircularSurvey> allRefs = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
DataReader oreader = new DataReader(ErCircularSurveyDA.GetByCircularID(tc, erCricularID));
allRefs = this.CreateObjects<ErCircularSurvey>(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<ErCircularSurvey> GetByErCircularID(int erCircularID)
{
List<ErCircularSurvey> allRefs = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
DataReader oreader = new DataReader(ErCircularSurveyDA.GetByErCircularID(tc, erCircularID));
allRefs = this.CreateObjects<ErCircularSurvey>(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 ErCircularSurvey Get(int erCircularDetailID)
{
ErCircularSurvey cv = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
DataReader oreader = new DataReader(ErCircularSurveyDA.Get(tc, erCircularDetailID));
if (oreader.Read())
{
cv = this.CreateObject<ErCircularSurvey>(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(ErCircularSurvey 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
}
}