EchoTex_Payroll/HRM.DA/Service/PMP/ObjectiveCategoryGradesService.cs

282 lines
8.7 KiB
C#
Raw Normal View History

2024-10-14 10:01:49 +06:00
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
{
public class ObjectiveCategoryGradesService : ServiceTemplate, IObjectiveCategoryGradesService
{
#region Object Mapping
private void MapObject(ObjectiveCategoryGrades oObjectiveCategoryGrades, DataReader oReader)
{
SetObjectID(oObjectiveCategoryGrades, oReader.GetInt32("ObjectiveCategoryGradesID", 0));
oObjectiveCategoryGrades.ObjectiveType = oReader.GetInt32("ObjectiveType").Value;
oObjectiveCategoryGrades.ObjectiveCategoryID = oReader.GetInt32("ObjectiveCategoryID", 0);
oObjectiveCategoryGrades.GradeID = oReader.GetInt32("GradeID", 0); //(oReader.GetInt32("GradeID").Value);
oObjectiveCategoryGrades.Tier = oReader.GetInt32("Tier").Value;
oObjectiveCategoryGrades.Percent =
oReader.GetDouble("Percent").Value == 0.0 ? 0.0 : oReader.GetDouble("Percent").Value;
oObjectiveCategoryGrades.OBMOSRequired = oReader.GetBoolean("OBMOSRequired").Value;
oObjectiveCategoryGrades.DPMOSRequired = oReader.GetBoolean("DPMOSRequired").Value;
this.SetObjectState(oObjectiveCategoryGrades, ObjectState.Saved);
}
protected override T CreateObject<T>(DataReader oReader)
{
ObjectiveCategoryGrades oObjectiveCategoryGrades = new ObjectiveCategoryGrades();
MapObject(oObjectiveCategoryGrades, oReader);
return oObjectiveCategoryGrades as T;
}
#endregion
#region IObjectiveCategoryGradesService Members
#region Get All
public List<ObjectiveCategoryGrades> Get()
{
List<ObjectiveCategoryGrades> oObjectiveCategoryGrades = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader oreader = new DataReader(ObjectiveCategoryGradesDA.Get(tc));
oObjectiveCategoryGrades = this.CreateObjects<ObjectiveCategoryGrades>(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 oObjectiveCategoryGrades;
}
public List<ObjectiveCategoryGrades> Get(int nPmpyearID, int nCategory)
{
List<ObjectiveCategoryGrades> oObjectiveCategoryGrades = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader oreader = new DataReader(ObjectiveCategoryGradesDA.Get(tc, nPmpyearID, nCategory));
oObjectiveCategoryGrades = this.CreateObjects<ObjectiveCategoryGrades>(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 oObjectiveCategoryGrades;
}
public List<ObjectiveCategoryGrades> GetByPMPYear(int nPmpyearID)
{
List<ObjectiveCategoryGrades> oObjectiveCategoryGrades = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader oreader = new DataReader(ObjectiveCategoryGradesDA.GetByPMPYear(tc, nPmpyearID));
oObjectiveCategoryGrades = this.CreateObjects<ObjectiveCategoryGrades>(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 oObjectiveCategoryGrades;
}
public List<ObjectiveCategoryGrades> GetByGradeId(int gradeId, int pmpYearId)
{
List<ObjectiveCategoryGrades> items = new List<ObjectiveCategoryGrades>();
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader oreader = new DataReader(ObjectiveCategoryGradesDA.GetByGradeId(tc, gradeId, pmpYearId));
items = this.CreateObjects<ObjectiveCategoryGrades>(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 items;
}
public List<ObjectiveCategoryGrades> GetByEmpTier(int empID, int nPmpyearID)
{
List<ObjectiveCategoryGrades> oObjectiveCategoryGrades = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader oreader = new DataReader(ObjectiveCategoryGradesDA.GetByEmpTier(tc, empID, nPmpyearID));
oObjectiveCategoryGrades = this.CreateObjects<ObjectiveCategoryGrades>(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 oObjectiveCategoryGrades;
}
#endregion
#region Get By ID
public ObjectiveCategoryGrades Get(int id)
{
ObjectiveCategoryGrades oObjectiveCategoryGrades = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader oreader = new DataReader(ObjectiveCategoryGradesDA.Get(tc, id));
oObjectiveCategoryGrades = this.CreateObject<ObjectiveCategoryGrades>(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 oObjectiveCategoryGrades;
}
#endregion
#region Insert
public int Save(ObjectiveCategoryGrades item)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
if (item.IsNew)
{
int id = tc.GenerateID("ObjectiveCategoryGrades", "ObjectiveCategoryGradesID");
base.SetObjectID(item, (id));
ObjectiveCategoryGradesDA.Save(tc, item);
}
else
{
ObjectiveCategoryGradesDA.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);
ObjectiveCategoryGradesDA.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
}
}