public static UserInfo GetUser(string name, string pwd)
{
//填写搜索姓名和密码的sql语句
string sql = string.Format("select * from UserInfo where LoginName='{0}' and Password='{1}'", name, pwd);
DataTable dt = DBHelper.ExcuteTable(sql);
//判断数据是否为空
if (dt.Rows.Count > 0)
{
对用户名和密码,角色进行检查
UserInfo model = new UserInfo();
model.UserID = Convert.ToInt32(dt.Rows[0]["UserID"]);
model.LoginName = Convert.ToString(dt.Rows[0]["LoginName"]);
model.Password = Convert.ToString(dt.Rows[0]["Password"]);
model.UserRole = Convert.ToInt32(dt.Rows[0]["UserRole"]);
return model;
}
return null;
}
BLL
pub