protected void btnAssign_Click(object sender, EventArgs e) { foreach (ListItem li in lbxUsers.Items) { if (li.Selected) { User selectedUser = new SPA.User(Int32.Parse(li.Value)); selectedUser.UserTypeID = int.Parse(lbxUserTypes.SelectedValue); selectedUser.Update(); } } lbxUsers.Items.Clear(); FillOrgUnitMembers(Int32.Parse(lbxOrgUnits.SelectedValue), txtFilter.Text.Trim()); }
private bool SaveItem() { bool success = false; try { if (!IsValid) { Script("resizeModalDialog('True');"); } bool isUpdate = (IView == ItemView.Edit); item = (isUpdate) ? new SPA.User(ItemID) : new SPA.User(); item.Email = txtEmail.Text.Trim(); item.LastName = txtLastName.Text.Trim(); item.FirstName = txtFirstName.Text.Trim(); item.MiddleInitial = txtMiddleInitial.Text.Trim(); item.GenerationalQualifier = txtGenerationalQualifier.Text.Trim(); item.PreferredName = txtPreferredName.Text.Trim(); item.UserTypeID = int.Parse(ddlUserType.SelectedItem.Value); item.SeniorStaff = ckbxSeniorStaff.Checked; item.ITAdmin = ckbxITAdmin.Checked; item.SuppressTrngAlerts = ckbxSuppressTrngAlerts.Checked; item.ModifiedBy = CurrentUser.DisplayName; Transaction xAction = new Transaction(); if (!isUpdate) { item.CreatedBy = item.ModifiedBy; if (item.Insert()) { success = true; xAction.Action = string.Format("Successfully added {0} to the user catalog", item.UserName); xAction.Category = "Application Administration"; xAction.Type = Transaction.TYPE_SUCCESS; xAction.CreatedBy = item.ModifiedBy; xAction.Insert(); } else { xAction.Action = string.Format("Failed to add {0} to the user catalog", item.UserName); xAction.Category = "Application Administration"; xAction.Type = Transaction.TYPE_FAILURE; xAction.CreatedBy = item.ModifiedBy; xAction.Insert(); } } else { if (item.Update()) { success = true; xAction.Action = string.Format("Successfully update {0} in the user catalog", item.UserName); xAction.Category = "Application Administration"; xAction.Type = Transaction.TYPE_SUCCESS; xAction.CreatedBy = item.ModifiedBy; xAction.Insert(); } else { xAction.Action = string.Format("Failed to update {0} in the user catalog", item.UserName); xAction.Category = "Application Administration"; xAction.Type = Transaction.TYPE_FAILURE; xAction.CreatedBy = item.ModifiedBy; xAction.Insert(); } } ItemID = (success) ? item.ID : 0; } catch (Exception ex) { SPA.Error.WriteError(ex); if (ShowDebug) { lblErrorMessage.Text = ex.ToString(); } } return(success); }