Beispiel #1
0
 /// <summary>
 /// Grabs the information that was inputted and adds it to the database.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ButtonAddGrade_Click(object sender, EventArgs e)
 {
     try
     {
         context.Grades.Add(new Grade {
             Id     = context.Grades.Max(s => s.Id) + 1, StudentId = Int32.Parse(listBoxStudent.SelectedItem.ToString()), Assignment = textBoxAssignment.Text, CourseId = CourseID,
             Grade1 = Double.Parse(textBoxGrade.Text)
         });
         context.SaveChanges();
         MessageBox.Show("Grade added.");
         ProfessorModifyGradesForm content = new ProfessorModifyGradesForm(CourseID);
         content.Show();
         this.Close();
     }
     catch
     {
         MessageBox.Show("An error has occured while adding the grade. Please make sure all the entries are correct.");
     }
 }
 /// <summary>
 /// Grabs the course ID from the selected row and opens up the modify grades form of the class chosen
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ButtonGrades_Click(object sender, EventArgs e)
 {
     CourseID = 0;
     try
     {
         try
         {
             foreach (DataGridViewRow row in dataGridViewProfessorCourses.SelectedRows)
             {
                 CourseID = Int32.Parse(row.Cells[0].Value.ToString());
             }
         }
         catch
         {
         }
         var contextCourse = context.Courses.Find(CourseID);
         ProfessorModifyGradesForm contentForm = new ProfessorModifyGradesForm(CourseID);
         contentForm.Show();
     }
     catch
     {
         MessageBox.Show("Please select a valid class.");
     }
 }