Ejemplo n.º 1
0
        protected void btnSubmitRoles_Click(object sender, System.EventArgs e)
        {
            if (this.htxtRoleId.Value != "")
            {
                this.btnEditRoles_Click();
                return;
            }
            string text        = Globals.HtmlEncode(this.txtAddRoleName.Text.Trim()).Replace(",", "");
            string description = Globals.HtmlEncode(this.txtRoleDesc.Text.Trim());

            if (string.IsNullOrEmpty(text) || text.Length > 60)
            {
                this.ShowMsg("部门名称不能为空,长度限制在60个字符以内", false);
                return;
            }
            if (!ManagerHelper.RoleExists(text))
            {
                ManagerHelper.AddRole(new RoleInfo
                {
                    RoleName    = text,
                    Description = description,
                    IsDefault   = bool.Parse(base.Request["rdIsDefault"])
                });
                this.BindUserGroup();
                this.ShowMsg("成功添加了一个部门", true);
                return;
            }
            this.ShowMsg("已经存在相同的部门名称", false);
        }
Ejemplo n.º 2
0
 protected void btnSubmitRoles_Click(object sender, EventArgs e)
 {
     if (this.htxtRoleId.Value != "")
     {
         this.btnEditRoles_Click();
     }
     else
     {
         string str  = Globals.HtmlEncode(this.txtAddRoleName.Text.Trim()).Replace(",", "");
         string str2 = Globals.HtmlEncode(this.txtRoleDesc.Text.Trim());
         if (string.IsNullOrEmpty(str) || (str.Length > 60))
         {
             this.ShowMsg("部门名称不能为空,长度限制在60个字符以内", false);
         }
         else if (!ManagerHelper.RoleExists(str))
         {
             RoleInfo role = new RoleInfo {
                 RoleName    = str,
                 Description = str2
             };
             ManagerHelper.AddRole(role);
             this.BindUserGroup();
             this.ShowMsg("成功添加了一个部门", true);
         }
         else
         {
             this.ShowMsg("已经存在相同的部门名称", false);
         }
     }
 }
Ejemplo n.º 3
0
        private void AddAndUpdate(HttpContext context)
        {
            int    value      = base.GetIntParam(context, "RoleId", false).Value;
            string parameter  = base.GetParameter(context, "RoleName", false);
            string parameter2 = base.GetParameter(context, "RoleDesc", false);

            if (string.IsNullOrEmpty(parameter) || parameter.Length > 60)
            {
                throw new HidistroAshxException("部门名称不能为空,长度限制在60个字符以内!");
            }
            RoleInfo roleInfo = new RoleInfo();

            if (value > 0)
            {
                roleInfo.RoleId      = value;
                roleInfo.RoleName    = Globals.HtmlEncode(parameter).Replace(",", "");
                roleInfo.Description = Globals.HtmlEncode(parameter2);
                ManagerHelper.UpdateRole(roleInfo);
                base.ReturnSuccessResult(context, "修改部门成功!", 0, true);
            }
            else
            {
                roleInfo.RoleName    = Globals.HtmlEncode(parameter).Replace(",", "");
                roleInfo.Description = Globals.HtmlEncode(parameter2);
                ManagerHelper.AddRole(roleInfo);
                base.ReturnSuccessResult(context, "成功添加了一个部门!", 0, true);
            }
        }