Esempio n. 1
0
        private void ButtonAdd_Click(object sender, EventArgs e)
        {
            Form2        form2  = new Form2();
            DialogResult result = form2.ShowDialog(this);

            if (result == DialogResult.Cancel)
            {
                return;
            }

            Product product = new Product();

            product.Name = form2.textBoxProduct.Text;

            warehouseDb.Products.Add(product);
            warehouseDb.SaveChanges();
            dataGridViewWarehouse.DataSource = warehouseDb.Products.ToList();
        }
Esempio n. 2
0
        private void ButtonYes_Click(object sender, EventArgs e)
        {
            var product = InitProduct();

            if (product == null)
            {
                return;
            }

            using (var context = new WarehouseContext())
            {
                context.Products.Add(product);
                context.SaveChanges();
            }

            MessageBox.Show("Product successfully added");

            Close();
        }