231 lines
6.6 KiB
C#
231 lines
6.6 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 HRM.DA;
|
|||
|
|
|||
|
|
|||
|
namespace HRM.DA
|
|||
|
{
|
|||
|
public class SurveyOrganizationService : ServiceTemplate, ISurveyOrganizationService
|
|||
|
{
|
|||
|
public SurveyOrganizationService()
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
private void MapObject(SurveyOrganization oSurveyOrganization, DataReader oReader)
|
|||
|
{
|
|||
|
//base.SetObjectID(oSurveyOrganization, oReader.GetID("SurveyOrganizationID"));
|
|||
|
oSurveyOrganization.SurveyID = oReader.GetInt32("SurveyID", 0);
|
|||
|
oSurveyOrganization.GradeID = oReader.GetInt32("GradeID", 0);
|
|||
|
oSurveyOrganization.CompanyID = oReader.GetInt32("CompanyID", 0);
|
|||
|
oSurveyOrganization.DepartmentID = oReader.GetInt32("DepartmentID", 0);
|
|||
|
oSurveyOrganization.LocationID = oReader.GetInt32("LocationID", 0);
|
|||
|
this.SetObjectState(oSurveyOrganization, Ease.Core.ObjectState.Saved);
|
|||
|
}
|
|||
|
|
|||
|
protected override T CreateObject<T>(DataReader oReader)
|
|||
|
{
|
|||
|
SurveyOrganization oSurveyOrganization = new SurveyOrganization();
|
|||
|
MapObject(oSurveyOrganization, oReader);
|
|||
|
return oSurveyOrganization as T;
|
|||
|
}
|
|||
|
|
|||
|
protected SurveyOrganization CreateObject(DataReader oReader)
|
|||
|
{
|
|||
|
SurveyOrganization oSurveyOrganization = new SurveyOrganization();
|
|||
|
MapObject(oSurveyOrganization, oReader);
|
|||
|
return oSurveyOrganization;
|
|||
|
}
|
|||
|
|
|||
|
#region Service implementation
|
|||
|
|
|||
|
public List<SurveyOrganization> GetSurveyOrganization(int surveyId)
|
|||
|
{
|
|||
|
List<SurveyOrganization> oSurveyOrganizations = null;
|
|||
|
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader dr = new DataReader(SurveyOrganizationDA.GetSurveyOrganization(tc, surveyId));
|
|||
|
oSurveyOrganizations = this.CreateObjects<SurveyOrganization>(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 oSurveyOrganizations;
|
|||
|
}
|
|||
|
|
|||
|
public SurveyOrganization Get(int id)
|
|||
|
{
|
|||
|
SurveyOrganization oSurveyOrganization = null;
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader oreader = new DataReader(SurveyOrganizationDA.Get(tc, id));
|
|||
|
if (oreader.Read())
|
|||
|
{
|
|||
|
oSurveyOrganization = this.CreateObject<SurveyOrganization>(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 oSurveyOrganization;
|
|||
|
}
|
|||
|
|
|||
|
public List<SurveyOrganization> Get()
|
|||
|
{
|
|||
|
List<SurveyOrganization> SurveyOrganizations = null;
|
|||
|
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
|
|||
|
DataReader dr = new DataReader(SurveyOrganizationDA.Get(tc));
|
|||
|
SurveyOrganizations = this.CreateObjects<SurveyOrganization>(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 SurveyOrganizations;
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
public List<SurveyOrganization> Get(EnumStatus status)
|
|||
|
{
|
|||
|
List<SurveyOrganization> SurveyOrganizations = null;
|
|||
|
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
|
|||
|
DataReader dr = new DataReader(SurveyOrganizationDA.Get(tc, status));
|
|||
|
SurveyOrganizations = this.CreateObjects<SurveyOrganization>(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 SurveyOrganizations;
|
|||
|
}
|
|||
|
|
|||
|
public int Save(SurveyOrganization oSurveyOrganization)
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
|
|||
|
if (oSurveyOrganization.IsNew)
|
|||
|
{
|
|||
|
//int id = tc.GenerateID("SurveyOrganization", "SurveyOrganizationID");
|
|||
|
//base.SetObjectID(oSurveyOrganization, (id));
|
|||
|
|
|||
|
|
|||
|
SurveyOrganizationDA.Insert(tc, oSurveyOrganization);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
SurveyOrganizationDA.Update(tc, oSurveyOrganization);
|
|||
|
}
|
|||
|
|
|||
|
tc.End();
|
|||
|
return oSurveyOrganization.SurveyID;
|
|||
|
}
|
|||
|
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);
|
|||
|
SurveyOrganizationDA.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
|
|||
|
}
|
|||
|
}
|