using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MyProject
{
public class User
{
public static string CurrentUser { get; set; } = "无";
private static Dictionary<string, string> UserDict = new Dictionary<string, string>()
{
{ "管理员", "111" },
{ "技术员", "222" },
{ "操作员", "333" },
};
public static OperationResult Login(string user, string password)
{
if (UserDict.ContainsKey(user))
{
if (UserDict[user] == password)
{
CurrentUser = user;
return new OperationResult
{
Result = 0,
Message = CurrentUser + "登录成功"
};
}
else
{
return new OperationResult
{
Result = -1,
Message = "密码错误"
};
}
}
else
{
return new OperationResult
{
Result = -2,
Message = "用户名错误"
};
}
}
public static OperationResult LogOut()
{
string user = CurrentUser;
CurrentUser = "无";
return new OperationResult
{
Result = 0,
Message = user + "退出登录"
};
}
}
}
namespace MyProject
{
public class OperationResult
{
public int Result { get; set; }
public string Message { get; set; }
}
}