Exemplo n.º 1
0
        private void UpdateChart()
        {
            this.subjects = new SortedSet <string>();

            sbjcts = SubjectsDAL.GetGradeSubjects(StudentDAL.GetStudentGradeID(this.StudentID));
            foreach (Subject s in sbjcts)
            {
                this.subjects.Add(s.Title);
            }

            //gain marks list on each subject
            List <string>           seriesList = new List <string>();
            List <List <MarkInfo> > marksList  = new List <List <MarkInfo> >();

            DateTime studyYearStart;                                        //= new DateTime(yearStart, 9, 1); //1st Septemper

            if (DateTime.Now.Month <= 7)                                    //it's previous study year
            {
                studyYearStart = new DateTime(DateTime.Now.Year - 1, 9, 1); //1st Septemper
            }
            else
            {
                studyYearStart = new DateTime(DateTime.Now.Year, 9, 1);
            }

            this.Text = string.Format("My overall progress - School Journal" +
                                      " - Results on the {0}/{1} study year", studyYearStart.Year, studyYearStart.Year + 1);

            foreach (Subject s in this.sbjcts)
            {
                if (seriesList.Contains(s.Title))
                {
                    continue;
                }
                seriesList.Add(s.Title);

                //select student marks
                marksList.Add(StudentDAL.GetStudentSubjectMarks(this.StudentID, s.SubjectID, studyYearStart));
            }

            this.chartProgress.Series.Clear();
            for (int i = 0; i < seriesList.Count; i++)
            {
                // Add series.
                Series series = this.chartProgress.Series.Add(seriesList[i]);

                series.XValueType = ChartValueType.Date;
                series.YValueType = ChartValueType.Double;

                if (marksList[i].Count > 0)
                {
                    this.chartProgress.BackImage = string.Empty;
                }
                series.Points.Clear();
                foreach (MarkInfo info in marksList[i])
                {
                    series.Points.AddXY(info.Date, (double)info.MarkValue);
                }
            }
        }
        private void UpdateSubjectsComboBox()
        {
            this.subjects = new SortedSet <string>();

            sbjcts = SubjectsDAL.GetGradeSubjects(StudentDAL.GetStudentGradeID(this.StudentID));
            foreach (Subject s in sbjcts)
            {
                this.subjects.Add(s.Title);
            }


            this.comboSubject.Items.Clear();
            foreach (string sTitle in this.subjects)
            {
                this.comboSubject.Items.Add(sTitle);
            }
            if (comboSubject.Items.Count > 0)
            {
                comboSubject.SelectedItem = comboSubject.Items[0];
            }
            else
            {
                comboSubject.Enabled = false;
            }
        }