private void DelStudBut_Click(object sender, EventArgs e) { var c = dataGridView1.SelectedCells; int indrow; if (c.Count == 0) { return; } indrow = c[0].RowIndex; var s = dataGridView1.Rows[indrow]; var dels = (int)s.Cells[0].Value; BD.SchoolEntities entities = new BD.SchoolEntities(); BD.Studs dt = entities.Studs.Find(dels); entities.Studs.Remove(dt); entities.SaveChanges(); MessageBox.Show("Stud delited!"); }
private void AddStudsBut_Click(object sender, EventArgs e) { BD.SchoolEntities entities = new BD.SchoolEntities(); BD.Studs studs = new BD.Studs(); studs.NameS = NameBox.Text; studs.SurNameS = SurNameBox.Text; var cl = comboBox1.SelectedItem as BD.Classes; studs.IdCl = cl.IdCl; entities.Studs.Add(studs); entities.SaveChanges(); MessageBox.Show("Stud add!"); }