/*private void button2_Click(object sender, EventArgs e) * { * int index = dataGridView1.SelectedRows[0].Index; * int id = 0; * bool converted = Int32.TryParse(dataGridView1[0, index].Value.ToString(), out id); * if (converted == false) * return; * DB.Schedule temp = db.Schedule.Find(id); * * ScheduleForm SF = new ScheduleForm(); * * SF.comboBox1.SelectedValue = temp.Day_Id; * SF.comboBox2.SelectedValue = temp.Lesson_Id; * SF.comboBox3.SelectedValue = temp.Auditory_Id; * SF.comboBox4.SelectedValue = temp.Group_Id; * SF.comboBox5.SelectedValue = temp.Subject_Id; * SF.comboBox6.SelectedValue = temp.LessonType_Id; * SF.comboBox7.SelectedValue = temp.Teacher_Id; * * DialogResult result = SF.ShowDialog(this); * * if (result == DialogResult.Cancel) * return; * * * DB.Schedule Sched = new DB.Schedule(); * Sched.Day_Id = (int)SF.comboBox1.SelectedValue; * Sched.Lesson_Id = (int)SF.comboBox2.SelectedValue; * Sched.Auditory_Id = (int)SF.comboBox3.SelectedValue; * Sched.Group_Id = (int)SF.comboBox4.SelectedValue; * Sched.Subject_Id = (int)SF.comboBox5.SelectedValue; * Sched.LessonType_Id = (int)SF.comboBox6.SelectedValue; * Sched.Teacher_Id = (int)SF.comboBox7.SelectedValue; * db.SaveChanges(); * DGV1fill(); * MessageBox.Show("Запись изменена"); * * }*/ private void button3_Click(object sender, EventArgs e) { if (dataGridView1.SelectedRows.Count > 0) { int index = dataGridView1.SelectedRows[0].Index; int id = 0; bool converted = Int32.TryParse(dataGridView1[0, index].Value.ToString(), out id); if (converted == false) { return; } Entity_DB.Progress Prog = db.Progress.Find(id); db.Progress.Remove(Prog); db.SaveChanges(); DGV1fill(); MessageBox.Show("Запись удалена"); } }
private void button1_Click(object sender, EventArgs e) { ProgressForm PF = new ProgressForm(this.FacultyId); DialogResult result = PF.ShowDialog(this); if (result == DialogResult.Cancel) { return; } Entity_DB.Progress Prog = new Entity_DB.Progress(); Prog.Subject_Id = (int)PF.comboBox2.SelectedValue; Prog.Student_Id = (int)PF.comboBox1.SelectedValue; Prog.Mark = PF.textBox1.SelectedText; db.Progress.Add(Prog); db.SaveChanges(); DGV1fill(); MessageBox.Show("Новая запись добавлена"); }