?? 新建 文本文檔 (3).txt
字號:
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using BankInnerMag.DataModel.UserManager;
using BankInnerMag.IDBALayer.UserManager;
namespace BankInnerMag.SqlServerDBALayer.UserManager
{
public class ManageRight :IRightSet
{
string SqlConnString;//定義連接字符串
/// <summary>
/// 數據庫連接
/// </summary>
public ManageRight()
{
SqlConnString=DBDealHelp.SqlHelper.ConnectionStringLocalTransaction;//獲取字符串值
//SqlConnection SqlConn;//定義數據庫連接對象;
//SqlConn = new SqlConnection(SqlConnString);//實例化數據庫連接對象;
}
//權限組操作
/// <summary>
/// 增加權限組信息
/// </summary>
/// <param name="Obj_RightTeam">權限組對象</param>
/// <returns>是否操作成功</returns>
public Boolean AddRightTeam(RightTeam obj_RightTeam)
{
bool IsSuccess;//定義返回值變量
IsSuccess = false;
int val;//定義獲取返回值的變量
//定義參數SqlParameter列表并賦值
SqlParameter[] InsParm = new SqlParameter[5];
InsParm[0] = new SqlParameter("@RightTeam_Name", SqlDbType.VarChar, 50);
InsParm[1] = new SqlParameter("@RightTeam_Code", SqlDbType.VarChar, 50);
InsParm[2] = new SqlParameter("@RightTeam_Memo", SqlDbType.VarChar, 200);
InsParm[3] = new SqlParameter("@Type", SqlDbType.Int);
InsParm[4] = new SqlParameter("@TeamID", SqlDbType.VarChar,200);
InsParm[0].SqlValue = obj_RightTeam.Name;
InsParm[1].SqlValue = obj_RightTeam.Code;
InsParm[2].SqlValue = obj_RightTeam.Memo;
InsParm[3].SqlValue = 2;
InsParm[4].SqlValue = "0";
InsParm[0].Direction = ParameterDirection.Input;
InsParm[1].Direction = ParameterDirection.Input;
InsParm[2].Direction = ParameterDirection.Input;
InsParm[3].Direction = ParameterDirection.Input;
InsParm[4].Direction = ParameterDirection.Input;
//調用函數執行數據庫操作
val =(int)DBDealHelp.SqlHelper.ExecuteScalar(SqlConnString, CommandType.StoredProcedure, "p_ab_ContrlRightTeam", InsParm);
if (val > 0)
{
IsSuccess = true;
}
return IsSuccess;
}
/// <summary>
/// 批量刪除權限組信息
/// </summary>
/// <param name="TeamID">指定權限組ID列表</param>
/// <returns>是否操作成功</returns>
public Boolean RemoveRightTeam(List<int> TeamID)
{
bool IsSuccess;//定義返回值變量
IsSuccess = false;
int val;//定義獲取返回值得變量
string TeamIDListStr = "";//定義權限組ID列表字符串
//循環獲取List列表中的值
for (int i = 0; i < TeamID.Count; i++)
{
TeamIDListStr += TeamID[i].ToString() + ",";
}
TeamIDListStr=TeamIDListStr.Substring(0, (TeamIDListStr.Length - 1));
//定義參數SqlParameter列表并賦值
SqlParameter[] DelParm = new SqlParameter[5];
DelParm[0] = new SqlParameter("@TeamID", SqlDbType.VarChar,200);
DelParm[0].SqlValue = TeamIDListStr;
DelParm[0].Direction = ParameterDirection.Input;
DelParm[1] = new SqlParameter("@RightTeam_Name", SqlDbType.VarChar, 50);
DelParm[1].SqlValue = "";
DelParm[1].Direction = ParameterDirection.Input;
DelParm[2] = new SqlParameter("@RightTeam_Code", SqlDbType.VarChar, 50);
DelParm[2].SqlValue = "";
DelParm[2].Direction = ParameterDirection.Input;
DelParm[3] = new SqlParameter("@RightTeam_Memo", SqlDbType.VarChar, 50);
DelParm[3].SqlValue = "";
DelParm[3].Direction = ParameterDirection.Input;
DelParm[4] = new SqlParameter("@Type", SqlDbType.Int);
DelParm[4].SqlValue = 1;
DelParm[4].Direction = ParameterDirection.Input;
//調用函數執行數據庫操作
val = (int)DBDealHelp.SqlHelper.ExecuteScalar(SqlConnString, CommandType.StoredProcedure, "p_ab_ContrlRightTeam", DelParm);
if (val == 1)
{
IsSuccess = true;
}
return IsSuccess;
}
/// <summary>
/// 更新權限組對象
/// </summary>
/// <param name="obj_RightTeam">準備權限組信息對象</param>
/// <returns>是否操作成功</returns>
public Boolean UpdateRightTeam(RightTeam obj_RightTeam)
{
bool IsSuccess;//定義返回值變量
IsSuccess = false;
int val;//定義獲取返回值的變量
//定義參數SqlParameter列表并賦值
SqlParameter[] UpdParm = new SqlParameter[5];
UpdParm[0] = new SqlParameter("@RightTeam_Name", SqlDbType.VarChar, 50);
UpdParm[1] = new SqlParameter("@RightTeam_Code", SqlDbType.VarChar, 50);
UpdParm[2] = new SqlParameter("@RightTeam_Memo", SqlDbType.VarChar, 200);
UpdParm[3] = new SqlParameter("@TeamID", SqlDbType.VarChar,200);
UpdParm[4] = new SqlParameter("@Type", SqlDbType.Int);
UpdParm[0].SqlValue = obj_RightTeam.Name;
UpdParm[1].SqlValue = obj_RightTeam.Code;
UpdParm[2].SqlValue = obj_RightTeam.Memo;
UpdParm[3].SqlValue = obj_RightTeam.ID.ToString();
UpdParm[4].SqlValue = 3;
UpdParm[0].Direction = ParameterDirection.Input;
UpdParm[1].Direction = ParameterDirection.Input;
UpdParm[2].Direction = ParameterDirection.Input;
UpdParm[3].Direction = ParameterDirection.Input;
UpdParm[4].Direction = ParameterDirection.Input;
//調用函數執行數據庫操作
val = (int)DBDealHelp.SqlHelper.ExecuteScalar(SqlConnString, CommandType.StoredProcedure, "p_ab_ContrlRightTeam", UpdParm);
if (val > 0)
{
IsSuccess = true;
}
return IsSuccess;
}
/// <summary>
/// 通過權限組ID獲得權限組對象
/// </summary>
/// <param name="TeamID">權限組ID</param>
/// <returns>權限組對象</returns>
public List<RightTeam> GetRightTeamByID(List<int> TeamListID)
{
List<RightTeam> ORightTeamList = new List<RightTeam>();
RightTeam ORightTeam;
SqlDataReader reader;//定義讀取器
string TeamID = "";
if (TeamListID.Count > 0)
{
for (int i = 0; i < TeamListID.Count; i++)
{
TeamID += TeamListID[i].ToString()+ ",";
}
}
//定義參數SqlParameter列表并賦值
SqlParameter[] SelParm = new SqlParameter[2];
SelParm[0] = new SqlParameter("@TeamIDList", SqlDbType.VarChar, 200);
SelParm[0].SqlValue = TeamID;
SelParm[0].Direction = ParameterDirection.Input;
SelParm[1] = new SqlParameter("@Type", SqlDbType.Int);
SelParm[1].SqlValue = 1;
SelParm[1].Direction = ParameterDirection.Input;
//調用函數執行數據庫操作
reader = DBDealHelp.SqlHelper.ExecuteReader(SqlConnString, CommandType.StoredProcedure, "p_ab_SelectRightTeamOrFunInfo", SelParm);
while(reader.Read())//循環讀取查詢所得值
{
ORightTeam = new RightTeam();
ORightTeam.ID =Convert.ToInt32(reader[0]);
ORightTeam.Name = reader[1].ToString();
ORightTeam.Code = reader[2].ToString();
ORightTeam.Memo = reader[3].ToString();
ORightTeamList.Add(ORightTeam);
}
reader.Close();//關閉讀取器
return ORightTeamList;
}
/// <summary>
/// 通過權限功能ID獲得功能對象
/// </summary>
/// <param name="TeamID">權限功能ID</param>
/// <returns>權限功能對象</returns>
public List<RightTeamFun> GetRightTeamFunByID(List<int> TeamFunListID)
{
List<RightTeamFun> ORightTeamFunList = new List<RightTeamFun>();
RightTeamFun ORightTeamFun;
SqlDataReader reader;//定義讀取器
string TeamID = "";
if (TeamFunListID.Count > 0)
{
for (int i = 0; i < TeamFunListID.Count; i++)
{
TeamID += TeamFunListID[i].ToString() + ",";
}
}
//定義參數SqlParameter列表并賦值
SqlParameter[] SelParm = new SqlParameter[2];
SelParm[0] = new SqlParameter("@TeamIDList", SqlDbType.VarChar, 200);
SelParm[0].SqlValue = TeamID;
SelParm[0].Direction = ParameterDirection.Input;
SelParm[1] = new SqlParameter("@Type", SqlDbType.Int);
SelParm[1].SqlValue = 2;
SelParm[1].Direction = ParameterDirection.Input;
//調用函數執行數據庫操作
reader = DBDealHelp.SqlHelper.ExecuteReader(SqlConnString, CommandType.StoredProcedure, "p_ab_SelectRightTeamOrFunInfo", SelParm);
while (reader.Read())//循環讀取查詢所得值
{
ORightTeamFun = new RightTeamFun();
ORightTeamFun.ID = Convert.ToInt32(reader[0]);
ORightTeamFun.Name = reader[1].ToString();
ORightTeamFun.ParentID = Convert.ToInt32(reader[2]);
ORightTeamFun.Code = reader[3].ToString();
ORightTeamFunList.Add(ORightTeamFun);
}
reader.Close();//關閉讀取器
return ORightTeamFunList;
}
/// <summary>
/// 通過權限組ID獲得該權限組的所有權限功能
/// </summary>
/// <param name="TeamID">權限組ID</param>
/// <returns>屬于該權限組的權限功能碼</returns>
public List<string> GetRightFunCodeByTeamID(int TeamID)
{
List<string> FunList = new List<string>();
SqlDataReader reader;//定義讀取器
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -