private void btnSaveOrder_Click(object sender, RoutedEventArgs e) { if (cbCustomer.SelectedItem != null) { //Combobox ui customer myCustomer = (customer)cbCustomer.SelectedItem; producttype myProductType = (producttype)cbProductType.SelectedItem; product myProduct = (product)cbProduct.SelectedItem; //Textbox uitlezen en opslaan in variable string sHoeveelheid = txtHoeveelheid.Text; int iHoeveelheid = Convert.ToInt32(sHoeveelheid); //Nieuw product aanmaken order myOrder = new order(); itemsinorder myItemsInOrder = new itemsinorder(); //Velden met variabele vullen myOrder.date = DateTime.Now; customer selCustomer = (customer)cbCustomer.SelectedItem; myOrder.customerId = selCustomer.id; db.orders.InsertOnSubmit(myOrder); db.SubmitChanges(); myItemsInOrder.amount = iHoeveelheid; myItemsInOrder.orderId = myOrder.id; myItemsInOrder.productId = myProduct.id; //Ready changes & changes uitvoeren db.itemsinorders.InsertOnSubmit(myItemsInOrder); db.SubmitChanges(); //Refresh database SetData(); //Confirmation MessageBox.Show("Opgeslagen"); } else { MessageBox.Show("Selecteer eerst een type"); } }
private void detach_itemsinorders(itemsinorder entity) { this.SendPropertyChanging(); entity.product = null; }
partial void Deleteitemsinorder(itemsinorder instance);
partial void Updateitemsinorder(itemsinorder instance);
partial void Insertitemsinorder(itemsinorder instance);
private void attach_itemsinorders(itemsinorder entity) { this.SendPropertyChanging(); entity.order = this; }