예제 #1
0
 public bool AddRole(RoleInfo role)
 {
     DbCommand sqlStringCommand = this.database.GetSqlStringCommand("INSERT INTO aspnet_Roles (RoleName, Description) VALUES (@RoleName, @Description)");
     this.database.AddInParameter(sqlStringCommand, "RoleName", DbType.String, role.RoleName);
     this.database.AddInParameter(sqlStringCommand, "Description", DbType.String, role.Description);
     return (this.database.ExecuteNonQuery(sqlStringCommand) > 0);
 }
예제 #2
0
 private void btnEditRoles_Click(object sender, EventArgs e)
 {
     RoleInfo target = new RoleInfo();
     if (string.IsNullOrEmpty(this.txtEditRoleName.Text.Trim()))
     {
         this.ShowMsg("部门名称不能为空,长度限制在60个字符以内", false);
     }
     else if ((string.Compare(this.txtRoleName.Value, this.txtEditRoleName.Text) == 0) || !ManagerHelper.RoleExists(this.txtEditRoleName.Text.Trim().Replace(",", "")))
     {
         target.RoleId = int.Parse(this.txtRoleId.Value);
         target.RoleName = Globals.HtmlEncode(this.txtEditRoleName.Text.Trim()).Replace(",", "");
         target.Description = Globals.HtmlEncode(this.txtEditRoleDesc.Text.Trim());
         ValidationResults results = Hishop.Components.Validation.Validation.Validate<RoleInfo>(target, new string[] { "ValRoleInfo" });
         string msg = string.Empty;
         if (!results.IsValid)
         {
             foreach (ValidationResult result in (IEnumerable<ValidationResult>) results)
             {
                 msg = msg + Formatter.FormatErrorMessage(result.Message);
             }
             this.ShowMsg(msg, false);
         }
         else
         {
             ManagerHelper.UpdateRole(target);
             this.BindUserGroup();
         }
     }
     else
     {
         this.ShowMsg("已经存在相同的部门名称", false);
     }
 }
예제 #3
0
 protected void btnSubmitRoles_Click(object sender, EventArgs e)
 {
     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);
     }
 }
예제 #4
0
 public bool UpdateRole(RoleInfo role)
 {
     DbCommand sqlStringCommand = this.database.GetSqlStringCommand("UPDATE aspnet_Roles SET RoleName = @RoleName, Description = @Description WHERE RoleId = @RoleId");
     this.database.AddInParameter(sqlStringCommand, "RoleId", DbType.Int32, role.RoleId);
     this.database.AddInParameter(sqlStringCommand, "RoleName", DbType.String, role.RoleName);
     this.database.AddInParameter(sqlStringCommand, "Description", DbType.String, role.Description);
     return (this.database.ExecuteNonQuery(sqlStringCommand) > 0);
 }
예제 #5
0
 public static bool AddRole(RoleInfo role)
 {
     return new RoleDao().AddRole(role);
 }
예제 #6
0
 public static bool UpdateRole(RoleInfo role)
 {
     return new RoleDao().UpdateRole(role);
 }