223 lines
6.2 KiB
C#
223 lines
6.2 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
|
|||
|
{
|
|||
|
class ObjectiveEmployeesService : ServiceTemplate
|
|||
|
{
|
|||
|
#region Object Mapping
|
|||
|
|
|||
|
private void MapObject(ObjectiveEmployees oObjectiveEmployees, DataReader oReader)
|
|||
|
{
|
|||
|
SetObjectID(oObjectiveEmployees, oReader.GetInt32("ObjectiveEmployeesID", 0));
|
|||
|
oObjectiveEmployees.ObjectiveID = oReader.GetInt32("ObjectiveID", 0);
|
|||
|
oObjectiveEmployees.EmployeeID = oReader.GetInt32("EmployeeID", 0);
|
|||
|
oObjectiveEmployees.ObjectiveNodeID = oReader.GetInt32("ObjectiveNodeID", 0);
|
|||
|
//oObjectiveEmployees.EmployeeNodeID = oReader.GetInt32("EmployeeNodeID");
|
|||
|
this.SetObjectState(oObjectiveEmployees, ObjectState.Saved);
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
protected override T CreateObject<T>(DataReader oReader)
|
|||
|
{
|
|||
|
ObjectiveEmployees oObjectiveEmployees = new ObjectiveEmployees();
|
|||
|
MapObject(oObjectiveEmployees, oReader);
|
|||
|
return oObjectiveEmployees as T;
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region IObjectiveEmployeesService Members
|
|||
|
|
|||
|
#region Get All
|
|||
|
|
|||
|
public List<ObjectiveEmployees> Get()
|
|||
|
{
|
|||
|
List<ObjectiveEmployees> oObjectiveEmployees = null;
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader oreader = new DataReader(ObjectiveEmployeesDA.Get(tc));
|
|||
|
oObjectiveEmployees = this.CreateObjects<ObjectiveEmployees>(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 oObjectiveEmployees;
|
|||
|
}
|
|||
|
|
|||
|
public List<ObjectiveEmployees> GetByObjIDs(string sObjIDs)
|
|||
|
{
|
|||
|
List<ObjectiveEmployees> oObjectiveEmployees = null;
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader oreader = new DataReader(ObjectiveEmployeesDA.GetByObjIDs(tc, sObjIDs));
|
|||
|
oObjectiveEmployees = this.CreateObjects<ObjectiveEmployees>(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 oObjectiveEmployees;
|
|||
|
}
|
|||
|
|
|||
|
public List<ObjectiveEmployees> GetByEmployeeID(int empID, int pmpID)
|
|||
|
{
|
|||
|
List<ObjectiveEmployees> oObjectiveEmployees = null;
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader oreader = new DataReader(ObjectiveEmployeesDA.GetByEmployeeID(tc, empID, pmpID));
|
|||
|
oObjectiveEmployees = this.CreateObjects<ObjectiveEmployees>(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 oObjectiveEmployees;
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Get By ID
|
|||
|
|
|||
|
public ObjectiveEmployees Get(int id)
|
|||
|
{
|
|||
|
ObjectiveEmployees oObjectiveEmployees = null;
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader oreader = new DataReader(ObjectiveEmployeesDA.Get(tc, id));
|
|||
|
oObjectiveEmployees = this.CreateObject<ObjectiveEmployees>(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 oObjectiveEmployees;
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Insert
|
|||
|
|
|||
|
public int Save(ObjectiveEmployees item)
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
if (item.IsNew)
|
|||
|
{
|
|||
|
int id = tc.GenerateID("ObjectiveEmployees", "ObjectiveEmployeesID");
|
|||
|
base.SetObjectID(item, (id));
|
|||
|
ObjectiveEmployeesDA.Save(tc, item);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
ObjectiveEmployeesDA.Update(tc, item);
|
|||
|
}
|
|||
|
|
|||
|
tc.End();
|
|||
|
return item.ID;
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Delete
|
|||
|
|
|||
|
public void Delete(int id)
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
ObjectiveEmployeesDA.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
|
|||
|
}
|
|||
|
}
|