📄 user.cs
字号:
using System;
using System.Data;
using System.Data.SqlClient;
namespace eOA
{
/// <summary>
/// User 的摘要说明。
/// </summary>
public class User
{
public User()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
public int Login(string UserName, string UserPwd)
{
SqlParameter[] LoginPara = {
new SqlParameter("@userName", UserName),
new SqlParameter("@userPwd", UserPwd)
};
//返回userId的值,如果不存在记录,返回为0
return Convert.ToInt32(SqlAccess.ExecuteScalar(SqlAccess.CONN_STRING, CommandType.StoredProcedure, "Login", LoginPara));
}
public SqlDataReader GetUser(string userName)
{
string strSQL = "Select * From UserInfo where UserName = " + "'" + userName + "'";
return SqlAccess.ExecuteReader(SqlAccess.CONN_STRING, CommandType.Text,strSQL);
}
//获得用户角色
public string GetUserRole(int userID)
{
SqlParameter[] GetRolePara = {
new SqlParameter("@userId", userID)
};
//返回用户角色的值,如果不存在记录,返回为0
return Convert.ToString (SqlAccess.ExecuteScalar(SqlAccess.CONN_STRING, CommandType.StoredProcedure, "GetUserRole", GetRolePara));
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -