private void Worker_DoWork(object sender, DoWorkEventArgs e) { StudentAttendInfo info = new StudentAttendInfo(); Worker.ReportProgress(0); //快取指定學期的課程清單,查詢用。 Dictionary <string, JHCourseRecord> courseDict = new Dictionary <string, JHCourseRecord>(); foreach (JHCourseRecord course in JHCourse.SelectBySchoolYearAndSemester(SchoolYear, Semester)) { courseDict.Add(course.ID, course); } Worker.ReportProgress(30); foreach (JHSCAttendRecord sc in JHSCAttend.SelectByStudentIDs(Students.AsKeyList())) { //修習的課程必須是指定學期的課程 if (courseDict.ContainsKey(sc.RefCourseID)) { info.Add(sc.RefStudentID, courseDict[sc.RefCourseID]); } } Worker.ReportProgress(80); info.RemoveRegular(); Worker.ReportProgress(100); e.Result = info; }
internal CheckForm(StudentAttendInfo info, int schoolYear, int semester) { InitializeComponent(); Info = info; SchoolYear = schoolYear; Semester = semester; SetDisplayCount(); }
private void Worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { if (e.Error != null) { MsgBox.Show("檢查過程中發生錯誤。" + e.Error.Message); FISCA.Presentation.MotherForm.SetStatusBarMessage("檢查失敗"); return; } FISCA.Presentation.MotherForm.SetStatusBarMessage("檢查重覆修課完成"); StudentAttendInfo info = e.Result as StudentAttendInfo; CheckForm checkForm = new CheckForm(info, SchoolYear, Semester); checkForm.ShowDialog(); }