private void createNewClient(string accountManagerName) { int newID = 0; bool inCurrentEntity = (selectedEntityID == Globals.CurrentEntityID); string savedInEntity = ""; string contactsCopied = ""; try { newID = ClientFunctions.NewClient(ClientCode.Text, ClientName.Text, accountManagerName, (bool)ActiveCheckBox.IsChecked, selectedEntityID); } catch (Exception generalException) { MessageFunctions.Error("Error creating new client record", generalException); } if (newID > 0) { try { if (!inCurrentEntity) { if (CopyContactsCheckBox.IsChecked == true) { bool success = ClientFunctions.CopyContacts(selectedRecord.ID, newID); contactsCopied = success ? ", and all active linked contacts have been copied to it" : " but contacts could not be copied"; } savedInEntity = " in Entity '" + EntityFunctions.GetEntityName(selectedEntityID) + "'" + contactsCopied + ". Switch to that Entity if you need to work with the new record"; } MessageFunctions.SuccessAlert("New client '" + ClientName.Text + "' saved successfully" + savedInEntity + ".", "Client Created"); if (pageMode == PageFunctions.Amend) { resetAmendPage(accountManagerName); if (inCurrentEntity) { refreshClientGrid(); // This is not necessarily done for us by the Account Managers list ClientDataGrid.SelectedValue = gridList.First(c => c.ID == newID); ClientDataGrid.ScrollIntoView(ClientDataGrid.SelectedItem); } AddButtonText.Text = "Add Another"; } else { ClientFunctions.ReturnToTilesPage(); } } catch (Exception generalException) { MessageFunctions.Error("Error updating page for new client record", generalException); } } }