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

1522 lines
51 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 PMPProcessService : ServiceTemplate, IPMPProcessService
{
#region Object Mapping
#region PMPProcess Object Mapping
private void MapPMPProcessObject(PMPProcess oPMPProcess, DataReader oReader)
{
base.SetObjectID(oPMPProcess, oReader.GetInt32("PMPProcessID", 0));
oPMPProcess.PmpYear = oReader.GetDateTime("PmpYear").Value;
oPMPProcess.Description = oReader.GetString("Description");
oPMPProcess.PmpStatus = (EnumPMPStatus)oReader.GetInt32("PmpStatus").Value;
oPMPProcess.TargetSettingFrom = oReader.GetDateTime("TargetSettingFrom").Value;
oPMPProcess.TargetSettingTo = oReader.GetDateTime("TargetSettingTo").Value;
oPMPProcess.MedianAppraisalFrom = oReader.GetDateTime("MedianAppraisalFrom").Value;
oPMPProcess.MedianAppraisalTo = oReader.GetDateTime("MedianAppraisalTo").Value;
oPMPProcess.FinalApprovalFrom = oReader.GetDateTime("FinalApprovalFrom").Value;
oPMPProcess.FinalApprovalTo = oReader.GetDateTime("FinalApprovalTo").Value;
oPMPProcess.DevelopmentFrom = oReader.GetDateTime("DevelopmentFrom").HasValue ? oReader.GetDateTime("DevelopmentFrom").Value : null;
oPMPProcess.DevelopmentTo = oReader.GetDateTime("DevelopmentTo").HasValue ? oReader.GetDateTime("DevelopmentTo").Value : null;
oPMPProcess.IsFinalize = oReader.GetBoolean("IsFinalize").Value;
oPMPProcess.CreatedBy = oReader.GetInt32("CreatedBy", 0);
oPMPProcess.CreatedDate = oReader.GetDateTime("CREATIONDATE").HasValue
? oReader.GetDateTime("CREATIONDATE").Value
: DateTime.MinValue;
oPMPProcess.ModifiedBy = oReader.GetInt32("ModifiedBy", 0);
oPMPProcess.ModifiedDate = oReader.GetDateTime("ModifiedDate").HasValue
? oReader.GetDateTime("ModifiedDate").Value
: (DateTime?)null;
oPMPProcess.Sequence = (int)oReader.GetInt32("Sequence");
oPMPProcess.Status = (EnumStatus)oReader.GetInt32("Status");
oPMPProcess.CutOffDate = oReader.GetDateTime("CutOffDate").HasValue ? oReader.GetDateTime("CutOffDate").Value : null;
oPMPProcess.IsPublish = oReader.GetBoolean("IsPublish", false);
this.SetObjectState(oPMPProcess, ObjectState.Saved);
}
protected override T CreateObject<T>(DataReader oReader)
{
PMPProcess oPMPProcess = new PMPProcess();
MapPMPProcessObject(oPMPProcess, oReader);
return oPMPProcess as T;
}
#endregion
#region PMPTargetSetting Object Mapping
private void MapPMPTargetSettingObject(PMPTargetSetting oPMPTargetSetting, DataReader oReader)
{
SetObjectID(oPMPTargetSetting, oReader.GetInt32("PMPTargetSettingId", 0));
oPMPTargetSetting.PmpEmployeeRatingID = oReader.GetInt32("PmpEmployeeRatingID", 0);
oPMPTargetSetting.PmpProcessId = oReader.GetInt32("PmpProcessId", 0);
oPMPTargetSetting.EmployeeID = oReader.GetInt32("EmployeeID", 0);
oPMPTargetSetting.Objective = oReader.GetString("Objective");
oPMPTargetSetting.ObjectivePercent = oReader.GetDouble("ObjectivePercent").Value;
if (oReader.GetDateTime("TargetDate") == null)
{
oPMPTargetSetting.TargetDate = DateTime.MinValue;
}
else oPMPTargetSetting.TargetDate = oReader.GetDateTime("TargetDate").Value;
oPMPTargetSetting.SelfComments = oReader.GetString("SelfComments") == null
? String.Empty
: oReader.GetString("SelfComments");
oPMPTargetSetting.SelfRatingID = oReader.GetInt32("SelfRatingID", 0);
//oPMPTargetSetting.Sequence = oReader.GetInt32("Sequence").Value;
oPMPTargetSetting.EvaluationCriteria = oReader.GetString("EvaluationCriteria") == null
? String.Empty
: oReader.GetString("EvaluationCriteria");
oPMPTargetSetting.ApprovarID = oReader.GetInt32("ApprovarID", 0);
oPMPTargetSetting.ApprovarComments = oReader.GetString("ApprovarComments") == null
? String.Empty
: oReader.GetString("ApprovarComments");
oPMPTargetSetting.ApprovarRatingID = oReader.GetInt32("ApprovarRatingID", 0);
this.SetObjectState(oPMPTargetSetting, ObjectState.Saved);
}
protected List<PMPTargetSetting> CreatePMPTargetSettingObject(DataReader oReader)
{
List<PMPTargetSetting> allPMPTargetSettings = new List<PMPTargetSetting>();
while (oReader.Read())
{
PMPTargetSetting oPMPTargetSetting = new PMPTargetSetting();
MapPMPTargetSettingObject(oPMPTargetSetting, oReader);
allPMPTargetSettings.Add(oPMPTargetSetting);
}
return allPMPTargetSettings;
}
#endregion
#region PMPValueBehaviorRating Object Mapping
private void MapPMPValueBehaviorRatingObject(PMPValueBehaviorRating oPMPValueBehaviorRating, DataReader oReader)
{
SetObjectID(oPMPValueBehaviorRating, oReader.GetInt32("PMPValueBehaviorRatingId", 0));
oPMPValueBehaviorRating.PmpEmployeeRatingID = oReader.GetInt32("PmpEmployeeRatingID", 0);
oPMPValueBehaviorRating.PMPValueBehaviorID = oReader.GetInt32("PMPValueBehaviorID", 0);
oPMPValueBehaviorRating.EmployeeID = oReader.GetInt32("EmployeeID", 0);
oPMPValueBehaviorRating.SelfComments = oReader.GetString("SelfComments") == null
? string.Empty
: oReader.GetString("SelfComments");
oPMPValueBehaviorRating.SelfRatingID = oReader.GetInt32("SelfRatingID", 0);
oPMPValueBehaviorRating.ApprovarComments = oReader.GetString("ApprovarComments") == null
? string.Empty
: oReader.GetString("ApprovarComments");
oPMPValueBehaviorRating.ApprovarRatingID = oReader.GetInt32("ApprovarRatingID", 0);
oPMPValueBehaviorRating.PmpProcessId = oReader.GetInt32("PmpProcessID", 0);
this.SetObjectState(oPMPValueBehaviorRating, ObjectState.Saved);
}
protected List<PMPValueBehaviorRating> CreatePMPValueBehaviorRatingObject(DataReader oReader)
{
List<PMPValueBehaviorRating> allPMPValueBehaviorRatings = new List<PMPValueBehaviorRating>();
while (oReader.Read())
{
PMPValueBehaviorRating oPMPValueBehaviorRating = new PMPValueBehaviorRating();
MapPMPValueBehaviorRatingObject(oPMPValueBehaviorRating, oReader);
allPMPValueBehaviorRatings.Add(oPMPValueBehaviorRating);
}
return allPMPValueBehaviorRatings;
}
#endregion
#region PMPEmployeeRating Object Mapping
private void MapPMPEmployeeRatingObject(PMPEmployeeRating oPMPEmployeeRating, DataReader oReader)
{
SetObjectID(oPMPEmployeeRating, oReader.GetInt32("PMPEmployeeRatingId", 0));
oPMPEmployeeRating.HrValueBehaValueBehaviorRatingID =
oReader.GetInt32("HrValueBehaValueBehaviorRatingID", 0);
oPMPEmployeeRating.HrTargetSettingRatingID = oReader.GetInt32("HrTargetSettingRatingID", 0);
oPMPEmployeeRating.PmpProcessID = oReader.GetInt32("PmpProcessID", 0);
oPMPEmployeeRating.EmployeeID = oReader.GetInt32("EmployeeID", 0);
oPMPEmployeeRating.SelfObjectRatingID = oReader.GetInt32("SelfObjectRatingID", 0);
oPMPEmployeeRating.ApprovarObjectRatingID = oReader.GetInt32("ApprovarObjectRatingID", 0);
oPMPEmployeeRating.ApprovarID = oReader.GetInt32("ApprovarID", 0);
oPMPEmployeeRating.SelfValueBehaviorRatingID = oReader.GetInt32("SelfValueBehaviorRatingID", 0);
oPMPEmployeeRating.AppValueBehaviorRatingID = oReader.GetInt32("AppValueBehaviorRatingID", 0);
oPMPEmployeeRating.IsTargetSettingDone = oReader.GetBoolean("IsTargetSettingDone").Value;
oPMPEmployeeRating.IsMedianDone = oReader.GetBoolean("IsMedianDone").Value;
oPMPEmployeeRating.IsValueBehaviorDone = oReader.GetBoolean("IsValueBehaviorDone").Value;
oPMPEmployeeRating.PmpStatus = (EnumPMPStatus)oReader.GetInt32("PmpStatus");
if (oReader.GetInt32("PmpWFStatus") != null)
oPMPEmployeeRating.PmpWFStatus = (PMPWFStatus)oReader.GetInt32("PmpWFStatus");
oPMPEmployeeRating.RemarksByHR = oReader.GetString("RemarksByHR") == null
? String.Empty
: oReader.GetString("RemarksByHR");
oPMPEmployeeRating.IncrementedPercentByHR = oReader.GetDouble("IncrementedPercentByHR") == null
? Double.MinValue
: oReader.GetDouble("IncrementedPercentByHR").Value;
oPMPEmployeeRating.IsFinalized = oReader.GetBoolean("IsFinalized") == null
? false
: oReader.GetBoolean("IsFinalized").Value;
this.SetObjectState(oPMPEmployeeRating, ObjectState.Saved);
}
protected List<PMPEmployeeRating> CreatePMPEmployeeRatingObject(DataReader oReader)
{
List<PMPEmployeeRating> allPMPEmployeeRatings = new List<PMPEmployeeRating>();
while (oReader.Read())
{
PMPEmployeeRating oPMPEmployeeRating = new PMPEmployeeRating();
MapPMPEmployeeRatingObject(oPMPEmployeeRating, oReader);
allPMPEmployeeRatings.Add(oPMPEmployeeRating);
}
return allPMPEmployeeRatings;
}
#endregion
#endregion
#region IPMPProcessService Members
#region Insert PMPProcess
public int Save(PMPProcess item)
{
PMPProcess Prvmpm = null;
if (item.IsNew == false)
{
Prvmpm = (new PMPProcessService()).GetByPMPProcessID(item.ID);
}
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
if (item.IsNew)
{
int id = tc.GenerateID("PMP_Process", "PMPProcessID");
int sequenceNo = tc.GenerateID("PMP_Process", "Sequence");
item.Sequence = sequenceNo;
base.SetObjectID(item, (id));
PMPProcessDA.InsertPMPProcessItem(tc, item);
}
else
{
PMPProcessDA.UpdatePMPProcessItem(tc, item);
if (Prvmpm.PmpStatus != item.PmpStatus)
{
PMPProcessDA.UpdatePMPStatus(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 Insert PMPEmployeeRating Object
public int SavePMPEmployeeRating(PMPEmployeeRating item)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
if (item.IsNew)
{
int id = tc.GenerateID("PMP_EmployeeRating", "PMPEmployeeRatingId");
base.SetObjectID(item, (id));
PMPProcessDA.InsertPMPEmployeeRatingItem(tc, item);
}
else
{
PMPProcessDA.UpdatePMPEmployeeRatingItem(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 Insert PMPTargetSetting Object
public int SavePMPTargetSetting(PMPTargetSetting item)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
if (item.IsNew)
{
int id = tc.GenerateID("PMP_TargetSetting", "PMPTargetSettingId");
base.SetObjectID(item, (id));
PMPProcessDA.InsertPMPTargetSettingItem(tc, item);
}
else
{
PMPProcessDA.UpdatePMPTargetSettingItem(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 SaveSinglePMPEmployeeRatingObject
//
public void SaveSinglePMPEmployeeRatingObject(PMPEmployeeRating obPmpempRating)
{
TransactionContext tc = null;
try
{
int obID = 0;
tc = TransactionContext.Begin(true);
if (obPmpempRating.IsNew)
{
int id = tc.GenerateID("PMP_EmployeeRating", "PMPEmployeeRatingId");
obID = (id);
base.SetObjectID(obPmpempRating, (id));
PMPProcessDA.InsertPMPEmployeeRatingItem(tc, obPmpempRating);
}
else
{
obID = obPmpempRating.ID;
PMPProcessDA.UpdatePMPEmployeeRatingItem(tc, obPmpempRating);
PMPProcessDA.DeleteAllPmpTargetSetting(tc, obPmpempRating.EmployeeID, obPmpempRating.PmpProcessID);
PMPProcessDA.DeleteValueBehaviorRating(tc, obPmpempRating.EmployeeID, obPmpempRating.PmpProcessID);
}
// PMPProcessDA.DeleteAllPmpTargetSetting(tc,obPmpempRating.EmployeeID, obPmpempRating.PmpProcessID);
List<PMPTargetSetting> allSettings = obPmpempRating.OPMPTargetSettings;
List<PMPValueBehaviorRating> allValueBehaviorRatings = obPmpempRating.OPMPValueBehaviorRatings;
if (allSettings != null)
{
foreach (PMPTargetSetting item in allSettings)
{
//if (item.IsNew)
//{
int id = tc.GenerateID("PMP_TargetSetting", "PMPTargetSettingId");
base.SetObjectID(item, (id));
item.PmpEmployeeRatingID = obPmpempRating.ID;
PMPProcessDA.InsertPMPTargetSettingItem(tc, item);
//}
//else
//{
// item.PmpEmployeeRatingID = obID;
// PMPProcessDA.UpdatePMPTargetSettingItem(tc, item);
//}
}
}
if (allValueBehaviorRatings != null)
{
foreach (PMPValueBehaviorRating item in allValueBehaviorRatings)
{
//if (item.IsNew)
//{
int id = tc.GenerateID("PMP_ValueBehaviorRating", "PMPValueBehaviorRatingId");
base.SetObjectID(item, (id));
item.PmpEmployeeRatingID = obPmpempRating.ID;
PMPProcessDA.InsertPMPValueBehaviorRatingItem(tc, item);
//}
//else
//{
// item.PmpEmployeeRatingID = obID;
// PMPProcessDA.UpdatePMPValueBehaviorRatingItem(tc, item);
//}
}
}
tc.End();
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
}
#endregion
#region SaveAllPMPTargetSettings
public void SaveAllPMPTargetSettings(List<PMPTargetSetting> allSettings)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
foreach (PMPTargetSetting item in allSettings)
{
if (item.IsNew)
{
int id = tc.GenerateID("PMP_TargetSetting", "PMPTargetSettingId");
base.SetObjectID(item, (id));
PMPProcessDA.InsertPMPTargetSettingItem(tc, item);
}
else
{
PMPProcessDA.UpdatePMPTargetSettingItem(tc, item);
}
tc.End();
}
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
}
#endregion
#region SavePMPValueBehaviorRating Object
public int SavePMPValueBehaviorRating(PMPValueBehaviorRating item)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
if (item.IsNew)
{
int id = tc.GenerateID("PMP_ValueBehaviorRating", "PMPValueBehaviorRatingId");
base.SetObjectID(item, (id));
PMPProcessDA.InsertPMPValueBehaviorRatingItem(tc, item);
}
else
{
PMPProcessDA.UpdatePMPValueBehaviorRatingItem(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 SaveAllPMPValueBehaviorRaings
public void SaveAllPMPValueBehaviorRaings(List<PMPValueBehaviorRating> allValueBehaviorRatings)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
foreach (PMPValueBehaviorRating item in allValueBehaviorRatings)
{
if (item.IsNew)
{
int id = tc.GenerateID("PMP_ValueBehaviorRating", "PMPValueBehaviorRatingId");
base.SetObjectID(item, (id));
PMPProcessDA.InsertPMPValueBehaviorRatingItem(tc, item);
}
else
{
PMPProcessDA.UpdatePMPValueBehaviorRatingItem(tc, item);
}
}
tc.End();
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
}
#endregion
#region Update
public void Update(PMPProcess item)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
PMPProcessDA.Delete(tc, item.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
#region Delete
public void Delete(int id)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
PMPProcessDA.DeletePmpTargetSettingsByPMPId(id, tc);
PMPProcessDA.DeletePmpValueBehaviorRatingByPMPId(id, tc);
PMPProcessDA.DeletePmpEmployeeRatingByPMPIDd(id, tc);
PMPProcessDA.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
#region GetPMPEmployeeRatingByPMPProcessID
public PMPEmployeeRating GetPMPEmployeeRatingByPMPProcessID(int id)
{
List<PMPEmployeeRating> allPMPEmployeeRatings = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader oreader = new DataReader(PMPProcessDA.GetEmployeeRatingById(tc, id));
allPMPEmployeeRatings = this.CreatePMPEmployeeRatingObject(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
}
if (allPMPEmployeeRatings.Count == 1) return allPMPEmployeeRatings[0];
else return null;
}
#endregion
#region GetPmpEmployeeRatingByEmployeeIdAndPmpProcessId
public PMPEmployeeRating GetPmpEmployeeRatingByEmployeeIdAndPmpProcessId(int empId, int pmpProcessId)
{
List<PMPEmployeeRating> allPMPEmployeeRatings = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader oreader =
new DataReader(
PMPProcessDA.GetPmpEmployeeRatingByEmployeeIdAndPmpProcessId(tc, empId, pmpProcessId));
allPMPEmployeeRatings = this.CreatePMPEmployeeRatingObject(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
}
if (allPMPEmployeeRatings.Count == 1) return allPMPEmployeeRatings[0];
else return null;
}
#endregion
#region GetPmpTargetSettingByPmpTargetSettingId
public PMPTargetSetting GetPmpTargetSettingByPmpTargetSettingId(int Id)
{
List<PMPTargetSetting> allPMPTargetSettings = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader oreader = new DataReader(PMPProcessDA.GetPmpTargetSettingByPmpTargetSettingId(tc, Id));
allPMPTargetSettings = this.CreatePMPTargetSettingObject(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
}
if (allPMPTargetSettings.Count == 1) return allPMPTargetSettings[0];
else return null;
}
#endregion
#region GetPMPTargetSettingsByEmployeeId
public List<PMPTargetSetting> GetPMPTargetSettingsByEmployeeIdAndPMPProcessID(int id, int pmpProcessID)
{
List<PMPTargetSetting> allPMPTargetSettings = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader oreader =
new DataReader(PMPProcessDA.GetPMPTargetSettingsByEmployeeIdAndPMPProcessID(tc, id, pmpProcessID));
allPMPTargetSettings = this.CreatePMPTargetSettingObject(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 allPMPTargetSettings;
}
#endregion
#region GetAllPMPTargetSettings
public List<PMPTargetSetting> GetAllPMPTargetSettings()
{
List<PMPTargetSetting> allPMPTargetSettings = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader oreader = new DataReader(PMPProcessDA.GetAllPMPTargetSettings(tc));
allPMPTargetSettings = this.CreatePMPTargetSettingObject(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 allPMPTargetSettings;
}
#endregion
#region GetPmpValueBehaviorRatingById
public PMPValueBehaviorRating GetPmpValueBehaviorRatingById(int Id)
{
List<PMPValueBehaviorRating> allPMPValueBehaviorRatings = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader oreader = new DataReader(PMPProcessDA.GetPmpValueBehaviorRatingById(tc, Id));
allPMPValueBehaviorRatings = this.CreatePMPValueBehaviorRatingObject(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
}
if (allPMPValueBehaviorRatings.Count == 1) return allPMPValueBehaviorRatings[0];
else return null;
}
#endregion
#region GetValueBehaviorRatingsByEmployeeIdAndPmpProcessId
public List<PMPValueBehaviorRating> GetValueBehaviorRatingsByEmployeeIdAndPmpProcessId(int empId,
int pmpProcessId)
{
List<PMPValueBehaviorRating> allPMPValueBehaviorRatings = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader oreader =
new DataReader(
PMPProcessDA.GetValueBehaviorRatingsByEmployeeIdAndPmpProcessId(tc, empId, pmpProcessId));
allPMPValueBehaviorRatings = this.CreatePMPValueBehaviorRatingObject(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
}
if (allPMPValueBehaviorRatings.Count > 0) return allPMPValueBehaviorRatings;
else return null;
}
#endregion
#region GetAllPmpProcess
public List<PMPProcess> Get(EnumStatus status)
{
List<PMPProcess> oPMPProcesses = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader oreader = new DataReader(PMPProcessDA.Get(tc, status));
oPMPProcesses = this.CreateObjects<PMPProcess>(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 oPMPProcesses;
}
public PMPProcess Get(EnumPMPStatus status)
{
List<PMPProcess> allPMPProcesses = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader oreader = new DataReader(PMPProcessDA.Get(tc, status));
allPMPProcesses = this.CreateObjects<PMPProcess>(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
}
if (allPMPProcesses.Count > 0)
return allPMPProcesses[0];
else
return null;
}
#endregion
#region GetPmpProcessByPmpProcesId
public PMPProcess GetPmpProcessByPmpProcesId(int id)
{
List<PMPProcess> oPMPProcesses = null;
TransactionContext tc = null;
PMPProcess obPMPProcess = null;
try
{
tc = TransactionContext.Begin();
DataReader oreader = new DataReader(PMPProcessDA.GetByPMPProcessId(tc, id));
oPMPProcesses = this.CreateObjects<PMPProcess>(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
}
if (oPMPProcesses.Count == 1)
{
return oPMPProcesses[0];
}
else return obPMPProcess;
}
#endregion
#region DeletePMPTargetSettingById
public void DeletePMPTargetSettingById(int id)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
PMPProcessDA.DeletePMPTargetSettingById(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
#region GetByPMPProcessID
public PMPProcess GetByPMPProcessID(int id)
{
List<PMPProcess> allPMPProcesses = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader oreader = new DataReader(PMPProcessDA.GetByPMPProcessID(tc, id));
allPMPProcesses = this.CreateObjects<PMPProcess>(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 allPMPProcesses[0];
}
public PMPProcess Get(DateTime pmpYear)
{
List<PMPProcess> allPMPProcesses = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader oreader = new DataReader(PMPProcessDA.Get(tc, pmpYear));
allPMPProcesses = this.CreateObjects<PMPProcess>(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 allPMPProcesses[0];
}
#endregion
#region GetPmpEmployeeRatingByRatingId
public PMPEmployeeRating GetPmpEmployeeRatingByRatingId(int ratingId)
{
List<PMPEmployeeRating> allPMPEmployeeRatings = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader oreader = new DataReader(PMPProcessDA.GetPmpEmployeeRatingByRatingId(tc, ratingId));
allPMPEmployeeRatings = this.CreatePMPEmployeeRatingObject(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
}
if (allPMPEmployeeRatings.Count == 1) return allPMPEmployeeRatings[0];
else return null;
}
#endregion
#region GetEmployeeRating
public List<PMPEmployeeRating> GetEmployeeRating(int processID)
{
List<PMPEmployeeRating> allPMPEmployeeRatings = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader oreader = new DataReader(PMPProcessDA.GetEmployeeRating(tc, processID));
allPMPEmployeeRatings = this.CreatePMPEmployeeRatingObject(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 allPMPEmployeeRatings;
}
#endregion
#region GetEmployeeRating
public PMPEmployeeRating GetEmployeeRating(int employeeID, int processID)
{
List<PMPEmployeeRating> allPMPEmployeeRatings = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader oreader =
new DataReader(
PMPProcessDA.GetPmpEmployeeRatingByEmployeeIdAndPmpProcessId(tc, employeeID, processID));
allPMPEmployeeRatings = this.CreatePMPEmployeeRatingObject(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
}
if (allPMPEmployeeRatings.Count == 1) return allPMPEmployeeRatings[0];
else return null;
}
#endregion
#region DeleteAllPmpTargetSettings
public void DeleteAllPmpTargetSettings(List<PMPTargetSetting> allSettings)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
foreach (PMPTargetSetting obDelObj in allSettings)
{
if (!obDelObj.IsNew) PMPProcessDA.DeletePMPTargetSettingById(tc, obDelObj.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
#region GetEmployeeRating
public List<PMPEmployeeRating> GetEmployeeRating(int pmpProcessId, EnumPMPStatus pmpStatus, PMPWFStatus status)
{
List<PMPEmployeeRating> allPMPEmployeeRatings = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader oreader =
new DataReader(PMPProcessDA.GetEmployeeRating(tc, pmpProcessId, pmpStatus, status));
allPMPEmployeeRatings = this.CreatePMPEmployeeRatingObject(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 allPMPEmployeeRatings;
}
#endregion
#region GetEmployeeRatingForDraft
public List<PMPEmployeeRating> GetEmployeeRatingForDraft(int pmpProcessId)
{
List<PMPEmployeeRating> allPMPEmployeeRatings = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader oreader = new DataReader(PMPProcessDA.GetEmployeeRatingForDraft(tc, pmpProcessId));
allPMPEmployeeRatings = this.CreatePMPEmployeeRatingObject(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 allPMPEmployeeRatings;
}
#endregion
#region GetEmployeeRatingForNotInitiate
public List<PMPEmployeeRating> GetEmployeeRatingForNotInitiate(int pmpProcessId, EnumPMPStatus pmpStatus)
{
List<PMPEmployeeRating> allPMPEmployeeRatings = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataSet ds = PMPProcessDA.GetEmployeeRatingForNotInitiate(tc, pmpProcessId, pmpStatus);
if (ds.Tables[0].Rows.Count >= 1)
allPMPEmployeeRatings = new List<PMPEmployeeRating>();
foreach (DataRow dr in ds.Tables[0].Rows)
{
PMPEmployeeRating obEmpRating = new PMPEmployeeRating();
obEmpRating.EmployeeID = (Convert.ToInt32(dr["EmployeeID"]));
obEmpRating.PmpProcessID = pmpProcessId;
allPMPEmployeeRatings.Add(obEmpRating);
}
tc.End();
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
return allPMPEmployeeRatings;
}
#endregion
#region SavePMPEmployeeRatingObject(PMPEmployeeRating obPmpempRating)
public void SavePMPEmployeeRatingObject(PMPEmployeeRating obPmpempRating)
{
TransactionContext tc = null;
try
{
int obID = 0;
tc = TransactionContext.Begin(true);
List<PMPTargetSetting> allSettings = obPmpempRating.OPMPTargetSettings;
List<PMPValueBehaviorRating> allValueBehaviorRatings = obPmpempRating.OPMPValueBehaviorRatings;
if (obPmpempRating.IsNew)
{
int id = tc.GenerateID("PMP_EmployeeRating", "PMPEmployeeRatingId");
obID = (id);
base.SetObjectID(obPmpempRating, (id));
PMPProcessDA.InsertPMPEmployeeRatingItem(tc, obPmpempRating);
}
else
{
obID = obPmpempRating.ID;
PMPProcessDA.UpdatePMPEmployeeRatingItem(tc, obPmpempRating);
if (allSettings != null)
PMPProcessDA.DeleteAllPmpTargetSetting(tc, obPmpempRating.EmployeeID,
obPmpempRating.PmpProcessID);
if (allValueBehaviorRatings != null)
PMPProcessDA.DeleteValueBehaviorRating(tc, obPmpempRating.EmployeeID,
obPmpempRating.PmpProcessID);
}
// PMPProcessDA.DeleteAllPmpTargetSetting(tc,obPmpempRating.EmployeeID, obPmpempRating.PmpProcessID);
if (allSettings != null)
{
foreach (PMPTargetSetting item in allSettings)
{
//if (item.IsNew)
//{
int id = tc.GenerateID("PMP_TargetSetting", "PMPTargetSettingId");
base.SetObjectID(item, (id));
item.PmpEmployeeRatingID = obPmpempRating.ID;
PMPProcessDA.InsertPMPTargetSettingItem(tc, item);
//}
//else
//{
// item.PmpEmployeeRatingID = obID;
// PMPProcessDA.UpdatePMPTargetSettingItem(tc, item);
//}
}
}
if (allValueBehaviorRatings != null)
{
foreach (PMPValueBehaviorRating item in allValueBehaviorRatings)
{
//if (item.IsNew)
//{
int id = tc.GenerateID("PMP_ValueBehaviorRating", "PMPValueBehaviorRatingId");
base.SetObjectID(item, (id));
item.PmpEmployeeRatingID = obPmpempRating.ID;
PMPProcessDA.InsertPMPValueBehaviorRatingItem(tc, item);
//}
//else
//{
// item.PmpEmployeeRatingID = obID;
// PMPProcessDA.UpdatePMPValueBehaviorRatingItem(tc, item);
//}
}
}
tc.End();
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
}
#endregion
#region SavePMPValueBehaviorRating(PMPValueBehaviorRating item)
public void SavePMPValueBehaviorRatingItem(PMPValueBehaviorRating item)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
if (item.IsNew)
{
int id = tc.GenerateID("PMP_ValueBehaviorRating", "PMPValueBehaviorRatingId");
base.SetObjectID(item, (id));
PMPProcessDA.InsertPMPValueBehaviorRatingItem(tc, item);
}
else
{
PMPProcessDA.UpdatePMPValueBehaviorRatingItem(tc, item);
}
tc.End();
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
}
#endregion
#region GetCurrentPMPYear
public List<PMPProcess> GetCurrentPMPYearWithPmpStatus(EnumPMPStatus pmpStatus, bool IsFinalize)
{
List<PMPProcess> oPMPProcesses = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader oreader = new DataReader(PMPProcessDA.GetCurrentPMPYearWithPmpStatus(tc, pmpStatus, IsFinalize));
oPMPProcesses = this.CreateObjects<PMPProcess>(oreader);
oreader.Close();
tc.End();
}
//tc = TransactionContext.Begin();
//DataReader oreader = new DataReader(PMPProcessDA.GetCurrentPMPYear(tc, pmpStatus, IsFinalize));
//if (ds.Tables[0].Rows.Count >= 1)
// currentPMPYears = new List<PMPProcess>();
//foreach (DataRow dr in ds.Tables[0].Rows)
//{
// PMPProcess oPMPProcess = new PMPProcess();
// SetObjectID(oPMPProcess,(Convert.ToInt32(dr["PmpYear"].ToString())));
// oPMPProcess.PmpYear = Convert.ToDateTime(dr["PmpYear"]);
// oPMPProcess.Description = dr["Description"].ToString();
// currentPMPYears.Add(oPMPProcess);
//}
//tc.End();
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
return oPMPProcesses;
}
public PMPProcess GetCurrentPMPYear(bool isFinalize)
{
PMPProcess item = new PMPProcess();
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader oreader = new DataReader(PMPProcessDA.GetCurrentPMPYear(tc, isFinalize));
while (oreader.Read())
{
item = this.CreateObject<PMPProcess>(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 item;
}
#endregion
public PMPProcess GetByYear(int pmpYear)
{
PMPProcess pmpProcess = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader oreader = new DataReader(PMPProcessDA.GetByYear(tc, pmpYear));
while (oreader.Read())
{
pmpProcess = this.CreateObject<PMPProcess>(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 pmpProcess;
}
public DataSet GetReportData(EnumPMPReports selectedReport, int PMPYearID, int locationID, string levelIDs,
string designationIDs, int orgaBasicID, int programmeID, int projectID)
{
DataSet reportData = new DataSet();
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
reportData = PMPProcessDA.GetReportData(tc, selectedReport, PMPYearID, locationID, levelIDs,
designationIDs, orgaBasicID, programmeID, projectID);
tc.End();
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
return reportData;
}
public DataSet GetReportData(int PmpYearYear, int EmployeeID)
{
DataSet reportData = new DataSet();
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
reportData = PMPProcessDA.GetReportData(tc, PmpYearYear, EmployeeID);
tc.End();
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
return reportData;
}
#endregion
}
}