using System;
using System.Collections.Generic;
using System.Text;
using JuSNS.Model;
using JuSNS.Factory;
using System.Data;

namespace JuSNS.Manage
{
    public class Manager
    {
        private IManager dal;
        /// <summary>
        /// 构造函数
        /// </summary>
        public Manager()
        {
            dal = DataAccess.CreateManager();
        }
        /// <summary>
        /// 检查登录
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public EnumLoginState CheckLogin(int adminId, string password)
        {
            return dal.CheckLogin(adminId, password);
        }
        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="Email">用户名</param>
        /// <param name="Password">密码</param>
        /// <returns></returns>
        public EnumLoginState Login(string loginName, string md5Password, out int adminId, out string trueName)
        {
            return dal.Login(loginName, md5Password, out adminId, out trueName);
        }
        /// <summary>
        /// 修改密码
        /// </summary>
        /// <param name="adminId"></param>
        /// <param name="oldPassword">未经md5的旧密码</param>
        /// <param name="newPassword">未经md5的新密码</param>
        /// <returns>0,成功,1,该管理员ID不存在,2旧密码错误</returns>
        public int ChangePasswrod(int adminId, string oldPassword, string newPassword)
        {
            return dal.ChangePasswrod(adminId, oldPassword, newPassword);
        }

        public int AddAdmin(string AdminName, string Password, string TrueName, int state)
        {
            return dal.AddAdmin(AdminName, Password, TrueName, state);
        }
        public int updateAdmin(string AdminName, string Password, string TrueName, int state, int AdminID)
        {
            return dal.updateAdmin(AdminName, Password, TrueName, state, AdminID);
        }

        public DataTable GetAdminInfo(int ID)
        {
            return dal.GetAdminInfo(ID);
        }

        public DataTable AdminList()
        {
            return dal.AdminList();
        }
    }
}
