using System;
using System.Data;
using System.Web;
using LTP.Common;
using FOUPOS.Model;
using FOUPOS.DALFactory;
using FOUPOS.IDAL;

namespace FOUPOS.BLL
{
    /// <summary>
    /// 业务逻辑类AdminUser 的摘要说明。
    /// </summary>
    public class AdminUser
    {
        private readonly IAdminUser dal = DataAccess.CreateAdminUser();
        public AdminUser()
        { }
        #region  成员方法
        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(int ID)
        {
            return dal.Exists(ID);
        }

        /// <summary>
        /// 增加一条数据
        /// </summary>
        public void Add(FOUPOS.Model.AdminUser model)
        {
            dal.Add(model);
        }

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

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

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        /// <param name="username"></param>
        /// <param name="pwd"></param>
        /// <returns></returns>
        public FOUPOS.Model.AdminUser GetModel(string username, string pwd)
        {
            return dal.GetModel(username, pwd);
        }
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public FOUPOS.Model.AdminUser GetModel(int ID)
        {
            return dal.GetModel(ID);
        }

        /// <summary>
        /// 得到一个对象实体，从缓存中。
        /// </summary>
        public FOUPOS.Model.AdminUser GetModelByCache(int ID)
        {
            string CacheKey = "AdminUserModel-" + ID;
            object objModel = LTP.Common.DataCache.GetCache(CacheKey);
            if (objModel == null)
            {
                try
                {
                    objModel = dal.GetModel(ID);
                    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.AdminUser)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  成员方法
    }
}

