📄 新建 文本文档 (3).txt
字号:
string SelString = "select Function_Code from System_b_Function where Id in ( select Function_ID from UserMag_l_RightTeamFun where RightTeam_ID=@RightTeam_ID)";
//定义参数SqlParameter列表并赋值
SqlParameter[] SelParm = new SqlParameter[1];
SelParm[0] = new SqlParameter("@RightTeam_ID", SqlDbType.Int);
SelParm[0].SqlValue = TeamID;
SelParm[0].Direction = ParameterDirection.Input;
reader = DBDealHelp.SqlHelper.ExecuteReader(SqlConnString, CommandType.Text, SelString, SelParm);
while (reader.Read())//循环读取查询所得值
{
FunList.Add(reader["Function_Code"].ToString());
}
reader.Close();
return FunList;
}
/// <summary>
/// 通过权限组ID获得该权限组的所有权限功能ID
/// </summary>
/// <param name="TeamID">权限组ID</param>
/// <returns>属于该权限组的权限功能ID列表</returns>
public List<int> GetRightFunByTeamID(int TeamID)
{
List<int> FunList = new List<int>();
SqlDataReader reader;//定义读取器
string SelString = "select Function_ID from UserMag_l_RightTeamFun where RightTeam_ID=@RightTeam_ID";
//定义参数SqlParameter列表并赋值
SqlParameter[] SelParm = new SqlParameter[1];
SelParm[0] = new SqlParameter("@RightTeam_ID", SqlDbType.Int);
SelParm[0].SqlValue = TeamID;
SelParm[0].Direction = ParameterDirection.Input;
reader = DBDealHelp.SqlHelper.ExecuteReader(SqlConnString, CommandType.Text, SelString, SelParm);
while (reader.Read())//循环读取查询所得值
{
FunList.Add(Convert.ToInt32(reader["Function_ID"]));
}
reader.Close();
return FunList;
}
/// <summary>
/// 将权限功能列表里面的权限功能对象统一插入一个权限组
/// </summary>
/// <param name="TeamID">将要加入的权限组ID</param>
/// <param name="RightFunList">权限功能列表</param>
/// <returns>是否操作成功</returns>
public Boolean AddRightFunToTeam(int TeamID, List<int> RightFunList)
{
bool IsSuccess;//定义返回值变量
IsSuccess = false;
int val;//定义获取返回值得变量
string RightFunListStr="";//定义权限功能列表字符串
//循环获取List列表中的值
for (int i = 0; i < RightFunList.Count; i++)
{
RightFunListStr += RightFunList[i].ToString() + ",";
}
//定义参数SqlParameter列表并赋值
SqlParameter[] InsParm = new SqlParameter[3];
InsParm[0] = new SqlParameter("@RightTeam_ID", SqlDbType.Int);
InsParm[0].SqlValue = TeamID;
InsParm[0].Direction = ParameterDirection.Input;
InsParm[1] = new SqlParameter("@FunctionIDList", SqlDbType.VarChar, 200);
InsParm[1].SqlValue = RightFunListStr;
InsParm[1].Direction = ParameterDirection.Input;
InsParm[2] = new SqlParameter("@Type", SqlDbType.Int);
InsParm[2].SqlValue = 1;
InsParm[2].Direction = ParameterDirection.Input;
//调用函数执行数据库操作
val = (int)DBDealHelp.SqlHelper.ExecuteScalar(SqlConnString, CommandType.StoredProcedure, "p_ab_ContrlRightFunTeam", InsParm);
if (val == 1)
{
IsSuccess = true;
}
return IsSuccess;
}
/// <summary>
/// 从指定的权限组中删除权限功能
/// </summary>
/// <param name="TeamID">权限组ID</param>
/// <param name="RightFunList">权限功能列表</param>
/// <returns>是否操作成功</returns>
public Boolean RemoveRightFunFromTeam(int TeamID, List<int> RightFunList)
{
bool IsSuccess;//定义返回值变量
IsSuccess = false;
int val;//定义获取返回值得变量
string RightFunListStr="";//定义权限功能列表字符串
//循环获取List列表中的值
for (int i = 0; i < RightFunList.Count; i++)
{
RightFunListStr += RightFunList[i].ToString() + ",";
}
//定义参数SqlParameter列表并赋值
SqlParameter[] DelParm = new SqlParameter[3];
DelParm[0] = new SqlParameter("@RightTeam_ID", SqlDbType.Int);
DelParm[0].SqlValue = TeamID;
DelParm[0].Direction = ParameterDirection.Input;
DelParm[1] = new SqlParameter("@FunctionIDList", SqlDbType.VarChar, 200);
DelParm[1].SqlValue = RightFunListStr;
DelParm[1].Direction = ParameterDirection.Input;
DelParm[2] = new SqlParameter("@Type", SqlDbType.Int);
DelParm[2].SqlValue = 2;
DelParm[2].Direction = ParameterDirection.Input;
//调用函数执行数据库操作
val = (int)DBDealHelp.SqlHelper.ExecuteScalar(SqlConnString, CommandType.StoredProcedure, "p_ab_ContrlRightFunTeam", DelParm);
if (val == 1)
{
IsSuccess = true;
}
return IsSuccess;
}
//权限功能操作
/// <summary>
/// 增加权限功能信息
/// </summary>
/// <param name="obj_RightFun">权限组功能对象</param>
/// <returns>是否操作成功</returns>
public Boolean AddRightFun(RightTeamFun obj_RightFun)
{
bool IsSuccess;//定义返回值变量
IsSuccess = false;
int val;//定义获取返回值得变量
//定义参数SqlParameter列表并赋值
SqlParameter[] InsParm = new SqlParameter[3];
InsParm[0] = new SqlParameter("@TeamID", SqlDbType.Int);
InsParm[0].SqlValue = 0;
InsParm[0].Direction = ParameterDirection.Input;
InsParm[1] = new SqlParameter("@Function_Name", SqlDbType.VarChar, 50);
InsParm[1].SqlValue = obj_RightFun.Name;
InsParm[1].Direction = ParameterDirection.Input;
InsParm[2] = new SqlParameter("@Type", SqlDbType.Int);
InsParm[2].SqlValue = 2;
InsParm[2].Direction = ParameterDirection.Input;
//调用函数执行数据库操作
val = (int)DBDealHelp.SqlHelper.ExecuteScalar(SqlConnString, CommandType.StoredProcedure, "p_ab_ContrlRightFun", InsParm);
if (val == 1)
{
IsSuccess = true;
}
return IsSuccess;
}
/// <summary>
/// 根据权限信息ID删除权限功能信息
/// </summary>
/// <param name="RightFunID">权限功能信息ID</param>
/// <returns>是否操作成功</returns>
public Boolean RemoveRightFun(RightTeamFun RightFunID)
{
bool IsSuccess;//定义返回值变量
IsSuccess = false;
int val;//定义获取返回值的变量
//定义参数SqlParameter列表并赋值
SqlParameter[] DelParm = new SqlParameter[3];
DelParm[0] = new SqlParameter("@TeamID", SqlDbType.Int);
DelParm[0].SqlValue = RightFunID.ID;
DelParm[0].Direction = ParameterDirection.Input;
DelParm[1] = new SqlParameter("@Type", SqlDbType.Int);
DelParm[1].SqlValue = 1;
DelParm[1].Direction = ParameterDirection.Input;
DelParm[2] = new SqlParameter("@Function_Name", SqlDbType.VarChar, 50);
DelParm[2].SqlValue ="";
DelParm[2].Direction = ParameterDirection.Input;
//调用函数执行数据库操作
val = DBDealHelp.SqlHelper.ExecuteNonQuery(SqlConnString, CommandType.StoredProcedure, "p_ab_ContrlRightFun", DelParm);
if (val > 0)
{
IsSuccess = true;
}
return IsSuccess;
}
/// <summary>
/// 更新权限功能信息
/// </summary>
/// <param name="obj_RightFun">权限功能对象</param>
/// <returns>是否操作成功</returns>
public Boolean UpdateRightFun(RightTeamFun obj_RightFun)
{
bool IsSuccess;//定义返回值变量
IsSuccess = false;
int val;//定义获取返回值得变量
//定义参数SqlParameter列表并赋值
SqlParameter[] UpdParm = new SqlParameter[3];
UpdParm[0] = new SqlParameter("@TeamID", SqlDbType.Int);
UpdParm[0].SqlValue = obj_RightFun.ID;
UpdParm[0].Direction = ParameterDirection.Input;
UpdParm[1] = new SqlParameter("@Function_Name", SqlDbType.VarChar,50);
UpdParm[1].SqlValue = obj_RightFun.Name;
UpdParm[1].Direction = ParameterDirection.Input;
UpdParm[2] = new SqlParameter("@Type", SqlDbType.Int);
UpdParm[2].SqlValue = 3;
UpdParm[2].Direction = ParameterDirection.Input;
//调用函数执行数据库操作
val = (int)DBDealHelp.SqlHelper.ExecuteScalar(SqlConnString, CommandType.StoredProcedure, "p_ab_ContrlRightFun", UpdParm);
if (val == 1)
{
IsSuccess = true;
}
return IsSuccess;
}
/// <summary>
/// 添加权限组列表到指定用户的
/// </summary>
/// <param name="TeamID">权限组ID列表</param>
/// <param name="UserID">用户ID</param>
/// <param name="Type">类型(0:添加权限组,1:移出权限组)</param>
/// <returns>操作是否成功</returns>
public Boolean UserLinkRightTeam(List<int> TeamID, int UserID, int Type)
{
bool IsSuccess;//定义返回值变量
IsSuccess = false;
int val;//定义获取返回值得变量
string TeamIDListStr = "";//定义权限功能列表字符串
//循环获取List列表中的值
for (int i = 0; i < TeamID.Count; i++)
{
TeamIDListStr += TeamID[i].ToString() + ",";
}
//定义参数SqlParameter列表并赋值
SqlParameter[] Parm = new SqlParameter[3];
Parm[0] = new SqlParameter("@User_ID", SqlDbType.Int);
Parm[0].SqlValue = UserID;
Parm[0].Direction = ParameterDirection.Input;
Parm[1] = new SqlParameter("@RightTeamIDList", SqlDbType.VarChar, 2000);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -