266 lines
8.2 KiB
C#
266 lines
8.2 KiB
C#
using System;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using Ease.CoreV35;
|
|
using Ease.CoreV35.DataAccess;
|
|
using System.Collections.Generic;
|
|
using Ease.Core.Model;
|
|
using Ease.Core.DataAccess;
|
|
using Ease.Core;
|
|
using Ease.Core.Utility;
|
|
using HRM.BO;
|
|
|
|
namespace HRM.DA
|
|
{
|
|
[Serializable]
|
|
public class SkillLevelMappingService : ServiceTemplate
|
|
{
|
|
public SkillLevelMappingService()
|
|
{
|
|
}
|
|
|
|
private void MapObject(SkillLevelMapping oSkillLevelMapping, DataReader oReader)
|
|
{
|
|
base.SetObjectID(oSkillLevelMapping, oReader.GetInt32("SkillLevelMappingID", 0));
|
|
oSkillLevelMapping.PMPYearID = oReader.GetInt32("PMPYearID", 0);
|
|
oSkillLevelMapping.GradeID = oReader.GetInt32("GradeID", 0);
|
|
oSkillLevelMapping.CategoryID = oReader.GetInt32("CategoryID", 0);
|
|
oSkillLevelMapping.SkillID = oReader.GetInt32("SkillID", 0);
|
|
oSkillLevelMapping.LevelID = oReader.GetInt32("LevelID", 0);
|
|
oSkillLevelMapping.CreatedBy = oReader.GetInt32("CreatedBy", 0);
|
|
oSkillLevelMapping.CreatedDate = oReader.GetDateTime("CreationDate").Value;
|
|
oSkillLevelMapping.ModifiedBy = oReader.GetInt32("ModifiedBy", 0);
|
|
oSkillLevelMapping.ModifiedDate = oReader.GetDateTime("ModifiedDate");
|
|
this.SetObjectState(oSkillLevelMapping, ObjectState.Saved);
|
|
}
|
|
|
|
protected override T CreateObject<T>(DataReader oReader)
|
|
{
|
|
SkillLevelMapping oSkillLevelMapping = new SkillLevelMapping();
|
|
MapObject(oSkillLevelMapping, oReader);
|
|
return oSkillLevelMapping as T;
|
|
}
|
|
|
|
protected SkillLevelMapping CreateObject(DataReader oReader)
|
|
{
|
|
SkillLevelMapping oSkillLevelMapping = new SkillLevelMapping();
|
|
MapObject(oSkillLevelMapping, oReader);
|
|
return oSkillLevelMapping;
|
|
}
|
|
|
|
|
|
#region Service implementation
|
|
|
|
public SkillLevelMapping Get(int id)
|
|
{
|
|
SkillLevelMapping oSkillLevelMapping = new SkillLevelMapping();
|
|
|
|
TransactionContext tc = null;
|
|
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader oreader = new DataReader(SkillLevelMappingDA.Get(tc, id));
|
|
if (oreader.Read())
|
|
{
|
|
oSkillLevelMapping = this.CreateObject<SkillLevelMapping>(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 oSkillLevelMapping;
|
|
}
|
|
|
|
public List<SkillLevelMapping> Get()
|
|
{
|
|
List<SkillLevelMapping> oSkillLevelMappings = new List<SkillLevelMapping>();
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader dr = new DataReader(SkillLevelMappingDA.Get(tc));
|
|
oSkillLevelMappings = this.CreateObjects<SkillLevelMapping>(dr);
|
|
dr.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 oSkillLevelMappings;
|
|
}
|
|
|
|
public List<SkillLevelMapping> Get(int pmpYearID, int gradeID)
|
|
{
|
|
List<SkillLevelMapping> oSkillLevelMappings = new List<SkillLevelMapping>();
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader dr = new DataReader(SkillLevelMappingDA.Get(tc, pmpYearID, gradeID));
|
|
oSkillLevelMappings = this.CreateObjects<SkillLevelMapping>(dr);
|
|
dr.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 oSkillLevelMappings;
|
|
}
|
|
|
|
public List<SkillLevelMapping> GetCompetency(int pmpYearID, int gradeID)
|
|
{
|
|
List<SkillLevelMapping> oSkillLevelMappings = new List<SkillLevelMapping>();
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader dr = new DataReader(SkillLevelMappingDA.GetCompetency(tc, pmpYearID, gradeID));
|
|
oSkillLevelMappings = this.CreateObjects<SkillLevelMapping>(dr);
|
|
dr.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 oSkillLevelMappings;
|
|
}
|
|
|
|
public int Save(SkillLevelMapping oSkillLevelMapping)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
if (oSkillLevelMapping.IsNew)
|
|
{
|
|
int id = tc.GenerateID("SkillLevelMapping", "SkillLevelMappingID");
|
|
base.SetObjectID(oSkillLevelMapping, id);
|
|
|
|
SkillLevelMappingDA.Insert(tc, oSkillLevelMapping);
|
|
}
|
|
else
|
|
{
|
|
SkillLevelMappingDA.Update(tc, oSkillLevelMapping);
|
|
}
|
|
|
|
tc.End();
|
|
return oSkillLevelMapping.ID;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
public void Save(List<SkillLevelMapping> oSkillLevelMappings)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
|
|
SkillLevelMappingDA.DeleteWithYearGrade(tc, oSkillLevelMappings[0].PMPYearID,
|
|
oSkillLevelMappings[0].GradeID);
|
|
|
|
foreach (SkillLevelMapping oSkillLevelMapping in oSkillLevelMappings)
|
|
{
|
|
if (oSkillLevelMapping.IsNew)
|
|
{
|
|
int id = tc.GenerateID("SkillLevelMapping", "SkillLevelMappingID");
|
|
base.SetObjectID(oSkillLevelMapping, id);
|
|
|
|
SkillLevelMappingDA.Insert(tc, oSkillLevelMapping);
|
|
}
|
|
else
|
|
{
|
|
SkillLevelMappingDA.Update(tc, oSkillLevelMapping);
|
|
}
|
|
}
|
|
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
public void Delete(int id)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
SkillLevelMappingDA.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
|
|
}
|
|
} |