CEL_Payroll/Payroll.BO/Attendence/CardOperation.cs

316 lines
8.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.Caching;
using Ease.CoreV35.Model;
namespace Payroll.BO
{
#region CardOperation
[Serializable]
public class CardOperation : AuditTrailBase
{
#region Cache Store
private static Cache _cache = new Cache(typeof(CardOperation));
#endregion
#region Constructor
public CardOperation()
{
_cardID = null;
_cardNumber = string.Empty;
_status = 0;
_employeeID = null;
_comments = string.Empty;
_assignDate = DateTime.MinValue;
_employee = null;
}
#endregion
#region Properties
#region cardID : ID
private ID _cardID;
public ID CardID
{
get { return _cardID; }
set
{
base.OnPropertyChange<ID>("cardID", _cardID, value);
_cardID = value;
}
}
#endregion
#region cardNumber : string
private string _cardNumber;
public string CardNumber
{
get { return _cardNumber; }
set
{
base.OnPropertyChange<string>("cardNumber", _cardNumber, value);
_cardNumber = value;
}
}
#endregion
#region Status : EnumCardStatus
private EnumCardStatus _status;
public EnumCardStatus Status
{
get { return _status; }
set
{
// base.OnPropertyChange<EnumCardStatus>("Status", _status, value);
_status = 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 comments : string
private string _comments;
public string Comments
{
get { return _comments; }
set
{
base.OnPropertyChange<string>("comments", _comments, value);
_comments = value;
}
}
#endregion
#region assignDate : DateTime
private DateTime _assignDate;
public DateTime AssignDate
{
get { return _assignDate; }
set
{
base.OnPropertyChange<DateTime>("assignDate", _assignDate, value);
_assignDate = 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 AccessCard : AccessCard
private AccessCard _accessCard;
public AccessCard AccessCard
{
get
{
if (_cardID.Integer > 0 && _accessCard == null)
{
_accessCard = new AccessCard();
_accessCard = AccessCard.Get(_cardID);
}
return this._accessCard;
}
set
{
_accessCard = value;
}
}
#endregion
//for Excel Data Upload
private Shift _shift;
public Shift Shift
{
get
{
if (_shift == null)
{
_shift = new Shift();
}
return _shift;
}
set { _shift = value; }
}
//
#region Service Factory ICardOperationService : ICardOperationService
internal static ICardOperationService Service
{
get { return Services.Factory.CreateService<ICardOperationService>(typeof(ICardOperationService)); }
}
#endregion
#endregion
#region Functions
public static CardOperation Get(ID nID)
{
CardOperation oCardOperation = null;
#region Cache Header
oCardOperation = (CardOperation)_cache["Get", nID];
if (oCardOperation != null)
return oCardOperation;
#endregion
oCardOperation = CardOperation.Service.Get(nID);
#region Cache Footer
_cache.Add(oCardOperation, "Get", nID);
#endregion
return oCardOperation;
}
public static CardOperation GetByCardID(ID nID)
{
CardOperation oCardOperation = null;
#region Cache Header
oCardOperation = (CardOperation)_cache["GetByCardID", nID];
if (oCardOperation != null)
return oCardOperation;
#endregion
oCardOperation = CardOperation.Service.GetByCardID(nID);
#region Cache Footer
_cache.Add(oCardOperation, "GetByCardID", nID);
#endregion
return oCardOperation;
}
public static CardOperation GetByEmpIDAndCardID(ID EmpID, ID CardID)
{
CardOperation oCardOperation = null;
#region Cache Header
oCardOperation = (CardOperation)_cache["GetByEmpIDAndCardID", EmpID, CardID];
if (oCardOperation != null)
return oCardOperation;
#endregion
oCardOperation = CardOperation.Service.GetByEmpIDAndCardID(EmpID, CardID);
#region Cache Footer
_cache.Add(oCardOperation, "GetByEmpIDAndCardID", EmpID, CardID);
#endregion
return oCardOperation;
}
public static CardOperation Get(string CardNumber)
{
CardOperation oCardOperation = null;
#region Cache Header
oCardOperation = (CardOperation)_cache["Get", CardNumber];
if (oCardOperation != null)
return oCardOperation;
#endregion
oCardOperation = CardOperation.Service.Get(CardNumber);
#region Cache Footer
_cache.Add(oCardOperation, "Get", CardNumber);
#endregion
return oCardOperation;
}
public static ObjectsTemplate<CardOperation> Get()
{
#region Cache Header
ObjectsTemplate<CardOperation> cardOperations = _cache["Get"] as ObjectsTemplate<CardOperation>;
if (cardOperations != null)
return cardOperations;
#endregion
try
{
cardOperations = Service.Get();
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(cardOperations, "Get");
#endregion
return cardOperations;
}
public ID Save()
{
this.SetAuditTrailProperties();
return CardOperation.Service.Save(this);
}
public static void Save(ObjectsTemplate<CardOperation> _cardOperations)
{
foreach (CardOperation cardOp in _cardOperations)
{
cardOp.SetAuditTrailProperties();
}
CardOperation.Service.Save(_cardOperations);
}
public void Delete()
{
CardOperation.Service.Delete(ID);
}
#endregion
}
#endregion
#region ICardOperation Service
public interface ICardOperationService
{
CardOperation Get(ID id);
CardOperation GetByCardID(ID nID);
CardOperation GetByEmpIDAndCardID(ID EmpID, ID CardID);
CardOperation Get(string CardNumber);
ObjectsTemplate<CardOperation> Get();
ID Save(CardOperation item);
void Save(ObjectsTemplate<CardOperation> _cardOperations);
void Delete(ID id);
}
#endregion
}