CEL_Payroll/Payroll.BO/Organogram/OrganogramEmployee.cs

261 lines
7.0 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.DataAccess;
using Ease.CoreV35.Caching;
using System.Data.Linq.Mapping;
using System.Data;
namespace Payroll.BO
{
#region OrganogramEmployee
[Serializable]
public class OrganogramEmployee : AuditTrailBase
{
#region Cache Store
private static Cache _cache = new Cache(typeof(OrganogramEmployee));
#endregion
#region Constructor
public OrganogramEmployee()
{
//_organEmpID = null;
_nodeID = null;
_employeeID = null;
_assignDate = DateTime.MinValue;
}
#endregion
#region Property
//#region OrganEmpID : ID
//private ID _organEmpID;
//public ID OrganEmpID
//{
// get { return _organEmpID; }
// set
// {
// base.OnPropertyChange<ID>("organEmpID", _organEmpID, value);
// _organEmpID = value;
// }
//}
//#endregion
#region nodeID : ID
private ID _nodeID;
public ID NodeID
{
get { return _nodeID; }
set
{
base.OnPropertyChange<ID>("nodeID", _nodeID, value);
_nodeID = value;
}
}
#endregion
#region employeeID : ID
private ID _employeeID;
public ID EmployeeID
{
get { return _employeeID; }
set
{
base.OnPropertyChange<ID>("employeeID", _employeeID, value);
_employeeID = value;
}
}
#endregion
#region employee : Employee
private Employee _employee;
public Employee Employee
{
get
{
if (_employeeID.Integer > 0 && _employee == null)
{
_employee = new Employee();
_employee = Employee.Get(_employeeID);
}
return this._employee;
}
set
{
_employee = value;
}
}
#endregion
#region assignDate : DateTime
private DateTime _assignDate;
public DateTime AssignDate
{
get { return _assignDate; }
set
{
base.OnPropertyChange<DateTime>("assignDate", _assignDate, value);
_assignDate = value;
}
}
#endregion
private OrganogramBasic _position;
public OrganogramBasic Position
{
get
{
if (_nodeID != null && !_nodeID.IsUnassigned)
{
if (_nodeID.Integer > 0 && _position == null)
{
_position = new OrganogramBasic();
_position = OrganogramBasic.Get(_nodeID);
}
}
return this._position;
}
set
{
_position = value;
}
}
#region Service Factory IOrganogramEmployee : IOrganogramEmployee
internal static IOrganogramEmployeeService Service
{
get { return Services.Factory.CreateService<IOrganogramEmployeeService>(typeof(IOrganogramEmployeeService)); }
}
#endregion
#endregion
#region Functions
public ID Save()
{
base.SetAuditTrailProperties();
return OrganogramEmployee.Service.Save(this);
}
internal static void SaveEmp(ObjectsTemplate<OrganogramEmployee> _organEmps)
{
OrganogramEmployee.Service.SaveEmp(_organEmps);
}
public void Delete()
{
OrganogramEmployee.Service.Delete(ID);
}
public static ObjectsTemplate<OrganogramEmployee> Get(ID nodeID)
{
ObjectsTemplate<OrganogramEmployee> oOrganEmp = null;
#region Cache Header
oOrganEmp = (ObjectsTemplate<OrganogramEmployee>)_cache["Get", nodeID];
if (oOrganEmp != null)
return oOrganEmp;
#endregion
oOrganEmp = OrganogramEmployee.Service.Get(nodeID);
#region Cache Footer
_cache.Add(oOrganEmp, "Get", nodeID);
#endregion
return oOrganEmp;
}
public static ObjectsTemplate<OrganogramEmployee> GetByEmp(ID empID)
{
ObjectsTemplate<OrganogramEmployee> oOrganEmp = null;
#region Cache Header
oOrganEmp = (ObjectsTemplate<OrganogramEmployee>)_cache["GetByEmp", empID];
if (oOrganEmp != null)
return oOrganEmp;
#endregion
oOrganEmp = OrganogramEmployee.Service.GetByEmp(empID);
#region Cache Footer
_cache.Add(oOrganEmp, "GetByEmp", empID);
#endregion
return oOrganEmp;
}
public static ObjectsTemplate<OrganogramEmployee> GetByPositionType(EnumOGPositionType enPositionType)
{
ObjectsTemplate<OrganogramEmployee> oOrganEmp = null;
#region Cache Header
oOrganEmp = (ObjectsTemplate<OrganogramEmployee>)_cache["GetByPositionType", enPositionType];
if (oOrganEmp != null)
return oOrganEmp;
#endregion
oOrganEmp = OrganogramEmployee.Service.GetByPositionType(enPositionType);
#region Cache Footer
_cache.Add(oOrganEmp, "GetByPositionType", enPositionType);
#endregion
return oOrganEmp;
}
public static ObjectsTemplate<OrganogramEmployee> Get()
{
#region Cache Header
ObjectsTemplate<OrganogramEmployee> oOrganEmp = _cache["Get"] as ObjectsTemplate<OrganogramEmployee>;
if (oOrganEmp != null)
return oOrganEmp;
#endregion
try
{
oOrganEmp = Service.Get();
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(oOrganEmp, "Get");
#endregion
return oOrganEmp;
}
#endregion
}
#endregion
#region IOrganogramEmployeeService
public interface IOrganogramEmployeeService
{
ID Save(OrganogramEmployee OrganEmp);
void Delete(ID id);
ObjectsTemplate<OrganogramEmployee> Get(ID nodeID);
ObjectsTemplate<OrganogramEmployee> GetByEmp(ID empID);
ObjectsTemplate<OrganogramEmployee> GetByPositionType(EnumOGPositionType enPositionType);
ObjectsTemplate<OrganogramEmployee> Get();
void SaveEmp(ObjectsTemplate<OrganogramEmployee> _organEmps);
}
#endregion
}