/// <summary> /// Returns a collection of Role objects /// </summary> /// <param name="criteria"></param> /// <returns>Roles</returns> public Roles GetRoles(RoleCriteria criteria) { criteria.Code = this.Code; Roles roles = new Roles(this.phreezer); roles.Query(criteria); return(roles); }
protected void Page_Load(object sender, EventArgs e) { this.Master.SetLayout("Edit Account", MasterPage.LayoutStyle.ContentOnly); this.RequirePermission(Affinity.RolePermission.AdminSystem); if (!Page.IsPostBack) { // populate the form Affinity.Roles roles = new Affinity.Roles(this.phreezer); Affinity.RoleCriteria rc = new Affinity.RoleCriteria(); rc.AppendToOrderBy("Description"); roles.Query(rc); ddRole.DataSource = roles; ddRole.DataTextField = "Description"; ddRole.DataValueField = "Code"; ddRole.SelectedValue = this.account.RoleCode; ddRole.DataBind(); Affinity.Underwriters uws = new Affinity.Underwriters(this.phreezer); Affinity.UnderwriterCriteria uwc = new Affinity.UnderwriterCriteria(); uwc.AppendToOrderBy("Description"); uws.Query(uwc); cblUnderwriterCodes.DataSource = uws; cblUnderwriterCodes.DataTextField = "Description"; cblUnderwriterCodes.DataValueField = "Code"; cblUnderwriterCodes.DataBind(); // pre-select the checkboxes from the comma-separated user setting string[] codes = this.account.UnderwriterCodes.Split(",".ToCharArray()); foreach (string c in codes) { ListItem cb = cblUnderwriterCodes.Items.FindByValue(c.Trim()); if (cb != null) { cb.Selected = true; } } foreach (ListItem cb in cblUnderwriterCodes.Items) { ListItem i = new ListItem("100%", cb.Value + "100%"); Endorse100.Items.Add(i); if (this.account.UnderwriterEndorsements.IndexOf(cb.Value + "100%") > -1) { i.Selected = true; } i = new ListItem("70%", cb.Value + "70%"); Endorse70.Items.Add(i); i.Attributes.Add("onclick", "verifyCheckboxes(this);"); if (this.account.UnderwriterEndorsements.IndexOf(cb.Value + "70%") > -1) { i.Selected = true; } i = new ListItem("75%", cb.Value + "75%"); Endorse75.Items.Add(i); i.Attributes.Add("onclick", "verifyCheckboxes(this);"); if (this.account.UnderwriterEndorsements.IndexOf(cb.Value + "75%") > -1) { i.Selected = true; } i = new ListItem("80%", cb.Value + "80%"); Endorse80.Items.Add(i); i.Attributes.Add("onclick", "verifyCheckboxes(this);"); if (this.account.UnderwriterEndorsements.IndexOf(cb.Value + "80%") > -1) { i.Selected = true; } i = new ListItem("85%", cb.Value + "85%"); Endorse85.Items.Add(i); i.Attributes.Add("onclick", "verifyCheckboxes(this);"); if (this.account.UnderwriterEndorsements.IndexOf(cb.Value + "85%") > -1) { i.Selected = true; } i = new ListItem("88%", cb.Value + "88%"); Endorse88.Items.Add(i); i.Attributes.Add("onclick", "verifyCheckboxes(this);"); if (this.account.UnderwriterEndorsements.IndexOf(cb.Value + "88%") > -1) { i.Selected = true; } i = new ListItem("90%", cb.Value + "90%"); Endorse90.Items.Add(i); i.Attributes.Add("onclick", "verifyCheckboxes(this);"); if (this.account.UnderwriterEndorsements.IndexOf(cb.Value + "90%") > -1) { i.Selected = true; } if (cb.Text.IndexOf("Direct") > -1) { Endorse100.Items[(Endorse100.Items.Count - 1)].Attributes.Add("style", "visibility:hidden"); Endorse70.Items[(Endorse70.Items.Count - 1)].Attributes.Add("style", "visibility:hidden"); Endorse75.Items[(Endorse75.Items.Count - 1)].Attributes.Add("style", "visibility:hidden"); Endorse80.Items[(Endorse80.Items.Count - 1)].Attributes.Add("style", "visibility:hidden"); Endorse85.Items[(Endorse85.Items.Count - 1)].Attributes.Add("style", "visibility:hidden"); Endorse88.Items[(Endorse88.Items.Count - 1)].Attributes.Add("style", "visibility:hidden"); Endorse90.Items[(Endorse90.Items.Count - 1)].Attributes.Add("style", "visibility:hidden"); } else if (!cb.Selected) { cb.Attributes.Add("onclick", "enableDisableCheckboxes(this);"); Endorse100.Items[(Endorse100.Items.Count - 1)].Enabled = false; Endorse70.Items[(Endorse70.Items.Count - 1)].Enabled = false; Endorse75.Items[(Endorse75.Items.Count - 1)].Enabled = false; Endorse80.Items[(Endorse80.Items.Count - 1)].Enabled = false; Endorse85.Items[(Endorse85.Items.Count - 1)].Enabled = false; Endorse88.Items[(Endorse88.Items.Count - 1)].Enabled = false; Endorse90.Items[(Endorse90.Items.Count - 1)].Enabled = false; } else { cb.Attributes.Add("onclick", "enableDisableCheckboxes(this);"); } } Affinity.Companys companies = new Affinity.Companys(this.phreezer); Affinity.CompanyCriteria cc = new Affinity.CompanyCriteria(); companies.Query(cc); ddCompany.DataSource = companies; ddCompany.DataTextField = "Name"; ddCompany.DataValueField = "Id"; ddCompany.SelectedValue = this.account.CompanyId.ToString(); ddCompany.DataBind(); txtId.Text = this.account.Id.ToString(); txtUsername.Text = this.account.Username.ToString(); txtFirstName.Text = this.account.FirstName.ToString(); txtLastName.Text = this.account.LastName.ToString(); txtCreated.Text = this.account.Created.ToShortDateString(); txtModified.Text = this.account.Modified.ToShortDateString(); txtPasswordHint.Text = this.account.PasswordHint.ToString(); txtInternalId.Text = this.account.InternalId.ToString(); txtEmail.Text = this.account.Email.ToString(); txtBusinessLicenseId.Text = this.account.BusinessLicenseID.ToString(); txtIndividualLicenseId.Text = this.account.IndividualLicenseID.ToString(); } }
protected void Page_Load(object sender, EventArgs e) { this.RequirePermission(Affinity.RolePermission.AdminSystem); this.RequirePermission(Affinity.RolePermission.AffinityManager); this.RequirePermission(Affinity.RolePermission.AffinityStaff); this.Master.SetLayout("AttachmentPurpose Details", MasterPage.LayoutStyle.ContentOnly); this.btnDelete.Attributes.Add("onclick", "return confirm('Delete this record?')"); if (!Page.IsPostBack) { // populate the form string code = this.attachmentPurpose.Code.ToString(); txtCode.Text = code; lblCode.Text = code; txtDescription.Text = this.attachmentPurpose.Description.ToString(); txtChangeStatusTo.Text = this.attachmentPurpose.ChangeStatusTo.ToString(); txtPermissionRequired.Text = this.attachmentPurpose.PermissionRequired.ToString(); cbSendNotification.Checked = this.attachmentPurpose.SendNotification; if (this.isUpdate) { lblCode.Visible = true; } else { txtCode.Visible = true; } // Display checkbox roles Affinity.Roles roles = new Affinity.Roles(this.phreezer); Affinity.RoleCriteria rc = new Affinity.RoleCriteria(); // order by description rc.AppendToOrderBy("Description"); roles.Query(rc); // display checkboxes in columns of 3 RolesCheckboxes.RepeatColumns = 3; RolesCheckboxes.Width = 700; Affinity.AttachmentRole ardao = new Affinity.AttachmentRole(this.phreezer); Affinity.AttachmentRolesCriteria arcrit = new Affinity.AttachmentRolesCriteria(); IEnumerator i = roles.GetEnumerator(); // loop through all the roles and add checkboxes for each one while (i.MoveNext()) { ListItem li = new ListItem(); Affinity.Role r = (Affinity.Role)i.Current; li.Text = r.Description; li.Value = r.Code; // verify if this checkbox should be checked arcrit.AttachmentPurposeCode = code; arcrit.RoleCode = r.Code; Affinity.AttachmentRoles aroles = ardao.GetAttachmentRoles(arcrit); li.Selected = (aroles.Count > 0); // Add checkbox to RolesCheckboxes div RolesCheckboxes.Items.Add(li); } } }