private void onExpertAddClicked(object sender, RoutedEventArgs e) { //Use this for input errors bool hasInputError = false; //Check first name if (textBoxExternVoornaam.Text.Equals(String.Empty)) { textBoxExternVoornaam.BorderBrush = Brushes.Red; hasInputError = true; } else { textBoxExternVoornaam.BorderBrush = Brushes.Gray; } //Check surname if (textBoxExternAchternaam.Text.Equals(String.Empty)) { textBoxExternAchternaam.BorderBrush = Brushes.Red; hasInputError = true; } else { textBoxExternAchternaam.BorderBrush = Brushes.Gray; } //Check email adress if (textBoxExternEmail.Text.Equals(String.Empty)) { textBoxExternEmail.BorderBrush = Brushes.Red; hasInputError = true; } else { textBoxExternEmail.BorderBrush = Brushes.Gray; } if (!textBoxExternEmail.Text.IsValidEmailAddress()) { textBoxExternEmail.BorderBrush = Brushes.Red; hasInputError = true; } else { textBoxExternEmail.BorderBrush = Brushes.Gray; } //Check company if (textBoxExternBedrijf.Text.Equals(String.Empty)) { textBoxExternBedrijf.BorderBrush = Brushes.Red; hasInputError = true; } else { textBoxExternBedrijf.BorderBrush = Brushes.Gray; } //Check Adres if (textBoxExternAdres.Text.Equals(String.Empty)) { textBoxExternAdres.BorderBrush = Brushes.Red; hasInputError = true; } else { textBoxExternAdres.BorderBrush = Brushes.Gray; } //Check Postcode if (textBoxExternPostcode.Text.Equals(String.Empty)) { textBoxExternPostcode.BorderBrush = Brushes.Red; hasInputError = true; } else { textBoxExternPostcode.BorderBrush = Brushes.Gray; } //Check telephone if (textBoxExternTelefoonnummer.Text.Equals(String.Empty)) { textBoxExternTelefoonnummer.BorderBrush = Brushes.Red; hasInputError = true; } else { textBoxExternTelefoonnummer.BorderBrush = Brushes.Gray; } //Check city if (textBoxExpertCity.Text.Equals(String.Empty)) { textBoxExpertCity.BorderBrush = Brushes.Red; hasInputError = true; } else { textBoxExpertCity.BorderBrush = Brushes.Gray; } if (hasInputError == false) { //Create expert object and add values Expert newExpert = new Expert(); newExpert.Firstname = textBoxExternVoornaam.Text; newExpert.Surname = textBoxExternAchternaam.Text; newExpert.Email = textBoxExternEmail.Text; newExpert.Company = textBoxExternBedrijf.Text; newExpert.Address = textBoxExternAdres.Text; newExpert.Postcode = textBoxExternPostcode.Text; newExpert.Telephone = textBoxExternTelefoonnummer.Text; newExpert.City = textBoxExpertCity.Text; if (blockedDayTimesExpert.SelectedItems != null) { foreach (ListBoxItem selectedBlockdays in blockedDayTimesExpert.SelectedItems) { Blocked_timeslot thisTimeslot = new Blocked_timeslot(); thisTimeslot.Daytime_id = (int)selectedBlockdays.Tag; thisTimeslot.Hardblock = true; newExpert.BlockedTimeslots.Add(thisTimeslot); } } if (softblockedDayTimesExpert.SelectedItems != null) { foreach (ListBoxItem selectedBlockdays in softblockedDayTimesExpert.SelectedItems) { Blocked_timeslot thisTimeslot = new Blocked_timeslot(); thisTimeslot.Daytime_id = (int)selectedBlockdays.Tag; thisTimeslot.Hardblock = true; newExpert.BlockedTimeslots.Add(thisTimeslot); } } //Send to the database _controller.ExpertMapper.Save(newExpert); MessageBox.Show("Expert toegevoegd"); textBoxExternVoornaam.Text = ""; textBoxExternAchternaam.Text = ""; textBoxExternEmail.Text = ""; textBoxExternBedrijf.Text = ""; textBoxExternAdres.Text = ""; textBoxExternPostcode.Text = ""; textBoxExternTelefoonnummer.Text = ""; textBoxExpertCity.Text = ""; } }
private void onStudentEditClicked(object sender, RoutedEventArgs e) { //Use this for input errors bool hasInputError = false; //Check study if (textBoxStudywijzig.Text.Equals(String.Empty)) { textBoxStudywijzig.BorderBrush = Brushes.Red; hasInputError = true; } else { textBoxStudywijzig.BorderBrush = Brushes.Gray; } //Check email adress if (EmailLeering1wijzig.Text.Equals(String.Empty)) { EmailLeering1wijzig.BorderBrush = Brushes.Red; hasInputError = true; } else { EmailLeering1wijzig.BorderBrush = Brushes.Gray; } if (!EmailLeering1wijzig.Text.IsValidEmailAddress()) { EmailLeering1wijzig.BorderBrush = Brushes.Red; hasInputError = true; } else { EmailLeering1wijzig.BorderBrush = Brushes.Gray; } //Check student number if (textBoxStudentennummerwijzig.Text.Equals(String.Empty)) { textBoxStudentennummerwijzig.BorderBrush = Brushes.Red; hasInputError = true; } else { textBoxStudentennummerwijzig.BorderBrush = Brushes.Gray; } //Check first name if (textBoxVoornaamwijzig.Text.Equals(String.Empty)) { textBoxVoornaamwijzig.BorderBrush = Brushes.Red; hasInputError = true; } else { textBoxVoornaamwijzig.BorderBrush = Brushes.Gray; } //Check surname if (textBoxAchternaamwijzig.Text.Equals(String.Empty)) { textBoxAchternaamwijzig.BorderBrush = Brushes.Red; hasInputError = true; } else { textBoxAchternaamwijzig.BorderBrush = Brushes.Gray; } //Check Blocked timeslots if (blockedDayTimesWijzig.SelectedItem == null) { blockedDayTimesWijzig.BorderBrush = Brushes.Red; hasInputError = true; } else { blockedDayTimesWijzig.BorderBrush = Brushes.Gray; } if (hasInputError == false) { //Create expert object and add values foreach(Student student in _students) { if(student.Studentnumber == Convert.ToInt32(textBoxStudentennummerwijzig.Text)) { student.Firstname = textBoxVoornaamwijzig.Text; student.Surname = textBoxAchternaamwijzig.Text; student.Email = EmailLeering1wijzig.Text; student.Studentnumber = Convert.ToInt32(textBoxStudentennummerwijzig.Text); student.Study = textBoxStudywijzig.Text; student.WasChanged = false; Blocked_timeslot timeslot = new Blocked_timeslot(); //Blocked Timeslot ListBoxItem selectedItem = (ListBoxItem)blockedDayTimesWijzig.SelectedItem; string date = selectedItem.Content.ToString(); List<Daytime> foundDayTimes = _controller.DaytimeMapper.FindWithDate(date); student.BlockedTimeslots.Clear(); foreach (Daytime thisTimeslot in foundDayTimes) { student.BlockedTimeslots.Add(new Blocked_timeslot(thisTimeslot, true)); } //Send to the database _controller.StudentMapper.Save(student); MessageBox.Show("Student gewijzigd"); break; } } } }
private void onTeacherAddClicked(object sender, RoutedEventArgs e) { //Use this for input errors bool hasInputError = false; //Check first name if (textBoxLeraarVoornaam.Text.Equals(String.Empty)) { textBoxLeraarVoornaam.BorderBrush = Brushes.Red; hasInputError = true; } else { textBoxLeraarVoornaam.BorderBrush = Brushes.Gray; } //Check surname if (textLeraarAchternaam.Text.Equals(String.Empty)) { textLeraarAchternaam.BorderBrush = Brushes.Red; hasInputError = true; } else { textLeraarAchternaam.BorderBrush = Brushes.Gray; } //Check email adress if (EmailLeraar1.Text.Equals(String.Empty)) { EmailLeraar1.BorderBrush = Brushes.Red; hasInputError = true; } else { EmailLeraar1.BorderBrush = Brushes.Gray; } if (!EmailLeraar1.Text.IsValidEmailAddress()) { EmailLeraar1.BorderBrush = Brushes.Red; hasInputError = true; } else { EmailLeraar1.BorderBrush = Brushes.Gray; } //Create sessionspread variable Teacher.session_spread sessionSpread; //See which session spread option was chosen if(sessionVerspreid.IsChecked == true) { sessionSpread = Teacher.session_spread.FAR; } else if (sessionDichtBijElkaar.IsChecked == true) { sessionSpread = Teacher.session_spread.CLOSE; } else { sessionSpread = Teacher.session_spread.ANY; } if (hasInputError == false) { //Create teacher object and add values Teacher newTeacher = new Teacher(); newTeacher.Firstname = textBoxLeraarVoornaam.Text; newTeacher.Surname = textLeraarAchternaam.Text; newTeacher.Email = EmailLeraar1.Text; newTeacher.Session_spread = sessionSpread; newTeacher.WasChanged = false; if (blockedDayTimesTeacher.SelectedItems != null) { foreach (ListBoxItem selectedBlockdays in blockedDayTimesTeacher.SelectedItems) { Blocked_timeslot thisTimeslot = new Blocked_timeslot(); thisTimeslot.Daytime_id = (int)selectedBlockdays.Tag; thisTimeslot.Hardblock = true; newTeacher.BlockedTimeslots.Add(thisTimeslot); } } if (softblockedDayTimesDocent.SelectedItems != null) { foreach (ListBoxItem selectedBlockdays in softblockedDayTimesDocent.SelectedItems) { Blocked_timeslot thisTimeslot = new Blocked_timeslot(); thisTimeslot.Daytime_id = (int)selectedBlockdays.Tag; thisTimeslot.Hardblock = true; newTeacher.BlockedTimeslots.Add(thisTimeslot); } } //Send to the database _controller.TeacherMapper.Save(newTeacher); MessageBox.Show("Leraar toegevoegd"); textBoxLeraarVoornaam.Text = ""; textLeraarAchternaam.Text = ""; EmailLeraar1.Text = ""; sessionVerspreid.IsChecked = false; sessionDichtBijElkaar.IsChecked = false; } }
private void onStudentAddClicked(object sender, RoutedEventArgs e) { //Use this for input errors bool hasInputError = false; //Check study if (textBoxStudy.Text.Equals(String.Empty)) { textBoxStudy.BorderBrush = Brushes.Red; hasInputError = true; } else { textBoxStudy.BorderBrush = Brushes.Gray; } //Check email adress if (EmailLeering1.Text.Equals(String.Empty)) { EmailLeering1.BorderBrush = Brushes.Red; hasInputError = true; } else { EmailLeering1.BorderBrush = Brushes.Gray; } if (!EmailLeering1.Text.IsValidEmailAddress()) { EmailLeering1.BorderBrush = Brushes.Red; hasInputError = true; } else { EmailLeering1.BorderBrush = Brushes.Gray; } //Check student number if (textBoxStudentennummer.Text.Equals(String.Empty)) { textBoxStudentennummer.BorderBrush = Brushes.Red; hasInputError = true; } else { textBoxStudentennummer.BorderBrush = Brushes.Gray; } //Check first name if (textBoxVoornaam.Text.Equals(String.Empty)) { textBoxVoornaam.BorderBrush = Brushes.Red; hasInputError = true; } else { textBoxVoornaam.BorderBrush = Brushes.Gray; } //Check surname if (textBoxAchternaam.Text.Equals(String.Empty)) { textBoxAchternaam.BorderBrush = Brushes.Red; hasInputError = true; } else { textBoxAchternaam.BorderBrush = Brushes.Gray; } //Check Blocked timeslots if (blockedDayTimes.SelectedItem == null) { blockedDayTimes.BorderBrush = Brushes.Red; hasInputError = true; } else { blockedDayTimes.BorderBrush = Brushes.Gray; } if (_controller.StudentMapper.FindWithDuplicateCheck(int.Parse(textBoxStudentennummer.Text), EmailLeering1.Text)) { textBoxStudentennummer.BorderBrush = Brushes.Red; EmailLeering1.BorderBrush = Brushes.Red; hasInputError = true; MessageBox.Show("Studentnummer of emailadres bestaat al."); } if (hasInputError == false) { //Create expert object and add values Student newStudent = new Student(); newStudent.Firstname = textBoxVoornaam.Text; newStudent.Surname = textBoxAchternaam.Text; newStudent.Email = EmailLeering1.Text; newStudent.Studentnumber = Convert.ToInt32(textBoxStudentennummer.Text); newStudent.Study = textBoxStudy.Text; newStudent.WasChanged = false; Blocked_timeslot timeslot = new Blocked_timeslot(); //Blocked Timeslot ListBoxItem selectedItem = (ListBoxItem)blockedDayTimes.SelectedItem; string date = selectedItem.Content.ToString(); List<Daytime> foundDayTimes = _controller.DaytimeMapper.FindWithDate(date); foreach (Daytime thisTimeslot in foundDayTimes) { newStudent.BlockedTimeslots.Add(new Blocked_timeslot(thisTimeslot, true)); } //Send to the database _controller.StudentMapper.Save(newStudent); MessageBox.Show("Student toegevoegd"); textBoxVoornaam.Text = ""; textBoxAchternaam.Text = ""; EmailLeering1.Text = ""; textBoxStudentennummer.Text = ""; } }