private void lnkEdit_Click(object sender, EventArgs e) { var Brick = (Brick)brickBindingSource.Current; var Brick_edit = new Brick { Mark = Brick.Mark, Lenght = Brick.Lenght, Height = Brick.Height, Width = Brick.Width, Parameters = Brick.Parameters }; using (var frm = new BricksTypesAddEditFrom(Brick_edit)) { frm.Theme = this.Theme; frm.Style = this.Style; if (frm.ShowDialog() == DialogResult.OK) { Brick.Mark = Brick_edit.Mark; Brick.Lenght = Brick_edit.Lenght; Brick.Height = Brick_edit.Height; Brick.Width = Brick_edit.Width; Brick.Parameters = Brick_edit.Parameters; db.SaveChanges(); brickBindingSource.DataSource = db.Bricks.OrderByDescending(d => d.Id).ToList(); gridBricks.Refresh(); } } }
private void lnkAdd_Click(object sender, EventArgs e) { var Brick = new Brick(); using (var frm = new BricksTypesAddEditFrom(Brick)) { frm.Theme = this.Theme; frm.Style = this.Style; if (frm.ShowDialog() == DialogResult.OK) { db.Bricks.Add(Brick); db.SaveChanges(); brickBindingSource.DataSource = db.Bricks.OrderByDescending(d => d.Id).ToList(); gridBricks.Refresh(); } } }