// ---------------------- // // -- 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); } }