private void StudentForm_Load(object sender, EventArgs e)
        {
            Text = $"Student {_student.Id}";
            dteBirthday.MaxDate = DateTime.Now;
            dteBirthday.MinDate = DateTime.MinValue;
            cbxCourses.Items.AddRange(CourseManager.GetAll());

            lblId.Text        = _student.Id.ToString();
            txtFirstName.Text = _student.FirstName;
            txtLastName.Text  = _student.LastName;
            txtTelephone.Text = _student.Telephone;
            txtEmail.Text     = _student.Email;
            dteBirthday.Value = _student.Birthday;

            foreach (var grade in _student.Grades.Values)
            {
                var gradeItem = new ListViewItem()
                {
                    Tag = grade
                };
                gradeItem.SubItems.AddRange(new string[6] {
                    "", "", "", "", "", ""
                });
                UpdateGradeItem(gradeItem);
                lstCourses.Items.Add(gradeItem);
            }

            UpdateInfo();
        }
Esempio n. 2
0
        private void btnexportCourses_Click(object sender, EventArgs e)
        {
            string fileName  = "Courses.txt";
            string seperator = "===========================================================================================";
            var    courses   = CourseManager.GetAll();

            using (var writer = new StreamWriter(fileName, false))
            {
                for (int i = 0; i < courses.Length; i++)
                {
                    if (i > 1)
                    {
                        writer.WriteLine(seperator);
                    }
                    writer.WriteLine(courses[i].GetInfoText());
                }
            }
            MessageBox.Show($"Exported all courses info to file {fileName}", "Exported Courses Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Esempio n. 3
0
        private void ReloadCourses()
        {
            lstCourses.Items.Clear();

            foreach (var course in CourseManager.GetAll())
            {
                var stat = CourseManager.GetStatistics(course.Id);

                var courseItem = new ListViewItem {
                    Text = course.Id.ToString(), Tag = course
                };
                courseItem.SubItems.Add(course.Name);
                courseItem.SubItems.Add(stat.NumberOfEnrolledStudents.ToString());
                courseItem.SubItems.Add(stat.NumberOfPassedStudents.ToString());
                courseItem.SubItems.Add(stat.NumberOfFailedStudents.ToString());
                courseItem.SubItems.Add(stat.LowestGrade.ToString());
                courseItem.SubItems.Add(stat.HighestGrade.ToString());
                lstCourses.Items.Add(courseItem);
            }
        }