protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e) { UserBLL userBLL = new UserBLL(); RoleBLL roleBLL = new RoleBLL(); GroupBLL groupBLL = new GroupBLL(); string UserName = ((TextBox)CreateUserWizardStep1.ContentTemplateContainer.FindControl("UserName")).Text; int roleID = Convert.ToInt32(((DropDownList)CreateUserWizardStep1.ContentTemplateContainer.FindControl("ddlRoles")).SelectedValue); int groupID = Convert.ToInt32(((DropDownList)CreateUserWizardStep1.ContentTemplateContainer.FindControl("ddlGroups")).SelectedValue); Role role = roleBLL.GetRoleByRoleID(roleID); User user = userBLL.GetUserByUserName_WithoutApplication(UserName); Group group = groupBLL.GetGroupByGroupID(groupID); roleBLL.AddUserToRole(user, role); groupBLL.AddUserToGroup(user, group); Label lblEmail = (Label)CompleteWizardStep1.ContentTemplateContainer.FindControl("lblEmail"); Label lblUserType = (Label)CompleteWizardStep1.ContentTemplateContainer.FindControl("lblUserType"); Label lblGroup = (Label)CompleteWizardStep1.ContentTemplateContainer.FindControl("lblGroup"); lblEmail.Text = UserName; lblUserType.Text = ((DropDownList)CreateUserWizardStep1.ContentTemplateContainer.FindControl("ddlRoles")).SelectedItem.Text; lblGroup.Text = ((DropDownList)CreateUserWizardStep1.ContentTemplateContainer.FindControl("ddlGroups")).SelectedItem.Text; Response.Redirect("~/secured/admin/users.aspx", true); }
protected void ButtonDeleteSelected_Click(object sender, System.EventArgs e) { try { // Create a List to hold the GroupID values to delete List <Int32> GroupIDsToDelete = new List <Int32>(); // Iterate through the Groups.Rows property foreach (GridViewRow row in gridViewGroups.Rows) { // Access the CheckBox CheckBox cb = (CheckBox)(row.FindControl("chkGroupSelector")); if (cb != null && cb.Checked) { // Save the GroupID value for deletion // First, get the GroupID for the selected row Int32 GroupID = (Int32)gridViewGroups.DataKeys[row.RowIndex].Value; GroupBLL groupBLL = new GroupBLL(); Eisk.BusinessEntities.Group group = groupBLL.GetGroupByGroupID(GroupID); // Add it to the List... GroupIDsToDelete.Add(GroupID); // Add a confirmation message ltlMessage.Text += String.Format(MessageFormatter.GetFormattedSuccessMessage("Delete successful. Group <b>{0}</b> has been deleted"), group.GroupName); } } //perform the actual delete new GroupBLL().DeleteGroups(GroupIDsToDelete); } catch (Exception ex) { ltlMessage.Text = ExceptionManager.DoLogAndGetFriendlyMessageForException(ex); } //binding the grid gridViewGroups.PageIndex = 0; gridViewGroups.DataBind(); }