Ejemplo n.º 1
0
        private void menu_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            var row = dataGridView1.Rows[_selectedRow];

            switch (e.ClickedItem.Name.ToString())
            {
            case "Edytuj":
                Wentylator w = new Wentylator()
                {
                    Name  = row.Cells["Nazwa"].Value.ToString(),
                    Power = double.Parse(row.Cells["Moc"].Value.ToString()),
                    //Pressure = double.Parse(row.Cells["Ciśnienie"].Value.ToString()),
                    Revolution = double.Parse(row.Cells["Obroty"].Value.ToString()),
                    Nature     = row.Cells["Typ"].Value as Nature
                };
                FrmAddFan frm = new FrmAddFan(w);
                frm.ShowDialog();
                break;

            case "Usuń":
                using (var context = new DBContext())
                {
                    string name     = row.Cells["Nazwa"].Value.ToString();
                    var    toDelete = context.Wentylatory.Include(b => b.Coefficients).First(
                        we => we.Name.Equals(name));

                    context.Coefficients.RemoveRange(toDelete.Coefficients);
                    context.Wentylatory.Remove(toDelete);
                    context.SaveChanges();
                }
                dataGridView1.Rows.RemoveAt(_selectedRow);
                _selectedRow = -1;
                break;

            default:
                break;
            }
        }
Ejemplo n.º 2
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            FrmAddFan frm = new FrmAddFan();

            frm.ShowDialog();
        }