using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using Ease.Core;
using Ease.CoreV35;
using Ease.Core.Utility;

namespace HRM.BO
{
    #region TranElement

    [Serializable]
    public class TranElement : AuditTrailBase
    {
        
        #region Constructor
        public TranElement()
        {
            ProjectID = 0; //Ease.CoreV35.Model.ID.FromInteger(FM.BO.Common.User.CurrentMasterParam.ID.Integer);
            Name = string.Empty;
            Source = string.Empty;
            ElementType = EnumElementType.None;
            WhereCluse = string.Empty;
        }
        #endregion

        #region Properties
        #region Property ProjectID : ID

        public int ProjectID { get; set; }
        

        #endregion Property ProjectID : ID

        #region Property Name : string
        public string Name { get; set; }
        
        #endregion Property Name : string

        #region Property Source : string
        public string Source { get; set; }

        #endregion Property Source : string

        #region Property ElementType : shortementType _elementType;
        public EnumElementType ElementType { get; set; }
 
        #endregion

        #region Property WhereCluse : string
        public string WhereCluse { get; set; }

        #endregion Property WhereCluse : string
	

        #endregion


        //#region Function

        //public void Save()
        //{
        //    try
        //    {
        //        base.SetAuditTrailProperties(GlobalFunctions.GetServerDate().Date, User.CurrentUser.ID);
        //        Service.Save(this);

        //        //Clear Cache
        //        CacheInfo.ClearCache(typeof(TranElement).FullName);
        //    }
        //    catch (ServiceException e)
        //    {
        //        throw new Exception(e.Message, e);
        //    }
        //}

        //public TranElement Get(ID id)
        //{
        //    #region Cache Header

        //    TranElement tranElement = _cache["Get", id] as TranElement;

        //    if (tranElement != null)
        //        return tranElement;

        //    #endregion

        //    try
        //    {
        //        tranElement = Service.Get(id);
        //    }
        //    catch (ServiceException e)
        //    {
        //        throw new Exception(e.Message, e);
        //    }

        //    #region Cache Footer

        //    _cache.Add(tranElement, "Get", id);

        //    #endregion

        //    return tranElement;
        //}

        //public static ObjectsTemplate<TranElement> Get()
        //{
        //    #region Cache Header

        //    ObjectsTemplate<TranElement> tranElements = _cache["Get"] as ObjectsTemplate<TranElement>;
        //    if (tranElements != null)
        //        return tranElements;

        //    #endregion

        //    try
        //    {
        //        tranElements = Service.Get();
        //    }
        //    catch (ServiceException e)
        //    {
        //        throw new Exception(e.Message, e);
        //    }

        //    #region Cache Footer

        //    _cache.Add(tranElements, "Get");

        //    #endregion


        //    return tranElements;
        //}

        //public static ObjectsTemplate<TranElement> Get(string Source)
        //{
        //    #region Cache Header

        //    ObjectsTemplate<TranElement> tranElements = _cache["Get", Source] as ObjectsTemplate<TranElement>;
        //    if (tranElements != null)
        //        return tranElements;

        //    #endregion

        //    try
        //    {
        //        tranElements = Service.Get(Source);
        //    }
        //    catch (ServiceException e)
        //    {
        //        throw new Exception(e.Message, e);
        //    }

        //    #region Cache Footer

        //    _cache.Add(tranElements, "Get", Source);

        //    #endregion


        //    return tranElements;
        //}

        //public static ObjectsTemplate<TranElement> Get(string Source, EnumElementType ntype)
        //{
        //    #region Cache Header

        //    ObjectsTemplate<TranElement> tranElements = _cache["Get", Source, ntype] as ObjectsTemplate<TranElement>;
        //    if (tranElements != null)
        //        return tranElements;

        //    #endregion

        //    try
        //    {
        //        tranElements = Service.Get(Source, ntype);
        //    }
        //    catch (ServiceException e)
        //    {
        //        throw new Exception(e.Message, e);
        //    }

        //    #region Cache Footer

        //    _cache.Add(tranElements, "Get", Source, ntype);

        //    #endregion


        //    return tranElements;
        //}


        //public static DataTable GetTable()
        //{
        //    try
        //    {
        //        return Service.GetTable();
        //    }
        //    catch (ServiceException e)
        //    {
        //        throw new Exception(e.Message, e);
        //    }
        //}

        //public void Delete(ID tranElementID)
        //{
        //    try
        //    {
        //        Service.Delete(tranElementID);

        //        //Clear Cache
        //        CacheInfo.ClearCache(typeof(TranElement).FullName);
        //    }
        //    catch (ServiceException e)
        //    {
        //        throw new Exception(e.Message, e);
        //    }
        //}
        //public static ObjectsTemplate<TranElement> Get(string p, EnumElementType? nullable)
        //{
        //    throw new NotImplementedException();
        //}
        //#endregion


    }

    #endregion

    public interface ITranElementService
    {
        void Save(TranElement tranElement);
        void Delete(int tranElementID);

        TranElement Get(int tranElementID);
        DataTable GetTable();
        List<TranElement> Get();
        List<TranElement> Get(string source);
        List<TranElement> Get(string source, EnumElementType type);
    }
}