private void button1_Click(object sender, EventArgs e) { RequestForm r3 = new RequestForm(); r3.ShowDialog(); if (r3.DialogResult == DialogResult.OK) { r3.Request.Userid = userId; serviceDb.Request.Add(r3.Request); serviceDb.SaveChanges(); UpdateData(); } }
private void button1_Click(object sender, EventArgs e) { if (dataGridView1.SelectedCells.Count == 0) { MessageBox.Show("Не выбраны строки"); return; } DataGridViewCell cell = dataGridView1.SelectedCells[0]; var request = serviceDb.Request .Find(int.Parse(cell.OwningRow.Cells[0].Value.ToString())); serviceDb.Request.Remove(request); serviceDb.SaveChanges(); UpdateData(); }