private void LoadStudSemesterHsitoryEntity() { // 取得學期歷程 SemesterHistoryRecord = JHSchool.Data.JHSemesterHistory.SelectByStudentID(studRec.ID); // 當沒有學習歷程 if (SemesterHistoryRecord == null) { SemesterHistoryRecord = new JHSchool.Data.JHSemesterHistoryRecord(); SemesterHistoryRecord.RefStudentID = studRec.ID; } int rowIdx = 0; foreach (K12.Data.SemesterHistoryItem shi in SemesterHistoryRecord.SemesterHistoryItems) { rowIdx = dgSemestrHistory.Rows.Add(); if (shi.SchoolYear != null) { dgSemestrHistory.Rows[rowIdx].Cells[0].Value = shi.SchoolYear.ToString(); } if (shi.Semester != null) { ; } dgSemestrHistory.Rows[rowIdx].Cells[1].Value = shi.Semester.ToString(); if (shi.GradeYear != null) { dgSemestrHistory.Rows[rowIdx].Cells[2].Value = shi.GradeYear.ToString(); } if (shi.ClassName != null) { dgSemestrHistory.Rows[rowIdx].Cells[3].Value = shi.ClassName; } if (shi.SeatNo.HasValue) { dgSemestrHistory.Rows[rowIdx].Cells[4].Value = shi.SeatNo.Value.ToString(); } if (shi.Teacher != null) { dgSemestrHistory.Rows[rowIdx].Cells[5].Value = shi.Teacher; } if (shi.SchoolDayCount.HasValue) { dgSemestrHistory.Rows[rowIdx].Cells[6].Value = shi.SchoolDayCount.Value.ToString(); } rowIdx++; } }
/// <summary> /// 處理學習歷程 /// </summary> /// <param name="record"></param> /// <returns></returns> public static Dictionary <int, ValueObj.SchoolYearSemester> ProcessSemesterHistory(JHSchool.Data.JHSemesterHistoryRecord record) { Dictionary <int, ValueObj.SchoolYearSemester> result = new Dictionary <int, ValueObj.SchoolYearSemester>(); /* * 1: 一上; 2: 一下; 3: 二上; 4: 二下; 5: 三上; 6: 三下 * */ result.Add(1, null); result.Add(2, null); result.Add(3, null); result.Add(4, null); result.Add(5, null); result.Add(6, null); foreach (var item in record.SemesterHistoryItems) { int gradeYear = item.GradeYear; if (gradeYear > 6) { gradeYear -= 6; } // 由[(年級-1)*2+學期]取得Key int key = (gradeYear - 1) * 2 + item.Semester; if (result.ContainsKey(key)) { result[key] = new ValueObj.SchoolYearSemester(item.SchoolYear, item.Semester); } } return(result); }