EchoTex_Payroll/HRM.BO/TrainingBOs/TrainingSchedule.cs

690 lines
25 KiB
C#
Raw Normal View History

2024-10-14 10:01:49 +06:00

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<TrainingScheduleEmployee> EnrolledTrainingEmployees { get; set; }
public List<TrainingScheduleDate> TrainingScheduleDates { get; set; }
public List<TrainingScheduleAttn> TrainingScheduleAttns { get; set; }
//#region Property TrainingScheduleEmployees : TrainingScheduleEmployee
//private List<TrainingScheduleEmployee> _enrolledTrainingEmployees;
//public List<TrainingScheduleEmployee> 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<TrainingScheduleDate> _trainingScheduleDates;
//public List<TrainingScheduleDate> 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> _trainingScheduleAttn;
//public List<TrainingScheduleAttn> 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<TrainingSchedule> Get()
//{
// List<TrainingSchedule> oTrainingSchedules = null;
// #region Cache Header
// oTrainingSchedules = (List<TrainingSchedule>)_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<TrainingSchedule> GetbyStatus(int status)
//{
// List<TrainingSchedule> oTrainingSchedules = null;
// #region Cache Header
// oTrainingSchedules = (List<TrainingSchedule>)_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<TrainingSchedule> Get(bool active)
//{
// List<TrainingSchedule> oTrainingSchedules = null;
// #region Cache Header
// oTrainingSchedules = (List<TrainingSchedule>)_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<TrainingSchedule> Get(DateTime today)
//{
// List<TrainingSchedule> oTrainingSchedules = null;
// #region Cache Header
// oTrainingSchedules = (List<TrainingSchedule>)_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<TrainingSchedule> Get(DateTime fromDate, DateTime toDate, int training)
//{
// List<TrainingSchedule> oTrainingSchedules = null;
// #region Cache Header
// oTrainingSchedules = (List<TrainingSchedule>)_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<TrainingSchedule> Get(DateTime fromDate, DateTime toDate, int training, bool active)
//{
// List<TrainingSchedule> oTrainingSchedules = null;
// #region Cache Header
// oTrainingSchedules = (List<TrainingSchedule>)_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<TrainingSchedule> Get(int training,int TNAID, bool active)
//{
// List<TrainingSchedule> oTrainingSchedules = null;
// #region Cache Header
// oTrainingSchedules = (List<TrainingSchedule>)_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<TrainingSchedule> Get(DateTime today, int EmpID, int status)
//{
// List<TrainingSchedule> oTrainingSchedules = null;
// #region Cache Header
// oTrainingSchedules = (List<TrainingSchedule>)_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<TrainingSchedule> Get(int training, int TNAID)
//{
// List<TrainingSchedule> oTrainingSchedules = null;
// #region Cache Header
// oTrainingSchedules = (List<TrainingSchedule>)_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<TrainingSchedule> Get(DateTime fromDate, DateTime toDate, bool active)
//{
// List<TrainingSchedule> oTrainingSchedules = null;
// #region Cache Header
// oTrainingSchedules = (List<TrainingSchedule>)_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<TrainingSchedule> Get(DateTime fromDate, DateTime toDate)
//{
// List<TrainingSchedule> oTrainingSchedules = null;
// #region Cache Header
// oTrainingSchedules = (List<TrainingSchedule>)_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<Employee> GetEmployees()
//{
// List<Employee> employees = new List<Employee>();
// 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<ITrainingScheduleService>(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<TrainingSchEmpCost> TrainingSchEmpCosts { get; set; }
//#region Property TrainingSchEmpCost : TrainingSchEmpCost
//private List<TrainingSchEmpCost> _trainingSchEmpCosts;
//public List<TrainingSchEmpCost> 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
/// <summary>
/// this property is used for work flow, which return Training description
/// </summary>
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;
}
}
/// <summary>
/// this property is used for work flow, it's a constant value
/// </summary>
public int SetupID
{
get { return (5); }
}
/// <summary>
/// this property is used for work flow, which return leave entry id
/// </summary>
public int ObjectID
{
get { return this.ID; }
}
public List<PendingJobDetail> GetDetails()
{
List<PendingJobDetail> opJobsDetail = new List<PendingJobDetail>();
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<TrainingScheduleAttn> TrainingScheduleAttns { get; set; }
//#region Property TrainingScheduleDates : TrainingScheduleDate
//private List<TrainingScheduleAttn> _trainingScheduleAttns;
//public List<TrainingScheduleAttn> 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<TrainingSchedule> GetWithPayrollType(int payrollTypeID);
List<TrainingSchedule> Get(bool active, int payrollTypeID);
List<TrainingSchedule> Get(DateTime today, int payrollTypeID);
List<TrainingSchedule> Get(DateTime fromDate, DateTime toDate, int training, int payrollTypeID);
List<TrainingSchedule> GetbyStatus(int status,int payrollTypeID);
List<TrainingSchedule> Get(DateTime fromDate, DateTime toDate, int training, bool active, int payrollTypeID);
List<TrainingSchedule> Get(DateTime fromDate, DateTime toDate, int payrollTypeID);
List<TrainingSchedule> Get(DateTime fromDate, DateTime toDate, bool active, int payrollTypeID);
List<TrainingSchedule> Get(DateTime today, int EmpID, int status, int payrollTypeID);
List<TrainingSchedule> Get(int training, int TNAID, bool active, int payrollTypeID);
List<TrainingSchedule> 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<TrainingScheduleDate> GetTrainingScheduleDates(int trainingScheduleID);
List<TrainingScheduleEmployee> GetTrainingScheduleEmployees(int trainingScheduleID);
int SaveAttnStatus(TrainingSchedule trainingSchedule);
DataSet Get(string query);
List<TrainingSchedule> GetTrainingSchedule(int trainingId, int trainingTypeId, DateTime? fromDate, DateTime? toDate);
int SaveTrainingEmp(TrainingScheduleEmployee tEmp);
}
#endregion
}