using Ease.Core.Model; using System; using System.Collections.Generic; using System.Data; namespace HRM.BO { public class Objective : BasicBaseObject { #region Constructor public Objective() { this.Description = string.Empty; this.Title = string.Empty; this.Activities = string.Empty; this.MeasuresOfSuccess = string.Empty; this.Weightages = 0.0; this.ObjectiveDate = DateTime.MinValue; this.RagingDate = DateTime.MinValue; this.YEEmployeeComments = string.Empty; this.MYEmployeeComments = string.Empty; this.YELMComments = string.Empty; this.MYLMComments = string.Empty; this.LMRatingID = 0; MYLMAssessRating = EnumAssessment.None; MYAssessRating = EnumAssessment.None; YEStatus = EnumObjectiveStatus.No_Change; MYStatus = EnumObjectiveStatus.No_Change; this.IsOldObjective = false; this.PriorityPercent = 0; } #endregion #region Properties public int ObjectiveSetID { get; set; } public int GroupID { get; set; } public string Tier { get; set; } public int PMPYearID { get; set; } public string Title { get; set; } public string Description { get; set; } public string Activities { get; set; } public string MeasuresOfSuccess { get; set; } // target public string MeasuresOfSuccess2 { get; set; } // target public double Weightages { get; set; } // percentage public int EmployeeID { get; set; } public int EmployeeNodeID { get; set; } public DateTime ObjectiveDate { get; set; } public int LMID { get; set; } public int LMNodeID { get; set; } public int LMRatingID { get; set; } public double YEEmpMark { get; set; } public double YELMMark { get; set; } public double? YEAssessRating { get; set; } public double? YELMAssessRating { get; set; } public DateTime YEEmpMarkDate { get; set; } public DateTime YELMMarkDate { get; set; } public DateTime RagingDate { get; set; } public string MYEmployeeComments { get; set; } public string YEEmployeeComments { get; set; } public string MYLMComments { get; set; } public string YELMComments { get; set; } public EnumAssessment MYAssessRating { get; set; } public EnumAssessment MYLMAssessRating { get; set; } public string ObjComment { get; set; } public DateTime StartDate { get; set; } public DateTime EndDate { get; set; } public bool IsDraft { get; set; } public bool IsOldObjective { get; set; } public EnumObjectiveStatus MYStatus { get; set; } public EnumObjectiveStatus YEStatus { get; set; } //#region Property DevelopmentPlans : DevelopmentPlan //private List _developmentPlans; //public List DevelopmentPlans //{ // get // { // if (_developmentPlans == null && !this.ID.IsUnassigned && this.ID.Integer > 0) // { // _developmentPlans = Service.GetDevelopmentPlans(this.ID); // } // return _developmentPlans; // } // set // { // _developmentPlans = value; // } //} //#endregion //#region Property LMObjectives : LMObjective //private List _lMObjectives; //public List LMObjectives //{ // get // { // if (_lMObjectives == null && !this.ID.IsUnassigned && this.ID.Integer > 0) // { // _lMObjectives = Service.GetLMObjectives(this.ID); // } // else if (_lMObjectives == null) // { // _lMObjectives = new List(); // } // return _lMObjectives; // } // set // { // _lMObjectives = value; // } //} //#endregion public List ObjectiveEmployees { get; set; } public List LMObjectives { get; set; } public List DevelopmentPlans { get; set; } //#region Property ObjectiveEmployeess : ObjectiveEmployees //private List _objectiveEmployees; //public List ObjectiveEmployees //{ // get // { // if (_objectiveEmployees == null && !this.ID.IsUnassigned && this.ID.Integer > 0) // { // _objectiveEmployees = Service.GetObjectiveEmployees(this.ID); // } // return _objectiveEmployees; // } // set // { // _objectiveEmployees = value; // } //} //#endregion public int ObjectiveType { get; set; } public double PriorityPercent { get; set; } public int KPIType { get; set; } public int MasterKpiId { get; set; } public double LMAchivementPercentage { get; set; } public double EmpAchivementPercentage { get; set; } public double EmpPARating { get; set; } public double LMPARating { get; set; } public string ObjSecondLMComment { get; set; } public string MYSecondLMComment { get; set; } public string YESecondLMComment { get; set; } #endregion #region Old //#region Function //#region Get All //public static List Get() //{ // return Objective.Service.Get(); //} //#endregion //#region Get By ID //public static Objective Get(int id) //{ // return Objective.Service.Get(id); //} //#endregion //#region Get By Employee ID //public static List GetByEmployeeID(int Empid, int PMPYID, bool IsDrafted) //{ // return Objective.Service.GetByEmployeeID(Empid, PMPYID, IsDrafted); //} //public static List GetLMObjs(int Empid, int PMPYID, int nLMID) //{ // return Objective.Service.GetLMObjs(Empid, PMPYID, nLMID); //} //public static List GetByEmployeeID(string sEmpids, int PMPYID, bool IsDrafted) //{ // return Objective.Service.GetByEmployeeID(sEmpids, PMPYID, IsDrafted); //} //public static List GetByPMPYearID(int id, string InEmpSQL) //{ // return Objective.Service.GetByPMPYearID(id, InEmpSQL); //} //public static List GetByStatus(EnumPMPStatus estatus, bool IsFinalized) //{ // return Objective.Service.GetByStatus(estatus, IsFinalized); //} //#endregion //#region Get Draft Objective //public static List GetObjectives(int id, int draft) //{ // return Objective.Service.GetObjectives(id, draft); //} //#endregion //#region Get By Line Manager ID //public static Objective GetByLMID(int id) //{ // return Objective.Service.GetByLMID(id); //} //#endregion //#region Get Line Manager Obj //public static Objective GetLineManager(int id) //{ // return Objective.Service.GetLineManager(id); //} //#endregion //#region Save //public static void Update(List objectives) //{ // //this.SetAuditTrailProperties(); // Objective.Service.Update(objectives); //} //public int Save() //{ // this.SetAuditTrailProperties(); // return Objective.Service.Save(this); //} //public static void Save(List items) //{ // foreach (Objective item in items) // { // item.SetAuditTrailProperties(); // } // Objective.Service.Save(items); //} //public static void SaveForUpload(List items) //{ // foreach (Objective item in items) // { // item.SetAuditTrailProperties(); // } // Objective.Service.SaveForUpload(items); //} //public static void SaveForSalesUpload(List items) //{ // foreach (Objective item in items) // { // item.SetAuditTrailProperties(); // } // Objective.Service.SaveForSalesUpload(items); //} ////public string Save2(List UpdateHistory) ////{ //// this.SetAuditTrailProperties(); //// return Objective.Service.Save2(this, UpdateHistory); ////} //#endregion //#region Delete //public void Delete() //{ // Objective.Service.Delete(this.ID); //} //public static void DeleteAllCompanyObj(int yearID) //{ // Objective.Service.DeleteAllCompanyObj(yearID); //} //#endregion //public static DataSet GetComObjAssignedEmpID(int PMPYearID) //{ // DataSet oDataSet = new DataSet(); // oDataSet = Objective.Service.GetComObjAssignedEmpID(PMPYearID); // return oDataSet; //} //public static DataSet GetEmpObjectiveData(int year) //{ // DataSet oDataSet = new DataSet(); // oDataSet = Objective.Service.GetEmpObjectiveData(year); // return oDataSet; //} //public static DataSet GetEmpFreezedObjectiveData() //{ // DataSet oDataSet = new DataSet(); // oDataSet = Objective.Service.GetEmpFreezedObjectiveData(); // return oDataSet; //} //public bool IsValid(out string errorMessage) //{ // errorMessage = string.Empty; // StringBuilder sb = new StringBuilder(); // bool isValid = true; // ValidationContext context = new ValidationContext(this); // var result = new List(); // isValid = isValid && Validator.TryValidateObject(this, context, result, true); // foreach (var item in result) // { // sb.Append(item.ErrorMessage + Environment.NewLine); // } // double availablePercent; // if(this.EmployeeID == null || this.EmployeeID.IsUnassigned) // { // isValid = isValid && false; // sb.Append("Please Select an Employee." + Environment.NewLine); // } // if (!IsValidPercent(out availablePercent)) // { // isValid = isValid && false; // sb.Append("Total percent cannot greater than assigned percent. Available percent= " + availablePercent+ "% " + Environment.NewLine); // } // errorMessage = sb.ToString().Trim(); // return isValid; //} //private bool IsValidPercent(out double availablePercent) //{ // bool sts = true; // availablePercent = 0; // if (this.PriorityPercent > 0 && this.PriorityPercent <= 100) // { // List _ObjectiveCategoryGrades = ObjectiveCategoryGrades.GetByPMPYear(this.PMPYearID); // Employee oEmp = Employee.Get(this.EmployeeID); // List _ObjectiveGrades = _ObjectiveCategoryGrades.Where(obj => obj.GradeID == oEmp.GradeID && obj.Percent > 0).ToList(); // ObjectiveCategoryGrades oObjectiveType = _ObjectiveGrades.FirstOrDefault(item => item.ObjectiveType == this.ObjectiveType); // double nValidPercent = 0; // if (oObjectiveType != null) // nValidPercent = oObjectiveType.Percent; // double nTotalPercent = Objective.GetByEmployeeID(this.EmployeeID, this.PMPYearID, false) // .Where(x => x.ObjectiveType == this.ObjectiveType) // .Sum(x => x.PriorityPercent); // availablePercent = nValidPercent - nTotalPercent; // if (nTotalPercent + this.PriorityPercent > nValidPercent) // { // //MessageBox.Show("Total percent cannot greater than assigned percent. Available percent= " + (nValidPercent - nTotalPercent).ToString(), "Message", MessageBoxButtons.OK, MessageBoxIcon.Information); // sts = false; // } // } // return sts; //} //#endregion //#region Service Factory IObjective : IObjective //internal static IObjectiveService Service //{ // get { return Services.Factory.CreateService(typeof(IObjectiveService)); } //} //#endregion #endregion } #region IObjectiveService Service public interface IObjectiveService { List Get(); Objective Get(int id); Objective GetByLMID(int id); List GetByEmployeeID(int Empid, int PMPID, bool IsDrafted); List GetForValidation(int empId, int pmpYearId, int objectTypeId); List GetByEmployeeID(string Empids, int PMPID, bool IsDrafted); List GetByStatus(EnumPMPStatus estatus, bool IsFinalized); List GetObjectives(int id, int draft); int Save(Objective item); void Save(List items); //string Save2(Objective item, List UpdateHistory); void Delete(int id); List GetDevelopmentPlans(int iD); List GetLMObjectives(int iD); List GetObjectiveEmployees(int iD); Objective GetLineManager(int id); List GetByPMPYearID(int id, string InEmpSQL); void Update(List objectives); List GetLMObjs(int Empid, int PMPYID, int nLMID); DataSet GetComObjAssignedEmpID(int PMPYearID); void DeleteAllCompanyObj(int yearID); void SaveForUpload(List items); void SaveForSalesUpload(List items); DataSet GetEmpObjectiveData(int year); DataSet GetEmpFreezedObjectiveData(); DataSet GetPmsDataEmployeeWise(int pmpYearId, string empIds); DataSet GetPmsLmGoalReport(int pmpYearId, int empId); DataSet GetPmsIndividualGoalData(int pmpYearId, int empId); } #endregion }