Beispiel #1
0
        private void employeeAddToolStripMenuItem3_Click(object sender, EventArgs e)
        {
            var form = new EmployeeForm();

            if (form.ShowDialog() == DialogResult.OK)
            {
                db.Employees.Add(form.Employee);
                db.SaveChanges();
            }
        }
Beispiel #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            var id = dataGridView1.SelectedRows[0].Cells[0].Value;

            if (typeof(T) == typeof(Product))
            {
                if (set.Find(id) is Product product)
                {
                    var form = new ProductForm(product);
                    if (form.ShowDialog() == DialogResult.OK)
                    {
                        product = form.Product;
                    }
                }
                if (typeof(T) == typeof(Employee))
                {
                    if (set.Find(id) is Employee employee)
                    {
                        var form = new EmployeeForm(employee);
                        if (form.ShowDialog() == DialogResult.OK)
                        {
                            employee = form.Employee;
                        }
                    }
                }
                if (typeof(T) == typeof(Customer))
                {
                    if (set.Find(id) is Customer customer)
                    {
                        var form = new CustomerForm(customer);
                        if (form.ShowDialog() == DialogResult.OK)
                        {
                            customer = form.Customer;
                        }
                    }
                }
            }
            db.SaveChanges();
            dataGridView1.Update();
        }