private void btnAdd_Click(object sender, RoutedEventArgs e) { if (tbProdName.Text.Length <= 0) { MessageBox.Show("Enter name first!"); return; } var res = from p in DbContext.Products where p.Name == tbProdName.Text select p.Name; if (res.Any()) { return; } var mc = new MatSelect(); if (mc.ShowDialog() == false) { return; } var sel_name = mc.lbMaterSelect.SelectedValue.ToString(); double mat_qty; if (!double.TryParse(mc.tbQty.Text, out mat_qty)) { return; } mc.Close(); var mat = (from m in DbContext.Materials where m.Name == sel_name select m.Id).First(); var productMult = new ProductMult { Id = Guid.NewGuid(), Mater_Id = mat, Mater_Qty = mat_qty }; DbContext.ProductMults.InsertOnSubmit(productMult); DbContext.SubmitChanges(); UpdDataGrid(); }
partial void DeleteProductMult(ProductMult instance);
partial void InsertProductMult(ProductMult instance);
partial void UpdateProductMult(ProductMult instance);
private void detach_ProductMults(ProductMult entity) { this.SendPropertyChanging(); entity.Material = null; }