private void btnWijzig_Click(object sender, RoutedEventArgs e) { product myProduct = (product)cbWijzig.SelectedItem; txtProductName.Text = myProduct.name; cbProducttype.SelectedItem = myProduct.producttype; string sProductPrice = txtProductPrice.Text; pricehistory myPriceHistory = new pricehistory(); txtProductPrice.Text = myPriceHistory.price.ToString(); }
private void btnOpslaan_Click(object sender, RoutedEventArgs e) { { // Controle of er iemand is geselecteerd in de ComboBox if (cbWijzig.SelectedItem != null) { // Product ophalen uit ComboBox product myProd = (product)cbWijzig.SelectedItem; myProd.name = txtProductName.Text; producttype prodtype = (producttype)cbWijzig.SelectedItem; pricehistory myPrice = (pricehistory)cbWijzig.SelectedItem; myPrice.price = decimal.Parse(txtProductPrice.Text); // Data van de student laten zien in een MessageBox MessageBox.Show("Product: " + myProd.name + " is succesvol gewijzigd!"); } else { //Ingevoerde data ophalen string sProductName = txtProductName.Text; string sProductPrice = txtProductPrice.Text; producttype selPT = (producttype)cbProducttype.SelectedItem; //Product aanmaken en gegevens neerzetten product myProduct = new product(); myProduct.name = sProductName; myProduct.producttypeId = selPT.id; pricehistory myPriceHistory = new pricehistory(); decimal ProductPrice = decimal.Parse(sProductPrice); myPriceHistory.price = ProductPrice; // Product klaarzetten om op te slaan in de database db.products.InsertOnSubmit(myProduct); // Voer de wijzigingen door op de database db.SubmitChanges(); // Data opnieuw ophalen uit de database (het nieuwe product tonen) SetData(); // User feedback en velden legen txtProductName.Text = string.Empty; txtProductPrice.Text = string.Empty; MessageBox.Show("Het nieuwe product " + myProduct.name + " is succesvol opgeslagen!"); txtProductName.Focus(); } } }
partial void Deletepricehistory(pricehistory instance);
partial void Updatepricehistory(pricehistory instance);
partial void Insertpricehistory(pricehistory instance);
private void detach_pricehistories(pricehistory entity) { this.SendPropertyChanging(); entity.product = null; }