protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (this.txtRoleName.Text.Trim().Length > 15)
                {
                    JsAlert("角色名长度不能超过15个字符!");
                    return;
                }

                if (this.txtDescript.Text.Trim().Length > 100)
                {
                    JsAlert("描述不能超过100个字符!");
                    return;
                }

                if (!roleService.IsUnique(this.txtRoleName.Text.Trim()))
                {
                    JsAlert("角色名已经存在!");
                    return;
                }

                Ytg.BasicModel.Role role = roleService.Get(roleId);
                role.Name     = this.txtRoleName.Text.Trim();
                role.Descript = this.txtDescript.Text.Trim();

                roleService.Save();

                JsAlert("保存成功!", true);
            }
            catch (Exception ex)
            {
                JsAlert("保存失败,请稍后再试!");
            }
        }
 /// <summary>
 /// 初始化角色信息
 /// </summary>
 public void InitRoleInfo()
 {
     Ytg.BasicModel.Role role = roleService.Get(roleId);
     if (null != role)
     {
         this.txtRoleName.Text = role.Name;
         this.txtDescript.Text = role.Descript;
     }
 }
Esempio n. 3
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                IRoleService roleService = IoC.Resolve <IRoleService>();
                if (this.txtRoleName.Text.Trim().Length > 15)
                {
                    JsAlert("角色名长度不能超过15个字符!");
                    return;
                }

                if (this.txtDescript.Text.Trim().Length > 100)
                {
                    JsAlert("描述不能超过100个字符!");
                    return;
                }

                if (!roleService.IsUnique(this.txtRoleName.Text.Trim()))
                {
                    JsAlert("角色名已经存在!");
                    return;
                }

                Ytg.BasicModel.Role role = new Ytg.BasicModel.Role();
                role.Name     = this.txtRoleName.Text.Trim();
                role.Descript = this.txtDescript.Text.Trim();

                roleService.Create(role);
                roleService.Save();

                this.txtRoleName.Text = string.Empty;
                this.txtDescript.Text = string.Empty;
                JsAlert("保存成功!", true);
            }
            catch (Exception ex)
            {
                JsAlert("保存失败,请稍后再试!");
            }
        }