private void refreshClientSummaries(bool fromDatabase) { if (fromDatabase) { ClientFunctions.ClientsNotForProduct = ClientFunctions.ClientsWithoutProduct(activeOnly, selectedProductID); ClientFunctions.ClientsForProduct = ClientFunctions.ClientsWithProduct(activeOnly, selectedProductID); } ClientFrom.ItemsSource = ClientFunctions.ClientsNotForProduct; ClientFrom.Items.SortDescriptions.Clear(); ClientFrom.Items.SortDescriptions.Add(new SortDescription("ClientName", ListSortDirection.Ascending)); ClientFrom.Items.Refresh(); ClientFrom.SelectedItem = null; ClientTo.ItemsSource = ClientFunctions.ClientsForProduct; ClientTo.Items.SortDescriptions.Clear(); ClientTo.Items.SortDescriptions.Add(new SortDescription("ClientName", ListSortDirection.Ascending)); ClientTo.Items.Refresh(); ClientTo.SelectedItem = null; disableButtons(); if (selectedProduct != null) { PageHeader.Content = "Clients with Product '" + selectedProduct.ProductName + "'"; if (ClientFrom.Visibility == Visibility.Visible) { ProductVersionLabel.Content = "The latest version of " + selectedProduct.ProductName + " is " + selectedProduct.LatestVersion.ToString() + "."; } } }
private void removeProduct() { try { if (ProductTo.SelectedItem != null) { List <ClientProductProxy> removeList = new List <ClientProductProxy>(); ClientProductProxy thisProduct = null; ProjectProductProxy thisRecord = (ProjectProductProxy)ProductTo.SelectedItem; if (thisRecord.ClientID > 0) { thisProduct = ClientFunctions.ClientsWithProduct(false, thisRecord.ProductID).FirstOrDefault(cwp => cwp.ClientID == thisRecord.ClientID); if (thisProduct == null) { MessageFunctions.InfoAlert("No client product record found for client " + thisRecord.ClientName() + " with product " + thisRecord.ProductName + ". A 'dummy' record will be used instead.", null); thisProduct = ProjectFunctions.DummyClientProduct(thisRecord.Product); } } else { thisProduct = ProjectFunctions.DummyClientProduct(thisRecord.Product); } removeList.Add(thisProduct); bool success = ProjectFunctions.ToggleProjectProducts(removeList, false, Globals.SelectedProjectProxy); if (success) { refreshProductSummaries(false); CommitButton.IsEnabled = true; } } else { MessageFunctions.Error("Error removing products from project: no product selected.", null); } } catch (Exception generalException) { MessageFunctions.Error("Error removing products from project", generalException); } }