private void DelLessonBut_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.Lessons dt = entities.Lessons.Find(dels); entities.Lessons.Remove(dt); entities.SaveChanges(); MessageBox.Show("Lesson delited!"); }
private void AddTeachearsBut_Click(object sender, EventArgs e) { BD.SchoolEntities entities = new BD.SchoolEntities(); BD.Teachers teachers = new BD.Teachers(); teachers.NameT = NameBox.Text; teachers.SurNameT = SurNameBox.Text; entities.Teachers.Add(teachers); entities.SaveChanges(); MessageBox.Show("Add Teacher!"); }
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!"); }