private void frmCourse_Load(object sender, EventArgs e) { txtID.Text = course.CourseID; txtDesc.Text = course.Description; cbxFall.Checked = course.Fall; cbxWinter.Checked = course.Winter; cbxSpring.Checked = course.Spring; cbxSummer.Checked = course.Summer; if (course.Prereqs != null && course.Prereqs.Length > 0) { NList iter = course.Prereqs; for (iter.MoveFront(); iter.Index >= 0; iter.MoveNext()) { lbxPre.Items.Add(iter); } } else { lbxPre.Items.Add("None"); } if (course.Coreqs != null && course.Coreqs.Length > 0) { NList iter = course.Coreqs; for (iter.MoveFront(); iter.Index >= 0; iter.MoveNext()) { lbxCo.Items.Add(iter); } } else { lbxCo.Items.Add("None"); } }
private void AddCourse(Course course, CourseDB term, ListBox lbx) { NList iter = course.Prereqs.Copy(); AcademicYear ay; Course cs; bool found; // Check previous years for prereqs for (int i = 0; i < yearIndex; ++i) { ay = plan[i]; for (iter.MoveFront(); iter.Index >= 0; iter.MoveNext()) { cs = (Course)iter.Get(); found = ay.Fall.ContainsKey(cs.CourseID) || ay.Winter.ContainsKey(cs.CourseID) || ay.Spring.ContainsKey(cs.CourseID) || ay.Summer.ContainsKey(cs.CourseID); if (found) { iter.Delete(); } } } ay = plan[yearIndex]; // Check current year for prereqs for (iter.MoveFront(); iter.Index >= 0; iter.MoveNext()) { cs = (Course)iter.Get(); if (term == ay.Winter) { found = ay.Fall.ContainsKey(cs.CourseID); } else if (term == ay.Spring) { found = ay.Winter.ContainsKey(cs.CourseID) || ay.Fall.ContainsKey(cs.CourseID); } else if (term == ay.Summer) { found = ay.Spring.ContainsKey(cs.CourseID) || ay.Winter.ContainsKey(cs.CourseID) || ay.Fall.ContainsKey(cs.CourseID); } else { found = false; } if (found) { iter.Delete(); } } // Only add the course if it's prerequisites have been satisfied if (iter.Length < 1) { term.Add(course.CourseID, course); ay.SaveYear(); term.PopulateListBox(lbx); } }