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);
        }