private void Delete() { Role role = Role.GetByKey(Convert.ToInt32(txtRoleId.Text)); if (role != null) { if (role.Delete(HyperCatalog.Shared.SessionState.User.Id)) { SessionState.ClearAppRoles(); Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "clientScript", "<script>back();</script>"); } else { lbError.CssClass = "hc_error"; lbError.Text = Role.LastError; lbError.Visible = true; } } else { lbError.CssClass = "hc_error"; lbError.Text = "Error: Role is null"; lbError.Visible = true; } }
private void Save() { Role role = null; if (!panelId.Visible) { // Create role role = new Role(-1, txtRoleName.Text, txtDescription.Text); } else { // Update role role = Role.GetByKey(Convert.ToInt32(txtRoleId.Text)); if (role != null) { role.Name = txtRoleName.Text; role.Description = txtDescription.Text; } } if (role != null) { if (role.Save()) { SessionState.ClearAppRoles(); if (!panelId.Visible) { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "clientScript", "<script>back();</script>"); } else { lbError.Text = "Data saved!"; lbError.CssClass = "hc_success"; lbError.Visible = true; } } else { lbError.CssClass = "hc_error"; lbError.Text = Role.LastError; lbError.Visible = true; } } else { lbError.CssClass = "hc_error"; lbError.Text = "Error: Role is null"; lbError.Visible = true; } }