196 lines
6.7 KiB
C#
196 lines
6.7 KiB
C#
|
|
using Ease.Core.DataAccess;
|
|||
|
|
using Ease.Core.Model;
|
|||
|
|
using Ease.Core.Utility;
|
|||
|
|
using Ease.Core;
|
|||
|
|
using HRM.BO;
|
|||
|
|
using System;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.Data;
|
|||
|
|
using System.Linq;
|
|||
|
|
using System.Text;
|
|||
|
|
using System.Threading.Tasks;
|
|||
|
|
|
|||
|
|
namespace HRM.DA
|
|||
|
|
{
|
|||
|
|
public class RDRowAmountCalItemService :ServiceTemplate, IRDRowAmountCalItemService
|
|||
|
|
{
|
|||
|
|
#region Private functions and declaration
|
|||
|
|
|
|||
|
|
|
|||
|
|
public RDRowAmountCalItemService() { }
|
|||
|
|
|
|||
|
|
private void MapObject(RDRowAmountCalItem oRDRowAmountCalItem, DataReader oReader)
|
|||
|
|
{
|
|||
|
|
base.SetObjectID(oRDRowAmountCalItem, oReader.GetInt32("RowAmountCalID").Value);
|
|||
|
|
oRDRowAmountCalItem.RowID =oReader.GetInt32("ColRowID").Value;
|
|||
|
|
oRDRowAmountCalItem.GLID = oReader.GetInt32("GLID").Value;
|
|||
|
|
oRDRowAmountCalItem.Operator = (EnumOperator)oReader.GetInt32("Operator");
|
|||
|
|
base.SetObjectState(oRDRowAmountCalItem, ObjectState.Saved);
|
|||
|
|
}
|
|||
|
|
private RDRowAmountCalItem CreateObject(DataReader oReader)
|
|||
|
|
{
|
|||
|
|
RDRowAmountCalItem oRDRowAmountCalItem = new RDRowAmountCalItem();
|
|||
|
|
MapObject(oRDRowAmountCalItem, oReader);
|
|||
|
|
return oRDRowAmountCalItem;
|
|||
|
|
}
|
|||
|
|
protected override T CreateObject<T>(DataReader oReader)
|
|||
|
|
{
|
|||
|
|
RDRowAmountCalItem oRDRowAmountCalItems = new RDRowAmountCalItem();
|
|||
|
|
|
|||
|
|
MapObject(oRDRowAmountCalItems, oReader);
|
|||
|
|
return oRDRowAmountCalItems as T;
|
|||
|
|
//while (oReader.Read())
|
|||
|
|
//{
|
|||
|
|
// RDRowAmountCalItem oItem = CreateObject(oReader);
|
|||
|
|
// oRDRowAmountCalItems.Add(oItem);
|
|||
|
|
//}
|
|||
|
|
//return oRDRowAmountCalItems as T;
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region Service implementation
|
|||
|
|
public RDRowAmountCalItem Get(int id)
|
|||
|
|
{
|
|||
|
|
RDRowAmountCalItem oRDRowAmountCalItem = new RDRowAmountCalItem();
|
|||
|
|
TransactionContext tc = null;
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
tc = TransactionContext.Begin(true);
|
|||
|
|
IDataReader oreader = RDRowAmountCalItemDA.Get(tc, id);
|
|||
|
|
DataReader oReader = new DataReader(oreader);
|
|||
|
|
if (oreader.Read())
|
|||
|
|
{
|
|||
|
|
oRDRowAmountCalItem = CreateObject(oReader);
|
|||
|
|
}
|
|||
|
|
oreader.Close();
|
|||
|
|
|
|||
|
|
if (oRDRowAmountCalItem != null)
|
|||
|
|
{
|
|||
|
|
oRDRowAmountCalItem.GL = new GLService().Get(tc, oRDRowAmountCalItem.GLID);
|
|||
|
|
}
|
|||
|
|
tc.End();
|
|||
|
|
}
|
|||
|
|
catch (Exception e)
|
|||
|
|
{
|
|||
|
|
#region Handle Exception
|
|||
|
|
if (tc != null)
|
|||
|
|
tc.HandleError();
|
|||
|
|
ExceptionLog.Write(e);
|
|||
|
|
throw new ServiceException("Failed to Get RDRowAmountCalItem", e);
|
|||
|
|
#endregion
|
|||
|
|
}
|
|||
|
|
return oRDRowAmountCalItem;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public List<RDRowAmountCalItem> Get()
|
|||
|
|
{
|
|||
|
|
List<RDRowAmountCalItem> oRDRowAmountCalItems = new List<RDRowAmountCalItem>();
|
|||
|
|
TransactionContext tc = null;
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
tc = TransactionContext.Begin(true);
|
|||
|
|
DataReader oReader = new DataReader(RDRowAmountCalItemDA.Get(tc));
|
|||
|
|
oRDRowAmountCalItems = CreateObjects<RDRowAmountCalItem>(oReader);
|
|||
|
|
oReader.Close();
|
|||
|
|
|
|||
|
|
if (oRDRowAmountCalItems.Count > 0)
|
|||
|
|
{
|
|||
|
|
foreach (RDRowAmountCalItem oItem in oRDRowAmountCalItems)
|
|||
|
|
{
|
|||
|
|
oItem.GL = new GLService().Get(tc, oItem.GLID);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
tc.End();
|
|||
|
|
}
|
|||
|
|
catch (Exception e)
|
|||
|
|
{
|
|||
|
|
#region Handle Exception
|
|||
|
|
if (tc != null)
|
|||
|
|
tc.HandleError();
|
|||
|
|
ExceptionLog.Write(e);
|
|||
|
|
throw new ServiceException("Failed to Get RDRowAmountCalItem", e);
|
|||
|
|
#endregion
|
|||
|
|
}
|
|||
|
|
return oRDRowAmountCalItems;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public List<RDRowAmountCalItem> GetByRowID(int nRowID)
|
|||
|
|
{
|
|||
|
|
List<RDRowAmountCalItem> oRDRowAmountCalItems = new List<RDRowAmountCalItem>();
|
|||
|
|
|
|||
|
|
TransactionContext tc = null;
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
tc = TransactionContext.Begin(true);
|
|||
|
|
DataReader oReader = new DataReader(RDRowAmountCalItemDA.GetByRowID(tc, nRowID));
|
|||
|
|
oRDRowAmountCalItems = CreateObjects<RDRowAmountCalItem>(oReader);
|
|||
|
|
oReader.Close();
|
|||
|
|
|
|||
|
|
if (oRDRowAmountCalItems.Count > 0)
|
|||
|
|
{
|
|||
|
|
foreach (RDRowAmountCalItem oItem in oRDRowAmountCalItems)
|
|||
|
|
{
|
|||
|
|
oItem.GL = new GLService().Get(tc, oItem.GLID);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
tc.End();
|
|||
|
|
}
|
|||
|
|
catch (Exception e)
|
|||
|
|
{
|
|||
|
|
throw new ServiceException("Failed to Get RDRowAmountCalItem", e);
|
|||
|
|
}
|
|||
|
|
return oRDRowAmountCalItems;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//public int Save(RDRowAmountCalItem oRDRowAmountCalItem)
|
|||
|
|
//{
|
|||
|
|
// TransactionContext tc = null;
|
|||
|
|
// try
|
|||
|
|
// {
|
|||
|
|
// tc = TransactionContext.Begin(true);
|
|||
|
|
// if (oRDRowAmountCalItem.IsNew)
|
|||
|
|
// {
|
|||
|
|
// this.SetObjectID(oRDRowAmountCalItem, DARDRowAmountCalItem.GetNewID(tc));
|
|||
|
|
// DARDRowAmountCalItem.Insert(tc, oRDRowAmountCalItem);
|
|||
|
|
// }
|
|||
|
|
// else
|
|||
|
|
// {
|
|||
|
|
// DARDRowAmountCalItem.Update(tc, oRDRowAmountCalItem);
|
|||
|
|
// }
|
|||
|
|
// tc.End();
|
|||
|
|
// }
|
|||
|
|
// catch (Exception e)
|
|||
|
|
// {
|
|||
|
|
// #region Handle Exception
|
|||
|
|
// if (tc != null)
|
|||
|
|
// tc.HandleError();
|
|||
|
|
// ExceptionLog.Write(e);
|
|||
|
|
// throw new ServiceException("Failed to GetRDRowAmountCalItem", e);
|
|||
|
|
// #endregion
|
|||
|
|
// }
|
|||
|
|
// return oRDRowAmountCalItem.ID;
|
|||
|
|
//}
|
|||
|
|
|
|||
|
|
//public void Delete(int id)
|
|||
|
|
//{
|
|||
|
|
// TransactionContext tc = null;
|
|||
|
|
// try
|
|||
|
|
// {
|
|||
|
|
// tc = TransactionContext.Begin(true);
|
|||
|
|
// DARDRowAmountCalItem.Delete(tc, id);
|
|||
|
|
// tc.End();
|
|||
|
|
// }
|
|||
|
|
// catch (Exception e)
|
|||
|
|
// {
|
|||
|
|
// #region Handle Exception
|
|||
|
|
// if (tc != null)
|
|||
|
|
// tc.HandleError();
|
|||
|
|
// ExceptionLog.Write(e);
|
|||
|
|
// throw new ServiceException("Failed to GetRDRowAmountCalItem", e);
|
|||
|
|
// #endregion
|
|||
|
|
// }
|
|||
|
|
//}
|
|||
|
|
#endregion
|
|||
|
|
}
|
|||
|
|
}
|