Ejemplo n.º 1
0
        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();
        }
Ejemplo n.º 2
0
 partial void DeleteProductMult(ProductMult instance);
Ejemplo n.º 3
0
 partial void InsertProductMult(ProductMult instance);
Ejemplo n.º 4
0
 partial void UpdateProductMult(ProductMult instance);
Ejemplo n.º 5
0
 private void detach_ProductMults(ProductMult entity)
 {
     this.SendPropertyChanging();
     entity.Material = null;
 }