private void Instance_ItemUpdated(object sender, ItemUpdatedEventArgs e) { if (e.PrimaryKeys.Count > 0) { if (cboExistTemplates.Enabled == true && cboExistTemplates.SelectedItem is AssessmentSetupRecord) { AssessmentSetupRecord source = cboExistTemplates.SelectedItem as AssessmentSetupRecord; bool executeRequired = false; List <AEIncludeRecordEditor> aeincludeEditors = new List <AEIncludeRecordEditor>(); foreach (var each in source.GetAEIncludes()) { AEIncludeRecordEditor aeincludeEditor = AEInclude.Instance.AddAEInclude(); aeincludeEditor.RefAssessmentSetupID = e.PrimaryKeys[0]; aeincludeEditor.RefExamID = each.RefExamID; aeincludeEditor.UseScore = each.UseScore; aeincludeEditor.UseText = each.UseText; aeincludeEditor.UseEffort = each.UseEffort; aeincludeEditor.Weight = each.Weight; aeincludeEditor.StartTime = each.StartTime; aeincludeEditor.EndTime = each.EndTime; aeincludeEditors.Add(aeincludeEditor); executeRequired = true; } if (executeRequired) { aeincludeEditors.SaveAllEditors(); } } } AssessmentSetup.Instance.ItemUpdated -= new EventHandler <ItemUpdatedEventArgs>(Instance_ItemUpdated); }
/// <summary> /// Form_Load /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void CourseScoreInputForm_Load(object sender, EventArgs e) { _studentRowDict = new Dictionary <string, DataGridViewRow>(); _dirtyCellList = new List <DataGridViewCell>(); #region 取得修課學生 //_scAttendRecordList = _course.GetAttends(); _scAttendRecordList = JHSCAttend.SelectByCourseIDs(new string[] { _course.ID }); FillStudentsToDataGridView(); #endregion #region 取得評量設定 _assessmentSetupRecord = _course.GetAssessmentSetup(); if (!AEInclude.Instance.Loaded) { AEInclude.Instance.SyncAllBackground(); } _aeIncludeRecordList = _assessmentSetupRecord.GetAEIncludes(); FillToComboBox(); #endregion }
/// <summary> /// 依試別取得所有關聯課程 /// </summary> /// <param name="exam_id"></param> private void LoadCourses(string exam_id) { Dictionary <CourseRecord, AEIncludeRecord> courseAEDict = new Dictionary <CourseRecord, AEIncludeRecord>(); foreach (var course in Course.Instance.Items) { if (course.SchoolYear != intSchoolYear.Value) { continue; } if (course.Semester != intSemester.Value) { continue; } AssessmentSetupRecord asRecord = course.GetAssessmentSetup(); if (asRecord == null) { continue; } foreach (var ae in asRecord.GetAEIncludes()) { if (ae.RefExamID == exam_id) { if (!courseAEDict.ContainsKey(course)) { courseAEDict.Add(course, ae); } } } } Dictionary <string, List <SCETakeRecord> > courseScoreDict = GetCourseScores(exam_id); _courseListViewItemList.Clear(); foreach (CourseRecord course in courseAEDict.Keys) { List <SCETakeRecord> sceList = null; if (courseScoreDict.ContainsKey(course.ID)) { sceList = courseScoreDict[course.ID]; } else { sceList = new List <SCETakeRecord>(); } CourseListViewItem item = new CourseListViewItem(course, courseAEDict[course], sceList); _courseListViewItemList.Add(item); } }
private void btnDelete_Click(object sender, EventArgs e) { try { if (CurrentItem == null) { return; } string msg = "確定要刪除「" + (CurrentItem.Tag as AssessmentSetupRecord).Name + "」評量設定?\n"; msg += "刪除後,使用此評量設定的「課程」將會自動變成未設定評量設定狀態。"; DialogResult dr = MsgBox.Show(msg, Application.ProductName, MessageBoxButtons.YesNo); if (dr == DialogResult.Yes) { AssessmentSetupRecord record = CurrentItem.Tag as AssessmentSetupRecord; List <AEIncludeRecordEditor> editors = new List <AEIncludeRecordEditor>(); foreach (var item in record.GetAEIncludes()) { AEIncludeRecordEditor editor = item.GetEditor(); editor.Remove = true; editors.Add(editor); } if (editors.Count > 0) { editors.SaveAllEditors(); } AssessmentSetupRecordEditor ASEditor = record.GetEditor(); ASEditor.Remove = true; ASEditor.Save(); } } catch (Exception ex) { MsgBox.Show(ex.Message); //CurrentUser.ReportError(ex); } }
private bool SaveTemplate() { if (HasErrors()) { MsgBox.Show("請修正資料後再儲存。", Application.ProductName); return(false); } try { //string startTime = DateToSaveFormat(CurrentItem.StartTime); //string endTime = DateToSaveFormat(CurrentItem.EndTime); //if (cboScoreSource.SelectedIndex == 0) //{ // //if (string.IsNullOrEmpty(startTime) || string.IsNullOrEmpty(endTime)) // //{ // // MsgBox.Show("由教師提供課程成績必須指定上傳時間。", Application.ProductName); // // return false; // //} // //由教師提供 // EditTemplate.UpdateTemplate(CurrentItem.Identity, CurrentItem.TemplateName, CurrentItem.AllowUpload, startTime, endTime); //} //else //由學校計算 //{ // foreach (DataGridViewRow each in dataview.Rows) // { // if (each.IsNewRow) continue; // if ((bool)each.Cells["InputRequired"].FormattedValue) // { // MsgBox.Show("成績由「學校計算」時,所有「評量」必需設定成「強制繳交成績」。"); // return false; // } // } // EditTemplate.UpdateTemplate(CurrentItem.Identity, CurrentItem.TemplateName, CurrentItem.AllowUpload, string.Empty, string.Empty); //} AssessmentSetupRecord record = CurrentItem.Tag as AssessmentSetupRecord; List <AEIncludeRecordEditor> editors = new List <AEIncludeRecordEditor>(); foreach (var item in record.GetAEIncludes()) { AEIncludeRecordEditor editor = item.GetEditor(); editor.Remove = true; editors.Add(editor); } if (editors.Count > 0) { editors.SaveAllEditors(); } editors = new List <AEIncludeRecordEditor>(); foreach (DataGridViewRow each in dataview.Rows) { if (each.IsNewRow) { continue; } AEIncludeRecordEditor editor = AEInclude.Instance.AddAEInclude(); editor.RefAssessmentSetupID = record.ID; editor.RefExamID = "" + each.Cells[ExamID.Index].Value; editor.UseScore = GetYesNoString(each.Cells[UseScore.Index].FormattedValue, false); editor.UseText = GetYesNoString(each.Cells[UseText.Index].FormattedValue, false); editor.UseEffort = GetYesNoString(each.Cells[UseEffort.Index].FormattedValue, false); int i; editor.Weight = int.TryParse("" + each.Cells[Weight.Index].Value, out i) ? i : 0; editor.StartTime = DateToSaveFormat("" + each.Cells[StartTime.Index].Value); editor.EndTime = DateToSaveFormat("" + each.Cells[EndTime.Index].Value); editors.Add(editor); } if (editors.Count > 0) { editors.SaveAllEditors(); } _listener.Reset(); return(true); } catch (Exception ex) { //CurrentUser.ReportError(ex); MsgBox.Show(ex.Message); return(false); } }