326 lines
11 KiB
C#
326 lines
11 KiB
C#
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Linq;
|
|||
|
using System.Text;
|
|||
|
using System.Data;
|
|||
|
using HRM.BO;
|
|||
|
using Ease.Core.Model;
|
|||
|
using Ease.Core.DataAccess;
|
|||
|
using Ease.Core.Utility;
|
|||
|
|
|||
|
namespace HRM.DA
|
|||
|
{
|
|||
|
class AttnProcessRunSummaryService : ServiceTemplate
|
|||
|
{
|
|||
|
#region Map Object
|
|||
|
|
|||
|
private void MapObject(AttnProcessRunSummary oAttnProcessRunSummary, DataReader oReader)
|
|||
|
{
|
|||
|
base.SetObjectID(oAttnProcessRunSummary, oReader.GetInt32("AttnProcessRunSummeryID").Value);
|
|||
|
oAttnProcessRunSummary.ProcessDate = oReader.GetDateTime("ProcessDate").Value;
|
|||
|
oAttnProcessRunSummary.ProcessMode = (EnumProcessMode)oReader.GetInt32("ProcessMode").Value;
|
|||
|
oAttnProcessRunSummary.ProcessBy = oReader.GetInt32("ProcessBy", 0);
|
|||
|
oAttnProcessRunSummary.ProcessStatus = (EnumAttnProcessStatus)oReader.GetInt32("ProcessStatus").Value;
|
|||
|
oAttnProcessRunSummary.PayrollTypeID = oReader.GetInt32("PayrollTypeID", 0);
|
|||
|
this.SetObjectState(oAttnProcessRunSummary, Ease.Core.ObjectState.Saved);
|
|||
|
}
|
|||
|
|
|||
|
protected override T CreateObject<T>(DataReader oReader)
|
|||
|
{
|
|||
|
AttnProcessRunSummary oAttnProcessRunSummary = new AttnProcessRunSummary();
|
|||
|
MapObject(oAttnProcessRunSummary, oReader);
|
|||
|
return oAttnProcessRunSummary as T;
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Child Object Mapping
|
|||
|
|
|||
|
private List<AttnProcessRunDetail> CreateAttnProcessRunDetails(DataReader oReader)
|
|||
|
{
|
|||
|
List<AttnProcessRunDetail> oAttnProcessRunDetails = new List<AttnProcessRunDetail>();
|
|||
|
while (oReader.Read())
|
|||
|
{
|
|||
|
AttnProcessRunDetail oAttnProcessRunDetail = new AttnProcessRunDetail();
|
|||
|
MapAttnProcessRunDetailObject(oAttnProcessRunDetail, oReader);
|
|||
|
oAttnProcessRunDetails.Add(oAttnProcessRunDetail);
|
|||
|
}
|
|||
|
|
|||
|
return oAttnProcessRunDetails;
|
|||
|
}
|
|||
|
|
|||
|
private void MapAttnProcessRunDetailObject(AttnProcessRunDetail oAttnProcessRunDetail, DataReader oReader)
|
|||
|
{
|
|||
|
base.SetObjectID(oAttnProcessRunDetail, oReader.GetInt32("AttnProcessRunDetailID").Value);
|
|||
|
oAttnProcessRunDetail.ProcessSummaryID = oReader.GetInt32("AttnProcessSummaryID", 0);
|
|||
|
oAttnProcessRunDetail.EnumErrorType = (EnumErrorType)oReader.GetInt32("ErrorType").Value;
|
|||
|
oAttnProcessRunDetail.EmployeeNo = oReader.GetString("EmployeeNo");
|
|||
|
oAttnProcessRunDetail.EmployeeName = oReader.GetString("EmployeeName");
|
|||
|
oAttnProcessRunDetail.Description = oReader.GetString("Description");
|
|||
|
oAttnProcessRunDetail.LocationID = oReader.GetInt32("LocationID", 0);
|
|||
|
this.SetObjectState(oAttnProcessRunDetail, Ease.Core.ObjectState.Saved);
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region IAttnProcessRunSummaryService Members
|
|||
|
|
|||
|
#region Insert
|
|||
|
|
|||
|
public int Save(AttnProcessRunSummary oAttnProcessRunSummary, int payrollTypeID)
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
|
|||
|
if (oAttnProcessRunSummary.IsNew)
|
|||
|
{
|
|||
|
int id = tc.GenerateID("AttnProcessRunSummary", "AttnProcessRunSummeryID");
|
|||
|
base.SetObjectID(oAttnProcessRunSummary, id);
|
|||
|
AttnProcessRunSummaryDA.Insert(tc, oAttnProcessRunSummary, payrollTypeID);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
AttnProcessRunSummaryDA.Update(tc, oAttnProcessRunSummary);
|
|||
|
|
|||
|
#region Delete Childs
|
|||
|
|
|||
|
AttnProcessRunSummaryDA.DeleteAttnProcessRunDetails(tc, oAttnProcessRunSummary.ID);
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
|
|||
|
#region Insert Childs
|
|||
|
|
|||
|
foreach (AttnProcessRunDetail item in oAttnProcessRunSummary.AttnProcessRunDetails)
|
|||
|
{
|
|||
|
item.ProcessSummaryID = oAttnProcessRunSummary.ID;
|
|||
|
base.SetObjectID(item, tc.GenerateID("AttnProcessRunDetail", "AttnProcessRunDetailID"));
|
|||
|
AttnProcessRunSummaryDA.InsertAttnProcessRunDetail(tc, item);
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
tc.End();
|
|||
|
return oAttnProcessRunSummary.ID;
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public int Save(AttnProcessRunSummary oAttnProcessRunSummary, int payrollTypeID, TransactionContext tc)
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
if (oAttnProcessRunSummary.IsNew)
|
|||
|
{
|
|||
|
int id = tc.GenerateID("AttnProcessRunSummary", "AttnProcessRunSummeryID");
|
|||
|
base.SetObjectID(oAttnProcessRunSummary, id);
|
|||
|
AttnProcessRunSummaryDA.Insert(tc, oAttnProcessRunSummary, payrollTypeID);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
AttnProcessRunSummaryDA.Update(tc, oAttnProcessRunSummary);
|
|||
|
|
|||
|
#region Delete Childs
|
|||
|
|
|||
|
AttnProcessRunSummaryDA.DeleteAttnProcessRunDetails(tc, oAttnProcessRunSummary.ID);
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
|
|||
|
#region Insert Childs
|
|||
|
|
|||
|
foreach (AttnProcessRunDetail item in oAttnProcessRunSummary.AttnProcessRunDetails)
|
|||
|
{
|
|||
|
item.ProcessSummaryID = oAttnProcessRunSummary.ID;
|
|||
|
base.SetObjectID(item, tc.GenerateID("AttnProcessRunDetail", "AttnProcessRunDetailID"));
|
|||
|
AttnProcessRunSummaryDA.InsertAttnProcessRunDetail(tc, item);
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
return oAttnProcessRunSummary.ID;
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#region Child Class Functions
|
|||
|
|
|||
|
public List<AttnProcessRunDetail> GetAttnProcessRunDetails(int id)
|
|||
|
{
|
|||
|
List<AttnProcessRunDetail> oAttnProcessRunDetails = new List<AttnProcessRunDetail>();
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader oreader = new DataReader(AttnProcessRunSummaryDA.GetAttnProcessRunDetails(tc, id));
|
|||
|
|
|||
|
oAttnProcessRunDetails = this.CreateAttnProcessRunDetails(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 oAttnProcessRunDetails;
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Get By ID
|
|||
|
|
|||
|
public AttnProcessRunSummary GetByID(int id)
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
var oAttnProcessRunSummary = new AttnProcessRunSummary();
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader oreader = new DataReader(AttnProcessRunSummaryDA.GetByID(tc, id));
|
|||
|
if (oreader.Read())
|
|||
|
{
|
|||
|
oAttnProcessRunSummary = this.CreateObject<AttnProcessRunSummary>(oreader);
|
|||
|
}
|
|||
|
|
|||
|
oreader.Close();
|
|||
|
tc.End();
|
|||
|
return oAttnProcessRunSummary;
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Get All
|
|||
|
|
|||
|
public List<AttnProcessRunSummary> Get(int payrollTypeID)
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader dr = new DataReader(AttnProcessRunSummaryDA.Get(tc, payrollTypeID));
|
|||
|
var oAttnProcessRunSummary = this.CreateObjects<AttnProcessRunSummary>(dr);
|
|||
|
dr.Close();
|
|||
|
tc.End();
|
|||
|
return oAttnProcessRunSummary;
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Get By Status
|
|||
|
|
|||
|
//public List<AttnProcessRunSummary> GetByStatus(EnumProcessStatus ProcessStatus, int payrollTypeID)
|
|||
|
//{
|
|||
|
// TransactionContext tc = null;
|
|||
|
// try
|
|||
|
// {
|
|||
|
// tc = TransactionContext.Begin();
|
|||
|
// DataReader dr = new DataReader(AttnProcessRunSummaryDA.GetByStatus(tc, ProcessStatus, payrollTypeID));
|
|||
|
// var oAttnProcessRunSummarys = this.CreateObjects<AttnProcessRunSummary>(dr);
|
|||
|
// dr.Close();
|
|||
|
// tc.End();
|
|||
|
// return oAttnProcessRunSummarys;
|
|||
|
// }
|
|||
|
// catch (Exception e)
|
|||
|
// {
|
|||
|
// #region Handle Exception
|
|||
|
|
|||
|
// if (tc != null)
|
|||
|
// tc.HandleError();
|
|||
|
// ExceptionLog.Write(e);
|
|||
|
// throw new ServiceException(e.Message, e);
|
|||
|
|
|||
|
// #endregion
|
|||
|
// }
|
|||
|
//}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Get By Mode
|
|||
|
|
|||
|
public List<AttnProcessRunSummary> GetByMode(EnumProcessMode ProcessMode, int payrollTypeID)
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader dr = new DataReader(AttnProcessRunSummaryDA.GetByMode(tc, ProcessMode, payrollTypeID));
|
|||
|
var oAttnProcessRunSummarys = this.CreateObjects<AttnProcessRunSummary>(dr);
|
|||
|
dr.Close();
|
|||
|
tc.End();
|
|||
|
return oAttnProcessRunSummarys;
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|