public formLogIncident(Student student, formMain main, int TicketID) { try { InitializeComponent(); this.TID = TicketID; this.student = student; this.studentID = student.student_ID; this.main = main; lbSelectedStudentFilled.Text = student.givenName + " " + student.surname; fillCbTeacher(); fillCbComment(); } catch (Exception e) { MessageBox.Show("Kein Schüler ausgewählt"); } }
/// <summary> /// Gets a student object by givenName and surname of the student. /// </summary> /// <param name="givenName">The given name of the student.</param> /// <param name="surname">The surname of the student.</param> /// <returns>Returns a student object or null</returns> public static Student getStudent(string givenName, string surname) { try { openconnection(); cmd = new OleDbCommand("SELECT * FROM Student WHERE GivenName LIKE '" + givenName + "' AND Surname LIKE '" + surname + "'", connection); dr = cmd.ExecuteReader(); dr.Read(); int student_ID = Convert.ToInt32(dr[0].ToString()); int class_ID = Convert.ToInt32(dr[1].ToString()); Student s = new Student(student_ID, surname, givenName, class_ID); closeconnection(); return s; } catch { return null; } }
/// <summary> /// This method checks how much incidents a student has. If he has 3 or 5 a message will pop up. /// </summary> /// <param name="s">A student's object</param> private void checkStudentIncidentCount(Student s) { int studentIncidentCount = UtilityDB.getStudentIncidents(studentID).Count; if (studentIncidentCount == 3) { MessageBox.Show(s.getGivenName() + " " + s.getSurname() + " ist bereits zum 3. Mal im Trainingsraum. Ein Elterngespräch ist notwendig.", "", MessageBoxButtons.OK, MessageBoxIcon.Warning); } if (studentIncidentCount == 5) { MessageBox.Show(s.getGivenName() + " " + s.getSurname() + " ist bereits zum 5. Mal im Trainingsraum. Eine Klassenkonferenz ist notwendig.", "", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }