Files
FullAutoWaterCheck/全自动水压检测仪/DATA/LoginData.cs
2026-01-26 18:47:27 +08:00

64 lines
1.5 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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;
}
}
}