/// <summary> /// 初始化 BackgroundWorker /// </summary> private void InitializeWorker() { _worker = new BackgroundWorker(); _worker.WorkerReportsProgress = true; _worker.DoWork += new DoWorkEventHandler(Worker_DoWork); _worker.ProgressChanged += delegate(object sender, ProgressChangedEventArgs e) { MotherForm.SetStatusBarMessage("" + e.UserState, e.ProgressPercentage); }; _worker.RunWorkerCompleted += delegate(object sender, RunWorkerCompletedEventArgs e) { if (e.Result is List <string> ) { ErrorViewer viewer = new ErrorViewer(); viewer.SetHeader("班級"); foreach (string msg in e.Result as List <string> ) { string className = msg.Split(new string[] { ":" }, StringSplitOptions.None)[0]; string errMsg = msg.Split(new string[] { ":" }, StringSplitOptions.None)[1]; viewer.SetMessage(className, new List <string>(new string[] { errMsg })); } viewer.Show(); } else { MotherForm.SetStatusBarMessage("班級開課完成"); } }; }
/// <summary> /// 檢查每個班級是否有課程規劃表 /// </summary> /// <returns></returns> private bool EachClassHasProgramPlan() { List <JHClassRecord> noProgramPlanClasses = new List <JHClassRecord>(); foreach (JHClassRecord cla in JHClass.SelectByIDs(K12.Presentation.NLDPanels.Class.SelectedSource)) { if (string.IsNullOrEmpty(cla.RefProgramPlanID)) { noProgramPlanClasses.Add(cla); } } if (noProgramPlanClasses.Count > 0) { ErrorViewer viewer = new ErrorViewer(); viewer.SetColumns("班級", "錯誤訊息"); foreach (var cla in noProgramPlanClasses) { viewer.AddRow(cla.Name, "沒有設定課程規劃表。"); } viewer.Show(); return(false); } return(true); }