예제 #1
0
        public string SaveRoleRights(HttpContext context)
        {
            string        roleId     = context.Request.Form["RoleID"];
            string        roleRights = context.Request.Form["RoleRights"];
            StringBuilder str        = new StringBuilder();

            if (string.IsNullOrEmpty(roleId))
            {
                str.Append("{\"isSuccess\":false,\"Msg\":\"参数错误,操作失败!\"}");
                return(str.ToString());
            }
            YhglBLL BLL = new YhglBLL(WorkUser);

            if (string.IsNullOrEmpty(WorkUser.UserID))
            {
                str.Append("{\"isSuccess\":false,\"Msg\":\"未登录用户,操作失败!\"}");
                return(str.ToString());
            }

            List <ModuleOperate> list = JSONHelper.FromJson <List <ModuleOperate> >(roleRights);

            if (BLL.Update_RoleRights(roleId, list))
            {
                str.Append("{\"isSuccess\":true,\"Msg\":\"角色设置成功!\"}");
            }
            else
            {
                str.Append("{\"isSuccess\":false,\"Msg\":\"角色设置失败!\"}");
            }


            return(str.ToString());
        }
예제 #2
0
        public string SaveRoles(HttpContext context)
        {
            string userID = context.Request.Form["UserID"];

            string        roleIDs = context.Request.Form["RoleIDs"];
            StringBuilder str     = new StringBuilder();
            YhglBLL       BLL     = new YhglBLL(WorkUser);

            if (string.IsNullOrEmpty(userID))
            {
                str.Append("{\"isSuccess\":false,\"Msg\":\"非法请求,操作失败!\"}");
                return(str.ToString());
            }
            if (!WorkUser.list.Exists(p => p.moduleCode.Equals(ModuleCode_Enum.yhgl.ToString(), StringComparison.CurrentCultureIgnoreCase) &&
                                      (p.operateCode.Equals(Yhgl_Operate.Add.ToString(), StringComparison.CurrentCultureIgnoreCase) || p.operateCode.Equals(Yhgl_Operate.Edit.ToString(), StringComparison.CurrentCultureIgnoreCase))))
            {
                str.Append("{\"isSuccess\":false,\"Msg\":\"您无权限进行此操作!\"}");
                return(str.ToString());
            }

            if (BLL.Update_UserRoles(userID, roleIDs))
            {
                str.Append("{\"isSuccess\":true,\"Msg\":\"更新成功!\"}");
            }
            else
            {
                str.Append("{\"isSuccess\":false,\"Msg\":\"更新失败!\"}");
            }


            return(str.ToString());
        }
예제 #3
0
 protected void Page_Load(object sender, EventArgs e)
 {
     Operate = Request.QueryString["operate"];
     Id      = Request.QueryString["id"];
     BLL     = new YhglBLL(WorkUser);
     if (!this.IsPostBack)
     {
         if (Operate.Equals("edit"))
         {
             DataTable dt = BLL.ReadUser(Id).Result;
             if (dt.Rows.Count > 0)
             {
                 this.SetControlValue(dt.Rows[0].ToDataItem());
             }
         }
     }
 }
