コード例 #1
0
        private void CategoryAppendToolStripMenuItem2_Click(object sender, EventArgs e)
        {
            var formCategory = new CategoryProducAddForm();

            if (formCategory.ShowDialog() == DialogResult.OK)
            {
                db.CategoryProductsAll.Add(formCategory.CategoryProducts);
                db.SaveChanges();
            }
        }
コード例 #2
0
        // this is change items and properties.........................../////
        private void button2_Click(object sender, EventArgs e)
        {
            var id = dataGridView.SelectedRows[0].Cells[0].Value;

            if (typeof(T) == typeof(Product))
            {
                var product = set.Find(id) as Product;
                if (product != null)
                {
                    var form = new ProductAddForm(product);
                    if (form.ShowDialog() == DialogResult.OK)
                    {
                        product = form.Product;
                        db.SaveChanges();
                        //dataGridView.Update();
                        MessageBox.Show("This item has been modified.");
                    }
                }
            }
            else if (typeof(T) == typeof(CategoryProducts))
            {
                var category = set.Find(id) as CategoryProducts;
                if (category != null)
                {
                    var form = new CategoryProducAddForm(category);
                    if (form.ShowDialog() == DialogResult.OK)
                    {
                        category = form.CategoryProducts;
                        db.SaveChanges();
                        dataGridView.Update();
                        MessageBox.Show("This item has been modified.");
                    }
                }
            }
            else if (typeof(T) == typeof(Werehouse))
            {
                var werehouse = set.Find(id) as Werehouse;
                if (werehouse != null)
                {
                    var form = new WerehouseAddForm(werehouse);
                    if (form.ShowDialog() == DialogResult.OK)
                    {
                        werehouse = form.Werehouse;
                        db.SaveChanges();
                        dataGridView.Update();
                        MessageBox.Show("This item has been modified.");
                    }
                }
            }
        }
コード例 #3
0
 // here add new positions ..............................................////
 private void button1_Click(object sender, EventArgs e)
 {
     if (typeof(T) == typeof(Product))
     {
         var form = new ProductAddForm();
         if (form.ShowDialog() == DialogResult.OK)
         {
             db.Products.Add(form.Product);
             db.SaveChanges();
             MessageBox.Show("This item has been appended.");
         }
     }
     else if (typeof(T) == typeof(CategoryProducts))
     {
         var form = new CategoryProducAddForm();
         if (form.ShowDialog() == DialogResult.OK)
         {
             db.CategoryProductsAll.Add(form.CategoryProducts);
             db.SaveChanges();
             MessageBox.Show("This item has been appended.");
         }
     }
     else if (typeof(T) == typeof(CurrentRate))
     {
     }
     else if (typeof(T) == typeof(Werehouse))
     {
         var form = new WerehouseAddForm();
         if (form.ShowDialog() == DialogResult.OK)
         {
             db.Werehouses.Add(form.Werehouse);
             db.SaveChanges();
             MessageBox.Show("This item has been appended.");
         }
     }
 }