CEL_Payroll/Payroll.BO/Basic/ProcessItem.cs

228 lines
5.3 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 ProcessItem
[Serializable]
public class ProcessItem:AuditTrailBase
{
#region Cache Store
private static Cache _cache = new Cache(typeof(ProcessItem));
#endregion
#region Constructor
public ProcessItem()
{
_itemCode = 0;
_defaultDescription = string.Empty;
_userDescription = string.Empty;
_position = 0;
_itemGroup = 0;
}
#endregion
#region Properties
#region itemCode : int
private int _itemCode;
public int ItemCode
{
get { return _itemCode; }
set
{
base.OnPropertyChange<int>("itemCode", _itemCode, value);
_itemCode = value;
}
}
#endregion
#region defaultDescription : string
private string _defaultDescription;
public string DefaultDescription
{
get { return _defaultDescription; }
set
{
base.OnPropertyChange<string>("defaultDescription", _defaultDescription, value);
_defaultDescription = value;
}
}
#endregion
#region userDescription : string
private string _userDescription;
public string UserDescription
{
get { return _userDescription; }
set
{
base.OnPropertyChange<string>("userDescription", _userDescription, value);
_userDescription = value;
}
}
#endregion
#region position : int
private int _position;
public int Position
{
get { return _position; }
set
{
base.OnPropertyChange<int>("position", _position, value);
_position = value;
}
}
#endregion
#region itemGroup : int
private int _itemGroup;
public int ItemGroup
{
get { return _itemGroup; }
set
{
base.OnPropertyChange<int>("itemGroup", _itemGroup, value);
_itemGroup = value;
}
}
#endregion
#region Service Factory IProcessItemService : IProcessItemService
internal static IProcessItemService Service
{
get { return Services.Factory.CreateService<IProcessItemService>(typeof(IProcessItemService)); }
}
#endregion
#endregion
#region Functions
public static ProcessItem Get(ID nID)
{
ProcessItem oProcessItem = null;
#region Cache Header
oProcessItem = (ProcessItem)_cache["Get", nID];
if (oProcessItem != null)
return oProcessItem;
#endregion
oProcessItem = ProcessItem.Service.Get(nID);
#region Cache Footer
_cache.Add(oProcessItem, "Get", nID);
#endregion
return oProcessItem;
}
public static ProcessItem Get(int itemCode, ObjectsTemplate<ProcessItem> porcessItems)
{
return porcessItems.Find(delegate(ProcessItem item)
{ return item.ItemCode == itemCode; });
}
public static ObjectsTemplate<ProcessItem> Get()
{
#region Cache Header
ObjectsTemplate<ProcessItem> processItems = _cache["Get"] as ObjectsTemplate<ProcessItem>;
if (processItems != null)
return processItems;
#endregion
try
{
processItems = Service.Get();
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(processItems, "Get");
#endregion
return processItems;
}
public static ObjectsTemplate<ProcessItem> GetForTHeadGroup()
{
#region Cache Header
ObjectsTemplate<ProcessItem> processItems = _cache["GetForTHeadGroup"] as ObjectsTemplate<ProcessItem>;
if (processItems != null)
return processItems;
#endregion
try
{
processItems = Service.GetForTHeadGroup();
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(processItems, "GetForTHeadGroup");
#endregion
return processItems;
}
public ID Save()
{
return ProcessItem.Service.Save(this);
}
public void Delete()
{
ProcessItem.Service.Delete(ID);
}
#endregion
}
#endregion
#region IProcessItem Service
public interface IProcessItemService
{
ProcessItem Get(ID id);
ObjectsTemplate<ProcessItem> Get();
ObjectsTemplate<ProcessItem> GetForTHeadGroup();
ID Save(ProcessItem item);
void Delete(ID id);
}
#endregion
}