230 lines
6.3 KiB
C#
230 lines
6.3 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 DirectorList Service
|
|||
|
|
|||
|
public class DirectorListService : ServiceTemplate, IDirectorListService
|
|||
|
{
|
|||
|
#region Private functions and declaration
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
public DirectorListService()
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
private void MapObject(DirectorList oDirectorList, DataReader oReader)
|
|||
|
{
|
|||
|
//oDirectorList.ID = oReader.GetInt32("DirectorListID");
|
|||
|
base.SetObjectID(oDirectorList, oReader.GetInt32("DirectorListID", 0));
|
|||
|
oDirectorList.EmployeeNo = oReader.GetString("EmployeeNo");
|
|||
|
oDirectorList.ProjectID = oReader.GetInt32("ProjectID", 0);
|
|||
|
oDirectorList.Sequence = oReader.GetInt32("SequenceNO", 0);
|
|||
|
oDirectorList.Status = (EnumStatus)oReader.GetInt32("Status").Value;
|
|||
|
this.SetObjectState(oDirectorList, Ease.Core.ObjectState.Saved);
|
|||
|
}
|
|||
|
|
|||
|
protected override T CreateObject<T>(DataReader oReader)
|
|||
|
{
|
|||
|
DirectorList oDirectorList = new DirectorList();
|
|||
|
MapObject(oDirectorList, oReader);
|
|||
|
return oDirectorList as T;
|
|||
|
}
|
|||
|
|
|||
|
protected DirectorList CreateObject(DataReader oReader)
|
|||
|
{
|
|||
|
DirectorList oDirectorList = new DirectorList();
|
|||
|
MapObject(oDirectorList, oReader);
|
|||
|
return oDirectorList;
|
|||
|
}
|
|||
|
|
|||
|
#region Service implementation
|
|||
|
|
|||
|
public List<DirectorList> Get()
|
|||
|
{
|
|||
|
List<DirectorList> DirectorLists = null;
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader dr = new DataReader(DirectorListDA.Get(tc));
|
|||
|
DirectorLists = this.CreateObjects<DirectorList>(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 DirectorLists;
|
|||
|
}
|
|||
|
|
|||
|
public List<DirectorList> Get(EnumStatus status)
|
|||
|
{
|
|||
|
List<DirectorList> DirectorLists = null;
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
|
|||
|
DataReader dr = new DataReader(DirectorListDA.Get(tc, status));
|
|||
|
DirectorLists = this.CreateObjects<DirectorList>(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 DirectorLists;
|
|||
|
}
|
|||
|
|
|||
|
public List<DirectorList> Get(string sEmpNo)
|
|||
|
{
|
|||
|
List<DirectorList> DirectorLists = null;
|
|||
|
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
|
|||
|
DataReader dr = new DataReader(DirectorListDA.Get(tc, sEmpNo));
|
|||
|
DirectorLists = this.CreateObjects<DirectorList>(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 DirectorLists;
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
public void Save(List<DirectorList> oLists)
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
//if (oDirectorList.IsNew)
|
|||
|
//{
|
|||
|
if (oLists != null && oLists.Count > 0)
|
|||
|
DirectorListDA.Delete(tc, oLists[0].EmployeeNo);
|
|||
|
foreach (DirectorList oDirectorList in oLists)
|
|||
|
{
|
|||
|
int id = tc.GenerateID("DirectorList", "DirectorListID");
|
|||
|
base.SetObjectID(oDirectorList, (id));
|
|||
|
int seqNo = tc.GenerateID("DirectorList", "SequenceNO");
|
|||
|
oDirectorList.Sequence = seqNo;
|
|||
|
DirectorListDA.Insert(tc, oDirectorList);
|
|||
|
}
|
|||
|
|
|||
|
//}
|
|||
|
//else
|
|||
|
//{
|
|||
|
// DirectorListDA.Update(tc, oDirectorList);
|
|||
|
//}
|
|||
|
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);
|
|||
|
DirectorListDA.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);
|
|||
|
DirectorListDA.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
|
|||
|
}
|