CEL_Payroll/Payroll.BO/Basic/Grade.cs

595 lines
15 KiB
C#
Raw Normal View History

2024-09-17 14:30:13 +06:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Ease.CoreV35;
using Ease.CoreV35.Model;
using Ease.CoreV35.Caching;
using System.Data.Linq.Mapping;
namespace Payroll.BO
{
#region Grade
[Serializable]
public class Grade : BasicBaseObject
{
#region Cache Store
private static Cache _cache = new Cache(typeof(Grade));
#endregion
#region Constructor
#region Input validator
public string[] InputValidator()
{
string[] sErrorString = new string[2];
if (this.Code == "")
{
sErrorString[0] = "Code can not be empty";
sErrorString[1] = "Code";
return sErrorString;
}
if (this.Name == "")
{
sErrorString[0] = "Description can not be empty";
sErrorString[1] = "Description";
return sErrorString;
}
sErrorString = null;
return sErrorString;
}
#endregion
public Grade()
{
_code = string.Empty;
_name = string.Empty;
_maxBasic = 0;
_minBasic = 0;
_isTransport = false;
_hasGrossConcept = false;
_basicPercentofGross = 0;
_hasPayscale = false;
_confirmMonthDuration = 0;
_gradeSegmentID = null;
_gradeSegment = null;
_requiredDays = 0;
_status = EnumStatus.Active;
_colorCode = "White";
//_payrollTypeID = Payroll.BO.SystemInformation.CurrentSysInfo.PayrollTypeID;
}
#endregion
#region Properties
#region code : string
private string _code;
public string Code
{
get { return _code; }
set
{
base.OnPropertyChange<string>("code", _code, value);
_code = value;
}
}
#endregion
#region name : string
private string _name;
public string Name
{
get { return _name; }
set
{
base.OnPropertyChange<string>("name", _name, value);
_name = value;
}
}
#endregion
#region ColorCode : string
private string _colorCode;
public string ColorCode
{
get { return _colorCode; }
set
{
base.OnPropertyChange<string>("colorCode", _colorCode, value);
if (string.IsNullOrEmpty(value))
{
_colorCode = "White";
}
else
{
_colorCode = value;
}
}
}
#endregion
#region maxBasic : int
private int _maxBasic;
public int MaxBasic
{
get { return _maxBasic; }
set
{
base.OnPropertyChange<int>("maxBasic", _maxBasic, value);
_maxBasic = value;
}
}
#endregion
#region minBasic : int
private int _minBasic;
public int MinBasic
{
get { return _minBasic; }
set
{
base.OnPropertyChange<int>("minBasic", _minBasic, value);
_minBasic = value;
}
}
#endregion
#region isTransport : bool
private bool _isTransport;
public bool IsTransport
{
get { return _isTransport; }
set
{
base.OnPropertyChange<bool>("isTransport", _isTransport, value);
_isTransport = value;
}
}
#endregion
#region hasGrossConcept : bool
private bool _hasGrossConcept;
public bool HasGrossConcept
{
get { return _hasGrossConcept; }
set
{
base.OnPropertyChange<bool>("hasGrossConcept", _hasGrossConcept, value);
_hasGrossConcept = value;
}
}
#endregion
#region basicPercentofGross : double
private double _basicPercentofGross;
public double BasicPercentofGross
{
get { return _basicPercentofGross; }
set
{
base.OnPropertyChange<double>("basicPercentofGross", _basicPercentofGross, value);
_basicPercentofGross = value;
}
}
#endregion
#region hasPayscale : bool
private bool _hasPayscale;
public bool HasPayscale
{
get { return _hasPayscale; }
set
{
base.OnPropertyChange<bool>("hasPayscale", _hasPayscale, value);
_hasPayscale = value;
}
}
#endregion
#region confirmMonthDuration : int
private int _confirmMonthDuration;
public int ConfirmMonthDuration
{
get { return _confirmMonthDuration; }
set
{
base.OnPropertyChange<int>("confirmMonthDuration", _confirmMonthDuration, value);
_confirmMonthDuration = value;
}
}
#endregion
#region GradeSegmentID : ID
private ID _gradeSegmentID;
public ID GradeSegmentID
{
get { return _gradeSegmentID; }
set
{
base.OnPropertyChange<ID>("GradeSegmentID", _gradeSegmentID, value);
_gradeSegmentID = value;
}
}
#endregion
#region RequiredDays : int
private int _requiredDays;
public int RequiredDays
{
get { return _requiredDays; }
set
{
_requiredDays = value;
}
}
#endregion
#region gradeSegment : GradeSegment
private GradeSegment _gradeSegment;
public GradeSegment GradeSegment
{
get
{
if (_gradeSegmentID.Integer > 0 && _gradeSegment == null)
{
_gradeSegment = new GradeSegment();
_gradeSegment = GradeSegment.Get(_gradeSegmentID);
}
return this._gradeSegment;
}
set
{
_gradeSegment = value;
}
}
#endregion
#region PayrollTypeID : ID
private ID _payrollTypeID;
public ID PayrollTypeID
{
get { return _payrollTypeID; }
set { _payrollTypeID = value; }
}
#endregion
#region Service Factory IGradeService : IGradeService
internal static IGradeService Service
{
get { return Services.Factory.CreateService<IGradeService>(typeof(IGradeService)); }
}
#endregion
#endregion
#region Functions
public static Grade Get(ID nID)
{
Grade oGrade = null;
#region Cache Header
oGrade = (Grade)_cache["Get", nID];
if (oGrade != null)
return oGrade;
#endregion
oGrade = Grade.Service.Get(nID);
#region Cache Footer
_cache.Add(oGrade, "Get", nID);
#endregion
return oGrade;
}
public static Grade Get(string sCode)
{
Grade oGrade = null;
#region Cache Header
oGrade = (Grade)_cache["Get", sCode];
if (oGrade != null)
return oGrade;
#endregion
oGrade = Grade.Service.Get(sCode, Payroll.BO.SystemInformation.CurrentSysInfo.PayrollTypeID.Integer);
#region Cache Footer
_cache.Add(oGrade, "Get", sCode);
#endregion
return oGrade;
}
public static ObjectsTemplate<Grade> GetAllPayrollTypes(EnumStatus status)
{
#region Cache Header
ObjectsTemplate<Grade> grades = _cache["Get", status] as ObjectsTemplate<Grade>;
if (grades != null)
return grades;
#endregion
try
{
grades = Service.GetAllPayrollTypes(status);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(grades, "Get", status);
#endregion
return grades;
}
public string GetNextCode()
{
return Grade.Service.GetNextCode();
}
public static ObjectsTemplate<Grade> GetRegardlessPayrollType(EnumStatus status)
{
#region Cache Header
ObjectsTemplate<Grade> grades = _cache["GetRegardlessPayrollType", status] as ObjectsTemplate<Grade>;
if (grades != null)
return grades;
#endregion
try
{
grades = Service.GetRegardlessPayrollType(status, Payroll.BO.SystemInformation.CurrentSysInfo.PayrollTypeID.Integer);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(grades, "GetRegardlessPayrollType", status);
#endregion
return grades;
}
public static ObjectsTemplate<Grade> Get(EnumStatus status)
{
#region Cache Header
ObjectsTemplate<Grade> grades = _cache["Get",status] as ObjectsTemplate<Grade>;
if (grades != null)
return grades;
#endregion
try
{
grades = Service.Get(status, Payroll.BO.SystemInformation.CurrentSysInfo.PayrollTypeID.Integer);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(grades, "Get",status);
#endregion
return grades;
}
public static ObjectsTemplate<Grade> GetAddableGrades(ID nAllowDeductID,ID nADParamID)
{
#region Cache Header
ObjectsTemplate<Grade> grades = _cache["Get", nAllowDeductID, nADParamID] as ObjectsTemplate<Grade>;
if (grades != null)
return grades;
#endregion
try
{
grades = Service.GetAddableGrades(nAllowDeductID, nADParamID, Payroll.BO.SystemInformation.CurrentSysInfo.PayrollTypeID.Integer);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(grades, "Get", nAllowDeductID, nADParamID);
#endregion
return grades;
}
public static ObjectsTemplate<Grade> GetAllowableGrades(ID nOpiItmeID, ID nOpiParamID)
{
#region Cache Header
ObjectsTemplate<Grade> grades = _cache["GetAllowableGrades", nOpiItmeID, nOpiParamID] as ObjectsTemplate<Grade>;
if (grades != null)
return grades;
#endregion
try
{
grades = Service.GetAllowableGrades(nOpiItmeID, nOpiParamID,Payroll.BO.SystemInformation.CurrentSysInfo.PayrollTypeID.Integer);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(grades, "GetAllowableGrades", nOpiItmeID, nOpiParamID);
#endregion
return grades;
}
public static ObjectsTemplate<Grade> GetAddableGradesForOT(ID nTermID, ID nTermParameterID)
{
#region Cache Header
ObjectsTemplate<Grade> grades = _cache["Get", nTermID, nTermParameterID] as ObjectsTemplate<Grade>;
if (grades != null)
return grades;
#endregion
try
{
grades = Service.GetAddableGradesForOT(nTermID, nTermParameterID, Payroll.BO.SystemInformation.CurrentSysInfo.PayrollTypeID.Integer);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(grades, "Get", nTermID, nTermParameterID);
#endregion
return grades;
}
public static ObjectsTemplate<Grade> GetAddableGradesForBonus(ID nBonusID)
{
#region Cache Header
ObjectsTemplate<Grade> grades = _cache["Get", nBonusID] as ObjectsTemplate<Grade>;
if (grades != null)
return grades;
#endregion
try
{
grades = Service.GetAddableGradesForBonus(nBonusID, Payroll.BO.SystemInformation.CurrentSysInfo.PayrollTypeID.Integer);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(grades, "Get", nBonusID);
#endregion
return grades;
}
public ID Save()
{
this.SetAuditTrailProperties();
return Grade.Service.Save(this);
}
public void Delete()
{
Grade.Service.Delete(ID);
}
#endregion
public static ObjectsTemplate<Grade> GetAddableGradesForLoanParameter(ID LoaniD,ID LoanParameterId)
{
#region Cache Header
ObjectsTemplate<Grade> grades = _cache["Get", LoaniD] as ObjectsTemplate<Grade>;
if (grades != null)
return grades;
#endregion
try
{
grades = Service.GetAddableGradesForLoanParameter(LoaniD, LoanParameterId, Payroll.BO.SystemInformation.CurrentSysInfo.PayrollTypeID.Integer);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(grades, "Get", LoaniD);
#endregion
return grades;
}
}
#endregion
#region IGrade Service
public interface IGradeService
{
Grade Get(ID id);
ObjectsTemplate<Grade> Get(EnumStatus status, int payrollTypeID);
ObjectsTemplate<Grade> GetRegardlessPayrollType(EnumStatus status, int payrollTypeID);
ID Save(Grade item);
void Delete(ID id);
Grade Get(string sCode, int payrollTypeID);
string GetNextCode();
ObjectsTemplate<Grade> GetAddableGrades(ID nAllowDeductID, ID nADParamID, int payrollTypeID);
ObjectsTemplate<Grade> GetAddableGradesForOT(ID nTermID, ID nTermParameterID, int payrollTypeID);
ObjectsTemplate<Grade> GetAddableGradesForBonus(ID nBonusID, int payrollTypeID);
ObjectsTemplate<Grade> GetAllowableGrades(ID nOpiItmeID, ID nOpiParamID, int payrollTypeID);
ObjectsTemplate<Grade> GetAddableGradesForLoanParameter(ID LoaniD, ID LoanParameterId, int payrollTypeID);
ObjectsTemplate<Grade> GetAllPayrollTypes(EnumStatus status);
}
#endregion
}