public JournalViewWindow(int teacherID)
 {
     InitializeComponent();
     this.TeacherID       = teacherID;
     this.teacherGrades   = AttendanceJournalDAL.GetTeacherGrades(this.TeacherID);
     this.teacherSubjects = AttendanceJournalDAL.GetTeacherSubjects(this.TeacherID);
     if (this.teacherSubjects == null)
     {
         MessageBox.Show("Error occured! Teacher tells no subjects!");
         this.Close();
     }
 }
 private void comboBoxGrade_SelectedIndexChanged(object sender, EventArgs e)
 {
     studyYears = AttendanceJournalDAL.GetStudyYears(this.TeacherID,
                                                     (int)this.teacherGrades[comboBoxGrade.SelectedIndex].GradeNo,
                                                     7);
     if (studyYears.Count == 0)
     {
         studyYears.Add(GetCurrentStudyYear());
     }
     UpdateComboStudyYear();
     UpdateGridJournalData();
 }
        private void UpdateGridJournalData()
        {
            int      yearStart      = int.Parse(comboStudyYear.SelectedItem.ToString().Split('-')[0]);
            int      yearEnd        = int.Parse(comboStudyYear.SelectedItem.ToString().Split('-')[1]);
            DateTime studyYearStart = new DateTime(yearStart, 9, 1); //1st Septemper
            DateTime studyYearEnd   = new DateTime(yearEnd, 7, 31);  //31st of June

            gridJournal.DataSource = AttendanceJournalDAL.BuildDataTable(TeacherID,
                                                                         (int)this.teacherGrades[comboBoxGrade.SelectedIndex].GradeNo,
                                                                         this.teacherGrades[comboBoxGrade.SelectedIndex].Section,
                                                                         this.comboBoxSubject.SelectedItem.ToString(),
                                                                         studyYearStart,
                                                                         studyYearEnd);
        }
        private void JournalViewWindow_Load(object sender, EventArgs e)
        {
            lblTeacher.Text = TeacherID.ToString();

            foreach (Subject s in teacherSubjects)
            {
                comboBoxSubject.Items.Add(s.Title);
            }
            comboBoxSubject.SelectedIndex         = 0;
            comboBoxSubject.SelectedIndexChanged += comboBoxSubject_SelectedIndexChanged;

            //init grade ComboBox
            foreach (Grade g in this.teacherGrades)
            {
                comboBoxGrade.Items.Add(g.ToString());
            }
            comboBoxGrade.SelectedIndex = 0;

            //init study year combo box
            //comboStudyYear.DataSource = AttendanceJournalDAL.GetStudyYears(TeacherID,
            studyYears = AttendanceJournalDAL.GetStudyYears(this.TeacherID,
                                                            (int)this.teacherGrades[comboBoxGrade.SelectedIndex].GradeNo,
                                                            7);

            //-------------------only this order


            UpdateComboStudyYear();
            UpdateGridJournalData();
            //------------------only this order


            gridJournal.AllowUserToAddRows    = false;
            gridJournal.AllowUserToDeleteRows = false;

            this.gridJournal.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
            this.gridJournal.ColumnHeadersHeight         = 55;

            gridJournal.CellPainting += DataGridView_CellPaintingRotate; //rotate date header
        }