private async void btn_DeleteGrade_Grades_Click(object sender, RoutedEventArgs e) { if (await delete_grades() == ContentDialogResult.Secondary) { LessonTimeManager.DeleteLessonTime((lvw_LessonTimes.SelectedItem as LessonTime)); Frame.Navigate(this.GetType()); Frame.GoBack(); } }
protected override void OnNavigatedTo(NavigationEventArgs e) { if (e.Parameter is Lesson) { edit_lesson = (Lesson)e.Parameter; cmb_Day_AddLesson.SelectedIndex = (int)edit_lesson.day - 1; cmb_LessonTime_AddLesson.SelectedItem = LessonTimeManager.GetLessonTimes().Find(x => x.lesson_number == edit_lesson.lesson_time.lesson_number); cmb_Subject_AddLesson.SelectedItem = edit_lesson.subject; } else if (e.Parameter is int) { selected_day = (int)e.Parameter; cmb_Day_AddLesson.SelectedIndex = selected_day; } }
private void btn_Done_AddLesson_Click(object sender, RoutedEventArgs e) { try { int.Parse(tbx_LessonNumber_AddGrade_Timetable_Settings.Text); } catch (Exception) { LessonNumberInValid(); return; } TimeSpan starttime = tmp_Starttime_AddLesson_Timetable_Settings.Time; TimeSpan endtime = tmp_Endtime_AddLesson_Timetable_Settings.Time; if (edit && edit_lessontime != null) { LessonTimeManager.DeleteLessonTime(edit_lessontime); } bool exeption_comes = false; Time startTime = new Time(); startTime.setTime(starttime.Hours, starttime.Minutes); Time endTime = new Time(); endTime.setTime(endtime.Hours, endtime.Minutes); LessonTime new_lesson_time = new LessonTime(); new_lesson_time.setLessonTime(int.Parse(tbx_LessonNumber_AddGrade_Timetable_Settings.Text), startTime, endTime, tgs_DoubleLesson_AddLessonTime.IsOn); try { new_lesson_time.Save(); } catch (ArgumentException ae) { exeption_comes = true; if (ae.Message == "lessontime already exists") { LessonTimeManager.lesson_already_exists_dialog(); } } if (exeption_comes == false) { Frame.GoBack(); } }
private async void btn_Done_AddLesson_Click(object sender, RoutedEventArgs e) { bool cont = true; int daynumber = cmb_Day_AddLesson.SelectedIndex; DayOfWeek day = DayOfWeek.Monday; bool day_complete = true; LessonTime lessontime = LessonTimeManager.GetLessonTimes()[0]; bool lessontime_complete = true; Subject subject = SubjectManager.GetSubjects()[0]; bool subject_complete = true; if (daynumber == 0) { day = DayOfWeek.Monday; } else if (daynumber == 1) { day = DayOfWeek.Tuesday; } else if (daynumber == 2) { day = DayOfWeek.Wednesday; } else if (daynumber == 3) { day = DayOfWeek.Thursday; } else if (daynumber == 4) { day = DayOfWeek.Friday; } else { day_complete = false; } if (cmb_LessonTime_AddLesson.SelectedIndex != -1) { lessontime = (LessonTime)cmb_LessonTime_AddLesson.SelectedItem; } else { lessontime_complete = false; } if (cmb_Subject_AddLesson.SelectedIndex != -1) { subject = (Subject)cmb_Subject_AddLesson.SelectedItem; } else { subject_complete = false; } if (day_complete == false || lessontime_complete == false || subject_complete == false) { LessonManager.not_completed_dialog(); } else { if (LessonManager.GetLesson(day, lessontime) != null) { ContentDialogResult result = await LessonManager.already_exists_dialog(); if (result == ContentDialogResult.Secondary) { edit_lesson = LessonManager.GetLesson(day, lessontime); } else { cont = false; } } if (cont) { if (edit_lesson != null) { LessonManager.DeleteLesson(edit_lesson.day, edit_lesson.lesson_time); } LessonManager.AddLesson(new Lesson { day = day, lesson_time = lessontime, subject_id = subject.id }); } } if (cont) { Frame.GoBack(); } }