using Ease.Core.DataAccess; using Ease.Core.Model; using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using System.Data; using System.IO; using System.Reflection; namespace HRM.BO { #region Class TrainingSchedule public class TrainingSchedule : AuditTrailBase { #region Constructor public TrainingSchedule() { TrainingID = 0; TrainingNatureID = 0; InstituteID = 0; StartDate = DateTime.MinValue; EndDate = DateTime.MinValue; Cost = 0; MaxParticipants = 0; EnrolledParticipants = 0; CourseOutline = string.Empty; ScheduleStatus = true; EnrolledTrainingEmployees = null; TrainingScheduleDates = null; TNAnalysisID = 0; IsShowInWeb = false; //#### _payrollTypeID = SystemInformation.CurrentSysInfo.PayrollTypeID; Venue = string.Empty; } #endregion #region Properties public int TrainingID { get; set; } public int TrainingNatureID { get; set; } public int InstituteID { get; set; } public DateTime StartDate { get; set; } public DateTime EndDate { get; set; } public DateTime? EnrolledStartDate { get; set; } public DateTime? EnrolledEndDate { get; set; } public double Cost { get; set; } public int MaxParticipants { get; set; } public int EnrolledParticipants { get; set; } public string CourseOutline { get; set; } public string Venue { get; set; } public string TrainerDescription { get; set; } public bool ScheduleStatus { get; set; } public string Name { get; set; } //public string Name //{ // get // { // return String.Format("{0} From: {1} To: {2}", Training.Get(TrainingID).Name, // StartDate.ToString("dd MMM yyyy"), EndDate.ToString("dd MMM yyyy")); // } //} public bool IsShowInWeb { get; set; } public int TNAnalysisID { get; set; } public int PayrollTypeID { get; set; } public double VenueCost { get; set; } public double RefreshmentCost { get; set; } public double TrainerFees { get; set; } public double OthesCost { get; set; } public Training Training { get; set; } public double ManHour { get; set; } public double ManDays { get; set; } public string DocumentName { get; set; } public string TrainingName { get; set; } public string TrainingTypeName { get; set; } //private Training _training; //public Training Training //{ // get // { // if (_training == null && _trainingID != null) // { // //_employee = new Employee(); // _training = Training.Get(_trainingID.Integer); // } // return _training; // } // set // { // _training = value; // } //} public List EnrolledTrainingEmployees { get; set; } public List TrainingScheduleDates { get; set; } public List TrainingScheduleAttns { get; set; } //#region Property TrainingScheduleEmployees : TrainingScheduleEmployee //private List _enrolledTrainingEmployees; //public List EnrolledTrainingEmployees //{ // get // { // if (_enrolledTrainingEmployees == null && !this.ID.IsUnassigned && this.ID.Integer > 0) // { // _enrolledTrainingEmployees = Service.GetTrainingScheduleEmployees(this.ID); // } // return _enrolledTrainingEmployees; // } // set // { // _enrolledTrainingEmployees = value; // } //} //#endregion //#region Property TrainingScheduleDates : TrainingScheduleDate //private List _trainingScheduleDates; //public List TrainingScheduleDates //{ // get // { // if (_trainingScheduleDates == null && !this.ID.IsUnassigned && this.ID.Integer > 0) // { // _trainingScheduleDates = Service.GetTrainingScheduleDates(this.ID); // } // return _trainingScheduleDates; // } // set // { // _trainingScheduleDates = value; // } //} //#endregion //#region Property TrainingScheduleDates : TrainingScheduleDate //private List _trainingScheduleAttn; //public List TrainingScheduleAttns //{ // get // { // if (_trainingScheduleAttn == null && !this.ID.IsUnassigned && this.ID.Integer > 0) // { // _trainingScheduleAttn =Payroll.BO.TrainingScheduleAttn.GetByTrainingScheduleID(this.ID); // } // return _trainingScheduleAttn; // } // set // { // _trainingScheduleAttn = value; // } //} //#endregion #endregion //#region Functions //public static TrainingSchedule Get(int nTrainingScheduleID) //{ // TrainingSchedule oTrainingSchedule; // #region Cache Header // oTrainingSchedule = (TrainingSchedule)_cache["Get", nTrainingScheduleID]; // if (oTrainingSchedule != null) // return oTrainingSchedule; // #endregion // oTrainingSchedule = Service.Get((nTrainingScheduleID)); // #region Cache Footer // _cache.Add(oTrainingSchedule, "Get", nTrainingScheduleID); // #endregion // return oTrainingSchedule; //} //public static TrainingScheduleEmployee getScheduleEmp(int SEmpID) //{ // TrainingScheduleEmployee oTrainingScheduleEmp; // #region Cache Header // oTrainingScheduleEmp = (TrainingScheduleEmployee)_cache["getScheduleEmp", SEmpID]; // if (oTrainingScheduleEmp != null) // return oTrainingScheduleEmp; // #endregion // oTrainingScheduleEmp = Service.getScheduleEmp(SEmpID); // #region Cache Footer // _cache.Add(oTrainingScheduleEmp, "getScheduleEmp", SEmpID); // #endregion // return oTrainingScheduleEmp; //} //public int Save() //{ // this.SetAuditTrailProperties(); // return Service.Save(this); //} //public int SaveAttnStatus() //{ // this.SetAuditTrailProperties(); // return Service.SaveAttnStatus(this); //} //public int SaveTrainingEmp(TrainingScheduleEmployee tEmp) //{ // return Service.SaveTrainingEmp(tEmp); //} //public void Delete() //{ // TrainingSchedule.Service.Delete(this.ID); //} //public void DeleteNominatedEmp(int SEmpID) //{ //TrainingSchedule.Service.DeleteNominatedEmp(SEmpID); //} //public void updateScheduleEmp(int SEmpID, int status) //{ // TrainingSchedule.Service.updateScheduleEmp(SEmpID, status); //} //#endregion //#region Collection Functions //public static List Get() //{ // List oTrainingSchedules = null; // #region Cache Header // oTrainingSchedules = (List)_cache["Get"]; // if (oTrainingSchedules != null) // return oTrainingSchedules; // #endregion // oTrainingSchedules = Service.Get(SystemInformation.CurrentSysInfo.PayrollTypeID.Integer); // #region Cache Footer // _cache.Add(oTrainingSchedules, "Get"); // #endregion // return oTrainingSchedules; //} //public static List GetbyStatus(int status) //{ // List oTrainingSchedules = null; // #region Cache Header // oTrainingSchedules = (List)_cache["Get"]; // if (oTrainingSchedules != null) // return oTrainingSchedules; // #endregion // oTrainingSchedules = Service.GetbyStatus(status,SystemInformation.CurrentSysInfo.PayrollTypeID.Integer); // #region Cache Footer // _cache.Add(oTrainingSchedules, "Get"); // #endregion // return oTrainingSchedules; //} //public static List Get(bool active) //{ // List oTrainingSchedules = null; // #region Cache Header // oTrainingSchedules = (List)_cache["Get"]; // if (oTrainingSchedules != null) // return oTrainingSchedules; // #endregion // oTrainingSchedules = Service.Get(active,SystemInformation.CurrentSysInfo.PayrollTypeID.Integer); // #region Cache Footer // _cache.Add(oTrainingSchedules, "Get"); // #endregion // return oTrainingSchedules; //} //public static List Get(DateTime today) //{ // List oTrainingSchedules = null; // #region Cache Header // oTrainingSchedules = (List)_cache["Get"]; // if (oTrainingSchedules != null) // return oTrainingSchedules; // #endregion // oTrainingSchedules = Service.Get(today,SystemInformation.CurrentSysInfo.PayrollTypeID.Integer); // #region Cache Footer // _cache.Add(oTrainingSchedules, "Get"); // #endregion // return oTrainingSchedules; //} //public static List Get(DateTime fromDate, DateTime toDate, int training) //{ // List oTrainingSchedules = null; // #region Cache Header // oTrainingSchedules = (List)_cache["Get"]; // if (oTrainingSchedules != null) // return oTrainingSchedules; // #endregion // oTrainingSchedules = Service.Get(fromDate, toDate, training,SystemInformation.CurrentSysInfo.PayrollTypeID.Integer); // #region Cache Footer // _cache.Add(oTrainingSchedules, "Get"); // #endregion // return oTrainingSchedules; //} //public static List Get(DateTime fromDate, DateTime toDate, int training, bool active) //{ // List oTrainingSchedules = null; // #region Cache Header // oTrainingSchedules = (List)_cache["Get"]; // if (oTrainingSchedules != null) // return oTrainingSchedules; // #endregion // oTrainingSchedules = Service.Get(fromDate, toDate, training, active,SystemInformation.CurrentSysInfo.PayrollTypeID.Integer); // #region Cache Footer // _cache.Add(oTrainingSchedules, "Get"); // #endregion // return oTrainingSchedules; //} //public static List Get(int training,int TNAID, bool active) //{ // List oTrainingSchedules = null; // #region Cache Header // oTrainingSchedules = (List)_cache["Get"]; // if (oTrainingSchedules != null) // return oTrainingSchedules; // #endregion // oTrainingSchedules = Service.Get(training,TNAID, active,SystemInformation.CurrentSysInfo.PayrollTypeID.Integer); // #region Cache Footer // _cache.Add(oTrainingSchedules, "Get"); // #endregion // return oTrainingSchedules; //} //public static List Get(DateTime today, int EmpID, int status) //{ // List oTrainingSchedules = null; // #region Cache Header // oTrainingSchedules = (List)_cache["Get"]; // if (oTrainingSchedules != null) // return oTrainingSchedules; // #endregion // oTrainingSchedules = Service.Get(today, EmpID, status,SystemInformation.CurrentSysInfo.PayrollTypeID.Integer); // #region Cache Footer // _cache.Add(oTrainingSchedules, "Get"); // #endregion // return oTrainingSchedules; //} //public static List Get(int training, int TNAID) //{ // List oTrainingSchedules = null; // #region Cache Header // oTrainingSchedules = (List)_cache["Get"]; // if (oTrainingSchedules != null) // return oTrainingSchedules; // #endregion // oTrainingSchedules = Service.Get(training, TNAID,SystemInformation.CurrentSysInfo.PayrollTypeID.Integer); // #region Cache Footer // _cache.Add(oTrainingSchedules, "Get"); // #endregion // return oTrainingSchedules; //} //public static List Get(DateTime fromDate, DateTime toDate, bool active) //{ // List oTrainingSchedules = null; // #region Cache Header // oTrainingSchedules = (List)_cache["Get"]; // if (oTrainingSchedules != null) // return oTrainingSchedules; // #endregion // oTrainingSchedules = Service.Get(fromDate, toDate, active,SystemInformation.CurrentSysInfo.PayrollTypeID.Integer); // #region Cache Footer // _cache.Add(oTrainingSchedules, "Get"); // #endregion // return oTrainingSchedules; //} //public static List Get(DateTime fromDate, DateTime toDate) //{ // List oTrainingSchedules = null; // #region Cache Header // oTrainingSchedules = (List)_cache["Get"]; // if (oTrainingSchedules != null) // return oTrainingSchedules; // #endregion // oTrainingSchedules = Service.Get(fromDate, toDate,SystemInformation.CurrentSysInfo.PayrollTypeID.Integer); // #region Cache Footer // _cache.Add(oTrainingSchedules, "Get"); // #endregion // return oTrainingSchedules; //} //public List GetEmployees() //{ // List employees = new List(); // if (EnrolledTrainingEmployees == null || EnrolledTrainingEmployees.Count == 0) // return null; // foreach (TrainingScheduleEmployee trainingEmployee in _enrolledTrainingEmployees) // { // Employee employee = null; // employee = Employee.Get(trainingEmployee.EmployeeID); // employees.Add(employee); // } // return employees; //} //public static DataSet Get(string query) //{ // DataSet ds = null; // try // { // ds = Service.Get(query); // } // catch (ServiceException e) // { // throw new Exception(e.Message, e); // } // return ds; //} //#endregion //#region Service Factory //internal static ITrainingScheduleService Service //{ // get // { // return Services.Factory.CreateService(typeof(ITrainingScheduleService)); // } //} //#endregion } #endregion #region Child Classes #region Class TrainingScheduleEmployee public class TrainingScheduleEmployee : BasicBaseObject, IworkflowInterface { #region Constructor public TrainingScheduleEmployee() { TrainingScheduleID = 0; EmployeeID = 0; ProposedByID = 0; ProposedDate = DateTime.MinValue; ScheduleEmpStatus = EnumTSStatus.Requested; Remarks = string.Empty; } #endregion #region Properties public int ProposedByID { get; set; } public DateTime ProposedDate { get; set; } public int TrainingScheduleID { get; set; } public int EmployeeID { get; set; } public EnumTSStatus ScheduleEmpStatus { get; set; } public Employee Employee { get; set; } //private Employee _employee; //public Employee Employee //{ // get // { // if (_employee == null && _employeeID != null) // { // //_employee = new Employee(); // _employee = Employee.Get(_employeeID); // } // return _employee; // } // set // { // _employee = value; // } //} public double GetTrainingCost() { double nAmount = 0; if (this.TrainingSchEmpCosts == null) return 0; foreach (TrainingSchEmpCost item in this.TrainingSchEmpCosts) { nAmount = nAmount + item.Amount; } return nAmount; } public TrainingSchedule TrainingSchedule { get; set; } //private TrainingSchedule _trainingSchedule; //public TrainingSchedule TrainingSchedule //{ // get // { // if (_trainingSchedule == null && _trainingScheduleID != null && _trainingScheduleID != null) // { // //_employee = new Employee(); // _trainingSchedule = TrainingSchedule.Get( _trainingScheduleID.Integer); // } // return _trainingSchedule; // } // set // { // _trainingSchedule = value; // } //} public List TrainingSchEmpCosts { get; set; } //#region Property TrainingSchEmpCost : TrainingSchEmpCost //private List _trainingSchEmpCosts; //public List TrainingSchEmpCosts //{ // get // { // if (_trainingSchEmpCosts == null && !this.ID.IsUnassigned && this.ID.Integer > 0) // { // _trainingSchEmpCosts = TrainingSchEmpCost.Service.GetByTrainingScheduleEmpID(this.EmployeeID, this.ID); // } // return _trainingSchEmpCosts; // } // set // { // _trainingSchEmpCosts = value; // } //} //#endregion public string Remarks { get; set; } #endregion /// /// this property is used for work flow, which return Training description /// public string ObjectDescription { get { //string str = ""; //str = " Employee (" + this.Employee.EmployeeNo + ")" + this.Employee.Name // + " applied enrollment request for " + this.TrainingSchedule.Training.Name + " on " + // this.CreatedDate.ToString("dd MMM yyyy"); //return str; return null; } } /// /// this property is used for work flow, it's a constant value /// public int SetupID { get { return (5); } } /// /// this property is used for work flow, which return leave entry id /// public int ObjectID { get { return this.ID; } } public List GetDetails() { List opJobsDetail = new List(); opJobsDetail.Add(new PendingJobDetail() { Type = "Trainee:", Value = this.Employee.Name }); if (TrainingSchedule != null) { opJobsDetail.Add(new PendingJobDetail() { Type = "Training:", Value = this.TrainingSchedule.Training.Name }); opJobsDetail.Add(new PendingJobDetail() { Type = "Training Schedule:", Value = this.TrainingSchedule.Name }); opJobsDetail.Add(new PendingJobDetail() { Type = "Training Cost:", Value = this.TrainingSchedule.Cost.ToString("#,###") }); opJobsDetail.Add(new PendingJobDetail() { Type = "Training Duration:", Value = this.TrainingSchedule.StartDate.ToString("dd MMM yyyy") + " - " + this.TrainingSchedule.EndDate.ToString("dd MMM yyyy") }); } // add more items as per need return opJobsDetail; } } #endregion #region Class TrainingScheduleDate public class TrainingScheduleDate: BasicBaseObject { #region Constructor public TrainingScheduleDate() { TrainingScheduleID = 0; ScheduleDate = DateTime.MinValue; StartTime = DateTime.MinValue; EndTime = DateTime.MinValue; Remarks = string.Empty; } #endregion #region Properties public int TrainingScheduleID { get; set; } public DateTime ScheduleDate { get; set; } public DateTime StartTime { get; set; } public DateTime EndTime { get; set; } public string Remarks { get; set; } public String StartTimeString { get; set; } public String EndTimeString { get; set; } public List TrainingScheduleAttns { get; set; } //#region Property TrainingScheduleDates : TrainingScheduleDate //private List _trainingScheduleAttns; //public List TrainingScheduleAttns //{ // get // { // if (_trainingScheduleAttns == null && !this.ID.IsUnassigned && this.ID.Integer > 0) // { // _trainingScheduleAttns = TrainingScheduleAttn.Service.GetByTrainingScheduleDateID(this.ID); // } // return _trainingScheduleAttns; // } // set // { // _trainingScheduleAttns = value; // } //} //#endregion #endregion } #endregion #endregion #region ITrainingSchedule Service public interface ITrainingScheduleService { TrainingSchedule Get(int id); List GetWithPayrollType(int payrollTypeID); List Get(bool active, int payrollTypeID); List Get(DateTime today, int payrollTypeID); List Get(DateTime fromDate, DateTime toDate, int training, int payrollTypeID); List GetbyStatus(int status,int payrollTypeID); List Get(DateTime fromDate, DateTime toDate, int training, bool active, int payrollTypeID); List Get(DateTime fromDate, DateTime toDate, int payrollTypeID); List Get(DateTime fromDate, DateTime toDate, bool active, int payrollTypeID); List Get(DateTime today, int EmpID, int status, int payrollTypeID); List Get(int training, int TNAID, bool active, int payrollTypeID); List Get(int training, int TNAID, int payrollTypeID); int Save(TrainingSchedule oTrainingSchedule); void Delete(int id); void DeleteNominatedEmp(int SEmpID); void updateScheduleEmp(int SEmpID, int status); TrainingScheduleEmployee getScheduleEmp(int SEmpID); List GetTrainingScheduleDates(int trainingScheduleID); List GetTrainingScheduleEmployees(int trainingScheduleID); int SaveAttnStatus(TrainingSchedule trainingSchedule); DataSet Get(string query); List GetTrainingSchedule(int trainingId, int trainingTypeId, DateTime? fromDate, DateTime? toDate); int SaveTrainingEmp(TrainingScheduleEmployee tEmp); } #endregion }