Ejemplo n.º 1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            this.DisableEventHandlers();
            this.dbContext = new StudentInfoModelContainer();
            this.school    = this.dbContext.Schools.First();

            this.school.Departments = this.dbContext.Departments.ToList();
            this.departmentsDropDownList.DisplayMember = "DeptName";
            this.departmentsDropDownList.DataSource    = this.school.Departments;
            Department comc = this.school.FindDepartment("COMC");

            this.departmentsDropDownList.SelectedItem = comc;

            comc.Courses = this.dbContext.Courses.Where(c =>
                                                        c.Department.Id == comc.Id).ToList();
            this.coursesDropDownList.DisplayMember = "CourseTitle";
            this.coursesDropDownList.DataSource    = comc.Courses;
            Course comc2750 = comc.FindCourse("2750");

            this.coursesDropDownList.SelectedItem = comc2750;

            this.school.Terms = this.dbContext.Terms.ToList();
            this.termsDropDownList.DisplayMember = "DisplayString";
            this.termsDropDownList.DataSource    = this.school.Terms;
            Term spr2020 = this.school.FindTerm(2020, TermsEnum.Spr);

            this.termsDropDownList.SelectedItem = spr2020;

            comc2750.Sections = this.dbContext.Sections.Where(s =>
                                                              s.Course.Id == comc2750.Id &&
                                                              s.Term.Id == spr2020.Id).ToList();
            this.sectionsDropDownList.DisplayMember = "Id";
            this.sectionsDropDownList.DataSource    = comc2750.Sections;
            Section section2750 = comc2750.Sections.Last();

            this.sectionsDropDownList.SelectedItem = section2750;

            section2750.Assignments = this.dbContext.Assignments.Where(a =>
                                                                       a.Section.Id == section2750.Id).ToList();
            this.assignmentsListBox.DisplayMember = "DisplayString";
            this.assignmentsListBox.DataSource    = section2750.Assignments;

            section2750.Enrollments = this.dbContext.Enrollments.Include("Student").Where(enr =>
                                                                                          enr.Section.Id == section2750.Id).ToList();
            this.enrollmentsListBox.DisplayMember = "DisplayString";
            this.enrollmentsListBox.DataSource    = section2750.Enrollments;

            Enrollment      selectedEnrollment = (Enrollment)this.enrollmentsListBox.SelectedValue;
            Assignment      selectedAssignment = (Assignment)this.assignmentsListBox.SelectedValue;
            AssignmentGrade grade = this.dbContext.AssignmentGrades.Where(g =>
                                                                          g.Enrollment.Id == selectedEnrollment.Id &&
                                                                          g.Assignment.Id == selectedAssignment.Id).SingleOrDefault();

            this.pointsTextBox.Text = grade.Points.ToString();
            this.dateTextBox.Text   = grade.DateCompleted.ToShortDateString();

            this.EnableEventHandlers();
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            this.dbContext = new StudentInfoModelContainer();
            //this.school = this.dbContext.Schools.First();

            //this.school.Departments = this.dbContext.Departments.ToList();
            //this.departmentsDropDownList.DisplayMember = "DeptName";
            //this.departmentsDropDownList.DataSource = this.school.Departments;
            //Department comc = this.school.FindDepartment("COMC");
            //this.departmentsDropDownList.SelectedItem = comc;

            //comc.Courses = this.dbContext.Courses.Where(c =>
            //    c.Department.Id == comc.Id).ToList();
            //this.coursesDropDownList.DisplayMember = "CourseTitle";
            //this.coursesDropDownList.DataSource = comc.Courses;
            //Course comc2750 = comc.FindCourse("2750");
            //this.coursesDropDownList.SelectedItem = comc2750;
        }