Esempio n. 1
0
        /// <summary>
        /// 获取角色权限模块
        /// <param name="roleId">角色编号</param>
        /// <param name="moduleId">模块编号</param>
        /// </summary>
        /// <returns>角色权限模块对象</returns>
        public TSRight Get(string roleId, string moduleId)
        {
            TSRight tsRight = null;

            try
            {
                string strSQL = "select * from TSRight where roleId=:roleId and moduleId=:moduleId";
                Param  param  = new Param();
                param.Clear();
                param.Add(":roleId", roleId);
                param.Add(":moduleId", moduleId);
                db.Open();
                ComDataReader dr = db.ExecuteReader(CommandType.Text, strSQL, param);
                if (dr.Read())
                {
                    tsRight = ReadData(dr);
                }
            }
            catch (Exception e)
            {
                throw e;
            }
            finally
            {
                db.Close();
            }
            return(tsRight);
        }
Esempio n. 2
0
        /// <summary>
        /// 保存角色权限【新增】
        /// </summary>
        /// <param name="roleId">角色编号</param>
        /// <param name="moduleIdList">模块编号列表</param>
        public void Save(string roleId, List <string> moduleIdList)
        {
            ComTransaction trans = null;

            try
            {
                db.Open();
                trans = db.BeginTransaction();
                this.Delete(db, roleId);
                foreach (string moduleId in moduleIdList)
                {
                    TSRight tsRight = new TSRight();
                    tsRight.roleId   = roleId;
                    tsRight.moduleId = moduleId;
                    this.Add(db, tsRight);
                }
                trans.Commit();
            }
            catch (Exception e)
            {
                trans.Rollback();
                throw e;
            }
            finally
            {
                db.Close();
            }
        }
Esempio n. 3
0
        /// <summary>
        /// 读取角色权限模块信息
        /// <param name="dr">记录指针</param>
        /// </summary>
        /// <returns>角色权限模块对象</returns>
        private TSRight ReadData(ComDataReader dr)
        {
            TSRight tsRight = new TSRight();

            tsRight.roleId   = dr["roleId"].ToString();   //角色编号
            tsRight.moduleId = dr["moduleId"].ToString(); //模块编号
            return(tsRight);
        }
Esempio n. 4
0
        /// <summary>
        /// 修改角色权限模块
        /// <param name="data">数据库连接</param>
        /// <param name="tsRight">角色权限模块</param>
        /// </summary>
        public void Edit(DataAccess data, TSRight tsRight)
        {
            string strSQL = "update TSRight set  where roleId=:roleId and moduleId=:moduleId";
            Param  param  = new Param();

            param.Clear();
            param.Add(":roleId", tsRight.roleId);     //角色编号
            param.Add(":moduleId", tsRight.moduleId); //模块编号
            data.ExecuteNonQuery(CommandType.Text, strSQL, param);
        }
Esempio n. 5
0
        /// <summary>
        /// 增加角色权限模块
        /// <param name="data">数据库连接</param>
        /// <param name="tsRight">角色权限模块</param>
        /// </summary>
        public void Add(DataAccess data, TSRight tsRight)
        {
            string strSQL = "insert into TSRight (roleId,moduleId) values (:roleId,:moduleId)";
            Param  param  = new Param();

            param.Clear();
            param.Add(":roleId", tsRight.roleId);     //角色编号
            param.Add(":moduleId", tsRight.moduleId); //模块编号
            data.ExecuteNonQuery(CommandType.Text, strSQL, param);
        }
Esempio n. 6
0
 /// <summary>
 /// 修改角色权限模块
 /// <param name="tsRight">角色权限模块</param>
 /// </summary>
 public void Edit(TSRight tsRight)
 {
     try
     {
         db.Open();
         Edit(db, tsRight);
     }
     catch (Exception e)
     {
         throw e;
     }
     finally
     {
         db.Close();
     }
 }
Esempio n. 7
0
 /// <summary>
 /// 增加角色权限模块
 /// </summary>
 /// <param name="tsRight">角色权限模块</param>
 public virtual void Add(TSRight tsRight)
 {
     try
     {
         db.Open();
         Add(db, tsRight);
     }
     catch (Exception e)
     {
         throw e;
     }
     finally
     {
         db.Close();
     }
 }