private void btnDone_Click(object sender, RoutedEventArgs e) { string Name; decimal Price; string Description; int BrandId; int CategoryId; Brand selectedBrand = (Brand)BrandCombo.SelectedItem; Category selectedCategory = (Category)CategoryCombo.SelectedItem; try { Name = txtName.Text; Price = decimal.Parse(txtPrice.Text); Description = txtDescription.Text; BrandId = selectedBrand.BrandId; CategoryId = selectedCategory.CategoryId; if (Name.Length > 0 && Description.Length > 0 && Price > 0 && BrandId > 0 && CategoryId > 0) { Product updatedProduct = (Product)listProducts.SelectedItem; updatedProduct.Name = Name; updatedProduct.Price = Price; updatedProduct.Description = Description; updatedProduct.BrandId = BrandId; updatedProduct.CategoryId = CategoryId; pctr.UpdateProduct(updatedProduct); MessageBox.Show(updatedProduct.Name + " has been updated!", "Success", MessageBoxButton.OK, MessageBoxImage.Information); } listProducts.Items.Refresh(); } catch (Exception ex) { Complain(ex, "Try again. "); } }
public void UpdateProduct(ServiceProduct product) { productControl.UpdateProduct(product); }