コード例 #1
0
        private void EntrySemiTrimesterComments_SelectedClassChangedEvent()
        {
            EntrySemiTrimesterCommentsViewModel entrySemiTrimesterComments = (EntrySemiTrimesterCommentsViewModel)DataContext;

            if (entrySemiTrimesterComments.SelectedClass != null && !entrySemiTrimesterComments.SelectedClass.SelectedStudentChangedSet)
            {
                entrySemiTrimesterComments.SelectedClass.SelectedStudentChangedEvent += SelectedClass_SelectedStudentChangedEvent;
                entrySemiTrimesterComments.SelectedClass.SelectedStudent              = entrySemiTrimesterComments.SelectedClass.Students.FirstOrDefault();
            }
            SelectedClass_SelectedStudentChangedEvent();
        }
コード例 #2
0
 private void SaveSemiTrimesterComments(EntrySemiTrimesterCommentsViewModel entrySemiTrimesterComments)
 {
     SemiTrimesterCommentModel.Save(new SemiTrimesterCommentModel()
     {
         DivisionPrefectComment = DivisionPrefectCommentTextBox.Text,
         MainTeacherComment     = MainTeacherCommentTextBox.Text,
         IdSemiTrimester        = entrySemiTrimesterComments.SelectedSemiTrimester.Id,
         IdStudent = entrySemiTrimesterComments.SelectedClass.SelectedStudent.Student.Id,
         Year      = entrySemiTrimesterComments.SelectedSemiTrimester.Year,
     });
 }
コード例 #3
0
        public EntrySemiTrimesterComments()
        {
            EntrySemiTrimesterCommentsViewModel entrySemiTrimesterComments = new EntrySemiTrimesterCommentsViewModel();

            DataContext = entrySemiTrimesterComments;
            InitializeComponent();

            entrySemiTrimesterComments.SelectedClassChangedEvent += EntrySemiTrimesterComments_SelectedClassChangedEvent;
            EntrySemiTrimesterComments_SelectedClassChangedEvent();
            SelectedClass_SelectedStudentChangedEvent();

            ListView_SelectionChanged(null, null);
        }
コード例 #4
0
        private void SelectedClass_SelectedStudentChangedEvent()
        {
            EntrySemiTrimesterCommentsViewModel entrySemiTrimesterComments = (EntrySemiTrimesterCommentsViewModel)DataContext;

            SemiTrimesterCommentModel semiTrimesterComment = SemiTrimesterCommentModel.Read(entrySemiTrimesterComments.SelectedSemiTrimester, entrySemiTrimesterComments.SelectedClass.SelectedStudent.Student);

            if (semiTrimesterComment != null)
            {
                MainTeacherCommentTextBox.Text     = semiTrimesterComment.MainTeacherComment;
                DivisionPrefectCommentTextBox.Text = semiTrimesterComment.DivisionPrefectComment;
            }
            else
            {
                MainTeacherCommentTextBox.Text     = "";
                DivisionPrefectCommentTextBox.Text = "";
            }
        }
コード例 #5
0
        private void SemiTrimesterComment_KeyDown(object sender, KeyEventArgs e)
        {
            EntrySemiTrimesterCommentsViewModel entrySemiTrimesterComments = (EntrySemiTrimesterCommentsViewModel)DataContext;

            switch (e.Key)
            {
            case Key.Down:
            {
                TextBox textBox = (TextBox)sender;
                if (textBox == MainTeacherCommentTextBox)
                {
                    DivisionPrefectCommentTextBox.Focus();
                }
                else if (textBox == DivisionPrefectCommentTextBox)
                {
                    SaveSemiTrimesterComments(entrySemiTrimesterComments);
                    if (entrySemiTrimesterComments.SelectedClass.SelectedStudent != entrySemiTrimesterComments.SelectedClass.Students.Last())
                    {
                        entrySemiTrimesterComments.SelectedClass.SelectedStudent
                            = entrySemiTrimesterComments.SelectedClass.Students[entrySemiTrimesterComments.SelectedClass.Students.IndexOf(entrySemiTrimesterComments.SelectedClass.SelectedStudent) + 1];
                    }
                    else
                    {
                        if (entrySemiTrimesterComments.SelectedClass != entrySemiTrimesterComments.Classes.Last())
                        {
                            entrySemiTrimesterComments.SelectedClass = entrySemiTrimesterComments.Classes[entrySemiTrimesterComments.Classes.IndexOf(entrySemiTrimesterComments.SelectedClass) + 1];
                        }
                        else
                        {
                            MessageBox.Show("Fin de la saisie.", "Fin", MessageBoxButton.OK, MessageBoxImage.Information);
                        }
                    }
                }
                e.Handled = true;
            }
            break;

            case Key.Up:
            {
                TextBox textBox = (TextBox)sender;
                if (textBox == DivisionPrefectCommentTextBox)
                {
                    MainTeacherCommentTextBox.Focus();
                }
                else if (textBox == MainTeacherCommentTextBox)
                {
                    SaveSemiTrimesterComments(entrySemiTrimesterComments);
                    if (entrySemiTrimesterComments.SelectedClass.SelectedStudent != entrySemiTrimesterComments.SelectedClass.Students.First())
                    {
                        entrySemiTrimesterComments.SelectedClass.SelectedStudent
                            = entrySemiTrimesterComments.SelectedClass.Students[entrySemiTrimesterComments.SelectedClass.Students.IndexOf(entrySemiTrimesterComments.SelectedClass.SelectedStudent) - 1];
                    }
                    else
                    {
                        if (entrySemiTrimesterComments.SelectedClass != entrySemiTrimesterComments.Classes.First())
                        {
                            entrySemiTrimesterComments.SelectedClass = entrySemiTrimesterComments.Classes[entrySemiTrimesterComments.Classes.IndexOf(entrySemiTrimesterComments.SelectedClass) - 1];
                            entrySemiTrimesterComments.SelectedClass.SelectedStudent = entrySemiTrimesterComments.SelectedClass.Students.FirstOrDefault();
                        }
                    }
                }
                e.Handled = true;
            }
            break;
            }
        }