Exemplo n.º 1
0
        /// <summary>
        /// 增加权限记录, 如果存在则更新
        /// 返回影响的行数,失败返回0
        /// </summary>
        /// <param name="pid">页面ID</param>
        /// <param name="btnRightExp">按钮权限表达式</param>
        /// <param name="aid">管理员ID</param>
        public int AddOrUpdate(int pid, string btnRightExp, bool updateWhenExists, params int[] aid)
        {
            int result = 0;

            Safe.Base.Contract.IDbHelper qmnobj = SQLHelpers.TcAdmin();
            qmnobj.SetHandClose(false);
            try {
                if (aid != null)
                {
                    foreach (int item in aid)
                    {
                        string         pname      = "p_AddUpdateAdminRight";
                        SqlParameter[] parameters =
                        {
                            new SqlParameter("@aid",              SqlDbType.Int,       4),
                            new SqlParameter("@pid",              SqlDbType.Int,       4),
                            new SqlParameter("@btnRightExp",      SqlDbType.NVarChar, 20),
                            new SqlParameter("@updateWhenExists", true)
                        };
                        parameters[0].Value = item;
                        parameters[1].Value = pid;
                        parameters[2].Value = btnRightExp;
                        result = result + qmnobj.ExecuteProc(pname, false, parameters).ReturnValue;
                    }
                }
            } finally {
                qmnobj.EndConnection();
            }
            return(result);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 批量更新权限
        /// 返回受影响的行数
        /// </summary>
        /// <param name="aids">管理员ID数组</param>
        /// <param name="info">权限集合</param>
        public int UpdateRights(int[] aids, Dictionary <int, string> info)
        {
            int result = 0;

            Safe.Base.Contract.IDbHelper qmnobj = SQLHelpers.TcAdmin();
            qmnobj.SetHandClose(false);
            try {
                foreach (int aid in aids)
                {
                    foreach (KeyValuePair <int, string> item in info)
                    {
                        string         pname      = "p_AddUpdateAdminRight";
                        SqlParameter[] parameters =
                        {
                            new SqlParameter("@aid",              aid),
                            new SqlParameter("@pid",              item.Key),
                            new SqlParameter("@btnRightExp",      item.Value),
                            new SqlParameter("@updateWhenExists", true)
                        };
                        result = result + qmnobj.ExecuteProc(pname, false, parameters).ReturnValue;
                    }
                }
            } finally {
                qmnobj.EndConnection();
            }
            return(result);
        }
Exemplo n.º 3
0
        /// <summary>
        ///  增加或更新数据, 如果存在则更新
        /// </summary>
        /// <param name="pid">页面ID</param>
        /// <param name="btnRightExp">访问权限</param>
        /// <param name="gids">组ID</param>
        /// <returns></returns>
        public int AddOrUpdate(int pid, string btnRightExp, bool updateWhenExists, params int[] gids)
        {
            int result = 0;

            Safe.Base.Contract.IDbHelper qmnobj = SQLHelpers.TcAdmin();
            qmnobj.SetHandClose(false);
            try {
                if (gids != null)
                {
                    foreach (int gid in gids)
                    {
                        string         pname      = "p_AddUpdateGroupRight";
                        SqlParameter[] parameters =
                        {
                            new SqlParameter("@gid",              gid),
                            new SqlParameter("@pid",              pid),
                            new SqlParameter("@btnRightExp",      btnRightExp),
                            new SqlParameter("@updateWhenExists", updateWhenExists)
                        };
                        result = result + qmnobj.ExecuteProc(pname, false, parameters).ReturnValue;
                    }
                }
            } finally {
                qmnobj.EndConnection();
            }
            return(result);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 根据用户名获取一个管理员信息实体
        /// <param name="aname">用户名</param>
        /// </summary>
        public MR_Admin GetModel(string aname, string ip)
        {
            Safe.Base.Contract.IDbHelper dbHelper = SQLHelpers.TcAdmin();
            try {
                StringBuilder strSql = new StringBuilder();

                strSql.Append("select  top 1 AID,AName,ANickName,IP,Email,R_Admin.GID ,R_Admin.ALastTime from R_Admin ");
                strSql.Append(" where AName=@AName ");
                SqlParameter[] parameters =
                {
                    new SqlParameter("@AName", aname)
                };
                DataTable dtbl = dbHelper.ExecuteFillDataTable(strSql.ToString(), parameters);
                if (dtbl.Rows.Count > 0)
                {
                    MR_Admin result = Safe.Base.Utility.ModelConvertHelper <MR_Admin> .ToModel(dtbl.Rows[0]);

                    dbHelper.ExecuteNonQuery("UPDATE R_Admin SET ALastTime=getdate() , IP=@ip Where AID=@aid", new SqlParameter("@aid", result.AID), new SqlParameter("@ip", ip));
                    return(result);
                }
                else
                {
                    return(null);
                }
            } finally {
                dbHelper.EndConnection();
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// 取得组的预设菜单, 不含隐藏目录
        /// </summary>
        /// <param name="groupID">组ID</param>
        /// <param name="parentID">用户ID</param>
        /// <param name="includeChild">是否同时取子节点</param>
        /// <returns></returns>
        public IList <MR_PageInfo> GetList(int groupID, int parentID, bool includeChild)
        {
            IList <MR_PageInfo> result = new List <MR_PageInfo>();

            Safe.Base.Contract.IDbHelper tqmn = SQLHelpers.TcAdmin();
            tqmn.SetHandClose(false);
            try {
                GetChilds(groupID, parentID, includeChild, ref result, ref tqmn);
                return(result);
            } finally {
                tqmn.EndConnection();
            }
        }
Exemplo n.º 6
0
 /// <summary>
 /// 删除管理员对某个页面的访问权限(会同时删除子页面,不含隐藏页)返回1
 /// </summary>
 /// <param name="PID">页面ID</param>
 /// <param name="AID">管理员ID</param>
 public int Delete(int PID, IList <int> AID)
 {
     Safe.Base.Contract.IDbHelper dbhelper = SQLHelpers.TcAdmin();
     dbhelper.SetHandClose(true);
     try {
         foreach (int taid in AID)
         {
             Delete(PID, taid, dbhelper);
         }
     } finally {
         dbhelper.EndConnection();
     }
     return(1);
 }
Exemplo n.º 7
0
        /// <summary>
        /// 登录后取得对应权限,不含隐藏菜单
        /// </summary>
        /// <param name="adminId">管理员ID</param>
        /// <param name="parentID">父节点ID</param>
        /// <param name="includeChild">是否同时取子节点</param>
        public IList <MR_PageInfo> GetMenus(int adminId, int parentID, bool includeChild, bool updateClickTime)
        {
            IList <MR_PageInfo> result = new List <MR_PageInfo>();

            Safe.Base.Contract.IDbHelper tqmn = SQLHelpers.TcAdmin();
            tqmn.SetHandClose(false);
            try {
                GetChilds(adminId, parentID, includeChild, ref result, ref tqmn);
                if (result != null && result.Count > 0 && updateClickTime)
                {
                    string sql = "UPDATE R_AdminRight SET ClickTimes=ClickTimes+1 WHERE AID=@AID AND PID=@PID";
                    tqmn.ExecuteNonQuery(sql, new SqlParameter("@AID", adminId), new SqlParameter("@PID", parentID));
                }
                return(result);
            } finally {
                tqmn.EndConnection();
            }
        }