?? 新建 文本文檔 (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 + -