CEL_Payroll/Payroll.BO/Attendence/AccessCard.cs

303 lines
8.2 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.Caching;
using Ease.CoreV35.Model;
namespace Payroll.BO
{
#region AccessCard
[Serializable]
public class AccessCard : ObjectTemplate,IComparable<AccessCard>
{
#region Cache Store
private static Cache _cache = new Cache(typeof(AccessCard));
#endregion
#region Constructor
public AccessCard()
{
_cardNumber = string.Empty;
_typeID = ID.FromInteger(0);
_status = 0;
}
#endregion
#region Properties
#region cardNumber : string
private string _cardNumber;
public string CardNumber
{
get { return _cardNumber; }
set
{
base.OnPropertyChange<string>("cardNumber", _cardNumber, value);
_cardNumber = value;
}
}
#endregion
#region typeID : ID
private ID _typeID;
public ID TypeID
{
get { return _typeID; }
set
{
base.OnPropertyChange<ID>("typeID", _typeID, value);
_typeID = value;
}
}
#endregion
#region Status : Enum
private EnumCardStatus _status;
public EnumCardStatus Status
{
get { return _status; }
set
{
base.OnPropertyChange<short>("Status", (short)_status, (short)value);
_status = value;
}
}
#endregion
#region AccessCardType : AccessCardType
private AccessCardType _accessCardType;
public AccessCardType AccessCardType
{
get
{
if (_typeID.Integer > 0 && _accessCardType == null)
{
_accessCardType = new AccessCardType();
_accessCardType = AccessCardType.Get(_typeID);
}
return this._accessCardType;
}
set
{
_accessCardType = value;
}
}
#endregion
#region For Excel Upload
private EmployeeWorkPlanSetup _empWorkPalnSetup;
public EmployeeWorkPlanSetup EmployeeWorkPlanSetup
{
get
{
if (_empWorkPalnSetup == null)
{
_empWorkPalnSetup = new EmployeeWorkPlanSetup();
}
return _empWorkPalnSetup;
}
set { _empWorkPalnSetup = value; }
}
private CardOperation _cardOperation;
public CardOperation CardOperation
{
get
{
if (_cardOperation == null)
{
_cardOperation = new CardOperation();
}
return _cardOperation;
}
set { _cardOperation = value; }
}
private ObjectsTemplate<RegularDataUpload> _errorList;
public ObjectsTemplate<RegularDataUpload> ErrorList
{
get { return _errorList; }
set { _errorList = value; }
}
#endregion
#region Service Factory IAccessCardService : IAccessCardService
internal static IAccessCardService Service
{
get { return Services.Factory.CreateService<IAccessCardService>(typeof(IAccessCardService)); }
}
#endregion
#endregion
#region Functions
public static AccessCard Get(ID nID)
{
AccessCard oAccessCard = null;
#region Cache Header
oAccessCard = (AccessCard)_cache["Get", nID];
if (oAccessCard != null)
return oAccessCard;
#endregion
oAccessCard = AccessCard.Service.Get(nID);
#region Cache Footer
_cache.Add(oAccessCard, "Get", nID);
#endregion
return oAccessCard;
}
public static AccessCard Get(string CardNumber)
{
AccessCard oAccessCard = null;
#region Cache Header
oAccessCard = (AccessCard)_cache["Get", CardNumber];
if (oAccessCard != null)
return oAccessCard;
#endregion
oAccessCard = AccessCard.Service.Get(CardNumber);
#region Cache Footer
_cache.Add(oAccessCard, "Get", CardNumber);
#endregion
return oAccessCard;
}
public ID Save()
{
return AccessCard.Service.Save(this);
}
public void Save(ObjectsTemplate<AccessCard> _accessCards)
{
AccessCard.Service.Save(_accessCards);
}
public void Delete()
{
AccessCard.Service.Delete(ID);
}
public void SetObjectID(int id)
{
this.SetID(ID.FromInteger(id));
}
public static ObjectsTemplate<AccessCard> Get()
{
#region Cache Header
ObjectsTemplate<AccessCard> accessCards = _cache["Get"] as ObjectsTemplate<AccessCard>;
if (accessCards != null)
return accessCards;
#endregion
try
{
accessCards = Service.Get();
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(accessCards, "Get");
#endregion
return accessCards;
}
public static ObjectsTemplate<AccessCard> Get(EnumCardStatus status)
{
#region Cache Header
ObjectsTemplate<AccessCard> accessCards = _cache["Get"] as ObjectsTemplate<AccessCard>;
if (accessCards != null)
return accessCards;
#endregion
try
{
accessCards = Service.Get(status);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(accessCards, "Get");
#endregion
return accessCards;
}
public static ObjectsTemplate<AccessCard> Get(params EnumCardStatus[] status)
{
#region Cache Header
ObjectsTemplate<AccessCard> accessCards = _cache["Get"] as ObjectsTemplate<AccessCard>;
if (accessCards != null)
return accessCards;
#endregion
try
{
accessCards = Service.Get(status);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(accessCards, "Get");
#endregion
return accessCards;
}
public bool IsExist(string CardNumber)
{
return AccessCard.Service.IsExist(CardNumber);
}
public void UpdateStatus(ID cardID, EnumCardStatus status)
{
AccessCard.Service.UpdateStatus(cardID, status);
}
////for excel upload
//public static void SaveForExcelUpload(ObjectsTemplate<AccessCard> accessCards)
//{
// AccessCard.Service.SaveForExcelUpload(accessCards);
//}
#region IComparable<AccessCard> Members
public int CompareTo(AccessCard other)
{
return this.CardNumber.CompareTo(other.CardNumber);
}
#endregion
#endregion
}
#endregion
#region IAccessCard Service
public interface IAccessCardService
{
AccessCard Get(ID id);
AccessCard Get(string CardNumber);
ObjectsTemplate<AccessCard> Get();
ObjectsTemplate<AccessCard> Get(EnumCardStatus status);
ObjectsTemplate<AccessCard> Get(params EnumCardStatus[] status);
ID Save(AccessCard item);
void Save(ObjectsTemplate<AccessCard> items);
void Delete(ID id);
bool IsExist(string CardNumber);
void UpdateStatus(ID cardID, EnumCardStatus status);
//void SaveForExcelUpload(ObjectsTemplate<AccessCard> accessCards);
}
#endregion
}