299 lines
11 KiB
C#
299 lines
11 KiB
C#
using Ease.Core.DataAccess;
|
|
using Ease.Core.Model;
|
|
using Ease.Core.Utility;
|
|
using HRM.BO;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace HRM.DA
|
|
{
|
|
public class ExitInterviewService : ServiceTemplate, IExitInterviewService
|
|
{
|
|
public ExitInterviewService() { }
|
|
|
|
private void MapObject(ExitInterview oExitInterview, DataReader oReader)
|
|
{
|
|
base.SetObjectID(oExitInterview, oReader.GetInt32("ExitInterviewID").Value);
|
|
oExitInterview.EmployeeID = oReader.GetString("EmployeeID") == null ? 0 : oReader.GetInt32("EmployeeID").Value;
|
|
oExitInterview.Name = oReader.GetString("Name");
|
|
oExitInterview.JobTitle = oReader.GetString("JobTitle");
|
|
oExitInterview.DepartmentName = oReader.GetString("DepartmentName");
|
|
oExitInterview.ManagerName = oReader.GetString("ManagerName");
|
|
oExitInterview.SourceofHire = oReader.GetString("SourceofHire");
|
|
oExitInterview.HireDate = oReader.GetDateTime("HireDate");
|
|
oExitInterview.TermDate = oReader.GetDateTime("TermDate");
|
|
oExitInterview.ExitInteviewDate = oReader.GetDateTime("ExitInteviewDate").Value;
|
|
oExitInterview.CultureandClimate = oReader.GetString("CultureandClimate");
|
|
oExitInterview.CareerDevelopment = oReader.GetString("CareerDevelopment");
|
|
oExitInterview.Settingobjectives = oReader.GetString("Settingobjectives");
|
|
oExitInterview.Providingfeedbackonperformance = oReader.GetString("Providingfeedbackonperformance");
|
|
oExitInterview.Facilitatingteamwork = oReader.GetString("Facilitatingteamwork");
|
|
oExitInterview.Communicatinginformationaffects = oReader.GetString("Communicatinginformationaffects");
|
|
oExitInterview.Relationshipwithemployees = oReader.GetString("Relationshipwithemployees");
|
|
oExitInterview.Other = oReader.GetString("Other");
|
|
oExitInterview.CreatedBy = oReader.GetString("CreatedBy") == null ? 0 : oReader.GetInt32("CreatedBy").Value;
|
|
oExitInterview.CreatedDate = oReader.GetDateTime("CreationDate").Value;
|
|
oExitInterview.ModifiedBy = oReader.GetString("ModifiedBy") == null ? null : oReader.GetInt32("ModifiedBy").Value;
|
|
oExitInterview.ModifiedDate = oReader.GetDateTime("ModifiedDate");
|
|
oExitInterview.AdditionalComments = oReader.GetString("AdditionalComments");
|
|
oExitInterview.ReasonID = (EnumReasonForLeaveing)oReader.GetInt32("ReasonID").Value;
|
|
|
|
|
|
this.SetObjectState(oExitInterview, Ease.Core.ObjectState.Saved);
|
|
}
|
|
//private void MapReasonForLeavingObject(ReasonsForLeaving oReasonForLeaving, DataReader oReader)
|
|
//{
|
|
// base.SetObjectID(oReasonForLeaving, oReader.GetInt32("ReasonsForLeavingID").Value);
|
|
// oReasonForLeaving.ExitInterviewID = oReader.GetInt32("ExitInterviewID", 0);
|
|
// oReasonForLeaving.ReasonID = (EnumReasonForLeaveing)oReader.GetInt32("ReasonID", 0);
|
|
// this.SetObjectState(oReasonForLeaving, Ease.Core.ObjectState.Saved);
|
|
//}
|
|
protected override T CreateObject<T>(DataReader oReader)
|
|
{
|
|
ExitInterview oExitInterview = new ExitInterview();
|
|
MapObject(oExitInterview, oReader);
|
|
return oExitInterview as T;
|
|
}
|
|
protected ExitInterview CreateObject(DataReader oReader)
|
|
{
|
|
ExitInterview oExitInterview = new ExitInterview();
|
|
MapObject(oExitInterview, oReader);
|
|
return oExitInterview;
|
|
}
|
|
|
|
//protected List<ReasonsForLeaving> CreateReasonForLeavingObjects(DataReader oReader)
|
|
//{
|
|
// List<ReasonsForLeaving> oReasonsForLeavings = new List<ReasonsForLeaving>();
|
|
// while (oReader.Read())
|
|
// {
|
|
// ReasonsForLeaving oItem = new ReasonsForLeaving();
|
|
// MapReasonForLeavingObject(oItem, oReader);
|
|
// oReasonsForLeavings.Add(oItem);
|
|
// }
|
|
// return oReasonsForLeavings;
|
|
|
|
//}
|
|
//protected ReasonsForLeaving CreateReasonForLeavingObject(DataReader oReader)
|
|
//{
|
|
// ReasonsForLeaving oReasonsForLeaving = new ReasonsForLeaving();
|
|
// MapReasonForLeavingObject(oReasonsForLeaving, oReader);
|
|
// return oReasonsForLeaving;
|
|
//}
|
|
#region Service implementation
|
|
|
|
public ExitInterview Get(int id)
|
|
{
|
|
ExitInterview oExitInterview = new ExitInterview();
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader oreader = new DataReader(ExitInterviewDA.Get(tc, id));
|
|
if (oreader.Read())
|
|
{
|
|
oExitInterview = this.CreateObject<ExitInterview>(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 oExitInterview;
|
|
}
|
|
|
|
public ExitInterview GetByEmployeeID(int id)
|
|
{
|
|
ExitInterview oExitInterview = new ExitInterview();
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader oreader = new DataReader(ExitInterviewDA.GetByEmployeeID(tc, id));
|
|
if (oreader.Read())
|
|
{
|
|
oExitInterview = this.CreateObject<ExitInterview>(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 oExitInterview;
|
|
}
|
|
public List<ExitInterview> Get()
|
|
{
|
|
List<ExitInterview> ExitInterviews = null;
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
|
|
DataReader dr = new DataReader(ExitInterviewDA.Get(tc));
|
|
ExitInterviews = this.CreateObjects<ExitInterview>(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 ExitInterviews;
|
|
}
|
|
//public List<ReasonsForLeaving> GetReasonsForLeaving(int nExitInterviewID)
|
|
//{
|
|
// #region Cache Header
|
|
|
|
// List<ReasonsForLeaving> oReasonsForLeaving = null;
|
|
// if (oReasonsForLeaving != null)
|
|
// return oReasonsForLeaving;
|
|
|
|
// #endregion
|
|
|
|
// TransactionContext tc = null;
|
|
// try
|
|
// {
|
|
// tc = TransactionContext.Begin();
|
|
|
|
// DataReader dr = new DataReader(ExitInterviewDA.GetReasonsForLeaving(tc, nExitInterviewID));
|
|
// oReasonsForLeaving = this.CreateReasonForLeavingObjects(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 oReasonsForLeaving;
|
|
//}
|
|
public List<ExitInterview> Get(DateTime dtFrom, DateTime dtTo, int nReasonID)
|
|
{
|
|
List<ExitInterview> oExitInterview = null;
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
|
|
DataReader dr = new DataReader(ExitInterviewDA.Get(tc, dtFrom, dtTo, nReasonID));
|
|
oExitInterview = this.CreateObjects<ExitInterview>(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 oExitInterview;
|
|
}
|
|
|
|
public int Save(ExitInterview oExitInterview)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
if (oExitInterview.IsNew)
|
|
{
|
|
int id = tc.GenerateID("ExitInterview", "ExitInterviewID");
|
|
base.SetObjectID(oExitInterview, id);
|
|
ExitInterviewDA.Insert(tc, oExitInterview);
|
|
}
|
|
else
|
|
{
|
|
ExitInterviewDA.Update(tc, oExitInterview);
|
|
}
|
|
//ExitInterviewDA.DeleteReasonsForLeaving(tc, oExitInterview.ID);
|
|
//foreach (ReasonsForLeaving oObj in oExitInterview.ReasonsForLeavingCol)
|
|
//{
|
|
// int id = tc.GenerateID("ReasonsForLeaving", "ReasonsForLeavingID");
|
|
// base.SetObjectID(oObj, id);
|
|
// oObj.ExitInterviewID = oExitInterview.ID;
|
|
// ExitInterviewDA.Insert(tc, oObj);
|
|
//}
|
|
tc.End();
|
|
return oExitInterview.ID;
|
|
}
|
|
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);
|
|
ExitInterviewDA.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
|
|
|
|
|
|
}
|
|
}
|