using System; using System.Collections.Generic; using System.Linq; using System.Text; using Ease.CoreV35.Caching; using Ease.CoreV35.Model; namespace Payroll.BO { #region Class TrainingNeedAnalysis [Serializable] public class TrainingNeedAnalysis: AuditTrailBase { #region Cache Store private static Cache _cache = new Cache(typeof(TrainingNeedAnalysis)); #endregion #region Constructor public TrainingNeedAnalysis() { _trainingYear = 0; _name = string.Empty; _departmentID = 0; _employeeID = 0; _trainingID = 0; _description = string.Empty; _maxParticipent = 0; // _schedule = string.Empty; _conduct_Required = 0; } #endregion #region Properties #region Salary TrainingYear : DateTime private int _trainingYear; public int TrainingYear { get { return _trainingYear; } set { _trainingYear = value; } } #endregion #region Property EmployeeID : ID private int _employeeID; public int EmployeeID { get { return _employeeID; } set { _employeeID = value; } } #endregion #region TrainingID:int private int _trainingID; public int TrainingID { get { return _trainingID; } set { _trainingID = value; } } #endregion #region DepartmentID:int private int _departmentID; public int DepartmentID { get { return _departmentID; } set { _departmentID = value; } } #endregion #region Property Description : string private string _description; public string Description { get { return _description; } set { _description = value; } } #endregion #region Property Name : string private string _name; public string Name { get { return _name; } set { _name = value; base.SetObjectStateModified(); } } #endregion #region Property MaxParticipent : int private int _maxParticipent; public int MaxParticipent { get { return _maxParticipent; } set { _maxParticipent = value; } } #endregion #region Property Conduct_Required : int private double _conduct_Required; public double Conduct_Required { get { return _conduct_Required; } set { _conduct_Required = value; } } #endregion //#region Property Schedule : string //private string _schedule; //public string Schedule //{ // get // { // return _schedule; // } // set // { // _schedule = value; // } //} //#endregion #region Property TrainingDepartments : TrainingDepartment private ObjectsTemplate _trainingDepartments; public ObjectsTemplate TrainingDepartments { get { if (_trainingDepartments == null && !this.ID.IsUnassigned && this.ID.Integer > 0) { _trainingDepartments = TrainingDepartment.Service.GetByTrainingNeedAnalysisID(this.ID); } return _trainingDepartments; } set { _trainingDepartments = value; } } #endregion #region Property TrainingNdAnalysisTimeSch : TrainingNdAnalysisTimeSch private ObjectsTemplate _trainingNdAnalysisTimeSchs; public ObjectsTemplate TrainingNdAnalysisTimeSchs { get { if (_trainingNdAnalysisTimeSchs == null && !this.ID.IsUnassigned && this.ID.Integer > 0) { _trainingNdAnalysisTimeSchs = TrainingNdAnalysisTimeSch.Service.GetByTrainingNeedAnalysisID(this.ID); } return _trainingNdAnalysisTimeSchs; } set { _trainingNdAnalysisTimeSchs = value; } } #endregion #endregion #region Functions public static TrainingNeedAnalysis Get(int nTrainingNeedAnalysisID) { TrainingNeedAnalysis oTrainingNeedAnalysis = null; #region Cache Header oTrainingNeedAnalysis = (TrainingNeedAnalysis)_cache["Get", nTrainingNeedAnalysisID]; if (oTrainingNeedAnalysis != null) return oTrainingNeedAnalysis; #endregion oTrainingNeedAnalysis = TrainingNeedAnalysis.Service.Get(ID.FromInteger(nTrainingNeedAnalysisID)); #region Cache Footer _cache.Add(oTrainingNeedAnalysis, "Get", nTrainingNeedAnalysisID); #endregion return oTrainingNeedAnalysis; } public ID Save() { this.SetAuditTrailProperties(); return TrainingNeedAnalysis.Service.Save(this); } public static void Delete(ID id) { TrainingNeedAnalysis.Service.Delete(id); } public static string GetStatus(TrainingNeedAnalysis oTNA) { string status = string.Empty; if (oTNA.TrainingID > 0) { ObjectsTemplate oTrainingSch = TrainingSchedule.Get(oTNA.TrainingID,oTNA.ID.Integer, true); if (oTrainingSch.Count > 0) { //int left = oTNA.TrainingNdAnalysisTimeSchs.Count - oTrainingSch.Count; status = "Scheduled (" + oTrainingSch.Count+")"; } else { status = "Not Schedule"; } } else { status = "Training Not Available"; } return status; } #endregion #region Collection Functions public static ObjectsTemplate Get() { ObjectsTemplate oTrainingNeedAnalysiss = null; #region Cache Header oTrainingNeedAnalysiss = (ObjectsTemplate)_cache["Get"]; if (oTrainingNeedAnalysiss != null) return oTrainingNeedAnalysiss; #endregion oTrainingNeedAnalysiss = TrainingNeedAnalysis.Service.Get(); #region Cache Footer _cache.Add(oTrainingNeedAnalysiss, "Get"); #endregion return oTrainingNeedAnalysiss; } public string GetTimeschedule(int year) { string str = ""; int nCount = 0; foreach (TrainingNdAnalysisTimeSch item in this.TrainingNdAnalysisTimeSchs) { nCount = nCount + 1; str = str + item.Month.ToString() + " " + year.ToString(); if (nCount != this.TrainingNdAnalysisTimeSchs.Count) str = str + ", "; } return str; } public string GetDepartmetns() { string str = ""; int nCount = 0; foreach (TrainingDepartment item in this.TrainingDepartments) { nCount = nCount + 1; Department od = Department.Get(item.DepartmentID); str = str + od.Name.ToString(); if (nCount != this.TrainingNdAnalysisTimeSchs.Count) str = str + ", "; } return str; } public static ObjectsTemplate GetByYear(int year) { ObjectsTemplate oTrainingNeedAnalysiss = null; #region Cache Header oTrainingNeedAnalysiss = (ObjectsTemplate)_cache["Get"]; if (oTrainingNeedAnalysiss != null) return oTrainingNeedAnalysiss; #endregion oTrainingNeedAnalysiss = TrainingNeedAnalysis.Service.GetByYear(year); #region Cache Footer _cache.Add(oTrainingNeedAnalysiss, "Get"); #endregion return oTrainingNeedAnalysiss; } public static ObjectsTemplate GetByParam(int year, string sDeptIDs, string sDeptForIDs) { ObjectsTemplate oTrainingNeedAnalysiss = null; #region Cache Header oTrainingNeedAnalysiss = (ObjectsTemplate)_cache["Get"]; if (oTrainingNeedAnalysiss != null) return oTrainingNeedAnalysiss; #endregion oTrainingNeedAnalysiss = TrainingNeedAnalysis.Service.GetByParam(year, sDeptIDs, sDeptForIDs); #region Cache Footer _cache.Add(oTrainingNeedAnalysiss, "Get"); #endregion return oTrainingNeedAnalysiss; } #endregion #region Service Factory internal static ITrainingNeedAnalysisService Service { get { return Services.Factory.CreateService(typeof(ITrainingNeedAnalysisService)); } } #endregion public static ObjectsTemplate Get(string query) { ObjectsTemplate oTrainingNeedAnalysiss = null; #region Cache Header oTrainingNeedAnalysiss = (ObjectsTemplate)_cache["Get"]; if (oTrainingNeedAnalysiss != null) return oTrainingNeedAnalysiss; #endregion oTrainingNeedAnalysiss = TrainingNeedAnalysis.Service.Get(query); #region Cache Footer _cache.Add(oTrainingNeedAnalysiss, "Get"); #endregion return oTrainingNeedAnalysiss; } } #endregion #region ITrainingNeedAnalysisService Service public interface ITrainingNeedAnalysisService { TrainingNeedAnalysis Get(ID id); ObjectsTemplate Get(); ObjectsTemplate GetByYear(int year); ObjectsTemplate Get(string query); ID Save(TrainingNeedAnalysis oTrainingNeedAnalysis); void Delete(ID id); ObjectsTemplate Get(int trainingID, int departmentID, int departmentForID, int trainingType); ObjectsTemplate GetByParam(int year, string sDeptIDs, string sDeptForIDs); } #endregion }