183 lines
5.0 KiB
C#
183 lines
5.0 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;
|
|||
|
|
|||
|
namespace HRM.DA
|
|||
|
{
|
|||
|
#region EmpDirectorList Service
|
|||
|
|
|||
|
public class EmpDirectorListService : ServiceTemplate, IEmpDirectorListService
|
|||
|
{
|
|||
|
public EmpDirectorListService()
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
private void MapObject(EmpDirectorList oEmpDirectorList, DataReader oReader)
|
|||
|
{
|
|||
|
base.SetObjectID(oEmpDirectorList, oReader.GetInt32("EmpDirectorListID", 0));
|
|||
|
oEmpDirectorList.EmployeeNo = oReader.GetString("EmployeeNo");
|
|||
|
oEmpDirectorList.DirectorNo = oReader.GetString("DirectorNo");
|
|||
|
this.SetObjectState(oEmpDirectorList, Ease.Core.ObjectState.Saved);
|
|||
|
}
|
|||
|
|
|||
|
protected override T CreateObject<T>(DataReader oReader)
|
|||
|
{
|
|||
|
EmpDirectorList oEmpDirectorList = new EmpDirectorList();
|
|||
|
MapObject(oEmpDirectorList, oReader);
|
|||
|
return oEmpDirectorList as T;
|
|||
|
}
|
|||
|
|
|||
|
protected EmpDirectorList CreateObject(DataReader oReader)
|
|||
|
{
|
|||
|
EmpDirectorList oEmpDirectorList = new EmpDirectorList();
|
|||
|
MapObject(oEmpDirectorList, oReader);
|
|||
|
return oEmpDirectorList;
|
|||
|
}
|
|||
|
|
|||
|
#region Service implementation
|
|||
|
|
|||
|
public List<EmpDirectorList> Get()
|
|||
|
{
|
|||
|
List<EmpDirectorList> EmpDirectorLists = new List<EmpDirectorList>();
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader dr = new DataReader(EmpDirectorListDA.Get(tc));
|
|||
|
EmpDirectorLists = this.CreateObjects<EmpDirectorList>(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 EmpDirectorLists;
|
|||
|
}
|
|||
|
|
|||
|
public List<EmpDirectorList> Get(string sEmpNo)
|
|||
|
{
|
|||
|
List<EmpDirectorList> EmpDirectorLists = new List<EmpDirectorList>();
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
|
|||
|
DataReader dr = new DataReader(EmpDirectorListDA.Get(tc, sEmpNo));
|
|||
|
EmpDirectorLists = this.CreateObjects<EmpDirectorList>(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 EmpDirectorLists;
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
public void Save(EmpDirectorList oLists)
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
|
|||
|
if (oLists.IsNew)
|
|||
|
{
|
|||
|
int id = tc.GenerateID("EmpDirectorList", "EmpDirectorListID");
|
|||
|
base.SetObjectID(oLists, (id));
|
|||
|
EmpDirectorListDA.Insert(tc, oLists);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
EmpDirectorListDA.Update(tc, oLists);
|
|||
|
}
|
|||
|
|
|||
|
tc.End();
|
|||
|
}
|
|||
|
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);
|
|||
|
EmpDirectorListDA.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
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void Delete(string sEmpNo)
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
EmpDirectorListDA.Delete(tc, sEmpNo);
|
|||
|
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
|
|||
|
}
|