예제 #4
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            int     allRecordCount = 0;
            string  sortname       = context.Request.Params["sortname"];
            string  sortorder      = context.Request.Params["sortorder"];
            int     page           = Convert.ToInt32(context.Request.Params["page"]) - 1; // 系统的索引从0开始,所以此处需要减1
            int     pagesize       = Convert.ToInt32(context.Request.Params["pagesize"]);
            string  fromWhere      = context.Request.QueryString["fromwhere"];
            string  rowid          = context.Request.QueryString["rowid"];
            object  sessionAppUser = context.Session[ConfigManager.GetSignInAppUserSessionName()];
            AppUser workUser       = (AppUser)sessionAppUser;

            yhglBLL = new YhglBLL(workUser);
            //排序
            string orderby = @" " + sortname + " " + sortorder + " ";
            //通过检索翻译 生成查询条件
            FilterTranslator ft = ContextExtension.GetGridData(context);
            //分页
            DataTable dt = new DataTable();

            switch (fromWhere)
            {
            case "yhxx":
                dt = yhglBLL.Retrieve_g_user(ft, pagesize, page, orderby, out allRecordCount).Result;
                break;

            case "roleRight_List":
                string userID = context.Request.QueryString["userID"];

                dt = yhglBLL.Retrieve_RoleRight_List(userID, ft, pagesize, page, orderby, out allRecordCount).Result;
                break;
            }
            ft.Parms.Clear();

            string result = JSONHelper.DataTableToJson(dt);

            //result = Regex.Replace(result, @"[/n/r]", ""); //去掉字符串里所有换行符
            //result = result.TrimEnd((char[])"\n\r".ToCharArray());  //去掉换行符
            json = @"{""Rows"":[" + result + @"],""Total"":""" + allRecordCount + @"""}";
            context.Response.Write(json);
            context.Response.End();
        }
예제 #5
0
        public string GetRoleRights(HttpContext context)
        {
            string        roleId     = context.Request.QueryString["roleId"];
            YhglBLL       BLL        = new YhglBLL(WorkUser);
            StringBuilder str        = new StringBuilder();
            DataTable     dt_modules = BLL.Get_RoleModules_List(roleId).Result;

            str.Append("[");
            foreach (DataRow row in dt_modules.Rows)
            {
                str.Append("{");

                str.AppendFormat("\"moduleCode\":\"{0}\",\"moduleName\":\"{1}\"", row["ModuleCode"], row["ModuleName"]);

                str.Append(",\"rights\":[");
                DataTable dt_operators = BLL.Get_ModuleOperators_List(roleId, row["ModuleCode"].ToString2()).Result;

                foreach (DataRow row_operate in dt_operators.Rows)
                {
                    str.Append("{");

                    str.AppendFormat("\"operateCode\":\"{0}\",\"operateName\":\"{1}\",\"hasRights\":{2}", row_operate["OperateCode"], row_operate["OperateName"], (row_operate["HasRight"].ToInt32(0) > 0).ToString().ToLower());
                    str.Append("},");
                }
                if (dt_modules.Rows.Count > 0)
                {
                    str.Remove(str.Length - 1, 1);
                }
                str.Append("]");
                str.Append("},");
            }
            if (dt_modules.Rows.Count > 0)
            {
                str.Remove(str.Length - 1, 1);
            }
            str.Append("]");



            return(str.ToString());
        }
예제 #6
0
        public string GetUserRights(HttpContext context)
        {
            YhglBLL       BLL        = new YhglBLL(WorkUser);
            StringBuilder str        = new StringBuilder();
            DataTable     dt_modules = BLL.Get_UserRights_List().Result;

            str.Append("[");
            foreach (DataRow row in dt_modules.Rows)
            {
                str.Append("{");

                str.AppendFormat("\"moduleCode\":\"{0}\",\"moduleName\":\"{1}\"", row["ModuleCode"], row["ModuleName"]);
                str.AppendFormat(",\"operateCode\":\"{0}\",\"operateName\":\"{1}\"", row["OperateCode"], row["OperateName"]);
                str.Append("},");
            }
            if (dt_modules.Rows.Count > 0)
            {
                str.Remove(str.Length - 1, 1);
            }
            str.Append("]");
            return(str.ToString());
        }
예제 #7
0
 protected void Page_Load(object sender, EventArgs e)
 {
     RoleId  = Request.QueryString["id"];
     Operate = Request.QueryString["operate"];
     BLL     = new YhglBLL(WorkUser);
     if (!this.IsPostBack)
     {
         if (!WorkUser.list.Exists(p => p.moduleCode.Equals(ModuleCode_Enum.yhgl.ToString(), StringComparison.CurrentCultureIgnoreCase) &&
                                   (p.operateCode.Equals(Yhgl_Operate.Add.ToString(), StringComparison.CurrentCultureIgnoreCase) || p.operateCode.Equals(Yhgl_Operate.Edit.ToString(), StringComparison.CurrentCultureIgnoreCase))))
         {
             ScriptManager.RegisterStartupScript(this, this.GetType(), "", "showWarn('您没有权限进行此操作!');", true);
             return;
         }
         if (Operate.Equals("edit"))
         {
             DataTable dt = BLL.ReadRole(this.RoleId).Result;
             if (dt.Rows.Count > 0)
             {
                 this.SetControlValue(dt.Rows[0].ToDataItem());
             }
         }
     }
 }