public void LoadTasks(Entities.RoleCollection roles) { using (SqlConnection cnn = new SqlConnection(sqlCnnStr)) { string query = "SELECT * FROM RoleTasks"; using (SqlCommand cmd = new SqlCommand(query, cnn)) { cmd.CommandType = CommandType.Text; cnn.Open(); using (SqlDataReader reader = cmd.ExecuteReader()) { if (reader != null && reader.HasRows) { Entities.Role role; Entities.Task task; while (reader.Read()) { role = Membership.Roles.GetById(Utils.GetSafeInt32(reader, "RoleId")); task = Membership.Tasks.GetById(Utils.GetSafeInt32(reader, "TaskId")); role.Tasks.Add(task); } } } } } }
public Entities.RoleCollection GetAll() { Entities.RoleCollection roles = new Entities.RoleCollection(); using (SqlConnection cnn = new SqlConnection(sqlCnnStr)) { string query = "SELECT * FROM Roles"; using (SqlCommand cmd = new SqlCommand(query, cnn)) { cmd.CommandType = CommandType.Text; cnn.Open(); using (SqlDataReader reader = cmd.ExecuteReader()) { if (reader != null && reader.HasRows) { while (reader.Read()) { Entities.Role role = new Entities.Role(); role.Id = Utils.GetSafeInt32(reader, "RoleId"); role.Name = Utils.GetSafeString(reader, "RoleName"); role.Priority = System.Convert.ToInt32(Utils.GetSafeString(reader, "RolePriority")); roles.Add(role); } } } } } return(roles); }
private void PopulateRoles() { pnlConfigureRoles.Visible = true; Facade.IRole facRole = new Facade.Security(); DataSet allRoles = facRole.GetAllRoles(); Entities.RoleCollection assignedRoles = facRole.GetRolesForSystemPortion((eSystemPortion)int.Parse(cboSystemPortion.SelectedValue)); Entities.RoleCollection unassignedRoles = facRole.GetUnassignedRolesForSystemPortion((eSystemPortion)int.Parse(cboSystemPortion.SelectedValue)); // Roles which can access system portion lbAssignedRoles.DataSource = assignedRoles; lbAssignedRoles.DataBind(); // Roles which cannot access system portion lbUnassignedRoles.DataSource = unassignedRoles; lbUnassignedRoles.DataBind(); }
public RolesListView() : base() { this.BorderStyle = BorderStyle.None; this.Dock = DockStyle.Fill; this.Font = new Font("Microsoft Sans Serif", 8.25F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(178))); this.Location = new Point(3, 16); this.Name = "lsvRoles"; this.Size = new Size(184, 418); this.TabIndex = 0; this.UseCompatibleStateImageBehavior = false; this.Visible = true; //this.Margin = new Padding(0); this.View = System.Windows.Forms.View.Details; this.MultiSelect = false; this.HeaderStyle = ColumnHeaderStyle.None; this.HideSelection = false; this.FullRowSelect = true; this.Columns.Add("Roles", this.Width - 5, HorizontalAlignment.Left); this.HotTracking = true; this.SmallImageList = new ImageList(); this.SmallImageList.ImageSize = new Size(16, 16); this.SmallImageList.Images.Add( DomainModel.Application.ResourceManager.GetImage( "clipboard")); this.dataSource = DomainModel.Membership.Roles.GetAll(); this.dataSource.ListChanged += new ListChangedEventHandler(dataSource_ListChanged); this.SizeChanged += new System.EventHandler(UsersListView_SizeChanged); UpdateList(); }
protected void Page_Load(object sender, System.EventArgs e) { // Get roles that can access requested SystemPortion Facade.IRole facRole = new Facade.Security(); Entities.RoleCollection rolesForSystemPortions = facRole.GetRolesForSystemPortions((eSystemPortion[])Session["SystemPortions"]); // Display Roles that can access the requested SystemPortion for (int i = 0; i < rolesForSystemPortions.Count; i++) { Entities.Role currentRole = (Entities.Role)rolesForSystemPortions[i]; if (i == 0) { lblRole.Text = currentRole.Name; } else if (i == 1 && rolesForSystemPortions.Count == 2) { lblRole.Text += " and " + currentRole.Name; } else if (i == 1 && rolesForSystemPortions.Count > 2) { lblRole.Text += ", " + currentRole.Name; } else if (i == (rolesForSystemPortions.Count - 1)) { lblRole.Text += " and " + currentRole.Name; } else { lblRole.Text += ", " + currentRole.Name; } } // Display the username of the requesting user lblUser.Text += ((Entities.CustomPrincipal)Page.User).UserName; }