//public Report(List<ClassExamScoreData> data, Dictionary<string, JHCourseRecord> courseDict, JHExamRecord exam, List<ComputeMethod> methods) //{ public Report(List <ClassExamScoreData> data, Dictionary <string, JHCourseRecord> courseDict, JHExamRecord exam, List <string> domains) { _data = data; _courseDict = courseDict; _exam = exam; _domains = domains; _calc = new JHSchool.Evaluation.Calculation.ScoreCalculator(null); //_methods = methods; InitializeWorker(); SchoolName = School.ChineseName; // Semester = string.Format("{0}學年度 第{1}學期", School.DefaultSchoolYear, School.DefaultSemester); Semester = string.Format("{0}學年度 第{1}學期", Global.UserSelectSchoolYear, Global.UserSelectSemester); }
public static string GetExamId(ComboBoxEx ctl) { if (ctl.InvokeRequired) { return(ctl.Invoke(new Func <ComboBoxEx, string>(GetExamId), ctl).ToString()); } else { JHExamRecord jh = (ctl.SelectedItem as JHExamRecord); if (jh == null) { return(""); } else { return(jh.ID); } } }
public ScoreInputForm(JHStudentRecord student, JHCourseRecord course) { InitializeComponent(); InitializeListener(); prlp = new PermRecLogProcess(); lblCourseName.Text = course.Name; lblStudent.Text = student.Name + " " + student.StudentNumber; _course = course; _student = student; List <JHSCAttendRecord> scattendList = JHSCAttend.SelectByStudentIDAndCourseID(new string[] { student.ID }, new string[] { course.ID }); if (scattendList.Count > 0) { _scattend = scattendList[0]; } #region 取得評量成績 _listener.SuspendListen(); // 取得所有試別 Dictionary <string, JHExamRecord> exams = JHExam.SelectAll().ToDictionary(x => x.ID); List <string> examIDs = new List <string>(exams.Keys); List <HC.JHAEIncludeRecord> aeList = new List <HC.JHAEIncludeRecord>(); if (course.RefAssessmentSetupID != null) { JHAssessmentSetupRecord assessment = JHAssessmentSetup.SelectByID(course.RefAssessmentSetupID); if (assessment != null) { foreach (JHAEIncludeRecord ae in JHAEInclude.SelectByAssessmentSetupID(assessment.ID)) { aeList.Add(new HC.JHAEIncludeRecord(ae)); } } //{ // foreach (JHAEIncludeRecord ae in JHAEInclude.SelectAll()) // { // if (ae.RefAssessmentSetupID == assessment.ID) // aeList.Add(new HC.JHAEIncludeRecord(ae)); // } //} } List <JHSCETakeRecord> jhSCEList = JHSCETake.SelectByStudentAndCourse(student.ID, course.ID); //aeList.Sort(delegate(HC.JHAEIncludeRecord x, HC.JHAEIncludeRecord y) //{ // return x.RefExamID.CompareTo(y.RefExamID); //}); aeList.Sort(delegate(HC.JHAEIncludeRecord x, HC.JHAEIncludeRecord y) { int ix = examIDs.IndexOf(x.RefExamID); int iy = examIDs.IndexOf(y.RefExamID); if (ix == -1) { ix = int.MaxValue; } if (iy == -1) { iy = int.MaxValue; } return(ix.CompareTo(iy)); }); List <HC.JHSCETakeRecord> sceList = JHSCETake.SelectByStudentAndCourse(student.ID, course.ID).AsHCJHSCETakeRecords(); Dictionary <string, DataGridViewRow> rows = new Dictionary <string, DataGridViewRow>(); foreach (HC.JHAEIncludeRecord ae in aeList) { DataGridViewRow row = new DataGridViewRow(); //JHExamRecord exam = JHExam.SelectByID(ae.RefExamID); JHExamRecord exam = null; if (exams.ContainsKey(ae.RefExamID)) { exam = exams[ae.RefExamID]; } row.CreateCells(dgv, (exam != null) ? exam.Name : "無此評量(" + ae.RefExamID + ")", "", "", ""); dgv.Rows.Add(row); row.Cells[chExamName.Index].Tag = (exam != null) ? exam.ID : ""; if (!ae.UseScore) { DisableCell(row, chScore); } if (!ae.UseAssignmentScore) { DisableCell(row, chAssignmentScore); } if (!ae.UseText) { DisableCell(row, chText); } if (!rows.ContainsKey(ae.RefExamID)) { rows.Add(ae.RefExamID, row); } } //List<HC.JHSCETakeRecord> sceList = jhSCEList.AsHCJHSCETakeRecords(); foreach (HC.JHSCETakeRecord sce in sceList) { if (rows.ContainsKey(sce.RefExamID)) { DataGridViewRow row = rows[sce.RefExamID]; row.Cells[chScore.Index].Value = sce.Score.HasValue ? "" + sce.Score.Value : ""; row.Cells[chAssignmentScore.Index].Value = sce.AssignmentScore.HasValue ? "" + sce.AssignmentScore.Value : ""; row.Cells[chText.Index].Value = sce.Text; row.Tag = sce; } else { DataGridViewRow row = new DataGridViewRow(); JHExamRecord exam = JHExam.SelectByID(sce.RefExamID); row.CreateCells(dgv, (exam != null) ? exam.Name : "無此評量(" + sce.RefExamID + ")", sce.Score.HasValue ? "" + sce.Score.Value : "", sce.AssignmentScore.HasValue ? "" + sce.AssignmentScore.Value : "", sce.Text); row.Tag = sce; row.Cells[chExamName.Index].Tag = (exam != null) ? exam.ID : ""; dgv.Rows.Add(row); DisableCell(row, chExamName); DisableCell(row, chScore); DisableCell(row, chAssignmentScore); DisableCell(row, chText); } } #region 填入修課總成績 if (_scattend != null) { DataGridViewRow row = new DataGridViewRow(); row.CreateCells(dgv, "課程總成績", "" + _scattend.Score, "", _scattend.Text); DisableCell(row, chAssignmentScore); row.Tag = "課程總成績"; dgv.Rows.Add(row); } #endregion foreach (DataGridViewRow dgv1 in dgv.Rows) { foreach (DataGridViewCell cell in dgv1.Cells) { cell.ErrorText = ""; if (cell.OwningColumn == chScore || cell.OwningColumn == chAssignmentScore) { cell.Style.ForeColor = Color.Black; if (!string.IsNullOrEmpty("" + cell.Value)) { decimal d; if (!decimal.TryParse("" + cell.Value, out d)) { cell.ErrorText = "分數必須為數字"; } else { if (d < 60) { cell.Style.ForeColor = Color.Red; } if (d > 100 || d < 0) { cell.Style.ForeColor = Color.Green; } } } } } } _listener.Reset(); _listener.ResumeListen(); #endregion SetLoadDataToLog(); }
internal static Dictionary <string, JHAEIncludeRecord> GetAEIncludeDict(List <string> list, JHExamRecord exam) { Dictionary <string, JHAEIncludeRecord> dictAEIncludes = new Dictionary <string, JHAEIncludeRecord>(); foreach (JHAEIncludeRecord ae in JHAEInclude.SelectByAssessmentSetupIDs(list)) { if (ae.RefExamID != exam.ID) { continue; } dictAEIncludes.Add(ae.RefAssessmentSetupID, ae); } return(dictAEIncludes); }
internal void SetExam(JHExamRecord exam) { Exam = exam; }
public ImportStartupForm() { InitializeComponent(); InitializeSemesters(); _effortMapper = new EffortMapper(); // 載入預設儲存值 LoadConfigData(); _worker = new BackgroundWorker(); _worker.WorkerReportsProgress = true; _worker.ProgressChanged += delegate(object sender, ProgressChangedEventArgs e) { lblMessage.Text = "" + e.UserState; }; _worker.DoWork += delegate(object sender, DoWorkEventArgs e) { #region Worker DoWork _worker.ReportProgress(0, "檢查讀卡文字格式…"); #region 檢查文字檔 ValidateTextFiles vtf = new ValidateTextFiles(intStudentNumberLenght.Value); ValidateTextResult vtResult = vtf.CheckFormat(_files); if (vtResult.Error) { e.Result = vtResult; return; } #endregion //文字檔轉 RawData RawDataCollection rdCollection = new RawDataCollection(); rdCollection.ConvertFromFiles(_files); //RawData 轉 DataRecord DataRecordCollection drCollection = new DataRecordCollection(); drCollection.ConvertFromRawData(rdCollection); _rawDataValidator = new DataValidator <RawData>(); _dataRecordValidator = new DataValidator <DataRecord>(); #region 取得驗證需要的資料 JHCourse.RemoveAll(); _worker.ReportProgress(0, "取得學生資料…"); List <JHStudentRecord> studentList = GetInSchoolStudents(); List <string> s_ids = new List <string>(); Dictionary <string, List <string> > studentNumberToStudentIDs = new Dictionary <string, List <string> >(); foreach (JHStudentRecord student in studentList) { string sn = SCValidatorCreator.GetStudentNumberFormat(student.StudentNumber); if (!studentNumberToStudentIDs.ContainsKey(sn)) { studentNumberToStudentIDs.Add(sn, new List <string>()); } studentNumberToStudentIDs[sn].Add(student.ID); } foreach (var dr in drCollection) { if (studentNumberToStudentIDs.ContainsKey(dr.StudentNumber)) { s_ids.AddRange(studentNumberToStudentIDs[dr.StudentNumber]); } } studentList.Clear(); _worker.ReportProgress(0, "取得課程資料…"); List <JHCourseRecord> courseList = JHCourse.SelectBySchoolYearAndSemester(SchoolYear, Semester); List <JHAEIncludeRecord> aeList = JHAEInclude.SelectAll(); //List<JHSCAttendRecord> scaList = JHSCAttend.SelectAll(); var c_ids = from course in courseList select course.ID; _worker.ReportProgress(0, "取得修課資料…"); //List<JHSCAttendRecord> scaList2 = JHSCAttend.SelectByStudentIDAndCourseID(s_ids, c_ids.ToList<string>()); List <JHSCAttendRecord> scaList = new List <JHSCAttendRecord>(); FunctionSpliter <string, JHSCAttendRecord> spliter = new FunctionSpliter <string, JHSCAttendRecord>(300, 3); spliter.Function = delegate(List <string> part) { return(JHSCAttend.Select(part, c_ids.ToList <string>(), null, SchoolYear.ToString(), Semester.ToString())); }; scaList = spliter.Execute(s_ids); _worker.ReportProgress(0, "取得試別資料…"); List <JHExamRecord> examList = JHExam.SelectAll(); #endregion #region 註冊驗證 _worker.ReportProgress(0, "載入驗證規則…"); _rawDataValidator.Register(new SubjectCodeValidator()); _rawDataValidator.Register(new ClassCodeValidator()); _rawDataValidator.Register(new ExamCodeValidator()); SCValidatorCreator scCreator = new SCValidatorCreator(JHStudent.SelectByIDs(s_ids), courseList, scaList); _dataRecordValidator.Register(scCreator.CreateStudentValidator()); _dataRecordValidator.Register(new ExamValidator(examList)); _dataRecordValidator.Register(scCreator.CreateSCAttendValidator()); _dataRecordValidator.Register(new CourseExamValidator(scCreator.StudentCourseInfo, aeList, examList)); #endregion #region 進行驗證 _worker.ReportProgress(0, "進行驗證中…"); List <string> msgList = new List <string>(); foreach (RawData rawData in rdCollection) { List <string> msgs = _rawDataValidator.Validate(rawData); msgList.AddRange(msgs); } if (msgList.Count > 0) { e.Result = msgList; return; } foreach (DataRecord dataRecord in drCollection) { List <string> msgs = _dataRecordValidator.Validate(dataRecord); msgList.AddRange(msgs); } if (msgList.Count > 0) { e.Result = msgList; return; } #endregion #region 取得學生的評量成績 _deleteScoreList.Clear(); _addScoreList.Clear(); //var student_ids = from student in scCreator.StudentNumberDictionary.Values select student.ID; //List<string> course_ids = scCreator.AttendCourseIDs; var scaIDs = from sca in scaList select sca.ID; Dictionary <string, JHSCETakeRecord> sceList = new Dictionary <string, JHSCETakeRecord>(); FunctionSpliter <string, JHSCETakeRecord> spliterSCE = new FunctionSpliter <string, JHSCETakeRecord>(300, 3); spliterSCE.Function = delegate(List <string> part) { return(JHSCETake.Select(null, null, null, null, part)); }; foreach (JHSCETakeRecord sce in spliterSCE.Execute(scaIDs.ToList())) { string key = GetCombineKey(sce.RefStudentID, sce.RefCourseID, sce.RefExamID); if (!sceList.ContainsKey(key)) { sceList.Add(key, sce); } } Dictionary <string, JHExamRecord> examTable = new Dictionary <string, JHExamRecord>(); Dictionary <string, JHSCAttendRecord> scaTable = new Dictionary <string, JHSCAttendRecord>(); foreach (JHExamRecord exam in examList) { if (!examTable.ContainsKey(exam.Name)) { examTable.Add(exam.Name, exam); } } foreach (JHSCAttendRecord sca in scaList) { string key = GetCombineKey(sca.RefStudentID, sca.RefCourseID); if (!scaTable.ContainsKey(key)) { scaTable.Add(key, sca); } } foreach (DataRecord dr in drCollection) { JHStudentRecord student = student = scCreator.StudentNumberDictionary[dr.StudentNumber]; JHExamRecord exam = examTable[dr.Exam]; List <JHCourseRecord> courses = new List <JHCourseRecord>(); foreach (JHCourseRecord course in scCreator.StudentCourseInfo.GetCourses(dr.StudentNumber)) { if (dr.Subjects.Contains(course.Subject)) { courses.Add(course); } } foreach (JHCourseRecord course in courses) { string key = GetCombineKey(student.ID, course.ID, exam.ID); if (sceList.ContainsKey(key)) { _deleteScoreList.Add(sceList[key]); } JHSCETakeRecord jh = new JHSCETakeRecord(); KH.JHSCETakeRecord sceNew = new KH.JHSCETakeRecord(jh); sceNew.RefCourseID = course.ID; sceNew.RefExamID = exam.ID; sceNew.RefSCAttendID = scaTable[GetCombineKey(student.ID, course.ID)].ID; sceNew.RefStudentID = student.ID; sceNew.Score = dr.Score; sceNew.Effort = _effortMapper.GetCodeByScore(dr.Score); _addScoreList.Add(sceNew.AsJHSCETakeRecord()); } } #endregion e.Result = null; #endregion }; _worker.RunWorkerCompleted += delegate(object sender, RunWorkerCompletedEventArgs e) { #region Worker Completed if (e.Error == null && e.Result == null) { if (!_upload.IsBusy) { //如果學生身上已有成績,則提醒使用者 if (_deleteScoreList.Count > 0) { _warn.RunWorkerAsync(); } else { lblMessage.Text = "成績上傳中…"; FISCA.Presentation.MotherForm.SetStatusBarMessage("成績上傳中…", 0); counter = 0; _upload.RunWorkerAsync(); } } } else { ControlEnable = true; if (e.Error != null) { MsgBox.Show("匯入失敗。" + e.Error.Message); SmartSchool.ErrorReporting.ReportingService.ReportException(e.Error); } else if (e.Result != null && e.Result is ValidateTextResult) { ValidateTextResult result = e.Result as ValidateTextResult; ValidationErrorViewer viewer = new ValidationErrorViewer(); viewer.SetTextFileError(result.LineIndexes, result.ErrorFormatLineIndexes, result.DuplicateLineIndexes); viewer.ShowDialog(); } else if (e.Result != null && e.Result is List <string> ) { ValidationErrorViewer viewer = new ValidationErrorViewer(); viewer.SetErrorLines(e.Result as List <string>); viewer.ShowDialog(); } } #endregion }; _upload = new BackgroundWorker(); _upload.WorkerReportsProgress = true; _upload.ProgressChanged += new ProgressChangedEventHandler(_upload_ProgressChanged); //_upload.ProgressChanged += delegate(object sender, ProgressChangedEventArgs e) //{ // counter += double.Parse("" + e.ProgressPercentage); // FISCA.Presentation.MotherForm.SetStatusBarMessage("成績上傳中…", (int)(counter * 100f / (double)_addScoreList.Count)); //}; _upload.DoWork += new DoWorkEventHandler(_upload_DoWork); //_upload.DoWork += delegate //{ //#region Upload DoWork //Framework.MultiThreadWorker<JHSCETakeRecord> multi = new Framework.MultiThreadWorker<JHSCETakeRecord>(); //multi.MaxThreads = 3; //multi.PackageSize = 500; //multi.PackageWorker += delegate(object sender, Framework.PackageWorkEventArgs<JHSCETakeRecord> e) //{ // JHSCETake.Delete(e.List); //}; //multi.Run(_deleteScoreList); //Framework.MultiThreadWorker<JHSCETakeRecord> multi2 = new Framework.MultiThreadWorker<JHSCETakeRecord>(); //multi2.MaxThreads = 3; //multi2.PackageSize = 500; //multi2.PackageWorker += delegate(object sender, Framework.PackageWorkEventArgs<JHSCETakeRecord> e) //{ // JHSCETake.Insert(e.List); // lock (_upload) // { // _upload.ReportProgress(e.List.Count); // } //}; //multi2.Run(_addScoreList); //#endregion //}; _upload.RunWorkerCompleted += new RunWorkerCompletedEventHandler(_upload_RunWorkerCompleted); _warn = new BackgroundWorker(); _warn.WorkerReportsProgress = true; _warn.DoWork += delegate(object sender, DoWorkEventArgs e) { _warn.ReportProgress(0, "產生警告訊息..."); Dictionary <string, string> examDict = new Dictionary <string, string>(); foreach (JHExamRecord exam in JHExam.SelectAll()) { if (!examDict.ContainsKey(exam.ID)) { examDict.Add(exam.ID, exam.Name); } } WarningForm form = new WarningForm(); int count = 0; foreach (JHSCETakeRecord sce in _deleteScoreList) { // 當成績資料是空值跳過 if (sce.Score.HasValue == false && sce.Effort.HasValue == false && string.IsNullOrEmpty(sce.Text)) { continue; } count++; JHStudentRecord student = JHStudent.SelectByID(sce.RefStudentID); JHCourseRecord course = JHCourse.SelectByID(sce.RefCourseID); string exam = (examDict.ContainsKey(sce.RefExamID) ? examDict[sce.RefExamID] : "<未知的試別>"); string s = ""; if (student.Class != null) { s += student.Class.Name; } if (!string.IsNullOrEmpty("" + student.SeatNo)) { s += " " + student.SeatNo + "號"; } if (!string.IsNullOrEmpty(student.StudentNumber)) { s += " (" + student.StudentNumber + ")"; } s += " " + student.Name; form.Add(student.ID, s, string.Format("學生在「{0}」課程「{1}」中已有成績。", course.Name, exam)); _warn.ReportProgress((int)(count * 100 / _deleteScoreList.Count), "產生警告訊息..."); } e.Result = form; }; _warn.RunWorkerCompleted += delegate(object sender, RunWorkerCompletedEventArgs e) { WarningForm form = e.Result as WarningForm; if (form.ShowDialog() == DialogResult.OK) { lblMessage.Text = "成績上傳中…"; FISCA.Presentation.MotherForm.SetStatusBarMessage("成績上傳中…", 0); counter = 0; _upload.RunWorkerAsync(); } else { this.DialogResult = DialogResult.Cancel; } }; _warn.ProgressChanged += delegate(object sender, ProgressChangedEventArgs e) { FISCA.Presentation.MotherForm.SetStatusBarMessage("" + e.UserState, e.ProgressPercentage); }; _files = new List <FileInfo>(); _addScoreList = new List <JHSCETakeRecord>(); _deleteScoreList = new List <JHSCETakeRecord>(); }
private void btnNext_Click(object sender, EventArgs e) { if (!IsValid()) { return; } // 取得畫面賞用者所選的課程ID Global._selectCourseIDList.Clear(); foreach (ListViewItem lv in lvSubject.CheckedItems) { foreach (KeyValuePair <string, string> str in Global._CourseIDSubjectDict) { if (str.Value == lv.Text) { Global._selectCourseIDList.Add(str.Key); } } } // 儲存試別 //Campus.Configuration.ConfigData cd = Campus.Configuration.Config.App["高雄個人評量成績單試別"]; //cd["高雄個人評量成績單試別"] = cbExam.Text; //cd.Save(); K12.Data.Configuration.ConfigData cd = K12.Data.School.Configuration["高雄個人評量成績單試別"]; cd["高雄個人評量成績單試別"] = cbExam.Text; cd.Save(); ReportConfiguration rc = new ReportConfiguration(Global.ReportName); rc.SetString("缺曠獎懲統計開始日期", txtSDate.Text); rc.SetString("缺曠獎懲統計結束日期", txtEDate.Text); rc.SetString("成績校正日期", txtCorrect.Text); rc.Save(); JHExamRecord exam = cbExam.SelectedItem as JHExamRecord; DateTime from = DateTime.Parse(txtSDate.Text); DateTime to = DateTime.Parse(txtEDate.Text); List <JHStudentRecord> students = GetStudents(); students.Sort(delegate(JHStudentRecord x, JHStudentRecord y) { JHClassRecord c1 = x.Class; JHClassRecord c2 = y.Class; if (x.Class == null) { return(-1); } if (y.Class == null) { return(1); } if (c1.ID == c2.ID) { int seatNo1 = x.SeatNo.HasValue ? x.SeatNo.Value : int.MinValue; int seatNo2 = y.SeatNo.HasValue ? y.SeatNo.Value : int.MinValue; if (seatNo1 == seatNo2) { return(x.StudentNumber.CompareTo(y.StudentNumber)); } else { return(seatNo1.CompareTo(seatNo2)); } } else { return(c1.Name.CompareTo(c2.Name)); } }); _config.SetExam(exam); _config.SetDateRange(from, to); _config.SetStudents(students); _config.SchoolYear = iptSchoolYear.Value; _config.Semester = iptSemester.Value; _config.Load(); Report report = new Report(_config); report.Generate(); this.DialogResult = DialogResult.OK; }
public MainForm() { //GetSubjectList(); InitializeComponent(); InitializeSemester(); this.Text = Global.ReportName; this.MinimumSize = this.Size; this.MaximumSize = this.Size; _config = new Config(Global.ReportName); _data = new List <ClassExamScoreData>(); _courseDict = new Dictionary <string, JHCourseRecord>(); _exams = new List <JHExamRecord>(); //_ecMapping = new Dictionary<string, List<string>>(); _courseList = new List <string>(); cbExam.DisplayMember = "Name"; cbSource.Items.Add("定期"); cbSource.Items.Add("定期加平時"); cbSource.SelectedIndex = 0; cbExam.Items.Add(""); _exams = JHExam.SelectAll(); foreach (var exam in _exams) { cbExam.Items.Add(exam); } cbExam.SelectedIndex = 0; _worker = new BackgroundWorker(); _worker.DoWork += delegate(object sender, DoWorkEventArgs e) { JHExamRecord exam = e.Argument as JHExamRecord; #region 取得試別 //_ecMapping.Clear(); //_exams = JHExam.SelectAll(); //List<string> examIDs = new List<string>(); //foreach (JHExamRecord exam in _exams) //{ // examIDs.Add(exam.ID); //_ecMapping.Add(exam.ID, new List<string>()); //} #endregion #region 取得課程 _courseDict.Clear(); List <JHCourseRecord> courseList = JHCourse.SelectBySchoolYearAndSemester(_runningSchoolYear, _runningSemester); List <string> courseIDs = new List <string>(); foreach (JHCourseRecord course in courseList) { courseIDs.Add(course.ID); _courseDict.Add(course.ID, course); } #endregion #region 取得評量成績 //StudentID -> ClassExamScoreData Dictionary <string, ClassExamScoreData> scMapping = new Dictionary <string, ClassExamScoreData>(); List <string> ids = new List <string>(); _classes = JHClass.SelectByIDs(K12.Presentation.NLDPanels.Class.SelectedSource); // 排序 if (_classes.Count > 1) { _classes = DAL.DALTransfer.ClassRecordSortByDisplayOrder(_classes); } // TODO: 這邊要排序 //List<K12.Data.ClassRecord> c = new List<K12.Data.ClassRecord>(_classes); //c.Sort(); //_classes = new List<JHClassRecord>(c); //((List<K12.Data.ClassRecord>)_classes).Sort(); _data.Clear(); foreach (JHClassRecord cla in _classes) { ClassExamScoreData classData = new ClassExamScoreData(cla); foreach (JHStudentRecord stu in classData.Students) { scMapping.Add(stu.ID, classData); } _data.Add(classData); } //foreach (string examID in examIDs) //{ _courseList.Clear(); if (courseIDs.Count > 0) { // TODO: JHSCETake 需要提供 SelectBy 課程IDs and 試別IDs 嗎? foreach (JHSCETakeRecord sce in JHSCETake.SelectByCourseAndExam(courseIDs, exam.ID)) { // TODO: 下面前兩個判斷應該可以拿掉 //if (!examIDs.Contains(sce.RefExamID)) continue; //試別無效 //if (!courseIDs.Contains(sce.RefCourseID)) continue; //課程無效 if (!scMapping.ContainsKey(sce.RefStudentID)) { continue; //學生編號無效 } if (string.IsNullOrEmpty(_courseDict[sce.RefCourseID].RefAssessmentSetupID)) { continue; //課程無評量設定 } if (!_courseList.Contains(sce.RefCourseID)) { _courseList.Add(sce.RefCourseID); } //if (!_ecMapping[sce.RefExamID].Contains(sce.RefCourseID)) // _ecMapping[sce.RefExamID].Add(sce.RefCourseID); ClassExamScoreData classData = scMapping[sce.RefStudentID]; classData.AddScore(sce); } } //} #endregion }; _worker.RunWorkerCompleted += delegate { string running = _runningSchoolYear + "_" + _runningSemester; string current = (int)cboSchoolYear.SelectedItem + "_" + (int)cboSemester.SelectedItem; if (running != current) { if (!_worker.IsBusy) { _runningSchoolYear = (int)cboSchoolYear.SelectedItem; _runningSemester = (int)cboSemester.SelectedItem; RunWorker(); } } else { FillData(); ControlEnabled = true; } }; RunWorker(); }
private void btnPrint_Click(object sender, EventArgs e) { #region 進行驗證 if (!ValidItem()) { MsgBox.Show("請選擇要列印的" + gpSubject.Text + "或" + gpDomain.Text); return; } #endregion Report._UserSelectCount = 0; Global.UserSelectSchoolYear = cboSchoolYear.Text; Global.UserSelectSemester = cboSemester.Text; #region 取得使用者選取的課程(科目)編號 List <string> courseIDs = new List <string>(); foreach (ListViewItem item in lvSubject.Items) { if (item.Checked) { Report._UserSelectCount++; List <string> list = item.Tag as List <string>; courseIDs.AddRange(list); } } #endregion #region 取得使用者選取的領域 List <string> domains = new List <string>(); foreach (ListViewItem item in lvDomain.Items) { Report._UserSelectCount++; if (item.Checked) { domains.Add(item.Text); } } #endregion btnPrint.Enabled = false; pictureBox1.Visible = true; pictureBox2.Visible = true; #region 轉換成 CourseScore、計算分數、排名 JHExamRecord exam = cbExam.SelectedItem as JHExamRecord; //ScoreType type = GetScoreType(); List <string> asIDs = new List <string>(); Dictionary <string, string> asMapping = new Dictionary <string, string>(); Dictionary <string, JHAEIncludeRecord> aeDict = new Dictionary <string, JHAEIncludeRecord>(); foreach (string courseID in courseIDs) { string asID = _courseDict[courseID].RefAssessmentSetupID; asIDs.Add(asID); asMapping.Add(courseID, asID); } foreach (JHAEIncludeRecord record in JHAEInclude.SelectByAssessmentSetupIDs(asIDs)) { if (record.RefExamID != exam.ID) { continue; } aeDict.Add(record.RefAssessmentSetupID, record); } //ComputeScore computer = new ComputeScore(_courseDict); //List<ComputeMethod> methods = GetMethods(_config); //RankMethod rankMethod = GetRankMethod(_config); Rank rank = new Rank(); // TODO: 不確定排名是否接續 rank.Sequence = false; // 取得評量比例 Global.ScorePercentageHSDict = Global.GetScorePercentageHS(); foreach (var ced in _data) { //轉成 CourseScore ced.ConvertToCourseScores(courseIDs, exam.ID); //RankData rd = new RankData(); foreach (string studentID in ced.Rows.Keys) { StudentRow row = ced.Rows[studentID]; //計算單一評量成績 foreach (CourseScore courseScore in row.CourseScoreList) { string asID = asMapping[courseScore.CourseID]; if (aeDict.ContainsKey(asID)) { courseScore.CalculateScore(new HC.JHAEIncludeRecord(aeDict[asID]), "" + cbSource.SelectedItem); } } } //排序班級課程ID ced.SortCourseIDs(courseIDs); } #endregion #region 產生報表 //Report report = new Report(_data, _courseDict, exam, methods); Report report = new Report(_data, _courseDict, exam, domains); report.GenerateCompleted += new EventHandler(report_GenerateCompleted); report.GenerateError += new EventHandler(report_GenerateError); report.Generate(); #endregion }
/// <summary> /// 從DataGridView上取得SCETakeRecordEditors /// </summary> /// <returns></returns> //private List<SCETakeRecordEditor> MakeSCETakeRecordEditors() //{ // if (cboExamList.SelectedItem == null) return new List<SCETakeRecordEditor>(); // List<SCETakeRecordEditor> list = new List<SCETakeRecordEditor>(); // ExamComboBoxItem item = cboExamList.SelectedItem as ExamComboBoxItem; // ExamRecord exam = item.AEIncludeRecord.Exam; // foreach (DataGridViewRow row in dgv.Rows) // { // SCAttendTag tag = row.Tag as SCAttendTag; // if (tag.SCETake != null) // { // #region 修改or刪除 // bool is_remove = true; // SCETakeRecordEditor editor = tag.SCETake.GetEditor(); // if (chInputScore.Visible == true) // { // string value = "" + row.Cells[chInputScore.Index].Value; // is_remove &= string.IsNullOrEmpty(value); // if (!string.IsNullOrEmpty(value)) // editor.Score = decimal.Parse(value); // } // if (chInputEffort.Visible == true) // { // string value = "" + row.Cells[chInputEffort.Index].Value; // is_remove &= string.IsNullOrEmpty(value); // if (!string.IsNullOrEmpty(value)) // editor.Effort = int.Parse(value); // } // if (chInputText.Visible == true) // { // string value = "" + row.Cells[chInputText.Index].Value; // is_remove &= string.IsNullOrEmpty(value); // editor.Text = value; // } // editor.Remove = is_remove; // list.Add(editor); // #endregion // } // else // { // #region 新增 // bool is_add = false; // SCETakeRecordEditor editor = new SCETakeRecordEditor(tag.SCAttend, exam); // if (chInputScore.Visible == true) // { // string value = "" + row.Cells[chInputScore.Index].Value; // if (!string.IsNullOrEmpty(value)) // { // editor.Score = decimal.Parse(value); // is_add = true; // } // } // if (chInputEffort.Visible == true) // { // string value = "" + row.Cells[chInputEffort.Index].Value; // if (!string.IsNullOrEmpty(value)) // { // editor.Effort = int.Parse(value); // is_add = true; // } // } // if (chInputText.Visible == true) // { // string value = "" + row.Cells[chInputText.Index].Value; // if (!string.IsNullOrEmpty(value)) // { // editor.Text = value; // is_add = true; // } // } // if (is_add) list.Add(editor); // #endregion // } // } // return list; //} /// <summary> /// 從DataGridView上取得 HC.JHSCETakeRecord /// </summary> /// <returns></returns> private RecordIUDLists GetRecords() { if (cboExamList.SelectedItem == null) { return(new RecordIUDLists()); } RecordIUDLists lists = new RecordIUDLists(); ExamComboBoxItem item = cboExamList.SelectedItem as ExamComboBoxItem; JHExamRecord exam = item.AEIncludeRecord.Exam; foreach (DataGridViewRow row in dgv.Rows) { SCAttendTag tag = row.Tag as SCAttendTag; if (tag.SCETake != null) { HC.JHSCETakeRecord record = tag.SCETake; #region 修改or刪除 bool is_remove = true; if (chInputScore.Visible == true) { string value = ("" + row.Cells[chInputScore.Index].Value).Trim(); if (PluginMain.ScoreTextMap.ContainsKey(value)) { value = PluginMain.ScoreTextMap[value].UseValue.ToString(); } is_remove &= string.IsNullOrEmpty(value); if (!string.IsNullOrEmpty(value)) { record.Score = decimal.Parse(value); } // 小郭, 2013/12/30 else { record.Score = null; } } if (chInputAssignmentScore.Visible == true) { string value = ("" + row.Cells[chInputAssignmentScore.Index].Value).Trim(); if (PluginMain.ScoreTextMap.ContainsKey(value)) { value = PluginMain.ScoreTextMap[value].UseValue.ToString(); } is_remove &= string.IsNullOrEmpty(value); if (!string.IsNullOrEmpty(value)) { record.AssignmentScore = decimal.Parse(value); } // 小郭, 2013/12/30 else { record.AssignmentScore = null; } } if (chInputText.Visible == true) { string value = "" + row.Cells[chInputText.Index].Value; is_remove &= string.IsNullOrEmpty(value); record.Text = value; } if (is_remove) { lists.DeleteList.Add(record); } else { lists.UpdateList.Add(record); } #endregion } else { #region 新增 bool is_add = false; JHSchool.Data.JHSCETakeRecord jh = new JHSchool.Data.JHSCETakeRecord(); HC.JHSCETakeRecord record = new HC.JHSCETakeRecord(jh); record.RefCourseID = tag.SCAttend.Course.ID; record.RefExamID = exam.ID; record.RefSCAttendID = tag.SCAttend.ID; record.RefStudentID = tag.SCAttend.Student.ID; record.Score = null; record.AssignmentScore = null; record.Text = string.Empty; if (chInputScore.Visible == true) { string value = ("" + row.Cells[chInputScore.Index].Value).Trim(); if (PluginMain.ScoreTextMap.ContainsKey(value)) { value = PluginMain.ScoreTextMap[value].UseValue.ToString(); } if (!string.IsNullOrEmpty(value)) { record.Score = decimal.Parse(value); is_add = true; } } if (chInputAssignmentScore.Visible == true) { string value = ("" + row.Cells[chInputAssignmentScore.Index].Value).Trim(); if (PluginMain.ScoreTextMap.ContainsKey(value)) { value = PluginMain.ScoreTextMap[value].UseValue.ToString(); } if (!string.IsNullOrEmpty(value)) { record.AssignmentScore = decimal.Parse(value); is_add = true; } } if (chInputText.Visible == true) { string value = "" + row.Cells[chInputText.Index].Value; if (!string.IsNullOrEmpty(value)) { record.Text = value; is_add = true; } } if (is_add) { lists.InsertList.Add(record); } #endregion } } return(lists); }
//private string _weight; public ExamComboBoxItem(HC.JHAEIncludeRecord record) { _aeIncludeRecord = record; //_weight = record.Weight; _examRecord = record.Exam; }
public ScoreInputForm(JHStudentRecord student, JHCourseRecord course) { InitializeComponent(); InitializeListener(); prlp = new PermRecLogProcess(); lblCourseName.Text = course.Name; lblStudent.Text = student.Name + " " + student.StudentNumber; _course = course; _student = student; List <JHSCAttendRecord> scattendList = JHSCAttend.SelectByStudentIDAndCourseID(new string[] { student.ID }, new string[] { course.ID }); if (scattendList.Count > 0) { _scattend = scattendList[0]; } #region 取得評量成績缺考暨免試設定 PluginMain.ScoreTextMap.Clear(); PluginMain.ScoreValueMap.Clear(); Framework.ConfigData cd = JHSchool.School.Configuration["評量成績缺考暨免試設定"]; if (!string.IsNullOrEmpty(cd["評量成績缺考暨免試設定"])) { XmlElement element = Framework.XmlHelper.LoadXml(cd["評量成績缺考暨免試設定"]); foreach (XmlElement each in element.SelectNodes("Setting")) { var UseText = each.SelectSingleNode("UseText").InnerText; var AllowCalculation = bool.Parse(each.SelectSingleNode("AllowCalculation").InnerText); decimal Score; decimal.TryParse(each.SelectSingleNode("Score").InnerText, out Score); var Active = bool.Parse(each.SelectSingleNode("Active").InnerText); var UseValue = decimal.Parse(each.SelectSingleNode("UseValue").InnerText); if (Active) { if (!PluginMain.ScoreTextMap.ContainsKey(UseText)) { PluginMain.ScoreTextMap.Add(UseText, new ScoreMap { UseText = UseText, AllowCalculation = AllowCalculation, Score = Score, Active = Active, UseValue = UseValue, }); } if (!PluginMain.ScoreValueMap.ContainsKey(UseValue)) { PluginMain.ScoreValueMap.Add(UseValue, new ScoreMap { UseText = UseText, AllowCalculation = AllowCalculation, Score = Score, Active = Active, UseValue = UseValue, }); } } } } #endregion #region 取得評量成績 _listener.SuspendListen(); // 取得所有試別 Dictionary <string, JHExamRecord> exams = JHExam.SelectAll().ToDictionary(x => x.ID); List <string> examIDs = new List <string>(exams.Keys); List <HC.JHAEIncludeRecord> aeList = new List <HC.JHAEIncludeRecord>(); if (course.RefAssessmentSetupID != null) { JHAssessmentSetupRecord assessment = JHAssessmentSetup.SelectByID(course.RefAssessmentSetupID); if (assessment != null) { foreach (JHAEIncludeRecord ae in JHAEInclude.SelectByAssessmentSetupID(assessment.ID)) { aeList.Add(new HC.JHAEIncludeRecord(ae)); } } //{ // foreach (JHAEIncludeRecord ae in JHAEInclude.SelectAll()) // { // if (ae.RefAssessmentSetupID == assessment.ID) // aeList.Add(new HC.JHAEIncludeRecord(ae)); // } //} } List <JHSCETakeRecord> jhSCEList = JHSCETake.SelectByStudentAndCourse(student.ID, course.ID); //aeList.Sort(delegate(HC.JHAEIncludeRecord x, HC.JHAEIncludeRecord y) //{ // return x.RefExamID.CompareTo(y.RefExamID); //}); aeList.Sort(delegate(HC.JHAEIncludeRecord x, HC.JHAEIncludeRecord y) { int ix = examIDs.IndexOf(x.RefExamID); int iy = examIDs.IndexOf(y.RefExamID); if (ix == -1) { ix = int.MaxValue; } if (iy == -1) { iy = int.MaxValue; } return(ix.CompareTo(iy)); }); List <HC.JHSCETakeRecord> sceList = JHSCETake.SelectByStudentAndCourse(student.ID, course.ID).AsHCJHSCETakeRecords(); Dictionary <string, DataGridViewRow> rows = new Dictionary <string, DataGridViewRow>(); foreach (HC.JHAEIncludeRecord ae in aeList) { DataGridViewRow row = new DataGridViewRow(); //JHExamRecord exam = JHExam.SelectByID(ae.RefExamID); JHExamRecord exam = null; if (exams.ContainsKey(ae.RefExamID)) { exam = exams[ae.RefExamID]; } row.CreateCells(dgv, (exam != null) ? exam.Name : "無此評量(" + ae.RefExamID + ")", "", "", ""); dgv.Rows.Add(row); row.Cells[chExamName.Index].Tag = (exam != null) ? exam.ID : ""; if (!ae.UseScore) { DisableCell(row, chScore); } if (!ae.UseAssignmentScore) { DisableCell(row, chAssignmentScore); } if (!ae.UseText) { DisableCell(row, chText); } if (!rows.ContainsKey(ae.RefExamID)) { rows.Add(ae.RefExamID, row); } } //List<HC.JHSCETakeRecord> sceList = jhSCEList.AsHCJHSCETakeRecords(); foreach (HC.JHSCETakeRecord sce in sceList) { if (rows.ContainsKey(sce.RefExamID)) { DataGridViewRow row = rows[sce.RefExamID]; if (sce.Score.HasValue) { if (PluginMain.ScoreValueMap.ContainsKey(decimal.Parse(sce.Score.Value + ""))) { row.Cells[chScore.Index].Value = PluginMain.ScoreValueMap[decimal.Parse(sce.Score.Value + "")].UseText; } else { row.Cells[chScore.Index].Value = sce.Score.Value; } } else { row.Cells[chScore.Index].Value = ""; } if (sce.AssignmentScore.HasValue) { if (PluginMain.ScoreValueMap.ContainsKey(decimal.Parse(sce.AssignmentScore.Value + ""))) { row.Cells[chAssignmentScore.Index].Value = PluginMain.ScoreValueMap[decimal.Parse(sce.AssignmentScore.Value + "")].UseText; } else { row.Cells[chAssignmentScore.Index].Value = sce.AssignmentScore.Value; } } else { row.Cells[chAssignmentScore.Index].Value = ""; } row.Cells[chText.Index].Value = sce.Text; row.Tag = sce; } else { DataGridViewRow row = new DataGridViewRow(); JHExamRecord exam = JHExam.SelectByID(sce.RefExamID); row.CreateCells(dgv, (exam != null) ? exam.Name : "無此評量(" + sce.RefExamID + ")", sce.Score.HasValue ? "" + sce.Score.Value : "", sce.AssignmentScore.HasValue ? "" + sce.AssignmentScore.Value : "", sce.Text); row.Tag = sce; row.Cells[chExamName.Index].Tag = (exam != null) ? exam.ID : ""; dgv.Rows.Add(row); DisableCell(row, chExamName); DisableCell(row, chScore); DisableCell(row, chAssignmentScore); DisableCell(row, chText); } } #region 填入修課總成績 if (_scattend != null) { DataGridViewRow row = new DataGridViewRow(); row.CreateCells(dgv, "課程總成績", "" + _scattend.Score, "", _scattend.Text); DisableCell(row, chAssignmentScore); row.Tag = "課程總成績"; dgv.Rows.Add(row); } #endregion foreach (DataGridViewRow dgv1 in dgv.Rows) { foreach (DataGridViewCell cell in dgv1.Cells) { cell.ErrorText = ""; if (cell.OwningColumn == chScore || cell.OwningColumn == chAssignmentScore) { cell.Style.ForeColor = Color.Black; if (!string.IsNullOrEmpty("" + cell.Value)) { decimal d; if (!decimal.TryParse("" + cell.Value, out d)) { if (PluginMain.ScoreTextMap.Keys.Count > 0) { if (!PluginMain.ScoreTextMap.ContainsKey("" + cell.Value)) { cell.ErrorText = "分數必須為數字或「" + string.Join("、", PluginMain.ScoreTextMap.Keys) + "」"; } } else { cell.ErrorText = "分數必須為數字"; } } else { if (d < 60) { cell.Style.ForeColor = Color.Red; } if (d > 100 || d < 0) { cell.Style.ForeColor = Color.Green; } } } } } } _listener.Reset(); _listener.ResumeListen(); #endregion SetLoadDataToLog(); }