509 lines
16 KiB
C#
509 lines
16 KiB
C#
|
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
|
|||
|
{
|
|||
|
#region EmployeeRequisition Service
|
|||
|
|
|||
|
public class RecruitmentRequisitionService : ServiceTemplate, IRecruitmentRequisitionService
|
|||
|
{
|
|||
|
#region Private functions and declaration
|
|||
|
|
|||
|
#region base Object Functions
|
|||
|
|
|||
|
private void MapObject(RecruitmentRequisition item, DataReader oReader)
|
|||
|
{
|
|||
|
base.SetObjectID(item, oReader.GetInt32("RecruitmentRequisitionID").Value);
|
|||
|
item.DepartmentId = oReader.GetInt32("DepartmentID").Value;
|
|||
|
item.DepartmentHeadId = oReader.GetInt32("DepartmentHeadID").Value;
|
|||
|
item.EmployeeId = oReader.GetInt32("EmployeeID").Value;
|
|||
|
item.ExpectedJoiningDate = oReader.GetDateTime("ExpectedJoiningDate").Value;
|
|||
|
item.HrApprovedDate = oReader.GetDateTime("HRApprovedDate", DateTime.MinValue);
|
|||
|
item.MDApprovedDate = oReader.GetDateTime("MDApprovedDate", DateTime.MinValue);
|
|||
|
item.Position = oReader.GetString("Position");
|
|||
|
item.GradeId = oReader.GetInt32("GradeID").Value;
|
|||
|
item.DesignationId = oReader.GetInt32("DesignationID").Value;
|
|||
|
item.MaxEmployee = oReader.GetDecimal("MaxEmployee").Value;
|
|||
|
item.BudgetedHeadCount = oReader.GetInt32("BudgetedHeadCount").Value;
|
|||
|
item.BasicPay = oReader.GetString("BasicPay");
|
|||
|
item.JobDescription = oReader.GetString("JobDescription");
|
|||
|
item.Type = oReader.GetString("Type");
|
|||
|
item.RecruitmentMethod = oReader.GetString("RecruitmentMethod");
|
|||
|
item.KPI = oReader.GetString("KPI");
|
|||
|
item.FilePath = oReader.GetString("FilePath");
|
|||
|
item.Justification = oReader.GetString("Justification");
|
|||
|
item.Academic = oReader.GetString("Academic");
|
|||
|
item.Technical = oReader.GetString("Technical");
|
|||
|
item.Age = oReader.GetString("Age");
|
|||
|
item.Experience = oReader.GetString("Experience");
|
|||
|
item.Gender = (EnumGender)oReader.GetInt32("Gender");
|
|||
|
item.Areas = oReader.GetString("Areas");
|
|||
|
item.ResignationDate = oReader.GetDateTime("ResignationDate").Value;
|
|||
|
|
|||
|
item.OtherRequirements = oReader.GetString("OtherRequirements");
|
|||
|
item.Status = (EnumEmpReqStatus)oReader.GetInt32("Status");
|
|||
|
item.ReplacementDueTo = (EnumReplacementDueTo)oReader.GetInt32("ReplacementDueTo");
|
|||
|
item.IsCompleted = oReader.GetBoolean("IsCompleted").Value;
|
|||
|
item.IsHeadCount = oReader.GetBoolean("IsHeadCount").Value;
|
|||
|
item.CreatedBy = oReader.GetInt32("CreatedBy").Value;
|
|||
|
item.CreatedDate = oReader.GetDateTime("CreationDate").Value;
|
|||
|
item.Remarks = oReader.GetString("Remarks");
|
|||
|
this.SetObjectState(item, Ease.Core.ObjectState.Saved);
|
|||
|
}
|
|||
|
|
|||
|
protected override T CreateObject<T>(DataReader oReader)
|
|||
|
{
|
|||
|
RecruitmentRequisition oEmployeeRequisition = new RecruitmentRequisition();
|
|||
|
MapObject(oEmployeeRequisition, oReader);
|
|||
|
return oEmployeeRequisition as T;
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Child Object Functions
|
|||
|
|
|||
|
private void MapObject(RequisitionUser oRequisitionUser, DataReader oReader)
|
|||
|
{
|
|||
|
base.SetObjectID(oRequisitionUser, (oReader.GetInt32("RequisitionUserID").Value));
|
|||
|
oRequisitionUser.RecruitmentRequisitionId = (oReader.GetInt32("RecruitmentRequisitionID").Value);
|
|||
|
oRequisitionUser.EmployeeId = (oReader.GetInt32("EmployeeID").Value);
|
|||
|
oRequisitionUser.Status = (EnumEmpReqStatus)oReader.GetInt32("ProposedByID");
|
|||
|
oRequisitionUser.ChangeDate = oReader.GetDateTime("ChangeDate").GetValueOrDefault();
|
|||
|
oRequisitionUser.ChangeString = oReader.GetString("ChangeString");
|
|||
|
oRequisitionUser.Remarks = oReader.GetString("Remarks");
|
|||
|
this.SetObjectState(oRequisitionUser, Ease.Core.ObjectState.Saved);
|
|||
|
}
|
|||
|
|
|||
|
private RequisitionUser CreateChildObject(DataReader oReader)
|
|||
|
{
|
|||
|
RequisitionUser oRequisitionUser = new RequisitionUser();
|
|||
|
MapObject(oRequisitionUser, oReader);
|
|||
|
return oRequisitionUser;
|
|||
|
}
|
|||
|
|
|||
|
private List<RequisitionUser> CreateChildObjects(DataReader oReader)
|
|||
|
{
|
|||
|
List<RequisitionUser> requisitionUsers = new List<RequisitionUser>();
|
|||
|
|
|||
|
while (oReader.Read())
|
|||
|
{
|
|||
|
RequisitionUser oRequisitionUser = new RequisitionUser();
|
|||
|
oRequisitionUser = CreateChildObject(oReader);
|
|||
|
requisitionUsers.Add(oRequisitionUser);
|
|||
|
}
|
|||
|
|
|||
|
return requisitionUsers;
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region IEmployeeRequisitionService Members
|
|||
|
|
|||
|
public RecruitmentRequisition Get(int empReqID)
|
|||
|
{
|
|||
|
RecruitmentRequisition oEmployeeRequisition = null;
|
|||
|
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
#region Retrieving data
|
|||
|
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
|
|||
|
DataReader oreader = new DataReader(RecruitmentRequisitionDA.Get(tc, empReqID));
|
|||
|
if (oreader.Read())
|
|||
|
{
|
|||
|
oEmployeeRequisition = CreateObject<RecruitmentRequisition>(oreader);
|
|||
|
}
|
|||
|
|
|||
|
tc.End();
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
|
|||
|
return oEmployeeRequisition;
|
|||
|
}
|
|||
|
|
|||
|
public List<RecruitmentRequisition> Get()
|
|||
|
{
|
|||
|
List<RecruitmentRequisition> oEmployeeRequisitions = null;
|
|||
|
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
#region Retrieving data
|
|||
|
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
|
|||
|
DataReader oreader = new DataReader(RecruitmentRequisitionDA.Get(tc));
|
|||
|
|
|||
|
oEmployeeRequisitions = CreateObjects<RecruitmentRequisition>(oreader);
|
|||
|
|
|||
|
tc.End();
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
|
|||
|
return oEmployeeRequisitions;
|
|||
|
}
|
|||
|
|
|||
|
public List<RecruitmentRequisition> GetByDepartment(int departmentID)
|
|||
|
{
|
|||
|
List<RecruitmentRequisition> oEmployeeRequisitions = null;
|
|||
|
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
#region Retrieving data
|
|||
|
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
|
|||
|
DataReader oreader = new DataReader(RecruitmentRequisitionDA.GetByDepartmentID(tc, departmentID));
|
|||
|
|
|||
|
oEmployeeRequisitions = CreateObjects<RecruitmentRequisition>(oreader);
|
|||
|
|
|||
|
tc.End();
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
|
|||
|
return oEmployeeRequisitions;
|
|||
|
}
|
|||
|
|
|||
|
public List<RequisitionUser> GetRequisitionUserByEmpRequisitionID(int reqID)
|
|||
|
{
|
|||
|
List<RequisitionUser> requisitionUsers = null;
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
#region Retrieving data
|
|||
|
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
|
|||
|
DataReader oreader = new DataReader(RecruitmentRequisitionDA.GetRequisitionUserByReqID(tc, reqID));
|
|||
|
|
|||
|
requisitionUsers = CreateChildObjects(oreader);
|
|||
|
|
|||
|
tc.End();
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
|
|||
|
return requisitionUsers;
|
|||
|
}
|
|||
|
|
|||
|
public DataTable GetEmployeeRequisitionsByDepartmentID(int departmentID, EnumEmpReqStatus reqStatus)
|
|||
|
{
|
|||
|
DataSet employeeRequisitionDS = new DataSet();
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
employeeRequisitionDS =
|
|||
|
RecruitmentRequisitionDA.GetEmployeeRequisitionsByDepartmentID(tc, departmentID, reqStatus);
|
|||
|
tc.End();
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
|
|||
|
return employeeRequisitionDS.Tables[0];
|
|||
|
}
|
|||
|
|
|||
|
public DataTable GetEmployeeRequisitionsForCEO()
|
|||
|
{
|
|||
|
DataSet employeeRequisitionDS = new DataSet();
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
employeeRequisitionDS = RecruitmentRequisitionDA.GetEmployeeRequisitionsForCEO(tc);
|
|||
|
tc.End();
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
|
|||
|
return employeeRequisitionDS.Tables[0];
|
|||
|
}
|
|||
|
|
|||
|
public void RequisitionDeclinedByCEO(RecruitmentRequisition employeeRequisition)
|
|||
|
{
|
|||
|
DataSet employeeRequisitionDS = new DataSet();
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
RecruitmentRequisitionDA.RequisitionDeclinedByCEO(tc, employeeRequisition);
|
|||
|
tc.End();
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public DataTable GetEmployeeRequisitionsForHR()
|
|||
|
{
|
|||
|
DataSet employeeRequisitionDS = new DataSet();
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
employeeRequisitionDS = RecruitmentRequisitionDA.GetEmployeeRequisitionsForHR(tc);
|
|||
|
tc.End();
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
|
|||
|
return employeeRequisitionDS.Tables[0];
|
|||
|
}
|
|||
|
|
|||
|
public void RequisitionDeclinedByHR(RecruitmentRequisition employeeRequisition)
|
|||
|
{
|
|||
|
DataSet employeeRequisitionDS = new DataSet();
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
RecruitmentRequisitionDA.RequisitionDeclinedByHR(tc, employeeRequisition);
|
|||
|
tc.End();
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public int Save(RecruitmentRequisition oEmployeeRequisition)
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
#region Saving data
|
|||
|
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
|
|||
|
|
|||
|
if (oEmployeeRequisition.IsNew)
|
|||
|
{
|
|||
|
int newID = tc.GenerateID("RecruitmentRequisition", "RecruitmentRequisitionID");
|
|||
|
base.SetObjectID(oEmployeeRequisition, (newID));
|
|||
|
RecruitmentRequisitionDA.Insert(tc, oEmployeeRequisition);
|
|||
|
}
|
|||
|
|
|||
|
else
|
|||
|
{
|
|||
|
RecruitmentRequisitionDA.Update(tc, oEmployeeRequisition);
|
|||
|
// At present No RequisitionUsers needs updating so we'll only add new RequisitionUser
|
|||
|
// EmployeeRequisitionDA.DeleteRequisitionUsers(tc, oEmployeeRequisition.ID.Integer);
|
|||
|
}
|
|||
|
|
|||
|
if (oEmployeeRequisition.RequisitionUsers != null)
|
|||
|
{
|
|||
|
foreach (RequisitionUser oReqUser in oEmployeeRequisition.RequisitionUsers)
|
|||
|
{
|
|||
|
oReqUser.RecruitmentRequisitionId = oEmployeeRequisition.ID;
|
|||
|
base.SetObjectID(oReqUser, (tc.GenerateID("RequisitionUser", "RequisitionUserID")));
|
|||
|
RecruitmentRequisitionDA.InsertRequisitionUser(tc, oReqUser);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
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 Exception(e.Message, e);
|
|||
|
}
|
|||
|
|
|||
|
return oEmployeeRequisition.ID;
|
|||
|
}
|
|||
|
|
|||
|
public void Delete(int ID)
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
#region Deleting data
|
|||
|
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
RecruitmentRequisitionDA.DeleteRequisitionUsers(tc, ID);
|
|||
|
RecruitmentRequisitionDA.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 Exception(e.Message, e);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void ChangeStatus(RecruitmentRequisition employeeRequisition, int empID,
|
|||
|
EnumEmpReqStatus enumEmpReqStatus)
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
|
|||
|
RecruitmentRequisitionDA.ChangeStatus(tc, employeeRequisition.ID, enumEmpReqStatus);
|
|||
|
|
|||
|
RequisitionUser oReqUser = new RequisitionUser()
|
|||
|
{
|
|||
|
RecruitmentRequisitionId = (employeeRequisition.ID),
|
|||
|
EmployeeId = (empID),
|
|||
|
Status = enumEmpReqStatus,
|
|||
|
ChangeDate = DateTime.Now,
|
|||
|
ChangeString = "Status Changed",
|
|||
|
Remarks = string.Empty
|
|||
|
};
|
|||
|
base.SetObjectID(oReqUser, (tc.GenerateID("RequisitionUser", "RequisitionUserID")));
|
|||
|
RecruitmentRequisitionDA.InsertRequisitionUser(tc, oReqUser);
|
|||
|
|
|||
|
tc.End();
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
throw new Exception(e.Message, e);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|