private void add_Click(object sender, EventArgs e) { if (typeof(T) == typeof(Product)) { var form = new ProductForm(); if (form.ShowDialog() == DialogResult.OK) { db.Products.Add(form.Product); db.SaveChanges(); } } else if (typeof(T) == typeof(Seller)) { var form = new SellerForm(); if (form.ShowDialog() == DialogResult.OK) { db.Sellers.Add(form.Seller); db.SaveChanges(); } } else if (typeof(T) == typeof(Customer)) { var form = new CustomerForm(); if (form.ShowDialog() == DialogResult.OK) { db.Customers.Add(form.Customer); db.SaveChanges(); } } }
private void sellerAddToolStripMenuItem1_Click(object sender, EventArgs e) { var form = new SellerForm(); if (form.ShowDialog() == DialogResult.OK) { db.Sellers.Add(form.Seller); db.SaveChanges(); } }
private void change_Click(object sender, EventArgs e) { var id = dataGridView1.SelectedRows[0].Cells[0].Value; if (typeof(T) == typeof(Product)) { var product = set.Find(id) as Product; if (product != null) { var form = new ProductForm(product); if (form.ShowDialog() == DialogResult.OK) { product = form.Product; db.SaveChanges(); dataGridView1.Update(); } } } else if (typeof(T) == typeof(Seller)) { var seller = set.Find(id) as Seller; if (seller != null) { var form = new SellerForm(seller); if (form.ShowDialog() == DialogResult.OK) { seller = form.Seller; db.SaveChanges(); dataGridView1.Update(); } } } else if (typeof(T) == typeof(Customer)) { var customer = set.Find(id) as Customer; if (customer != null) { var form = new CustomerForm(customer); if (form.ShowDialog() == DialogResult.OK) { customer = form.Customer; db.SaveChanges(); dataGridView1.Update(); } } } }