CEL_Payroll/Payroll.Report/Class/rptPmp.cs

167 lines
7.5 KiB
C#
Raw Permalink Normal View History

2024-09-17 14:30:13 +06:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using Ease.CoreV35.Model;
using Payroll.BO;
namespace Payroll.Report
{
public class rptPmp
{
private ObjectsTemplate<PMPRating> allRatings = PMPRating.Get(EnumStatus.Active);
private string GetRatingName(ID selfRating)
{
string des = String.Empty;
if (selfRating != null)
{
if (!selfRating.IsUnassigned)
{
var sRating = allRatings.Where(ob => ob.ID.Integer == selfRating.Integer);
if (sRating.Count() == 1) des = sRating.First().RatingValue;
}
}
return des;
}
public DataTable GetEmployeePMPObjectives(ID empid, ID pmpProcessid)
{
PayrollDataSet.PayrollDataSet.PmpobjectivesDataTable dTEmpPMPobjectiveData = new PayrollDataSet.PayrollDataSet.PmpobjectivesDataTable();
ObjectsTemplate<PMPTargetSetting> allTargets = PMPProcess.GetPMPTargetSettingsByEmployeeIdAndPMPProcessID(empid, pmpProcessid);
foreach (PMPTargetSetting obTarget in allTargets)
{
DataRow dr = dTEmpPMPobjectiveData.NewRow();
dr["Objectives"] = obTarget.Objective;
dr["EvaluationCriteria"] = obTarget.EvaluationCriteria;
dr["TargetDate"] = obTarget.TargetDate;
dr["Priority"] = obTarget.ObjectivePercent.ToString() + "%";
dr["SelfComments"] = obTarget.SelfComments;
dr["SelfRating"] = GetRatingName(obTarget.SelfRatingID);
dr["ManagerComments"] = obTarget.ApprovarComments;
dr["ManagerRating"] = GetRatingName(obTarget.ApprovarRatingID);
dTEmpPMPobjectiveData.Rows.Add(dr);
}
dTEmpPMPobjectiveData.TableName = "PayrollDataSet_Pmpobjectives";
return dTEmpPMPobjectiveData;
}
public DataTable GetBasicPMPDataForEmployee(ID empId, ID pmpProcessID)
{
PayrollDataSet.PayrollDataSet.PmpbasicDataTable oDtPmpBasicEmp = new Payroll.Report.PayrollDataSet.PayrollDataSet.PmpbasicDataTable();
ObjectsTemplate<OrganogramEmployee> obOrEmp = OrganogramEmployee.GetByEmp(empId);
PMPEmployeeRating obEmpRating = PMPProcess.GetPmpEmployeeRatingByEmployeeIdAndPmpProcessId(empId, pmpProcessID);
DataRow dr;
dr = oDtPmpBasicEmp.NewRow();
ObjectsTemplate<Employee> oEmp = Employee.GetByEmpIDs(empId.Integer.ToString());
string managerName = String.Empty;
string managerPosition = String.Empty;
if (obEmpRating != null)
{
Employee ObEm = Employee.Get(obEmpRating.ApprovarID);
ObjectsTemplate<OrganogramEmployee> ObManagerOragn = OrganogramEmployee.GetByEmp(ObEm.ID);
if (ObManagerOragn.Count == 1)
{
OrganogramBasic ObOrganManagerBasic = OrganogramBasic.Get(ObManagerOragn[0].NodeID);
managerPosition = ObOrganManagerBasic.PositionName;
}
if (ObEm != null)
{
managerName = ObEm.Name;
}
}
dr["NameOfManager"] = managerName;
dr["ManagerPosition"] = managerPosition;
string dpt = String.Empty;
if (oEmp.Count == 1)
{
dr["AssociateName"] = oEmp[0].Name;
try
{
if (!oEmp[0].DepartmentID.IsUnassigned)
{
dpt = Department.Get(oEmp[0].DepartmentID).Name;
}
if (oEmp[0].JoiningDate != null && oEmp[0].JoiningDate != DateTime.MinValue)
{
dr["JoiningDate"] = oEmp[0].JoiningDate.ToString("yyyy");
}
dr["Country"] = "Bangladesh";
}
catch (Exception ex)
{
}
}
dr["BusinessUnit"] = dpt;
string prPos = String.Empty;
string nextLevelEmpName = String.Empty;
string nextLevelEmpPos = String.Empty;
if (obOrEmp.Count >= 1)
{
OrganogramBasic obOrganBasic = OrganogramBasic.Get(obOrEmp[0].NodeID);
if (obOrganBasic != null)
{
prPos = obOrganBasic.PositionName;
}
try
{
if (!obOrganBasic.ParentID.IsUnassigned)
{
OrganogramBasic obParentEmp = obOrganBasic.Parent;
if (obParentEmp.EmployeeAssigned)
{
Employee obParEmp = obParentEmp.GetAssignedEmployee();
nextLevelEmpName = obParEmp.Name;
nextLevelEmpPos = obParentEmp.PositionName;
}
}
}
catch (Exception e)
{
}
}
dr["PresentPosition"] = prPos;
dr["NameOfNextLevelManager"] = nextLevelEmpName;
dr["PositionOfNextLevelManager"] = nextLevelEmpPos;
oDtPmpBasicEmp.Rows.Add(dr);
oDtPmpBasicEmp.TableName = "PayrollDataSet_Pmpbasic";
return oDtPmpBasicEmp;
}
public DataTable GetPmpEmpValueBehaviorRatings(ID empID, ID pmpProcessId)
{
PayrollDataSet.PayrollDataSet.PmpEmpValueBehaviorRatingsDataTable oDtPmpempBehaviorratings = new Payroll.Report.PayrollDataSet.PayrollDataSet.PmpEmpValueBehaviorRatingsDataTable();
ObjectsTemplate<PMPValueBehavior> allBehaviors = PMPValueBehavior.Get(EnumStatus.Active);
ObjectsTemplate<PMPValueBehaviorRating> allVelueBehaviors = PMPProcess.GetValueBehaviorRatingsByEmployeeIdAndPmpProcessId(empID, pmpProcessId);
if (allVelueBehaviors.Count >= 1)
{
foreach (PMPValueBehaviorRating obrRatings in allVelueBehaviors)
{
DataRow dr = oDtPmpempBehaviorratings.NewRow();
var source = allBehaviors.Where(ob => ob.ID.Integer == obrRatings.PMPValueBehaviorID.Integer);
string des = String.Empty;
if (source.Count() == 1)
{
des = source.First().Name;
}
dr["ValueBehavior"] = des;
dr["SelfRating"] = GetRatingName(obrRatings.SelfRatingID);
dr["ManagerRating"] = GetRatingName(obrRatings.ApprovarRatingID);
dr["SelfComments"] = obrRatings.SelfComments;
dr["ManagerComments"] = obrRatings.ApprovarComments;
oDtPmpempBehaviorratings.Rows.Add(dr);
}
}
else
{
DataRow dr = oDtPmpempBehaviorratings.NewRow();
dr["ValueBehavior"] = String.Empty;
dr["SelfRating"] = String.Empty;
dr["ManagerRating"] = String.Empty;
dr["SelfComments"] = String.Empty;
dr["ManagerComments"] = String.Empty;
oDtPmpempBehaviorratings.Rows.Add(dr);
}
oDtPmpempBehaviorratings.TableName = "PayrollDataSet_PmpEmpValueBehaviorRatings";
return oDtPmpempBehaviorratings;
}
}
}