301 lines
8.5 KiB
C#
301 lines
8.5 KiB
C#
|
using System;
|
|||
|
using Ease.Core.Model;
|
|||
|
using Ease.Core.DataAccess;
|
|||
|
using Ease.Core.Utility;
|
|||
|
using System.Collections.Generic;
|
|||
|
using HRM.BO;
|
|||
|
using System.Data;
|
|||
|
using Ease.Core;
|
|||
|
using System.Linq;
|
|||
|
|
|||
|
namespace HRM.DA
|
|||
|
{
|
|||
|
#region Training Service
|
|||
|
|
|||
|
class TrainingNdAnalysisTimeSchService : ServiceTemplate
|
|||
|
{
|
|||
|
#region Private functions and declaration
|
|||
|
|
|||
|
private void MapObject(TrainingNdAnalysisTimeSch oTrainingNdAnalysisTimeSch, DataReader oReader)
|
|||
|
{
|
|||
|
base.SetObjectID(oTrainingNdAnalysisTimeSch, (oReader.GetInt32("TNATimeSchID").Value));
|
|||
|
oTrainingNdAnalysisTimeSch.TrainingNeedAnalysisID = oReader.GetInt32("TrainingNeedAnalysisID", 0);
|
|||
|
oTrainingNdAnalysisTimeSch.Month = (EnumMonths)oReader.GetInt16("Month").Value;
|
|||
|
oTrainingNdAnalysisTimeSch.Participent = oReader.GetInt32("Participent").Value;
|
|||
|
oTrainingNdAnalysisTimeSch.Remarks = oReader.GetString("Remarks");
|
|||
|
|
|||
|
this.SetObjectState(oTrainingNdAnalysisTimeSch, Ease.Core.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(int TrainingNdAnalysisTimeSchID)
|
|||
|
{
|
|||
|
TrainingNdAnalysisTimeSch oTrainingNdAnalysisTimeSch = null;
|
|||
|
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
#region Retrieving data
|
|||
|
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
|
|||
|
DataReader oreader = new DataReader(TrainingNdAnalysisTimeSchDA.Get(tc, TrainingNdAnalysisTimeSchID));
|
|||
|
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
|
|||
|
}
|
|||
|
|
|||
|
return oTrainingNdAnalysisTimeSch;
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Get List<TrainingNdAnalysisTimeSch>
|
|||
|
|
|||
|
public List<TrainingNdAnalysisTimeSch> Get()
|
|||
|
{
|
|||
|
List<TrainingNdAnalysisTimeSch> TrainingNdAnalysisTimeSchs = null;
|
|||
|
|
|||
|
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
|
|||
|
}
|
|||
|
|
|||
|
return TrainingNdAnalysisTimeSchs;
|
|||
|
}
|
|||
|
|
|||
|
public List<TrainingNdAnalysisTimeSch> GetByTrainingNeedAnalysisID(int TrainingNeedAnalysisID)
|
|||
|
{
|
|||
|
List<TrainingNdAnalysisTimeSch> TrainingNdAnalysisTimeSchs = null;
|
|||
|
|
|||
|
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
|
|||
|
}
|
|||
|
|
|||
|
return TrainingNdAnalysisTimeSchs;
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Insert TrainingNdAnalysisTimeSch
|
|||
|
|
|||
|
public int 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, (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 int Save(TransactionContext tc, TrainingNdAnalysisTimeSch oTrainingNdAnalysisTimeSch)
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
#region Saving data
|
|||
|
|
|||
|
if (oTrainingNdAnalysisTimeSch.IsNew)
|
|||
|
{
|
|||
|
int newID = tc.GenerateID("TrainingNdAnalysisTimeSch", "TNATimeSchID");
|
|||
|
base.SetObjectID(oTrainingNdAnalysisTimeSch, (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(int id)
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
#region Deleting data
|
|||
|
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
TrainingNdAnalysisTimeSchDA.Delete(tc, id);
|
|||
|
|
|||
|
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(int 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
|
|||
|
}
|