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.Collections; using System.Data; namespace Payroll.BO { #region SetupDetail [Serializable] public class SetupDetail : ObjectTemplate { #region Cache Store private static Cache _cache = new Cache(typeof(SetupDetail)); #endregion #region Constructor public SetupDetail() { _tranID = null; _tranType = EnmSetupManagerTranType.None; _code = string.Empty; _name = string.Empty; _isSelected = false; } #endregion #region Properties #region SetupID : int private ID _setupID; public ID SetupID { get { return _setupID; } set { base.OnPropertyChange("setupID", _setupID, value); _setupID = value; } } #endregion #region tranID : int private ID _tranID; public ID TranID { get { return _tranID; } set { base.OnPropertyChange("tranID", _tranID, value); _tranID = value; } } #endregion #region tranType : EnmSetupManagerTranType private EnmSetupManagerTranType _tranType; public EnmSetupManagerTranType TranType { get { return _tranType; } set { base.OnPropertyChange("tranType", (short)_tranType, (short)value); _tranType = value; } } #endregion #region code : string private string _code; public string Code { get { return _code; } set { base.OnPropertyChange("code", _code, value); _code = value; } } #endregion #region name : string private string _name; public string Name { get { return _name; } set { base.OnPropertyChange("name", _name, value); _name = value; } } #endregion #region isSelected : bool private bool _isSelected; public bool IsSelected { get { return _isSelected; } set { base.OnPropertyChange("isSelected", _isSelected, value); _isSelected = value; } } #endregion #region Service Factory ISetupDetailService : ISetupDetailService internal static ISetupDetailService Service { get { return Services.Factory.CreateService(typeof(ISetupDetailService)); } } #endregion #endregion #region Functions public static ID GetTranID(Employee employee, EnmSetupManagerTranType type) { ID nTranID = null; switch (type) { case EnmSetupManagerTranType.Category: nTranID =employee.CategoryID; break; case EnmSetupManagerTranType.Designation: nTranID = employee.DesignationID ; break; case EnmSetupManagerTranType.Grade: nTranID = employee.GradeID; break; case EnmSetupManagerTranType.Location: nTranID = employee.LocationID; break; } return nTranID; } public static int GetIndex(ObjectsTemplate details, int tranID, EnmSetupManagerTranType type) { int index = -1; foreach (SetupDetail item in details) { index = index + 1; if (item.TranID.Integer == tranID && item.TranType == type) { return index; } } return -1; } public static ObjectsTemplate GetParameters(EnumParameterSetup setup,int setupID) { #region Cache Header ObjectsTemplate setupDetails = _cache["Get",setupID] as ObjectsTemplate; if (setupDetails != null) return setupDetails; #endregion try { setupDetails = Service.GetParameters(setup, setupID); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(setupDetails, "Get",setupID); #endregion return setupDetails; } public static ObjectsTemplate GetParameters(EnumParameterSetup setup) { #region Cache Header ObjectsTemplate setupDetails = _cache["Get"] as ObjectsTemplate; if (setupDetails != null) return setupDetails; #endregion try { setupDetails = Service.GetParameters(setup); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(setupDetails, "Get"); #endregion return setupDetails; } internal static ObjectsTemplate GetOTDetail(EnumParameterSetup enumParameterSetup, EnmSetupManagerTranType enmSetupManagerTranType) { ObjectsTemplate setupDetails = null; try { setupDetails = Service.GetOTDetail(enumParameterSetup, enmSetupManagerTranType); } catch (ServiceException e) { throw new Exception(e.Message, e); } return setupDetails; } public static DataSet GetParameters(EnumParameterSetup setup, List sqlRelation, string InEmpSQL) { try { return Service.GetParameters(setup, sqlRelation,InEmpSQL); } catch (ServiceException e) { throw new Exception(e.Message, e); } } public static ObjectsTemplate GetUsedParameters(EnumParameterSetup setup, int setupID, int parameterId) { ObjectsTemplate setupDetails = null; try { setupDetails = Service.GetUsedParameters( setup, setupID, parameterId); } catch (ServiceException e) { throw new Exception(e.Message, e); } return setupDetails; } public static ObjectsTemplate GetUsedParameters(EnumParameterSetup setup, int parameterId) { ObjectsTemplate setupDetails = null; try { setupDetails = Service.GetUsedParameters(setup, parameterId); } catch (ServiceException e) { throw new Exception(e.Message, e); } return setupDetails; } public static List GetTypes(EnumParameterSetup setup) { List types = null; try { types = Service.GetTypes(setup); } catch (ServiceException e) { throw new Exception(e.Message, e); } return types; } //public ID Save(EnumParameterSetup setup ) //{ // return SetupDetail.Service.Save(setup, this); //} //public void Delete(EnumParameterSetup setup) //{ // SetupDetail.Service.Delete(setup, ID); //} //public static bool IsExist(Employee employee) //{ // Hashtable ids = new Hashtable(); // foreach (SetupDetail detail in details) // { // ids[detail.ID] = detail.ID; // } // return ids; //} public static Hashtable DistinctSetupID(ObjectsTemplate details) { Hashtable ids = new Hashtable(); foreach (SetupDetail detail in details) { ids[detail.ID] = detail.ID; } return ids; } #endregion } #endregion #region ISetupDetail Service public interface ISetupDetailService { ObjectsTemplate GetParameters(EnumParameterSetup setup); ObjectsTemplate GetParameters(EnumParameterSetup setup,int setupID); ObjectsTemplate GetUsedParameters(EnumParameterSetup setup, int setupID, int objectID); ObjectsTemplate GetUsedParameters(EnumParameterSetup setup, int objectID); List GetTypes(EnumParameterSetup setup); DataSet GetParameters(EnumParameterSetup setup, List sqlRelation, string InEmpSQL); List GetParameterID(EnumParameterSetup setup, EnmSetupManagerTranType type, ID TranID); ObjectsTemplate GetOTDetail(EnumParameterSetup enumParameterSetup, EnmSetupManagerTranType enmSetupManagerTranType); } #endregion }