// ---------------------- // // -- Data Management --- // // ---------------------- // // Data updates // // Data retrieval // // Other/shared functions // private void refreshClientGrid() { try { int selectedID = 0; if (Globals.SelectedClient != null) { selectedID = Globals.SelectedClient.ID; } if (selectedID == 0 && selectedClientGridRecord != null) { selectedID = selectedClientGridRecord.ID; } // Just in case clientGridList = ClientFunctions.ClientGridListByContact(clientActiveOnly, clientContains, contactContains, Globals.CurrentEntityID); ClientDataGrid.ItemsSource = clientGridList; ClientDataGrid.Items.SortDescriptions.Clear(); ClientDataGrid.Items.SortDescriptions.Add(new SortDescription("ClientCode", ListSortDirection.Ascending)); try { if (selectedID != 0 && clientGridList.Exists(c => c.ID == selectedID)) { ClientDataGrid.SelectedItem = clientGridList.First(c => c.ID == selectedID); ClientDataGrid.ScrollIntoView(ClientDataGrid.SelectedItem); } } catch (Exception generalException) { MessageFunctions.Error("Error selecting the current client row", generalException); } } catch (Exception generalException) { MessageFunctions.Error("Error refreshing client details in the grid", generalException); } }
// Other/shared functions // private void refreshClientDataGrid() { try { int selectedID = (Globals.SelectedClient != null) ? Globals.SelectedClient.ID : 0; clientGridList = ClientFunctions.ClientGridListByProduct(activeOnly, nameContains, selectedProductID, Globals.CurrentEntityID); ClientDataGrid.ItemsSource = clientGridList; ClientDataGrid.Items.SortDescriptions.Clear(); ClientDataGrid.Items.SortDescriptions.Add(new SortDescription("ClientCode", ListSortDirection.Ascending)); if (selectedID > 0) { try { if (clientGridList.Exists(c => c.ID == selectedID)) { ClientDataGrid.SelectedItem = clientGridList.First(c => c.ID == selectedID); ClientDataGrid.ScrollIntoView(ClientDataGrid.SelectedItem); } } catch (Exception generalException) { MessageFunctions.Error("Error selecting record", generalException); } } // refreshClientSummaries(true); } catch (Exception generalException) { MessageFunctions.Error("Error filling client grid", generalException); } }
// ---------------------- // // -- Data Management --- // // ---------------------- // // Data updates // // Data retrieval // // Other/shared functions // private void refreshClientGrid() { try { gridList = ClientFunctions.ClientGridList(activeOnly, nameContains, accountManagerID, Globals.CurrentEntityID); ClientDataGrid.ItemsSource = gridList; if (selectedRecord != null || Globals.SelectedClient != null) { try { int selectedID = (selectedRecord != null) ? selectedRecord.ID : Globals.SelectedClient.ID; if (gridList.Exists(c => c.ID == selectedID)) { ClientDataGrid.SelectedItem = gridList.First(c => c.ID == selectedID); ClientDataGrid.ScrollIntoView(ClientDataGrid.SelectedItem); } else { Globals.SelectedClient = null; } } catch (Exception generalException) { MessageFunctions.Error("Error selecting the current row", generalException); } } } catch (Exception generalException) { MessageFunctions.Error("Error refreshing client details in the grid", generalException); } }
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); } } }