private void finish_Click(object sender, EventArgs e) { Online_Exame ex = new Online_Exame(); IfStdExameExestBefor(); foreach (var item in StudentAnswers) { //var msg = ex.NewStudentExam(studentID, item.Key, examID, 0, item.Value); Student_Exam se = new Student_Exam() { St_id = studentID, Ex_id = examID, Q_id = item.Key, Result = 0, St_answer = item.Value }; ex.Student_Exam.Add(se); ex.SaveChanges(); } ex.ExamCorrection(studentID, examID); var res = ex.ExamRes(studentID, examID).First(); MessageBox.Show($"your grade {res}"); StudentDashbord std = new StudentDashbord(studentID); this.Close(); std.Show(); }