using System;

namespace 全自动水压检测仪
{
    public class LoginData
    {
        static string _userName = "";
        public static string UserName
        {
            get { return _userName; }
            set { _userName = value; }
        }

        //登陆权限
        static int _userPower = 0;//0为普通用户，1为管理员
        public static int UserPower
        {
            get { return _userPower; }
            set { _userPower = value; }
        }

        static int _currentUserId = 0; // 当前登录用户ID
        public static int CurrentUserId
        {
            get { return _currentUserId; }
            set { _currentUserId = value; }
        }

        static DateTime _loginTime = DateTime.Now;
        public static DateTime LoginTime
        {
            get { return _loginTime; }
            set { _loginTime = value; }
        }

        /// <summary>
        /// 检查是否为管理员
        /// </summary>
        public static bool IsAdmin()
        {
            return _userPower == 1;
        }

        /// <summary>
        /// 检查是否为普通用户
        /// </summary>
        public static bool IsNormalUser()
        {
            return _userPower == 0;
        }

        /// <summary>
        /// 退出登录，清空会话信息
        /// </summary>
        public static void Logout()
        {
            _userName = "";
            _userPower = 0;
            _currentUserId = 0;
            _loginTime = DateTime.Now;
        }
    }
}
