using System;
using System.Data;
using LTP.Common;
using FOUPOS.Model;
using FOUPOS.DALFactory;
using FOUPOS.IDAL;
namespace FOUPOS.BLL
{
    /// <summary>
    /// 业务逻辑类Membership 的摘要说明。
    /// </summary>
    public class Membership
    {
        private readonly IMembership dal = DataAccess.CreateMembership();
        public Membership()
        { }
        #region  成员方法
        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(string mnumber)
        {
            return dal.Exists(mnumber);
        }
        public int GetMaxMNumber()
        {
            return dal.GetMaxMNumber();
        }
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public void Add(FOUPOS.Model.Membership model)
        {
            dal.Add(model);
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(FOUPOS.Model.Membership model)
        {
            dal.Update(model);
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public void Delete(int MID)
        {
            dal.Delete(MID);
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public FOUPOS.Model.Membership GetModel(int MID)
        {
            return dal.GetModel(MID);
        }
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public FOUPOS.Model.Membership GetModel(string num)
        {
            return dal.GetModel(num);
        }

        /// <summary>
        /// 得到一个对象实体，从缓存中。
        /// </summary>
        public FOUPOS.Model.Membership GetModelByCache(int MID)
        {
            string CacheKey = "MembershipModel-" + MID;
            object objModel = LTP.Common.DataCache.GetCache(CacheKey);
            if (objModel == null)
            {
                try
                {
                    objModel = dal.GetModel(MID);
                    if (objModel != null)
                    {
                        int ModelCache = LTP.Common.ConfigHelper.GetConfigInt("ModelCache");
                        LTP.Common.DataCache.SetCache(CacheKey, objModel, DateTime.Now.AddMinutes(ModelCache), TimeSpan.Zero);
                    }
                }
                catch { }
            }
            return (FOUPOS.Model.Membership)objModel;
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            return dal.GetList(strWhere);
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetAllList()
        {
            return GetList("");
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        //public DataSet GetList(int PageSize,int PageIndex,string strWhere)
        //{
        //return dal.GetList(PageSize,PageIndex,strWhere);
        //}

        #endregion  成员方法
    }
}

