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();
                }
            }
        }
Beispiel #3
0
 partial void Deletepricehistory(pricehistory instance);
Beispiel #4
0
 partial void Updatepricehistory(pricehistory instance);
Beispiel #5
0
 partial void Insertpricehistory(pricehistory instance);
Beispiel #6
0
 private void detach_pricehistories(pricehistory entity)
 {
     this.SendPropertyChanging();
     entity.product = null;
 }