323 lines
9.8 KiB
C#
323 lines
9.8 KiB
C#
|
|
|||
|
using System;
|
|||
|
using Ease.CoreV35.Caching;
|
|||
|
using Ease.CoreV35.DataAccess;
|
|||
|
using Ease.CoreV35.Model;
|
|||
|
using Payroll.BO;
|
|||
|
|
|||
|
namespace Payroll.Service
|
|||
|
{
|
|||
|
#region Training Service
|
|||
|
[Serializable]
|
|||
|
class TrainingNdAnalysisTimeSchService : ServiceTemplate, ITrainingNdAnalysisTimeSchService
|
|||
|
{
|
|||
|
#region Private functions and declaration
|
|||
|
|
|||
|
Cache _cache = new Cache(typeof(TrainingNdAnalysisTimeSch));
|
|||
|
|
|||
|
private void MapObject(TrainingNdAnalysisTimeSch oTrainingNdAnalysisTimeSch, DataReader oReader)
|
|||
|
{
|
|||
|
base.SetObjectID(oTrainingNdAnalysisTimeSch, oReader.GetID("TNATimeSchID"));
|
|||
|
oTrainingNdAnalysisTimeSch.TrainingNeedAnalysisID = oReader.GetID("TrainingNeedAnalysisID");
|
|||
|
oTrainingNdAnalysisTimeSch.Month =(EnumMonths)oReader.GetInt16("Month").Value;
|
|||
|
oTrainingNdAnalysisTimeSch.Participent = oReader.GetInt32("Participent").Value;
|
|||
|
oTrainingNdAnalysisTimeSch.Remarks = oReader.GetString("Remarks");
|
|||
|
|
|||
|
this.SetObjectState(oTrainingNdAnalysisTimeSch, Ease.CoreV35.ObjectState.Saved);
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
protected override T CreateObject<T>(DataReader oReader)
|
|||
|
{
|
|||
|
TrainingNdAnalysisTimeSch oTrainingNdAnalysisTimeSchg = new TrainingNdAnalysisTimeSch();
|
|||
|
MapObject(oTrainingNdAnalysisTimeSchg, oReader);
|
|||
|
return oTrainingNdAnalysisTimeSchg as T;
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Implementation of ITrainingNdAnalysisTimeSchService
|
|||
|
|
|||
|
#region Get TrainingNdAnalysisTimeSch
|
|||
|
public TrainingNdAnalysisTimeSch Get(ID TrainingNdAnalysisTimeSchID)
|
|||
|
{
|
|||
|
TrainingNdAnalysisTimeSch oTrainingNdAnalysisTimeSch = null;
|
|||
|
|
|||
|
#region CacheHeader
|
|||
|
oTrainingNdAnalysisTimeSch = (TrainingNdAnalysisTimeSch)_cache["Get", TrainingNdAnalysisTimeSchID];
|
|||
|
if (oTrainingNdAnalysisTimeSch != null)
|
|||
|
return oTrainingNdAnalysisTimeSch;
|
|||
|
#endregion
|
|||
|
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
#region Retrieving data
|
|||
|
|
|||
|
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
|
|||
|
DataReader oreader = new DataReader(TrainingNdAnalysisTimeSchDA.Get(tc, TrainingNdAnalysisTimeSchID.Integer));
|
|||
|
oreader.Read();
|
|||
|
oTrainingNdAnalysisTimeSch = CreateObject<TrainingNdAnalysisTimeSch>(oreader);
|
|||
|
|
|||
|
tc.End();
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
#endregion
|
|||
|
}
|
|||
|
|
|||
|
#region CacheFooter
|
|||
|
_cache.Add(oTrainingNdAnalysisTimeSch, "Get", TrainingNdAnalysisTimeSchID);
|
|||
|
#endregion
|
|||
|
|
|||
|
return oTrainingNdAnalysisTimeSch;
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Get ObjectsTemplate<TrainingNdAnalysisTimeSch>
|
|||
|
|
|||
|
public ObjectsTemplate<TrainingNdAnalysisTimeSch> Get()
|
|||
|
{
|
|||
|
ObjectsTemplate<TrainingNdAnalysisTimeSch> TrainingNdAnalysisTimeSchs;
|
|||
|
|
|||
|
#region CacheHeader
|
|||
|
TrainingNdAnalysisTimeSchs = (ObjectsTemplate<TrainingNdAnalysisTimeSch>)_cache["Get"];
|
|||
|
if (TrainingNdAnalysisTimeSchs != null)
|
|||
|
return TrainingNdAnalysisTimeSchs;
|
|||
|
#endregion
|
|||
|
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
#region Retrieving data
|
|||
|
|
|||
|
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
|
|||
|
DataReader oreader = new DataReader(TrainingNdAnalysisTimeSchDA.Get(tc));
|
|||
|
TrainingNdAnalysisTimeSchs = CreateObjects<TrainingNdAnalysisTimeSch>(oreader);
|
|||
|
|
|||
|
tc.End();
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
#endregion
|
|||
|
}
|
|||
|
|
|||
|
#region CacheFooter
|
|||
|
_cache.Add(TrainingNdAnalysisTimeSchs, "Get");
|
|||
|
#endregion
|
|||
|
|
|||
|
return TrainingNdAnalysisTimeSchs;
|
|||
|
}
|
|||
|
|
|||
|
public ObjectsTemplate<TrainingNdAnalysisTimeSch> GetByTrainingNeedAnalysisID(ID TrainingNeedAnalysisID)
|
|||
|
{
|
|||
|
ObjectsTemplate<TrainingNdAnalysisTimeSch> TrainingNdAnalysisTimeSchs;
|
|||
|
|
|||
|
#region CacheHeader
|
|||
|
TrainingNdAnalysisTimeSchs = (ObjectsTemplate<TrainingNdAnalysisTimeSch>)_cache["Get"];
|
|||
|
if (TrainingNdAnalysisTimeSchs != null)
|
|||
|
return TrainingNdAnalysisTimeSchs;
|
|||
|
#endregion
|
|||
|
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
#region Retrieving data
|
|||
|
|
|||
|
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
|
|||
|
DataReader oreader = new DataReader(TrainingNdAnalysisTimeSchDA.GetByTrainingNeedAnalysisID(tc, TrainingNeedAnalysisID));
|
|||
|
TrainingNdAnalysisTimeSchs = CreateObjects<TrainingNdAnalysisTimeSch>(oreader);
|
|||
|
|
|||
|
tc.End();
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
#endregion
|
|||
|
}
|
|||
|
|
|||
|
#region CacheFooter
|
|||
|
_cache.Add(TrainingNdAnalysisTimeSchs, "Get");
|
|||
|
#endregion
|
|||
|
|
|||
|
return TrainingNdAnalysisTimeSchs;
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Save TrainingNdAnalysisTimeSch
|
|||
|
public ID Save(TrainingNdAnalysisTimeSch oTrainingNdAnalysisTimeSch)
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
#region Saving data
|
|||
|
|
|||
|
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
|
|||
|
|
|||
|
if (oTrainingNdAnalysisTimeSch.IsNew)
|
|||
|
{
|
|||
|
int newID = tc.GenerateID("TrainingNdAnalysisTimeSch", "TNATimeSchID");
|
|||
|
base.SetObjectID(oTrainingNdAnalysisTimeSch, ID.FromInteger(newID));
|
|||
|
|
|||
|
|
|||
|
|
|||
|
TrainingNdAnalysisTimeSchDA.Insert(tc, oTrainingNdAnalysisTimeSch);
|
|||
|
}
|
|||
|
else
|
|||
|
TrainingNdAnalysisTimeSchDA.Update(tc, oTrainingNdAnalysisTimeSch);
|
|||
|
|
|||
|
|
|||
|
tc.End();
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
//throw new ServiceException(e.Message, e);
|
|||
|
throw new Exception(e.Message, e);
|
|||
|
}
|
|||
|
|
|||
|
return oTrainingNdAnalysisTimeSch.ID;
|
|||
|
}
|
|||
|
public ID Save(TransactionContext tc, TrainingNdAnalysisTimeSch oTrainingNdAnalysisTimeSch)
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
#region Saving data
|
|||
|
if (oTrainingNdAnalysisTimeSch.IsNew)
|
|||
|
{
|
|||
|
int newID = tc.GenerateID("TrainingNdAnalysisTimeSch", "TNATimeSchID");
|
|||
|
base.SetObjectID(oTrainingNdAnalysisTimeSch, ID.FromInteger(newID));
|
|||
|
TrainingNdAnalysisTimeSchDA.Insert(tc, oTrainingNdAnalysisTimeSch);
|
|||
|
}
|
|||
|
else
|
|||
|
TrainingNdAnalysisTimeSchDA.Update(tc, oTrainingNdAnalysisTimeSch);
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
//throw new ServiceException(e.Message, e);
|
|||
|
throw new Exception(e.Message, e);
|
|||
|
}
|
|||
|
|
|||
|
return oTrainingNdAnalysisTimeSch.ID;
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Delete
|
|||
|
public void Delete(ID id)
|
|||
|
{
|
|||
|
|
|||
|
try
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
#region Deleting data
|
|||
|
|
|||
|
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
TrainingNdAnalysisTimeSchDA.Delete(tc, id.Integer);
|
|||
|
|
|||
|
tc.End();
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
public bool DoesTrainingNdAnalysisTimeSchExists(ID TrainingNdAnalysisTimeSchID)
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
bool result = false;
|
|||
|
result = TrainingNdAnalysisTimeSchDA.DoesTrainingNdAnalysisTimeSchExists(tc, TrainingNdAnalysisTimeSchID);
|
|||
|
tc.End();
|
|||
|
return result;
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
throw new Exception(e.Message, e);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
#endregion
|
|||
|
}
|