CEL_Payroll/Payroll.BO/Capitalization/Capitalization.cs

219 lines
5.6 KiB
C#
Raw Permalink 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;
using System.Data;
namespace Payroll.BO
{
[Serializable]
public class Capitalization : BasicBaseObject
{
#region Cache Store
private static Cache _cache = new Cache(typeof(Capitalization));
#endregion
#region Constructor
public Capitalization()
{
_salaryMonth = DateTime.MinValue;
_departmentID = null;
_percent = 0;
}
#endregion
#region Properties
#region SalaryMonth : DateTime
private DateTime _salaryMonth;
public DateTime SalaryMonth
{
get { return _salaryMonth; }
set
{
base.OnPropertyChange<DateTime>("SalaryMonth", _salaryMonth, value);
_salaryMonth = value;
}
}
#endregion
#region DepartmentID : ID
private ID _departmentID;
public ID DepartmentID
{
get { return _departmentID; }
set
{
base.OnPropertyChange<ID>("DepartmentID", _departmentID, value);
_departmentID = value;
}
}
#endregion
#region Percent : Double
private double _percent;
public double Percent
{
get { return _percent; }
set
{
base.OnPropertyChange<double>("Percent", _percent, value);
_percent = value;
}
}
#endregion
#endregion
#region Service Factory ICapitalizationService : ICapitalizationService
internal static ICapitalizationService Service
{
get { return Services.Factory.CreateService<ICapitalizationService>(typeof(ICapitalizationService)); }
}
#endregion
public static ObjectsTemplate<Capitalization> Get()
{
#region cache header
ObjectsTemplate<Capitalization> capitalizations = _cache["Get"] as ObjectsTemplate<Capitalization>;
if (capitalizations != null)
return capitalizations;
#endregion
try
{
capitalizations = Service.Get();
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region cache footer
_cache.Add(capitalizations, "Get");
#endregion
return capitalizations;
}
public static ObjectsTemplate<Capitalization> Get(DateTime sMonth)
{
#region cache header
ObjectsTemplate<Capitalization> capitalizations = _cache["Get"] as ObjectsTemplate<Capitalization>;
if (capitalizations != null)
return capitalizations;
#endregion
try
{
capitalizations = Service.Get(sMonth);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region cache footer
_cache.Add(capitalizations, "Get");
#endregion
return capitalizations;
}
public static ObjectsTemplate<Capitalization> Get(ID departmetID)
{
#region cache header
ObjectsTemplate<Capitalization> capitalizations = _cache["Get"] as ObjectsTemplate<Capitalization>;
if (capitalizations != null)
return capitalizations;
#endregion
try
{
capitalizations = Service.Get(departmetID);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region cache footer
_cache.Add(capitalizations, "Get");
#endregion
return capitalizations;
}
public static Capitalization Get(ID departmetID, DateTime sMonth)
{
#region cache header
Capitalization capitalization = _cache["Get"] as Capitalization;
if (capitalization != null)
return capitalization;
#endregion
try
{
capitalization = Service.Get(departmetID, sMonth);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region cache footer
_cache.Add(capitalization, "Get");
#endregion
return capitalization;
}
public static DateTime? GetMaxDate()
{
DateTime? maxDate = Capitalization.Service.GetMaxDate();
return maxDate;
}
public void Delete(ID id)
{
Capitalization.Service.Delete(id);
}
public void Save(ObjectsTemplate<Capitalization> capitalizations)
{
capitalizations.ForEach(x => x.SetAuditTrailProperties());
Capitalization.Service.Save(capitalizations);
}
}
#region ICategory Service
public interface ICapitalizationService
{
ObjectsTemplate<Capitalization> Get();
ObjectsTemplate<Capitalization> Get(DateTime sMonth);
ObjectsTemplate<Capitalization> Get(ID departmetID);
Capitalization Get(ID departmetID, DateTime sMonth);
void Save(ObjectsTemplate<Capitalization> capitalizations);
DateTime? GetMaxDate();
void Delete(ID id);
}
#endregion
}