235 lines
7.1 KiB
C#
235 lines
7.1 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
|
|
{
|
|
#region class ExtraCurricularActivityService
|
|
|
|
public class ExtraCurricularActivityService : ServiceTemplate, IExtraCurricularActivityService
|
|
{
|
|
#region constructor
|
|
|
|
public ExtraCurricularActivityService()
|
|
{
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Object
|
|
|
|
private void MapObject(ExtraCurricularActivity oExtraCurricularActivity, DataReader oReader)
|
|
{
|
|
base.SetObjectID(oExtraCurricularActivity, oReader.GetInt32("EXTRACURRICULARACTIVITYID").Value);
|
|
oExtraCurricularActivity.Code = oReader.GetString("CODE");
|
|
oExtraCurricularActivity.Description = oReader.GetString("DESCRIPTION");
|
|
oExtraCurricularActivity.Sequence = oReader.GetInt32("SequenceNo").Value;
|
|
oExtraCurricularActivity.Status = (EnumStatus)oReader.GetInt32("Status").Value;
|
|
oExtraCurricularActivity.CreatedBy = oReader.GetInt32("CreatedBy", 0);
|
|
oExtraCurricularActivity.CreatedDate = oReader.GetDateTime("CreationDate").Value;
|
|
oExtraCurricularActivity.ModifiedBy = oReader.GetInt32("ModifiedBy", 0);
|
|
oExtraCurricularActivity.ModifiedDate = oReader.GetDateTime("ModifiedDate");
|
|
|
|
this.SetObjectState(oExtraCurricularActivity, Ease.Core.ObjectState.Saved);
|
|
}
|
|
|
|
protected override T CreateObject<T>(DataReader oReader)
|
|
{
|
|
ExtraCurricularActivity oExtraCurricularActivity = new ExtraCurricularActivity();
|
|
MapObject(oExtraCurricularActivity, oReader);
|
|
return oExtraCurricularActivity as T;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Service implementation
|
|
|
|
public ExtraCurricularActivity Get(int id)
|
|
{
|
|
ExtraCurricularActivity oExtraCurricularActivity = null;
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader oreader = new DataReader(ExtraCurricularActivityDA.Get(tc, id));
|
|
if (oreader.Read())
|
|
{
|
|
oExtraCurricularActivity = this.CreateObject<ExtraCurricularActivity>(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 oExtraCurricularActivity;
|
|
}
|
|
|
|
public ExtraCurricularActivity Get(string sCode)
|
|
{
|
|
ExtraCurricularActivity oExtraCurricularActivity = null;
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader oreader = new DataReader(ExtraCurricularActivityDA.Get(tc, sCode));
|
|
if (oreader.Read())
|
|
{
|
|
oExtraCurricularActivity = this.CreateObject<ExtraCurricularActivity>(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 oExtraCurricularActivity;
|
|
}
|
|
|
|
public List<ExtraCurricularActivity> Get()
|
|
{
|
|
List<ExtraCurricularActivity> extraCurricularActivities = new List<ExtraCurricularActivity>();
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
|
|
DataReader dr = new DataReader(ExtraCurricularActivityDA.Get(tc));
|
|
extraCurricularActivities = this.CreateObjects<ExtraCurricularActivity>(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 extraCurricularActivities;
|
|
}
|
|
|
|
public List<ExtraCurricularActivity> Get(EnumStatus status)
|
|
{
|
|
List<ExtraCurricularActivity> extraCurricularActivities = new List<ExtraCurricularActivity>();
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
|
|
DataReader dr = new DataReader(ExtraCurricularActivityDA.Get(tc, status));
|
|
extraCurricularActivities = this.CreateObjects<ExtraCurricularActivity>(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 extraCurricularActivities;
|
|
}
|
|
|
|
public int Save(ExtraCurricularActivity oExtraCurricularActivity)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
if (oExtraCurricularActivity.IsNew)
|
|
{
|
|
int id = tc.GenerateID("EXTRACURRICULARACTIVITY", "EXTRACURRICULARACTIVITYID");
|
|
base.SetObjectID(oExtraCurricularActivity, id);
|
|
ExtraCurricularActivityDA.Insert(tc, oExtraCurricularActivity);
|
|
}
|
|
else
|
|
{
|
|
ExtraCurricularActivityDA.Update(tc, oExtraCurricularActivity);
|
|
}
|
|
|
|
tc.End();
|
|
return oExtraCurricularActivity.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);
|
|
ExtraCurricularActivityDA.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
|
|
} |