private void deleteProduct(Product product) { MessageBoxResult response = MessageBox.Show( String.Format("Delete {0}", product.ProductName), "Confirm", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No); if (response == MessageBoxResult.Yes) { this.northwindContext.Products.DeleteObject(product); saveChanges.IsEnabled = true; } }
/// <summary> /// Create a new Product object. /// </summary> /// <param name="productID">Initial value of the ProductID property.</param> /// <param name="productName">Initial value of the ProductName property.</param> /// <param name="discontinued">Initial value of the Discontinued property.</param> public static Product CreateProduct(global::System.Int32 productID, global::System.String productName, global::System.Boolean discontinued) { Product product = new Product(); product.ProductID = productID; product.ProductName = productName; product.Discontinued = discontinued; return product; }
/// <summary> /// Deprecated Method for adding a new object to the Products EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToProducts(Product product) { base.AddObject("Products", product); }
private void editProduct(Product product) { ProductForm pf = new ProductForm(); pf.Title = "Edit Product Details"; pf.productName.Text = product.ProductName; pf.quantityPerUnit.Text = product.QuantityPerUnit; pf.unitPrice.Text = product.UnitPrice.ToString(); if (pf.ShowDialog().Value) { product.ProductName = pf.productName.Text; product.QuantityPerUnit = pf.quantityPerUnit.Text; product.UnitPrice = Decimal.Parse(pf.unitPrice.Text); saveChanges.IsEnabled = true; } }
private void addnewProduct() { ProductForm pf = new ProductForm(); pf.Title = "New Product for " + supplier.CompanyName; if (pf.ShowDialog().Value) { Product newProd = new Product(); newProd.ProductName = pf.productName.Text; newProd.QuantityPerUnit = pf.quantityPerUnit.Text; newProd.UnitPrice = Decimal.Parse(pf.unitPrice.Text); this.supplier.Products.Add(newProd); this.productsInfo.Add(newProd); saveChanges.IsEnabled = true; } }