/// <summary> /// 根據使用者所選擇的條件取得學期科目成績 /// </summary> private void SelectByCondition() { if (!IsInput()) { MessageBox.Show("請完整輸入欄位資訊!"); return; } int SchoolYear = K12.Data.Int.Parse("" + cmbSchoolYear.SelectedItem); string Subject = "" + cmbSubjects.SelectedItem; strLog = new StringBuilder(); UpdateRecords = StudentScores.Where(x => x.SchoolYear == SchoolYear).ToList(); List <object> SubjectRecords = new List <object>(); foreach (SHSchoolYearScoreRecord record in UpdateRecords) { SHStudentRecord s = StudentRecords.Find(x => x.ID.Equals(record.RefStudentID)); foreach (SHSchoolYearScoreSubject SubjectScore in record.Subjects) { if (SubjectScore.Subject.Equals(Subject) || string.IsNullOrEmpty(Subject)) { SubjectRecords.Add(new { 學生編號 = s.ID, 學號 = s.StudentNumber, 姓名 = s.Name, 學年度 = record.SchoolYear, 科目名稱 = SubjectScore.Subject }); } } } grdData.DataSource = SubjectRecords; }
public static int SHClassSeatNoComparer(SHStudentRecord x, SHStudentRecord y) { string xx = (x.Class == null ? "" : x.Class.Name) + "::" + (x.SeatNo == null ? "" : x.SeatNo.ToString().PadLeft(2, '0')); string yy = (y.Class == null ? "" : y.Class.Name) + "::" + (y.SeatNo == null ? "" : y.SeatNo.ToString().PadLeft(2, '0')); return(xx.CompareTo(yy)); }
private void SetLog() { sbLog = new StringBuilder(); Dictionary <string, SHSCETakeRecord> delDic = new Dictionary <string, SHSCETakeRecord>(); foreach (SHSCETakeRecord sce in _deleteScoreList) { if (!delDic.ContainsKey(sce.RefStudentID + "_" + sce.RefCourseID)) { delDic.Add(sce.RefStudentID + "_" + sce.RefCourseID, sce); } } foreach (SHSCETakeRecord sce in _addScoreList) { SHStudentRecord student = SHStudent.SelectByID(sce.RefStudentID); SHCourseRecord course = SHCourse.SelectByID(sce.RefCourseID); string exam = (examDict.ContainsKey(sce.RefExamID) ? examDict[sce.RefExamID] : "<未知的試別>"); if (delDic.ContainsKey(sce.RefStudentID + "_" + sce.RefCourseID)) { string classname = student.Class != null ? student.Class.Name : ""; string seatno = student.SeatNo.HasValue ? student.SeatNo.Value.ToString() : ""; sbLog.AppendLine(string.Format("班級「{0}」座號「{1}」姓名「{2}」在試別「{3}」課程「{4}」將成績「{5}」修改為「{6}」。", classname, seatno, student.Name, course.Name, exam, delDic[sce.RefStudentID + "_" + sce.RefCourseID].Score, sce.Score)); } else { string classname = student.Class != null ? student.Class.Name : ""; string seatno = student.SeatNo.HasValue ? student.SeatNo.Value.ToString() : ""; sbLog.AppendLine(string.Format("班級「{0}」座號「{1}」姓名「{2}」在「{3}」課程「{4}」新增成績「{5}」。", classname, seatno, student.Name, course.Name, exam, sce.Score)); } } FISCA.LogAgent.ApplicationLog.Log("讀卡系統", "評量成績", sbLog.ToString()); }
private void FillDataGridView() { try { dataGridViewX1.SuspendLayout(); foreach (SHUpdateRecordRecord UpdateRec in _StudUpdateRecList) { SHStudentRecord student = new SHStudentRecord(); if (students.ContainsKey(UpdateRec.StudentID)) { student = students[UpdateRec.StudentID]; } string SeatNo = string.Empty, ClassName = string.Empty, Gender = string.Empty; if (student.SeatNo.HasValue) { SeatNo = student.SeatNo.Value + ""; } if (student.Class != null) { ClassName = student.Class.Name; } if (!string.IsNullOrEmpty(student.Gender)) { Gender = student.Gender; } DataGridViewRow row = new DataGridViewRow(); row.CreateCells(dataGridViewX1, UpdateRec.ID, UpdateRec.UpdateDate, ClassName, SeatNo, student.StudentNumber, student.Name, Gender, UpdateRec.UpdateCode, UpdateRec.UpdateDescription, "", "", UpdateRec.ADNumber ); row.Tag = UpdateRec.StudentID; dataGridViewX1.Rows.Add(row); } dataGridViewX1.ResumeLayout(); } catch (Exception ex) { MessageBox.Show("Error"); } }
private int SortStudent(SHStudentRecord x, SHStudentRecord y) { string xx1 = x.Class != null ? x.Class.Name : ""; string xx2 = x.SeatNo.HasValue ? x.SeatNo.Value.ToString().PadLeft(3, '0') : "000"; string xx3 = xx1 + xx2; string yy1 = y.Class != null ? y.Class.Name : ""; string yy2 = y.SeatNo.HasValue ? y.SeatNo.Value.ToString().PadLeft(3, '0') : "000"; string yy3 = yy1 + yy2; return(xx3.CompareTo(yy3)); }
/// <summary> /// 完整刪除單筆學年科目成績 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnCompleteDelete_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty("" + cmbSchoolYear.SelectedItem)) { MessageBox.Show("請選擇學年度!"); return; } int SchoolYear = K12.Data.Int.Parse("" + cmbSchoolYear.SelectedItem); strLog = new StringBuilder(); strLog.AppendLine("『完整刪除學年科目成績紀錄』"); List <SHSchoolYearScoreRecord> DeleteRecords = StudentScores.Where(x => x.SchoolYear == SchoolYear).ToList(); foreach (SHSchoolYearScoreRecord record in DeleteRecords) { SHStudentRecord s = StudentRecords.Find(x => x.ID.Equals(record.RefStudentID)); strLog.AppendLine("系統編號:" + record.ID + ",學生編號:" + s.ID + ",學生學號:" + s.StudentNumber + ",學生姓名:" + s.Name + ",學年度:" + record.SchoolYear); } int SuccessCount = 0; if (K12.Data.Utility.Utility.IsNullOrEmpty(DeleteRecords)) { MessageBox.Show("沒有資料不需刪除!!"); return; } try { if (MessageBox.Show("與您確認是否要刪除總共" + DeleteRecords.Count + "筆成績?提醒在刪除前先備份該位學生所有學年科目成績,並在成功後備份『刪除紀錄』。", "刪除學年科目成績確認", MessageBoxButtons.YesNo) == DialogResult.Yes) { SuccessCount = SHSchoolYearScore.Delete(DeleteRecords); MessageBox.Show("成功刪除筆數:" + SuccessCount); txtLog.Text = txtLog.Text + strLog.ToString(); FISCA.LogAgent.ApplicationLog.Log("成績模組.學年科目成績資料維護", strLog.ToString()); } } catch (Exception ve) { MessageBox.Show(ve.Message); txtLog.Text = txtLog.Text + ve.Message; } finally { RefreshUI(); } }
private void btnAdd_Click(object sender, EventArgs e) { // 初始化資料 SHUpdateRecordRecord updateRec = new SHUpdateRecordRecord(); // 取得學生ID // 先清DAL Cache List <string> rmIDs = new List <string> (); rmIDs.Add(PrimaryKey); SHStudent.RemoveByIDs(rmIDs); SHStudentRecord studRec = SHStudent.SelectByID(PrimaryKey); // 取得最後一筆異動資料,備查使用。 List <SHUpdateRecordRecord> UpdList = (from rec in SHUpdateRecord.SelectByStudentID(PrimaryKey) where rec.ID != updateRec.ID && rec.ADDate.Trim() != "" orderby DateTime.Parse(rec.ADDate) descending, int.Parse(rec.ID) descending select rec).ToList(); if (UpdList.Count > 0) { updateRec.LastADDate = UpdList[0].ADDate; updateRec.LastADNumber = UpdList[0].ADNumber; updateRec.LastUpdateCode = UpdList[0].UpdateCode; } updateRec.StudentID = studRec.ID; updateRec.StudentNumber = studRec.StudentNumber; updateRec.StudentName = studRec.Name; updateRec.IDNumber = studRec.IDNumber; if (studRec.Birthday.HasValue) { updateRec.Birthdate = studRec.Birthday.Value.ToShortDateString(); } updateRec.Gender = studRec.Gender; if (studRec.Department != null) { updateRec.Department = studRec.Department.FullName; } // 取得學生學籍特殊身分代碼 updateRec.SpecialStatus = DAL.DALTransfer.GetSpecialCode(studRec.ID); updateRec.UpdateDate = DateTime.Now.ToShortDateString(); if (updateRec == null) { return; } UpdateRecordItemForm form = new UpdateRecordItemForm(UpdateRecordItemForm.actMode.新增, updateRec, PrimaryKey); form.ShowDialog(); }
private int SortStudent(string kjr1, string kjr2) { SHStudentRecord s1 = StudentDic[kjr1]; SHStudentRecord s2 = StudentDic[kjr2]; string StudentSort1 = s1.Class != null ? (s1.Class.GradeYear.HasValue ? s1.Class.GradeYear.Value.ToString().PadLeft(2, '0') : "00") : "00"; string StudentSort2 = s2.Class != null ? (s2.Class.GradeYear.HasValue ? s2.Class.GradeYear.Value.ToString().PadLeft(2, '0') : "00") : "00"; StudentSort1 += s1.Class != null?s1.Class.Name.PadLeft(10, '0') : "0000000000"; StudentSort2 += s2.Class != null?s2.Class.Name.PadLeft(10, '0') : "0000000000"; StudentSort1 += s1.SeatNo.HasValue ? s1.SeatNo.Value.ToString().PadLeft(3, '0') : "000"; StudentSort2 += s2.SeatNo.HasValue ? s2.SeatNo.Value.ToString().PadLeft(3, '0') : "000"; return(StudentSort1.CompareTo(StudentSort2)); }
private bool Mode = false; //模式為true,就是新增資料 /// <summary> /// 建構子 /// </summary> public MoralScoreLogRobot(SHStudentRecord student, List <string> list) { _student = student; _List = list; _OldDic = new Dictionary <string, string>(); _NewDic = new Dictionary <string, string>(); foreach (string each in _List) { if (!_OldDic.ContainsKey(each)) { _OldDic.Add(each, ""); } if (!_NewDic.ContainsKey(each)) { _NewDic.Add(each, ""); } } }
// 載入系統預設學年度學期 private void SetDefaultSchoolYearSemester() { int sy, sm; if (int.TryParse(K12.Data.School.DefaultSchoolYear, out sy)) { intSchoolYear.Value = sy; } else { intSchoolYear.IsEmpty = true; } if (int.TryParse(K12.Data.School.DefaultSemester, out sm)) { intSemester.Value = sm; } else { intSemester.IsEmpty = true; } // 取得年級,如果學生狀態是延修生,年級顯示延修生,如果不是就依照原本年級顯示 SHStudentRecord studRec = SHStudent.SelectByID(_StudentID); if (studRec.Class != null) { if (studRec.Class.GradeYear.HasValue) { if (cbxGradeYear.Text == "") { if (studRec.Status == K12.Data.StudentRecord.StudentStatus.延修) { cbxGradeYear.Text = "延修生"; } else { cbxGradeYear.Text = studRec.Class.GradeYear.Value.ToString(); } } } } }
//private int SetColumn(string HeaderName, string HeaderTitle, bool readOnly) //{ // int ColumnsIndex = dataGridView.Columns.Add(HeaderName, HeaderTitle); // ColumnIndex.Add(HeaderTitle, ColumnsIndex); // dataGridView.Columns[ColumnsIndex].SortMode = DataGridViewColumnSortMode.NotSortable; // dataGridView.Columns[ColumnsIndex].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells; // dataGridView.Columns[ColumnsIndex].ReadOnly = readOnly; // dataGridView.Columns[ColumnsIndex].DefaultCellStyle.BackColor = Color.LightCyan; // return ColumnsIndex; //} private int SortStudentInClass(SHStudentRecord xStud, SHStudentRecord yStud) { string xClass = xStud.Class != null ? xStud.Class.Name : ""; xClass = xClass.PadLeft(6, '0'); string yClass = yStud.Class != null ? yStud.Class.Name : ""; yClass = yClass.PadLeft(6, '0'); string xSean = xStud.SeatNo.HasValue ? xStud.SeatNo.Value.ToString() : ""; xSean = xSean.PadLeft(6, '0'); string ySean = yStud.SeatNo.HasValue ? yStud.SeatNo.Value.ToString() : ""; ySean = ySean.PadLeft(6, '0'); string xx = xClass + xSean; string yy = yClass + ySean; return(xx.CompareTo(yy)); }
private void wizardPage3_FinishButtonClick(object sender, CancelEventArgs e) { StringBuilder desc = new StringBuilder(""); SHStudentRecord stu = SHStudent.SelectByID(mStudentID); desc.AppendLine("學生姓名:" + stu.Name + " "); if (office2007StyleRadioButton1.Checked) { desc.AppendLine("姓名由「" + stu.Name + "」變更為「" + textBoxX1.Text + "」"); stu.Name = textBoxX1.Text; } if (office2007StyleRadioButton2.Checked) { desc.AppendLine("身分證號由「" + stu.IDNumber + "」變更為「" + textBoxX1.Text + "」"); stu.IDNumber = textBoxX1.Text; } if (office2007StyleRadioButton3.Checked) { desc.AppendLine("學號由「" + stu.StudentNumber + "」變更為「" + textBoxX1.Text + "」"); stu.StudentNumber = textBoxX1.Text; } if (office2007StyleRadioButton4.Checked) { desc.AppendLine("生日由「" + stu.Birthday + "」變更為「" + textBoxX1.Text + "」"); stu.Birthday = K12.Data.DateTimeHelper.Parse(textBoxX1.Text); } if (office2007StyleRadioButton5.Checked) { desc.AppendLine("性別由「" + stu.Gender + "」變更為「" + textBoxX1.Text + "」"); stu.Gender = textBoxX1.Text; } this.Close(); // CurrentUser.Instance.AppLog.Write(EntityType.Student, "學籍更正", mStudentID, desc.ToString(), "", ""); SHStudent.Update(stu); this.updateRecordInfo1.Save(); // SmartSchool.Broadcaster.Events.Items["學生/資料變更"].Invoke(mStudentID); }
internal void Add(SHStudentRecord student) { if (string.IsNullOrEmpty(student.StudentNumber)) { return; } string studentNumber = student.StudentNumber;// SCValidatorCreator.GetStudentNumberFormat(student.StudentNumber); if (!studentNumberTable.ContainsKey(studentNumber)) { studentNumberTable.Add(studentNumber, student.ID); } if (!studentTable.ContainsKey(student.ID)) { studentTable.Add(student.ID, student); } if (!courseTable.ContainsKey(student.ID)) { courseTable.Add(student.ID, new List <SHCourseRecord>()); } }
/// <summary> /// 每1000筆資料,分批執行匯入 /// Return是Log資訊 /// </summary> public override string Import(List <Campus.DocumentValidator.IRowStream> Rows) { List <MoralScoreLogRobot> LogList = new List <MoralScoreLogRobot>(); //取得匯入資料中,所有學生編號下的的日常生活表現資料 List <SHMoralScoreRecord> MoralScoreList = GetMoralScoreList(Rows); List <SHMoralScoreRecord> InsertList = new List <SHMoralScoreRecord>(); List <SHMoralScoreRecord> UpdateList = new List <SHMoralScoreRecord>(); int NochangeCount = 0; //未處理資料記數 if (mOption.Action == ImportAction.InsertOrUpdate) { foreach (IRowStream Row in Rows) { int SchoolYear = int.Parse(Row.GetValue("學年度")); int Semester = int.Parse(Row.GetValue("學期")); string StudentNumber = Row.GetValue("學號"); SHStudentRecord student = StudentRecordByStudentNumber[StudentNumber]; SHMoralScoreRecord SSR = GetMoralScoreRecord(MoralScoreList, StudentNumber, SchoolYear, Semester); //Log機器人 MoralScoreLogRobot log = new MoralScoreLogRobot(student, faceDic.Keys.ToList()); if (SSR == null) //新增SHMoralScoreRecord { SHMoralScoreRecord newRecord = new SHMoralScoreRecord(); newRecord.RefStudentID = student.ID; newRecord.SchoolYear = SchoolYear; newRecord.Semester = Semester; newRecord.TextScore = GetInsertTextScore(Row); //Log log.SetOldLost(); log.SetNew(newRecord); InsertList.Add(newRecord); } else //已存在資料需要修改 or 覆蓋 { //Log(old) log.SetOld(SSR); //取得新的Xml結構 SSR.TextScore = GetUpdateTextScore(SSR, Row); //Log(New) log.SetNew(SSR); if (!string.IsNullOrEmpty(log.LogToString())) { UpdateList.Add(SSR); } } LogList.Add(log); } } if (InsertList.Count > 0) { try { SHMoralScore.Insert(InsertList); } catch (Exception ex) { MsgBox.Show("於新增資料時發生錯誤!!\n" + ex.Message); } } if (UpdateList.Count > 0) { try { SHMoralScore.Update(UpdateList); } catch (Exception ex) { MsgBox.Show("於更新資料時發生錯誤!!\n" + ex.Message); } } //批次記錄Log LogSaver Batch = FISCA.LogAgent.ApplicationLog.CreateLogSaverInstance(); foreach (MoralScoreLogRobot each in LogList) { if (!string.IsNullOrEmpty(each.LogToString())) { Batch.AddBatch("學務系統.匯入文字評量", "student", each._student.ID, each.LogToString()); } else { NochangeCount++; } } Batch.LogBatch(true); //Summary Log StringBuilder sbSummary = new StringBuilder(); sbSummary.AppendLine("匯入文字評量操作:"); sbSummary.AppendLine("新增:" + InsertList.Count + "筆資料"); sbSummary.AppendLine("更新:" + UpdateList.Count + "筆資料"); sbSummary.AppendLine("未更動:" + NochangeCount + "筆資料"); FISCA.LogAgent.ApplicationLog.Log("學務系統.匯入文字評量", "匯入", sbSummary.ToString()); //StringBuilder sbSummary2 = new StringBuilder(); //sbSummary2.AppendLine("匯入文字評量操作:"); //sbSummary2.AppendLine("新增:" + InsertList.Count + "筆資料"); //sbSummary2.AppendLine("更新:" + UpdateList.Count + "筆資料"); //sbSummary2.AppendLine("未更動:" + NochangeCount + "筆資料"); return(""); }
private void btnConfirm_Click(object sender, EventArgs e) { if (UpdateRecordEditorPanle.Controls.Count > 0) { IUpdateRecordInfo IU; IU = UpdateRecordEditorPanle.Controls[0] as IUpdateRecordInfo; _StudUpdateRec = IU.GetStudUpdateRecord(); _prlp = IU.GetLogData(); int codeInt; if (_StudUpdateRec != null) { if (int.TryParse(_StudUpdateRec.UpdateCode, out codeInt) && _actMode == actMode.新增) { int icode; List <SHUpdateRecordRecord> UpRec01List = new List <SHUpdateRecordRecord>(); // 檢查是否有新生異動 foreach (SHUpdateRecordRecord rec in SHUpdateRecord.SelectByStudentID(_StudentID)) { if (int.TryParse(rec.UpdateCode, out icode)) { if (icode > 0 && icode < 100) { UpRec01List.Add(rec); } } } if (UpRec01List.Count > 0 && codeInt < 100) { if (FISCA.Presentation.Controls.MsgBox.Show("已有" + UpRec01List.Count + "筆新生異動,是否覆蓋", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == System.Windows.Forms.DialogResult.Yes) { SHUpdateRecord.Delete(UpRec01List); } else { return; } } // 檢查是否有畢業異動 List <SHUpdateRecordRecord> UpRec05List = (from data in SHUpdateRecord.SelectByStudentID(_StudentID) where data.UpdateCode == "501" select data).ToList(); if (UpRec05List.Count > 0 && codeInt == 501) { if (FISCA.Presentation.Controls.MsgBox.Show("已有" + UpRec01List.Count + "筆畢業異動,是否覆蓋", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == System.Windows.Forms.DialogResult.Yes) { SHUpdateRecord.Delete(UpRec05List); } else { return; } } } } if (_StudUpdateRec != null) { // 儲存學年度學期 年級 _StudUpdateRec.SchoolYear = intSchoolYear.Value; _StudUpdateRec.Semester = intSemester.Value; if (cbxGradeYear.Text == "延修生") { _StudUpdateRec.GradeYear = "延修生"; } else { _StudUpdateRec.GradeYear = cbxGradeYear.Text; } // 儲存異動資料 string strItemName = ""; if (_actMode == actMode.新增) { SHUpdateRecord.Insert(_StudUpdateRec); strItemName = "新增:"; } else { SHUpdateRecord.Update(_StudUpdateRec); strItemName = "修改:"; } SHStudentRecord studRec = SHStudent.SelectByID(_StudentID); // Log strItemName += "學生姓名:" + studRec.Name + _actMode.ToString(); _prlp.SetActionBy("學生", strItemName); _prlp.SaveLog("", ":", "student", _StudentID); _checkSave = true; // 取得 UpdateCode int intUpdateCode; int.TryParse(_StudUpdateRec.UpdateCode, out intUpdateCode); // 學生資料 Cache List <SHStudentRecord> AllStudRec = null; // 復學,學生狀態是非一般,輸入異動代碼是復學,問使用者是否轉成一般。 if (intUpdateCode >= 221 && intUpdateCode <= 226 && studRec.Status != K12.Data.StudentRecord.StudentStatus.一般) { if (FISCA.Presentation.Controls.MsgBox.Show("請問是否將學生狀態變更成一般?", "提醒", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { if (AllStudRec == null) { AllStudRec = SHStudent.SelectAll(); } // 檢查將變更學生狀態 // 身分證 List <string> studIDNumber = (from stud in AllStudRec where stud.Status == K12.Data.StudentRecord.StudentStatus.一般 && stud.IDNumber == studRec.IDNumber select stud.ID).ToList(); // 學號 List <string> studNumber = (from stud in AllStudRec where stud.Status == K12.Data.StudentRecord.StudentStatus.一般 && stud.StudentNumber == studRec.StudentNumber select stud.ID).ToList(); if (studNumber.Count > 0) { FISCA.Presentation.Controls.MsgBox.Show("在一般狀態有相同的學號:" + studRec.StudentNumber + ",無法變更學生狀態"); } if (studIDNumber.Count > 0) { FISCA.Presentation.Controls.MsgBox.Show("在一般狀態有相同的身分證號:" + studRec.IDNumber + ",無法變更學生狀態"); } if (studIDNumber.Count == 0 && studNumber.Count == 0) { studRec.Status = K12.Data.StudentRecord.StudentStatus.一般; SHStudent.Update(studRec); } } } // 轉出,學生狀態是一般,輸入異動代碼是轉出,問使用者是否轉成畢業或離校。 if (intUpdateCode >= 311 && intUpdateCode <= 316 && studRec.Status == K12.Data.StudentRecord.StudentStatus.一般) { if (FISCA.Presentation.Controls.MsgBox.Show("請問是否將學生狀態變更成畢業或離校?", "提醒", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { if (AllStudRec == null) { AllStudRec = SHStudent.SelectAll(); } // 檢查將變更學生狀態 // 身分證 List <string> studIDNumber = (from stud in AllStudRec where stud.Status == K12.Data.StudentRecord.StudentStatus.畢業或離校 && stud.IDNumber == studRec.IDNumber select stud.ID).ToList(); // 學號 List <string> studNumber = (from stud in AllStudRec where stud.Status == K12.Data.StudentRecord.StudentStatus.畢業或離校 && stud.StudentNumber == studRec.StudentNumber select stud.ID).ToList(); if (studNumber.Count > 0) { FISCA.Presentation.Controls.MsgBox.Show("在畢業或離校狀態有相同的學號:" + studRec.StudentNumber + ",無法變更學生狀態"); } if (studIDNumber.Count > 0) { FISCA.Presentation.Controls.MsgBox.Show("在畢業或離校狀態有相同的身分證號:" + studRec.IDNumber + ",無法變更學生狀態"); } if (studIDNumber.Count == 0 && studNumber.Count == 0) { studRec.Status = K12.Data.StudentRecord.StudentStatus.畢業或離校; SHStudent.Update(studRec); } } } // 休學,學生狀態是一般,輸入異動代碼是休學,問使用者是否轉成休學。 if (intUpdateCode >= 341 && intUpdateCode <= 349 && studRec.Status == K12.Data.StudentRecord.StudentStatus.一般) { if (FISCA.Presentation.Controls.MsgBox.Show("請問是否將學生狀態變更成休學?", "提醒", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { if (AllStudRec == null) { AllStudRec = SHStudent.SelectAll(); } // 檢查將變更學生狀態 // 身分證 List <string> studIDNumber = (from stud in AllStudRec where stud.Status == K12.Data.StudentRecord.StudentStatus.休學 && stud.IDNumber == studRec.IDNumber select stud.ID).ToList(); // 學號 List <string> studNumber = (from stud in AllStudRec where stud.Status == K12.Data.StudentRecord.StudentStatus.休學 && stud.StudentNumber == studRec.StudentNumber select stud.ID).ToList(); if (studNumber.Count > 0) { FISCA.Presentation.Controls.MsgBox.Show("在休學狀態有相同的學號:" + studRec.StudentNumber + ",無法變更學生狀態"); } if (studIDNumber.Count > 0) { FISCA.Presentation.Controls.MsgBox.Show("在休學狀態有相同的身分證號:" + studRec.IDNumber + ",無法變更學生狀態"); } if (studIDNumber.Count == 0 && studNumber.Count == 0) { studRec.Status = K12.Data.StudentRecord.StudentStatus.休學; SHStudent.Update(studRec); } } } this.Close(); // 畫面同步 SmartSchool.StudentRelated.Student.Instance.SyncAllBackground(); } } }
// 科目學期成績資料 private void ProduceSHSemesterScoreData(SHStudentRecord pStudent, DataSet schoolRollTable, int yIndex, int pSchoolYear, int pSemester, DataPool dataPool, List<SHSubjectSemesterScoreInfo> pSHSubjectSemesterScoreInfo) { if (pSHSubjectSemesterScoreInfo == null) return; string prefix = "Y" + yIndex + "S" + pSemester; // 後期中等教育核心科目標示 schoolRollTable.Tables.Add(pSHSubjectSemesterScoreInfo.Select(x => (x.CoreSubject ? coreSubjectSign : "")).ToDataTable(prefix + "CoreSubjectSign", "核心科目標示")); // 綜合高中學程核心課程標示 schoolRollTable.Tables.Add(pSHSubjectSemesterScoreInfo.Select(x => ((dataPool.IsCoreCourse(x.StudentID, x.SubjectName, x.Level)) ? coreCourseSign : "")).ToDataTable(prefix + "CoreCourseSign", "核心課程標示")); // 科目名稱 schoolRollTable.Tables.Add(pSHSubjectSemesterScoreInfo.Select(x => x.SubjectName).ToDataTable(prefix + "Subject", "科目名稱")); // 學分 schoolRollTable.Tables.Add(pSHSubjectSemesterScoreInfo.Select(x => x.Credit).ToDataTable(prefix + "Credit", "學分")); //_CoreCourseTable.ForEach(delegate(String name) //{ // if (!String.IsNullOrEmpty(name) && key.IndexOf(name) >= 0) // youGotIt = true; //}); // 必選修 Dictionary<bool?, string> d = new Dictionary<bool?, string>(); d.Add(true, "必"); d.Add(false, "選"); schoolRollTable.Tables.Add(pSHSubjectSemesterScoreInfo.Select(x => x.Required).ConvertToString(d).ToDataTable(prefix + "Required", "必/選修")); // 校/部訂 schoolRollTable.Tables.Add(pSHSubjectSemesterScoreInfo.Select(x => (x.RequiredBy.Length == 0 ? "" : x.RequiredBy.Substring(0, 1))).ToDataTable(prefix + "RequiredBy", "校/部訂")); // 級別 schoolRollTable.Tables.Add(pSHSubjectSemesterScoreInfo.Select(x => x.Level).ToDataTable(prefix + "Level", "級別")); // 羅馬數字級別 schoolRollTable.Tables.Add(pSHSubjectSemesterScoreInfo.Select(x => Util.NumberToRomanChar((x.Level.HasValue ? x.Level.Value : 0))).ToDataTable(prefix + "RomanLevel", "羅馬數字級別")); // 原始成績 schoolRollTable.Tables.Add(pSHSubjectSemesterScoreInfo.Select(x => x.Score).ToDataTable(prefix + "Score", "原始成績")); // 補考成績 schoolRollTable.Tables.Add(pSHSubjectSemesterScoreInfo.Select(x => x.ReExamScore).ToDataTable(prefix + "ReExamScore", "補考成績")); // 手動調整成績 schoolRollTable.Tables.Add(pSHSubjectSemesterScoreInfo.Select(x => x.ManualScore).ToDataTable(prefix + "ManualScore", "手動調整成績")); // 學年擇優成績 schoolRollTable.Tables.Add(pSHSubjectSemesterScoreInfo.Select(x => x.SchoolYearAdjustScore).ToDataTable(prefix + "SchoolYearAdjustScore", "學年擇優成績")); // 重修成績 schoolRollTable.Tables.Add(pSHSubjectSemesterScoreInfo.Select(x => x.ReCourseScore).ToDataTable(prefix + "ReCourseScore", "重修成績")); // 成績加符號標示 List<string> ScoreWithSign = new List<string>(); // 擇優成績 List<string> ScoreBetter = new List<string>(); // 未取得學分標示 List<string> ScoreNoPass = new List<string>(); foreach (SHSubjectSemesterScoreInfo ss in pSHSubjectSemesterScoreInfo) { // 不計學分不列舉,此邏輯為 ischool 之現況(收集資料時已篩汰) // 不評分要列舉 // 所有分項要列舉(不判斷科目是否屬於「學業」之分項) //if (ss.NotIncludedInCredit.HasValue && ss.NotIncludedInCredit.Value) // continue; decimal? scoreBetter = null; string scoreSign = string.Empty; string scoreWithSign = string.Empty; if (ss.Score.HasValue) scoreBetter = ss.Score.Value; // 手動調整成績 if (ss.ManualScore.HasValue) { if (scoreBetter.HasValue) { if (ss.ManualScore.Value > scoreBetter.Value) { scoreBetter = ss.ManualScore.Value; scoreSign = manualAdjustSign; } } else { scoreBetter = ss.ManualScore.Value; scoreSign = manualAdjustSign; } } // 學年擇優成績 if (ss.SchoolYearAdjustScore.HasValue) { if (scoreBetter.HasValue) { if (ss.SchoolYearAdjustScore.Value > scoreBetter.Value) { scoreBetter = ss.SchoolYearAdjustScore.Value; scoreSign = schoolYearAdjustSign; } } else { scoreBetter = ss.SchoolYearAdjustScore.Value; scoreSign = schoolYearAdjustSign; } } // 補考成績 if (ss.ReExamScore.HasValue) { if (scoreBetter.HasValue) { if (ss.ReExamScore.Value > scoreBetter.Value) { scoreBetter = ss.ReExamScore.Value; scoreSign = resitSign; } } else { scoreBetter = ss.ReExamScore.Value; scoreSign = resitSign; } } scoreWithSign = scoreSign + (scoreBetter.HasValue ? scoreBetter.Value.ToString() : ""); // 不及格標示 if (ss.Pass.HasValue) { if (!ss.Pass.Value) ScoreNoPass.Add(failedSign); else ScoreNoPass.Add(""); } else ScoreNoPass.Add(""); // 重修成績 if (ss.ReCourseScore.HasValue) scoreWithSign += retakeSign + ss.ReCourseScore.Value; ScoreWithSign.Add(scoreWithSign); ScoreBetter.Add(scoreBetter.HasValue ? scoreBetter.Value.ToString() : string.Empty); } // 成績加符號標示 schoolRollTable.Tables.Add(ScoreWithSign.ToDataTable(prefix + "ScoreWithSign", "成績加符號標示")); // 擇優成績 schoolRollTable.Tables.Add(ScoreBetter.ToDataTable(prefix + "ScoreBetter", "擇優成績")); // 未取得學分標示 schoolRollTable.Tables.Add(ScoreNoPass.ToDataTable(prefix + "ScoreNoPass", "未取得學分標示")); }
public CommentLogRobot(SHStudentRecord student) { _student = student; }
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(StudentNumberMax); 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 取得驗證需要的資料 SHCourse.RemoveAll(); _worker.ReportProgress(5, "訊息:取得學生資料…"); List <StudentObj> studentList = GetInSchoolStudents(); List <string> s_ids = new List <string>(); Dictionary <string, List <string> > studentNumberToStudentIDs = new Dictionary <string, List <string> >(); foreach (StudentObj student in studentList) { string sn = student.StudentNumber;// SCValidatorCreator.GetStudentNumberFormat(student.StudentNumber); if (!studentNumberToStudentIDs.ContainsKey(sn)) { studentNumberToStudentIDs.Add(sn, new List <string>()); } studentNumberToStudentIDs[sn].Add(student.StudentID); } foreach (string each in studentNumberToStudentIDs.Keys) { if (studentNumberToStudentIDs[each].Count > 1) { //學號重覆 } } foreach (var dr in drCollection) { if (studentNumberToStudentIDs.ContainsKey(dr.StudentNumber)) { s_ids.AddRange(studentNumberToStudentIDs[dr.StudentNumber]); } } studentList.Clear(); _worker.ReportProgress(10, "訊息:取得課程資料…"); List <SHCourseRecord> courseList = SHCourse.SelectBySchoolYearAndSemester(SchoolYear, Semester); List <SHAEIncludeRecord> aeList = SHAEInclude.SelectAll(); //List<JHSCAttendRecord> scaList = JHSCAttend.SelectAll(); var c_ids = from course in courseList select course.ID; _worker.ReportProgress(15, "訊息:取得修課資料…"); //List<JHSCAttendRecord> scaList2 = JHSCAttend.SelectByStudentIDAndCourseID(s_ids, c_ids.ToList<string>()); List <SHSCAttendRecord> scaList = new List <SHSCAttendRecord>(); FunctionSpliter <string, SHSCAttendRecord> spliter = new FunctionSpliter <string, SHSCAttendRecord>(300, 3); spliter.Function = delegate(List <string> part) { return(SHSCAttend.Select(part, c_ids.ToList <string>(), null, SchoolYear.ToString(), Semester.ToString())); }; scaList = spliter.Execute(s_ids); _worker.ReportProgress(20, "訊息:取得試別資料…"); List <SHExamRecord> examList = SHExam.SelectAll(); #endregion #region 註冊驗證 _worker.ReportProgress(30, "訊息:載入驗證規則…"); _rawDataValidator.Register(new SubjectCodeValidator()); _rawDataValidator.Register(new ClassCodeValidator()); _rawDataValidator.Register(new ExamCodeValidator()); SCValidatorCreator scCreator = new SCValidatorCreator(SHStudent.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(45, "訊息:進行驗證中…"); 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 取得學生的評量成績 _worker.ReportProgress(65, "訊息:取得學生評量成績…"); _deleteScoreList.Clear(); _addScoreList.Clear(); AddScoreDic.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, SHSCETakeRecord> sceList = new Dictionary <string, SHSCETakeRecord>(); FunctionSpliter <string, SHSCETakeRecord> spliterSCE = new FunctionSpliter <string, SHSCETakeRecord>(300, 3); spliterSCE.Function = delegate(List <string> part) { return(SHSCETake.Select(null, null, null, null, part)); }; foreach (SHSCETakeRecord 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, SHExamRecord> examTable = new Dictionary <string, SHExamRecord>(); Dictionary <string, SHSCAttendRecord> scaTable = new Dictionary <string, SHSCAttendRecord>(); foreach (SHExamRecord exam in examList) { if (!examTable.ContainsKey(exam.Name)) { examTable.Add(exam.Name, exam); } } foreach (SHSCAttendRecord sca in scaList) { string key = GetCombineKey(sca.RefStudentID, sca.RefCourseID); if (!scaTable.ContainsKey(key)) { scaTable.Add(key, sca); } } _worker.ReportProgress(80, "訊息:成績資料建立…"); foreach (DataRecord dr in drCollection) { SHStudentRecord student = student = scCreator.StudentNumberDictionary[dr.StudentNumber]; SHExamRecord exam = examTable[dr.Exam]; List <SHCourseRecord> courses = new List <SHCourseRecord>(); foreach (SHCourseRecord course in scCreator.StudentCourseInfo.GetCourses(dr.StudentNumber)) { if (dr.Subjects.Contains(course.Subject)) { courses.Add(course); } } foreach (SHCourseRecord course in courses) { string key = GetCombineKey(student.ID, course.ID, exam.ID); if (sceList.ContainsKey(key)) { _deleteScoreList.Add(sceList[key]); } SHSCETakeRecord sh = new SHSCETakeRecord(); sh.RefCourseID = course.ID; sh.RefExamID = exam.ID; sh.RefSCAttendID = scaTable[GetCombineKey(student.ID, course.ID)].ID; sh.RefStudentID = student.ID; //轉型Double再轉回decimal,可去掉小數點後的0 double reScore = (double)dr.Score; decimal Score = decimal.Parse(reScore.ToString()); if (Global.StudentDocRemove) { string qq = Score.ToString(); if (qq.Contains(".")) { string[] kk = qq.Split('.'); sh.Score = decimal.Parse(kk[0]); } else { // sh.Score = decimal.Parse(Score.ToString()); } } else { sh.Score = decimal.Parse(Score.ToString()); } //sceNew.Effort = _effortMapper.GetCodeByScore(dr.Score); //是否有重覆的學生,課程,評量 if (!AddScoreDic.ContainsKey(sh.RefStudentID + "_" + course.ID + "_" + exam.ID)) { _addScoreList.Add(sh); AddScoreDic.Add(sh.RefStudentID + "_" + course.ID + "_" + exam.ID, sh); } } } #endregion _worker.ReportProgress(100, "訊息:背景作業完成…"); 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.DoWork += new DoWorkEventHandler(_upload_DoWork); _upload.RunWorkerCompleted += new RunWorkerCompletedEventHandler(_upload_RunWorkerCompleted); _warn = new BackgroundWorker(); _warn.WorkerReportsProgress = true; _warn.DoWork += delegate(object sender, DoWorkEventArgs e) { _warn.ReportProgress(0, "產生警告訊息..."); examDict = new Dictionary <string, string>(); foreach (SHExamRecord exam in SHExam.SelectAll()) { if (!examDict.ContainsKey(exam.ID)) { examDict.Add(exam.ID, exam.Name); } } WarningForm form = new WarningForm(); int count = 0; foreach (SHSCETakeRecord sce in _deleteScoreList) { // 當成績資料是空值跳過 //if (sce.Score.HasValue == false && sce.Effort.HasValue == false && string.IsNullOrEmpty(sce.Text)) //if (sce.Score == null && string.IsNullOrEmpty(sce.Text)) // continue; count++; SHStudentRecord student = SHStudent.SelectByID(sce.RefStudentID); SHCourseRecord course = SHCourse.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; string scoreName = sce.RefStudentID + "_" + sce.RefCourseID + "_" + sce.RefExamID; if (AddScoreDic.ContainsKey(scoreName)) { form.AddMessage(student.ID, s, string.Format("學生在「{0}」課程「{1}」中已有成績「{2}」將修改為「{3}」。", course.Name, exam, sce.Score, AddScoreDic[scoreName].Score)); } else { form.AddMessage(student.ID, s, string.Format("學生在「{0}」課程「{1}」中已有成績「{2}」。", course.Name, exam, sce.Score)); } _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 <SHSCETakeRecord>(); _deleteScoreList = new List <SHSCETakeRecord>(); AddScoreDic = new Dictionary <string, SHSCETakeRecord>(); examDict = new Dictionary <string, string>(); }
/// <summary> /// 更新學年科目名稱 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnChangeSubject_Click(object sender, System.EventArgs e) { if (!IsInput() && string.IsNullOrEmpty("" + cmbSubjects.SelectedItem) && !string.IsNullOrEmpty(txtChangeSubject.Text)) { MessageBox.Show("請完整輸入欄位資訊!"); return; } int SchoolYear = K12.Data.Int.Parse("" + cmbSchoolYear.SelectedItem); string Subject = "" + cmbSubjects.SelectedItem; string ChangeSubject = txtChangeSubject.Text; strLog = new StringBuilder(); strLog.AppendLine("『更改學年科目名稱』"); int UpdateCount = 0; List <SHSchoolYearScoreRecord> FinalUpdateRecords = new List <SHSchoolYearScoreRecord>(); UpdateRecords = StudentScores.Where(x => x.SchoolYear == SchoolYear).ToList(); foreach (SHSchoolYearScoreRecord record in UpdateRecords) { SHStudentRecord s = StudentRecords.Find(x => x.ID.Equals(record.RefStudentID)); List <string> UpdateSubjects = new List <string>(); foreach (SHSchoolYearScoreSubject SubjectScore in record.Subjects) { if (SubjectScore.Subject.Equals(Subject)) { UpdateSubjects.Add(SubjectScore.Subject); UpdateCount++; } } if (UpdateSubjects.Count > 0) { FinalUpdateRecords.Add(record); strLog.AppendLine("系統編號:" + record.ID + ",學生編號:" + s.ID + ",學生學號:" + s.StudentNumber + ",學生姓名:" + s.Name + ",學年度:" + record.SchoolYear + ",更新後科目名稱:" + ChangeSubject); } foreach (string UpdateSubject in UpdateSubjects) { SHSchoolYearScoreSubject Score = record.Subjects.Find(x => x.Subject.Equals(UpdateSubject)); record.Subjects.Remove(Score); Score.Subject = ChangeSubject; record.Subjects.Add(Score); } } int SuccessCount = 0; if (K12.Data.Utility.Utility.IsNullOrEmpty(FinalUpdateRecords)) { MessageBox.Show("沒有資料不需更新!!"); return; } try { if (MessageBox.Show("與您確認是否要更新總共" + UpdateCount + "筆成績?提醒在更新前先備份該位學生所有學年科目成績,並在成功後備份『更新紀錄』。", "更新學年科目成績確認", MessageBoxButtons.YesNo) == DialogResult.Yes) { SuccessCount = SHSchoolYearScore.Update(FinalUpdateRecords); MessageBox.Show("成功更新筆數:" + UpdateCount); txtLog.Text = txtLog.Text + strLog.ToString(); FISCA.LogAgent.ApplicationLog.Log("成績模組.學年科目成績資料維護", strLog.ToString()); } } catch (Exception ve) { MessageBox.Show(ve.Message); txtLog.Text = txtLog.Text + ve.Message; } finally { RefreshUI(); } }
//依學生學號排序副程式 static int CompareStudentNumber(SHStudentRecord a, SHStudentRecord b) { return a.StudentNumber.CompareTo(b.StudentNumber); }
// 科目學年成績資料 private void ProduceSHYearScoreData(SHStudentRecord pStudent, DataSet schoolRollTable, int yIndex, List<SHSubjectYearScoreInfo> pSHSubjectYearScoreInfo) { if (pSHSubjectYearScoreInfo == null) return; if (pSHSubjectYearScoreInfo.Count == 0) return; string prefix = "Y" + yIndex.ToString(); // 課時 schoolRollTable.Tables.Add(pSHSubjectYearScoreInfo.Select(x => x.Hour).ToDataTable(prefix + "Hour", "課時")); // 學分 schoolRollTable.Tables.Add(pSHSubjectYearScoreInfo.Select(x => (x.Credit.HasValue ? x.Credit.Value.ToString() : "")).ToDataTable(prefix + "Credit", "學分")); //// 原始成績 //schoolRollTable.Tables.Add(pSHSubjectYearScoreInfo.Select(x => (x.Score.HasValue ? x.Score.Value.ToString() : "")).ToDataTable(prefix + "ScoreWithSign", "原始成績")); // 補考成績 schoolRollTable.Tables.Add(pSHSubjectYearScoreInfo.Select(x => x.ReExamScore).ToDataTable(prefix + "ReExamScore", "補考成績")); // 重修成績 schoolRollTable.Tables.Add(pSHSubjectYearScoreInfo.Select(x => x.ReCourseScore).ToDataTable(prefix + "ReCourseScore", "重修成績")); // 學年實得學分 schoolRollTable.Tables.Add(pSHSubjectYearScoreInfo.Sum(x => x.Credit).ToDataTable(prefix + "AcquiredCredit", "學年實得學分")); /// 以下為新加的 2014/8/11 // 成績加符號標示 List<string> ScoreWithSign = new List<string>(); // 擇優成績 List<string> ScoreBetter = new List<string>(); // 未取得學分標示 List<string> ScoreNoPass = new List<string>(); foreach (SHSubjectYearScoreInfo ss in pSHSubjectYearScoreInfo) { decimal? scoreBetter = null; string scoreSign = string.Empty; string scoreWithSign = string.Empty; if (ss.Score.HasValue) scoreBetter = ss.Score.Value; // 補考成績 if (ss.ReExamScore.HasValue) { if (scoreBetter.HasValue) { if (ss.ReExamScore.Value > scoreBetter.Value) { scoreBetter = ss.ReExamScore.Value; scoreSign = resitSign; } } else { scoreBetter = ss.ReExamScore.Value; scoreSign = resitSign; } } scoreWithSign = scoreSign + (scoreBetter.HasValue ? scoreBetter.Value.ToString() : ""); // 不及格標示 if ((scoreBetter.HasValue ? scoreBetter.Value : 0) < dataPool.GetPassingStandard(pStudent.ID, ss.GradeYear)) { ScoreNoPass.Add(failedSign); } else ScoreNoPass.Add(""); // 重修成績 if (ss.ReCourseScore.HasValue) scoreWithSign += retakeSign + ss.ReCourseScore.Value; ScoreWithSign.Add(scoreWithSign); ScoreBetter.Add(scoreBetter.HasValue ? scoreBetter.Value.ToString() : string.Empty); } // 成績加符號標示 schoolRollTable.Tables.Add(ScoreWithSign.ToDataTable(prefix + "ScoreWithSign", "成績加符號標示")); // 擇優成績 schoolRollTable.Tables.Add(ScoreBetter.ToDataTable(prefix + "ScoreBetter", "擇優成績")); // 未取得學分標示 schoolRollTable.Tables.Add(ScoreNoPass.ToDataTable(prefix + "ScoreNoPass", "未取得學分標示")); }
public override void InitializeImport(SmartSchool.API.PlugIn.Import.ImportWizard wizard) { //學生資訊 Dictionary <string, SHStudentRecord> students = new Dictionary <string, SHStudentRecord>(); //學生修課資訊 studentID -> List:SCAttendRecord Dictionary <string, List <SHSCAttendRecord> > scattends = new Dictionary <string, List <SHSCAttendRecord> >(); //學生修習的課程 courseID -> CourseRecord Dictionary <string, SHCourseRecord> courses = new Dictionary <string, SHCourseRecord>(); //所有課程(依學年度學期分開) schoolYear_semester -> (courseName -> CourseRecord) Dictionary <string, Dictionary <string, SHCourseRecord> > allcourses = new Dictionary <string, Dictionary <string, SHCourseRecord> >(); //studentID_schoolYear_semester -> List:courseName Dictionary <string, List <string> > semesterCourseName = new Dictionary <string, List <string> >(); //準備加入修課的資料 studentID -> (schoolYear_semester_courseName -> RowData) Dictionary <string, Dictionary <string, RowData> > prepareAttends = new Dictionary <string, Dictionary <string, RowData> >(); wizard.PackageLimit = 3000; wizard.ImportableFields.Add("課程系統編號"); wizard.ImportableFields.AddRange("學年度", "學期"); wizard.ImportableFields.Add("課程名稱"); wizard.ImportableFields.AddRange("班級", "座號"); wizard.RequiredFields.AddRange("學年度", "學期"); wizard.RequiredFields.Add("課程名稱"); wizard.ValidateStart += delegate(object sender, SmartSchool.API.PlugIn.Import.ValidateStartEventArgs e) { #region 取得學生資訊 foreach (SHStudentRecord stu in SHStudent.SelectByIDs(e.List)) { if (!students.ContainsKey(stu.ID)) { students.Add(stu.ID, stu); } } #endregion #region 取得修課記錄 MultiThreadWorker <string> loader1 = new MultiThreadWorker <string>(); loader1.MaxThreads = 3; loader1.PackageSize = 250; loader1.PackageWorker += delegate(object sender1, PackageWorkEventArgs <string> e1) { foreach (SHSCAttendRecord record in SHSCAttend.SelectByStudentIDAndCourseID(e1.List, new string[] { })) { if (!scattends.ContainsKey(record.RefStudentID)) { scattends.Add(record.RefStudentID, new List <SHSCAttendRecord>()); } scattends[record.RefStudentID].Add(record); if (!courses.ContainsKey(record.RefCourseID)) { courses.Add(record.RefCourseID, null); } } }; loader1.Run(e.List); #endregion #region 取得課程資訊 MultiThreadWorker <string> loader2 = new MultiThreadWorker <string>(); loader2.MaxThreads = 3; loader2.PackageSize = 250; loader2.PackageWorker += delegate(object sender2, PackageWorkEventArgs <string> e2) { foreach (SHCourseRecord record in SHCourse.SelectByIDs(new List <string>(e2.List))) { if (courses.ContainsKey(record.ID)) { courses[record.ID] = record; } } }; loader2.Run(courses.Keys); foreach (SHCourseRecord course in SHCourse.SelectAll()) { string key = course.SchoolYear + "_" + course.Semester; if (!allcourses.ContainsKey(key)) { allcourses.Add(key, new Dictionary <string, SHCourseRecord>()); } if (!allcourses[key].ContainsKey(course.Name)) { allcourses[key].Add(course.Name, course); } } #endregion }; wizard.ValidateRow += delegate(object sender, SmartSchool.API.PlugIn.Import.ValidateRowEventArgs e) { int i; #region 檢查學生是否存在 SHStudentRecord student = null; if (students.ContainsKey(e.Data.ID)) { student = students[e.Data.ID]; } else { e.ErrorMessage = "壓根就沒有這個學生" + e.Data.ID; return; } #endregion #region 驗證各個欄位格式 bool inputFormatPass = true; foreach (string field in e.SelectFields) { string value = e.Data[field]; switch (field) { default: break; case "學年度": case "學期": if (value == "" || !int.TryParse(value, out i)) { inputFormatPass &= false; e.ErrorFields.Add(field, "必須填入整數"); } break; case "課程名稱": if (value == "") { inputFormatPass &= false; e.ErrorFields.Add(field, "必須填入課程名稱"); } break; case "班級": if (value == "") { } break; case "座號": if (value != "" && !int.TryParse(value, out i)) { inputFormatPass &= false; e.ErrorFields.Add(field, "必須填入空白或整數"); } break; } } #endregion //輸入格式正確才會針對情節做檢驗 #region 驗證各種情節 if (inputFormatPass) { string errorMessage = ""; string sy = e.Data["學年度"]; string se = e.Data["學期"]; string courseName = e.Data["課程名稱"]; string key = e.Data.ID + "_" + sy + "_" + se; string semsKey = sy + "_" + se; //int schoolyear = Framework.Int.ParseInt(sy); //int semester = Framework.Int.ParseInt(se); #region 一個學年度學期不能有重覆的課程名稱 if (!semesterCourseName.ContainsKey(key)) { semesterCourseName.Add(key, new List <string>()); } if (semesterCourseName[key].Contains(courseName)) { errorMessage += (errorMessage == "" ? "" : "\n") + " 同一學年度學期不允許修習多筆相同名稱的課程"; } else { semesterCourseName[key].Add(courseName); } #endregion #region 檢查課程是否存在系統中 bool noCourse = false; if (!allcourses.ContainsKey(semsKey)) { noCourse = true; errorMessage += (errorMessage == "" ? "" : "\n") + " 系統中找不到該課程"; } else if (!allcourses[semsKey].ContainsKey(courseName)) { noCourse = true; errorMessage += (errorMessage == "" ? "" : "\n") + " 系統中找不到該課程"; } else { } #endregion #region 檢查學生是否有修此課程 bool attended = false; if (scattends.ContainsKey(e.Data.ID)) { foreach (SHSCAttendRecord record in scattends[e.Data.ID]) { if (courses[record.RefCourseID].Name == courseName && "" + courses[record.RefCourseID].SchoolYear == sy && "" + courses[record.RefCourseID].Semester == se) { attended = true; } } } else //學生沒修半堂課 { } if (!attended && !noCourse) { if (!e.WarningFields.ContainsKey("無修課記錄")) { e.WarningFields.Add("無修課記錄", "學生在此學期並無修習此課程,將會新增修課記錄"); } if (!prepareAttends.ContainsKey(e.Data.ID)) { prepareAttends.Add(e.Data.ID, new Dictionary <string, RowData>()); } if (!prepareAttends[e.Data.ID].ContainsKey(semsKey + "_" + courseName)) { prepareAttends[e.Data.ID].Add(semsKey + "_" + courseName, e.Data); } } #endregion e.ErrorMessage = errorMessage; } #endregion }; wizard.ImportPackage += delegate(object sender, SmartSchool.API.PlugIn.Import.ImportPackageEventArgs e) { Dictionary <string, List <RowData> > id_Rows = new Dictionary <string, List <RowData> >(); #region 分包裝 foreach (RowData data in e.Items) { if (!id_Rows.ContainsKey(data.ID)) { id_Rows.Add(data.ID, new List <RowData>()); } id_Rows[data.ID].Add(data); } #endregion List <SHSCAttendRecord> insertList = new List <SHSCAttendRecord>(); List <SHSCAttendRecord> updateList = new List <SHSCAttendRecord>(); //交叉比對各學生資料 #region 交叉比對各學生資料 foreach (string id in id_Rows.Keys) { SHStudentRecord studentRec = students[id]; #region 處理要新增的修課記錄 if (prepareAttends.ContainsKey(id)) { foreach (RowData data in prepareAttends[id].Values) { string sy = data["學年度"]; string se = data["學期"]; string semsKey = sy + "_" + se; string courseName = data["課程名稱"]; if (allcourses.ContainsKey(semsKey) && allcourses[semsKey].ContainsKey(courseName)) { SHSCAttendRecord record = new SHSCAttendRecord(); record.RefStudentID = id; record.RefCourseID = allcourses[semsKey][courseName].ID; insertList.Add(record); } } } #endregion } try { if (updateList.Count > 0) { #region 分批次兩路上傳 List <List <SHSCAttendRecord> > updatePackages = new List <List <SHSCAttendRecord> >(); List <List <SHSCAttendRecord> > updatePackages2 = new List <List <SHSCAttendRecord> >(); { List <SHSCAttendRecord> package = null; int count = 0; foreach (SHSCAttendRecord var in updateList) { if (count == 0) { package = new List <SHSCAttendRecord>(30); count = 30; if ((updatePackages.Count & 1) == 0) { updatePackages.Add(package); } else { updatePackages2.Add(package); } } package.Add(var); count--; } } Thread threadUpdateSemesterSubjectScore = new Thread(new ParameterizedThreadStart(Update)); threadUpdateSemesterSubjectScore.IsBackground = true; threadUpdateSemesterSubjectScore.Start(updatePackages); Thread threadUpdateSemesterSubjectScore2 = new Thread(new ParameterizedThreadStart(Update)); threadUpdateSemesterSubjectScore2.IsBackground = true; threadUpdateSemesterSubjectScore2.Start(updatePackages2); threadUpdateSemesterSubjectScore.Join(); threadUpdateSemesterSubjectScore2.Join(); #endregion } } catch (Exception ex) { } if (insertList.Count > 0) { #region 分批次兩路上傳 List <List <SHSCAttendRecord> > insertPackages = new List <List <SHSCAttendRecord> >(); List <List <SHSCAttendRecord> > insertPackages2 = new List <List <SHSCAttendRecord> >(); { List <SHSCAttendRecord> package = null; int count = 0; foreach (SHSCAttendRecord var in insertList) { if (count == 0) { package = new List <SHSCAttendRecord>(30); count = 30; if ((insertPackages.Count & 1) == 0) { insertPackages.Add(package); } else { insertPackages2.Add(package); } } package.Add(var); count--; } } Thread threadInsertSemesterSubjectScore = new Thread(new ParameterizedThreadStart(Insert)); threadInsertSemesterSubjectScore.IsBackground = true; threadInsertSemesterSubjectScore.Start(insertPackages); Thread threadInsertSemesterSubjectScore2 = new Thread(new ParameterizedThreadStart(Insert)); threadInsertSemesterSubjectScore2.IsBackground = true; threadInsertSemesterSubjectScore2.Start(insertPackages2); threadInsertSemesterSubjectScore.Join(); threadInsertSemesterSubjectScore2.Join(); #endregion } ApplicationLog.Log("成績系統.匯入匯出", "匯入課程修課學生", "總共匯入" + (insertList.Count + updateList.Count) + "筆課程修課學生。"); #endregion }; }
protected override void OnSaveButtonClick(EventArgs e) { _BeforeEnrollmentRecord.School = txtSchool.Text; _BeforeEnrollmentRecord.SchoolLocation = txtSchoolLocation.Text; _BeforeEnrollmentRecord.ClassName = txtClass.Text; int intSeatNo; if (string.IsNullOrEmpty(txtSeatNo.Text)) { _BeforeEnrollmentRecord.SeatNo = null; } else { if (int.TryParse(txtSeatNo.Text, out intSeatNo)) { _BeforeEnrollmentRecord.SeatNo = intSeatNo; } else { epSeatNo.SetError(txtSeatNo, "請填入數字."); return; } } _BeforeEnrollmentRecord.Memo = txtMemo.Text; int GSchoolYear; if (string.IsNullOrEmpty(txtGraduateSchoolYear.Text)) { _BeforeEnrollmentRecord.GraduateSchoolYear = null; } else { if (int.TryParse(txtGraduateSchoolYear.Text, out GSchoolYear)) { _BeforeEnrollmentRecord.GraduateSchoolYear = GSchoolYear.ToString(); } else { epSeatNo.SetError(txtGraduateSchoolYear, "請填入數字."); return; } } SHBeforeEnrollment.Update(_BeforeEnrollmentRecord); listener.Reset(); SaveButtonVisible = false; CancelButtonVisible = SaveButtonVisible; prlp.SetAfterSaveText("學校名稱", txtSchool.Text); prlp.SetAfterSaveText("所在地", txtSchoolLocation.Text); prlp.SetAfterSaveText("班級", txtClass.Text); prlp.SetAfterSaveText("座號", txtSeatNo.Text); prlp.SetAfterSaveText("備註", txtMemo.Text); prlp.SetAfterSaveText("國中畢業學年度", txtGraduateSchoolYear.Text); prlp.SetActionBy("學籍", "學生前級畢業資訊"); prlp.SetAction("修改學生前級畢業資訊"); SHStudentRecord studRec = SHStudent.SelectByID(PrimaryKey); prlp.SetDescTitle("學生姓名:" + studRec.Name + ",學號:" + studRec.StudentNumber + ","); prlp.SaveLog("", "", "student", PrimaryKey); }
string eveCount; //給Log使用 void bkwNotPassComputer_DoWork(object sender, DoWorkEventArgs e) { SB = new StringBuilder(); //給Log使用 SB.AppendLine("詳細資料:"); //給Log使用 StudIDList.Clear(); //給Log使用 string fileName = (string)((object[])e.Argument)[0]; List <string> studentFieldList = (List <string>)((object[])e.Argument)[1]; List <string> exportFieldList = (List <string>)((object[])e.Argument)[2]; Dictionary <ManualResetEvent, List <RowData> > Filler = (Dictionary <ManualResetEvent, List <RowData> >)((object[])e.Argument)[3]; double totleProgress = 0.0; double packageProgress = 100.0 / Filler.Count; Workbook report = new Workbook(); report.Worksheets[0].Name = _Title; ((BackgroundWorker)sender).ReportProgress(1, _Title + " 資料整理中..."); int RowIndex = 0; int i = 0; //填表頭 for (; i < studentFieldList.Count; i++) { report.Worksheets[0].Cells[0, i].PutValue(studentFieldList[i]); } for (int j = 0; j < exportFieldList.Count; j++) { report.Worksheets[0].Cells[0, i + j].PutValue(exportFieldList[j]); } RowIndex = 1; foreach (ManualResetEvent eve in Filler.Keys) { eve.WaitOne(); eveCount = Filler[eve].Count.ToString(); //給Log使用 if (Filler[eve].Count != 0) { SHStudentRecord stud = SHStudent.SelectByID(Filler[eve][0].ID); } if (RowIndex <= 65535) { double miniProgress = Filler[eve].Count == 0 ? 1 : packageProgress / Filler[eve].Count; double miniTotle = 0; foreach (RowData row in Filler[eve]) { SHStudentRecord student = null; if (row.ID != "") { if (!StudIDList.Contains(row.ID)) //給Log使用 { StudIDList.Add(row.ID); } student = SHStudent.SelectByID(row.ID); } if (student != null) { if (RowIndex <= 65535) { i = 0; for (; i < studentFieldList.Count; i++) { switch (studentFieldList[i]) { case "學生系統編號": report.Worksheets[0].Cells[RowIndex, i].PutValue(student.ID); break; case "學號": report.Worksheets[0].Cells[RowIndex, i].PutValue(student.StudentNumber); break; case "班級": report.Worksheets[0].Cells[RowIndex, i].PutValue(student.Class == null ? "" : student.Class.Name); break; case "座號": report.Worksheets[0].Cells[RowIndex, i].PutValue(student.SeatNo); break; case "姓名": report.Worksheets[0].Cells[RowIndex, i].PutValue(student.Name); break; default: break; } } for (int j = 0; j < exportFieldList.Count; j++) { report.Worksheets[0].Cells[RowIndex, i + j].PutValue(row.ContainsKey(exportFieldList[j]) ? row[exportFieldList[j]] : ""); } } RowIndex++; } miniTotle += miniProgress; ((BackgroundWorker)sender).ReportProgress((int)(totleProgress + miniTotle), _Title + " 處理中..."); } } totleProgress += packageProgress; ((BackgroundWorker)sender).ReportProgress((int)(totleProgress), _Title + " 處理中..."); } for (int k = 0; k < studentFieldList.Count + exportFieldList.Count; k++) { report.Worksheets[0].AutoFitColumn(k, 0, 150); } report.Worksheets[0].FreezePanes(1, 0, 1, studentFieldList.Count + exportFieldList.Count); e.Result = new object[] { report, fileName, RowIndex > 65535 }; }
public override void InitializeImport(SmartSchool.API.PlugIn.Import.ImportWizard wizard) { // 取得學生資料 Dictionary <string, SHStudentRecord> Students = new Dictionary <string, SHStudentRecord>(); // 取得異動資料 Dictionary <string, List <SHUpdateRecordRecord> > UpdateRecs = new Dictionary <string, List <SHUpdateRecordRecord> >(); wizard.PackageLimit = 3000; wizard.ImportableFields.AddRange("班別", "特殊身份代碼", "異動科別", "年級", "異動學號", "異動姓名", "身分證號", "註1", "異動代碼", "異動日期", "原因及事項", "新學號", "更正後資料", "舊班別", "舊科別代碼", "備查日期", "備查文號", "核准日期", "核准文號", "備註"); wizard.RequiredFields.AddRange("異動代碼", "異動日期"); wizard.ValidateStart += delegate(object sender, SmartSchool.API.PlugIn.Import.ValidateStartEventArgs e) { Students.Clear(); UpdateRecs.Clear(); // 取得學生資料 foreach (SHStudentRecord studRec in SHStudent.SelectByIDs(e.List)) { if (!Students.ContainsKey(studRec.ID)) { Students.Add(studRec.ID, studRec); } } foreach (string str in Students.Keys) { List <SHUpdateRecordRecord> UpdRecList = new List <SHUpdateRecordRecord>(); UpdateRecs.Add(str, UpdRecList); } // 取得異動 MultiThreadWorker <string> loader1 = new MultiThreadWorker <string>(); loader1.MaxThreads = 3; loader1.PackageSize = 250; loader1.PackageWorker += delegate(object sender1, PackageWorkEventArgs <string> e1) { foreach (SHUpdateRecordRecord UpdRec in SHUpdateRecord.SelectByStudentIDs(e.List)) { // 過濾非符合標準的異動(目前是學籍) if (!_UpdateCodeList.Contains(UpdRec.UpdateCode)) { continue; } if (UpdateRecs.ContainsKey(UpdRec.StudentID)) { UpdateRecs[UpdRec.StudentID].Add(UpdRec); } } }; loader1.Run(e.List); }; wizard.ValidateRow += delegate(object sender, SmartSchool.API.PlugIn.Import.ValidateRowEventArgs e) { int i = 0; DateTime dt; // 檢查學生是否存在 SHStudentRecord studRec = null; if (Students.ContainsKey(e.Data.ID)) { studRec = Students[e.Data.ID]; } else { e.ErrorMessage = "沒有這位學生" + e.Data.ID; return; } // 驗證格式資料 bool InputFormatPass = true; foreach (string field in e.SelectFields) { string value = e.Data[field].Trim(); //// 驗證$無法匯入 //if (value.IndexOf('$') > -1) //{ // e.ErrorFields.Add(field, "儲存格有$無法匯入."); // break; //} switch (field) { default: break; //// 班別 //case "班別": break; //// 特殊身份代碼 //case "特殊身份代碼": break; //// 異動科別 //case "異動科別": break; //// 年級 //case "年級": break; //// 異動學號 //case "異動學號": break; //// 異動姓名 //case "異動姓名": break; //// 身分證號 //case "身分證號": break; //// 註1 //case "註1": break; //// 異動種類 //case "異動種類": break; // 異動代碼 case "異動代碼": if (!_UpdateCodeList.Contains(value)) { InputFormatPass &= false; e.ErrorFields.Add(field, "非學籍異動代碼!"); } break; // 異動日期(必填) case "異動日期": DateTime dtC1; if (DateTime.TryParse(value, out dtC1)) { } else { InputFormatPass &= false; e.ErrorFields.Add(field, "日期錯誤!"); } break; case "備查日期": case "核准日期": DateTime dtC2; if (value.Trim() != "") { if (DateTime.TryParse(value, out dtC2)) { } else { InputFormatPass &= false; e.ErrorFields.Add(field, "日期錯誤!"); } } break; //// 原因及事項 //case "原因及事項": break; //// 新學號 //case "新學號": break; //// 更正後資料 //case "更正後資料": break; //// 舊班別 //case "舊班別": break; //// 舊科別代碼 //case "舊科別代碼": break; //// 備查日期 //case "備查日期": // break; //// 備查文號 //case "備查文號": break; //// 核准日期 //case "核准日期": break; //// 核准文號 //case "核准文號": break; //// 備註 //case "備註": break; } } }; wizard.ImportPackage += delegate(object sender, SmartSchool.API.PlugIn.Import.ImportPackageEventArgs e) { Dictionary <string, List <RowData> > id_Rows = new Dictionary <string, List <RowData> >(); foreach (RowData data in e.Items) { if (!id_Rows.ContainsKey(data.ID)) { id_Rows.Add(data.ID, new List <RowData>()); } id_Rows[data.ID].Add(data); } List <SHUpdateRecordRecord> InsertList = new List <SHUpdateRecordRecord>(); List <SHUpdateRecordRecord> UpdateList = new List <SHUpdateRecordRecord>(); // 檢查新增或更新方式: // 每筆 Key 為:異動日期+異動代碼+原因及事項,如果三者內容相同更新,如果不同就新增。 foreach (string id in id_Rows.Keys) { DateTime dt; // 讀取工作表內資料 foreach (RowData data in id_Rows[id]) { // 當異動記錄內沒有工作表讀取轉換後學生ID,就跳過。 if (!UpdateRecs.ContainsKey(id)) { continue; } DateTime.TryParse(data["異動日期"], out dt); // 異動代碼 string UpdateCode = string.Empty; if (data.ContainsKey("異動代碼")) { UpdateCode = data["異動代碼"]; } // 取得原因及事項 string UpdateDesc = string.Empty; if (data.ContainsKey("原因及事項")) { UpdateDesc = data["原因及事項"]; } SHUpdateRecordRecord updateRec = null; // 異動日期+異動代碼 (如果相同有當更新,不同就新增) foreach (SHUpdateRecordRecord urr in UpdateRecs[id]) { if (UpdateCode == urr.UpdateCode) { DateTime dt1; DateTime.TryParse(urr.UpdateDate, out dt1); if (dt == dt1) { // 使用原因及事項當作Key if (UpdateDesc == urr.UpdateDescription) { updateRec = urr; } } } } bool isInsert = true; if (updateRec == null) { updateRec = new SHUpdateRecordRecord(); updateRec.StudentID = id; } else { isInsert = false; } // 這段在做資料填入異動紀錄 foreach (string field in e.ImportFields) { string value = data[field].Trim(); switch (field) { // 班別 case "班別": updateRec.ClassType = value; break; // 特殊身份代碼 case "特殊身份代碼": updateRec.SpecialStatus = value; break; // 異動科別 case "異動科別": updateRec.Department = value; break; // 年級 case "年級": updateRec.GradeYear = value; break; // 異動學號 case "異動學號": updateRec.StudentNumber = value; break; // 異動姓名 case "異動姓名": updateRec.StudentName = value; break; // 身分證號 case "身分證號": updateRec.IDNumber = value; break; // 註1 case "註1": updateRec.IDNumberComment = value; break; //// 異動種類 //case "異動種類": // break; // 異動代碼 case "異動代碼": updateRec.UpdateCode = value; break; // 異動日期 case "異動日期": DateTime dt1; if (DateTime.TryParse(value, out dt1)) { updateRec.UpdateDate = dt1.ToShortDateString(); } break; // 原因及事項 case "原因及事項": updateRec.UpdateDescription = value; break; // 新學號 case "新學號": updateRec.NewStudentNumber = value; break; // 更正後資料 case "更正後資料": updateRec.NewData = value; break; // 舊班別 case "舊班別": updateRec.OldClassType = value; break; // 舊科別代碼 case "舊科別代碼": updateRec.OldDepartmentCode = value; break; // 備查日期 case "備查日期": DateTime dt2; if (DateTime.TryParse(value, out dt2)) { updateRec.LastADDate = dt2.ToShortDateString(); } break; // 備查文號 case "備查文號": updateRec.LastADNumber = value; break; // 核准日期 case "核准日期": DateTime dt3; if (DateTime.TryParse(value, out dt3)) { updateRec.ADDate = dt3.ToShortDateString(); } break; // 核准文號 case "核准文號": updateRec.ADNumber = value; break; // 備註 case "備註": updateRec.GraduateComment = value; break; } } if (string.IsNullOrEmpty(updateRec.StudentID) || string.IsNullOrEmpty(updateRec.UpdateDate) || string.IsNullOrEmpty(updateRec.UpdateCode)) { continue; } else { if (isInsert) { InsertList.Add(updateRec); } else { UpdateList.Add(updateRec); } } } } try { if (InsertList.Count > 0) { Insert(InsertList); } if (UpdateList.Count > 0) { Update(UpdateList); } PermRecLogProcess prlp = new PermRecLogProcess(); prlp.SaveLog("學生.匯入異動", "匯入學籍異動", "匯入學籍異動:共新增" + InsertList.Count + "筆資料,共更新:" + UpdateList.Count + "筆資料"); SmartSchool.StudentRelated.Student.Instance.SyncAllBackground(); } catch (Exception ex) { } }; }
private void btnOK_Click(object sender, EventArgs e) { // 檢查是否要修改學生狀態 int UpdateCoodeInt; bool UpdateStudStatus = false; if (int.TryParse(updateRecordInfo1.UpdateCode, out UpdateCoodeInt)) { string StudIDNumber = "", StudNumber = ""; SHStudentRecord stud = SHStudent.SelectByID(updateRecordInfo1.StudentID); if (stud != null) { StudIDNumber = stud.IDNumber; StudNumber = stud.StudentNumber; } // 收集檢查用資料 // 一般 List <string> tmp01 = new List <string>(); // 畢業或離校 List <string> tmp02 = new List <string>(); // 休學 List <string> tmp03 = new List <string>(); foreach (SHStudentRecord studRec in SHStudent.SelectAll()) { if (studRec.Status == K12.Data.StudentRecord.StudentStatus.一般) { tmp01.Add(studRec.IDNumber); tmp01.Add(studRec.StudentNumber); } if (studRec.Status == K12.Data.StudentRecord.StudentStatus.畢業或離校) { tmp02.Add(studRec.IDNumber); tmp02.Add(studRec.StudentNumber); } if (studRec.Status == K12.Data.StudentRecord.StudentStatus.休學) { tmp03.Add(studRec.IDNumber); tmp03.Add(studRec.StudentNumber); } } // 復學 if (UpdateCoodeInt >= 221 && UpdateCoodeInt <= 226) { if (MessageBox.Show("請問是否更改學生狀態成 一般?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes) { // 檢查該狀態是否有相同學號或身分證號學生 if (tmp01.Contains(StudIDNumber) || tmp01.Contains(StudNumber)) { FISCA.Presentation.Controls.MsgBox.Show("在一般狀態已有相同身分證號或學號的學生,無法自動變更狀態。"); } else { UpdateStudStatus = true; stud.Status = K12.Data.StudentRecord.StudentStatus.一般; } } } // 轉出 if (UpdateCoodeInt >= 311 && UpdateCoodeInt <= 316) { if (MessageBox.Show("請問是否更改學生狀態成 畢業或離校?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes) { // 檢查該狀態是否有相同學號或身分證號學生 if (tmp02.Contains(StudIDNumber) || tmp02.Contains(StudNumber)) { FISCA.Presentation.Controls.MsgBox.Show("在畢業或離校狀態已有相同身分證號或學號的學生,無法自動變更狀態。"); } else { UpdateStudStatus = true; stud.Status = K12.Data.StudentRecord.StudentStatus.畢業或離校; } } } // 休學 if (UpdateCoodeInt >= 341 && UpdateCoodeInt <= 349) { if (MessageBox.Show("請問是否更改學生狀態成 休學?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes) { if (MessageBox.Show("請問是否更改學生狀態成 畢業或離校?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes) { // 檢查該狀態是否有相同學號或身分證號學生 if (tmp03.Contains(StudIDNumber) || tmp03.Contains(StudNumber)) { FISCA.Presentation.Controls.MsgBox.Show("在休學狀態已有相同身分證號或學號的學生,無法自動變更狀態。"); } else { UpdateStudStatus = true; stud.Status = K12.Data.StudentRecord.StudentStatus.休學; } } } } // 更新學生狀態 if (UpdateStudStatus) { SHStudent.Update(stud); StudentRelated.Student.Instance.SyncAllBackground(); } } if (updateRecordInfo1.Save()) { _saved = true; if (DataSaved != null) { DataSaved(this, null); } this.Close(); } }
/// <summary> /// 刪除單筆學年科目成績 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnDeleteSubject_Click(object sender, EventArgs e) { if (!IsInput()) { MessageBox.Show("請完整輸入欄位資訊!"); return; } int SchoolYear = K12.Data.Int.Parse("" + cmbSchoolYear.SelectedItem); string Subject = "" + cmbSubjects.SelectedItem; strLog = new StringBuilder(); strLog.AppendLine("『刪除學年科目成績紀錄』"); int RemoveCount = 0; List <SHSchoolYearScoreRecord> FinalUpdateRecords = new List <SHSchoolYearScoreRecord>(); List <SHSchoolYearScoreRecord> FinalDeleteRecords = new List <SHSchoolYearScoreRecord>(); UpdateRecords = StudentScores.Where(x => x.SchoolYear == SchoolYear).ToList(); foreach (SHSchoolYearScoreRecord record in UpdateRecords) { SHStudentRecord s = StudentRecords.Find(x => x.ID.Equals(record.RefStudentID)); List <string> RemoveSubjects = new List <string>(); foreach (SHSchoolYearScoreSubject SubjectScore in record.Subjects) { if (SubjectScore.Subject.Equals(Subject) || string.IsNullOrEmpty(Subject)) { RemoveSubjects.Add(SubjectScore.Subject); RemoveCount++; } } if (RemoveSubjects.Count > 0) { FinalUpdateRecords.Add(record); strLog.AppendLine("系統編號:" + record.ID + ",學生編號:" + s.ID + ",學生學號:" + s.StudentNumber + ",學生姓名:" + s.Name + ",學年度:" + record.SchoolYear); } foreach (string RemoveSubject in RemoveSubjects) { SHSchoolYearScoreSubject removerecord = record.Subjects.Find(x => x.Subject.Equals(RemoveSubject)); record.Subjects.Remove(removerecord); } #region 移除時判斷是否科目已清空,若是則加到刪除清單中 if (record.Subjects.Count == 0) { FinalDeleteRecords.Add(record); } #endregion } int SuccessCount = 0; if (K12.Data.Utility.Utility.IsNullOrEmpty(FinalUpdateRecords)) { MessageBox.Show("沒有資料不需刪除!!"); return; } try { if (MessageBox.Show("與您確認是否要刪除總共" + RemoveCount + "筆成績?提醒在刪除前先備份該位學生所有學年科目成績,並在成功後備份『刪除紀錄』。", "刪除學年科目成績確認", MessageBoxButtons.YesNo) == DialogResult.Yes) { SuccessCount = SHSchoolYearScore.Update(FinalUpdateRecords); if (FinalDeleteRecords.Count > 0) { SHSchoolYearScore.Delete(FinalDeleteRecords); } MessageBox.Show("成功刪除筆數:" + RemoveCount); txtLog.Text = txtLog.Text + strLog.ToString(); FISCA.LogAgent.ApplicationLog.Log("成績模組.學年科目成績資料維護", strLog.ToString()); } } catch (Exception ve) { MessageBox.Show(ve.Message); txtLog.Text = txtLog.Text + ve.Message; } finally { RefreshUI(); } }
/// <summary> /// 範例程式:收集學籍表相關資料。請注意:請儘量減少取得資料的 IO /// </summary> /// <param name="studentID">學生系統編號</param> /// <returns>個人學籍表相關資料</returns> private DataSet GetSchoolRollTable(SHStudentRecord student, DataPool dataPool) { // 此涵式的區域變數 // 學年歷程 Dictionary<int, int> _PersonalYearSubjectScoreHistoryInfo = dataPool.GetPersonalYearSubjectScoreHistoryInfo(student.ID); // 學期歷程 Dictionary<int, List<KeyValuePair<int, int>>> _PersonalSemesterSubjectScoreHistoryInfo = dataPool.GetPersonalSemesterSubjectScoreHistoryInfo(student.ID); // 學生修習科目學期成績資料 List<SHSubjectSemesterScoreInfo> _SHSemesterScore = dataPool.GetPersonalAllSemesterSubjectScoreInfo(student.ID); DataSet schoolRollTable = new DataSet("DataSection"); #region 學籍表字號 // 字 schoolRollTable.Tables.Add(text1.ToDataTable("AuthorityCode", "證明書字")); // 號 if (!string.IsNullOrEmpty(text2)) { schoolRollTable.Tables.Add(text2.ToDataTable("SerialNumber", "證明書流水號")); text2 = ((Convert.ToInt32(text2) + 1)).ToString("d" + text2.Length); } #endregion # region 學校、學生、監護人基本資料 // 校名 schoolRollTable.Tables.Add(School.ChineseName.ToDataTable("SchoolName", "校名")); // 學校代碼 schoolRollTable.Tables.Add(School.Code.ToDataTable("SchoolCode", "學校代碼")); // 學生基本資料:姓名 schoolRollTable.Tables.Add(student.Name.ToDataTable("StudentName", "學生姓名")); // 學生基本資料:性別 schoolRollTable.Tables.Add(student.Gender.ToDataTable("Gender", "性別")); // 學生基本資料:出生日期 string birthday = student.Birthday.HasValue ? student.Birthday.Value.ToShortDateString() : string.Empty; if (!String.IsNullOrEmpty(birthday)) { if (Convert.ToDateTime(birthday).Year.ToString().Length == 4) birthday = (Convert.ToDateTime(birthday).Year - 1911).ToString() + "/" + Convert.ToDateTime(birthday).Month.ToString() + "/" + Convert.ToDateTime(birthday).Day.ToString(); } schoolRollTable.Tables.Add(birthday.ToDataTable("Birthday", "出生日期")); // 學生基本資料:學號 schoolRollTable.Tables.Add(student.StudentNumber.ToDataTable("StudentNumber", "學號")); // 學生基本資料:座號 schoolRollTable.Tables.Add(student.SeatNo.ToString().ToDataTable("SeatNo", "座號")); // 學生基本資料:成績身份 schoolRollTable.Tables.Add(dataPool.TransferStudentTagToIdentity(student.ID).ToDataTable("EvaluationIdentity", "成績身份")); string pDepartmentName = string.Empty; string pDepartmentCode = string.Empty; if (dataPool.GetDepartment(student.ID) != null) { pDepartmentName = dataPool.GetDepartment(student.ID).Name; pDepartmentCode = dataPool.GetDepartment(student.ID).Code; } else { SHLeaveInfoRecord sr = dataPool.GetPersonalSHLeaveInfo(student.ID); if (sr != null) pDepartmentName = (sr.DepartmentName == null ? string.Empty : sr.DepartmentName); } // 學生基本資料:科別 schoolRollTable.Tables.Add(pDepartmentName.ToDataTable("DepartmentName", "科別")); // 學生基本資料:科別代碼 schoolRollTable.Tables.Add(pDepartmentCode.ToDataTable("DepartmentCode", "科別代碼")); // 學生基本資料:身份證字號 schoolRollTable.Tables.Add(student.IDNumber.ToDataTable("IDNumber", "身份證字號")); // 學生基本資料:班級 SHClassRecord clazz = dataPool.GetClass(student.ID); schoolRollTable.Tables.Add((clazz == null ? "" : clazz.Name).ToDataTable("ClassName", "班級")); // 學生基本資料:畢業照 => ischool 的格式為 Base64String,須轉為 ReportHelper 的格式:Byte[] // 如果沒有畢業照片,則用入學照片 string graduatePhoto = dataPool.GetGraduatePhoto(student.ID); string freshmanPhoto = dataPool.GetFreshmanPhoto(student.ID); if (string.IsNullOrEmpty(graduatePhoto)) graduatePhoto = freshmanPhoto; schoolRollTable.Tables.Add(graduatePhoto.FromBase64StringToByte().ToDataTable("GraduatePhoto", "畢業照", Type.GetType("System.Byte[]"))); // 監護人判讀 SHParentRecord parent = dataPool.GetParent(student.ID); string strCustodian = string.Empty; string strCustodianJob = string.Empty; string strCustodianRelationship = string.Empty; if (parent != null) { if (custodian == 0) { strCustodian = parent.CustodianName; strCustodianJob = parent.CustodianJob; strCustodianRelationship = parent.CustodianRelationship; } if (custodian == 1) { strCustodian = parent.FatherName; strCustodianJob = parent.FatherJob; strCustodianRelationship = "父親"; } if (custodian == 2) { strCustodian = parent.MotherName; strCustodianJob = parent.MotherJob; strCustodianRelationship = "母親"; } } // 監護人基本資料:監護人姓名 schoolRollTable.Tables.Add(strCustodian.ToDataTable("CustodianName", "監護人姓名")); // 監護人基本資料:職業 schoolRollTable.Tables.Add(strCustodianJob.ToDataTable("CustodianJob", "監護人職業")); // 監護人基本資料:稱謂 schoolRollTable.Tables.Add(strCustodianRelationship.ToDataTable("CustodianRelationship", "稱謂")); // 學生基本資料:戶籍電話 SHPhoneRecord oPhone = dataPool.GetPhone(student.ID); string strPhone = string.Empty; if (oPhone != null) { if (phone == 0) strPhone = oPhone.Permanent; if (phone == 1) strPhone = oPhone.Contact; } schoolRollTable.Tables.Add(strPhone.ToDataTable("Phone", "電話")); // 學生基本資料:戶籍地址 SHAddressRecord oAddress = dataPool.GetAddress(student.ID); string strAddress = string.Empty; if (oAddress != null) { if (address == 0) strAddress = oAddress.PermanentAddress.Trim(); if (address == 1) strAddress = oAddress.MailingAddress.Trim(); } schoolRollTable.Tables.Add(strAddress.ToDataTable("Address", "地址")); # endregion # region 學期(年)成績資料 if (_PersonalSemesterSubjectScoreHistoryInfo != null && _PersonalSemesterSubjectScoreHistoryInfo.Count > 0) { int yIndex = 0; List<int> schoolYear = new List<int>(); foreach (int gradeYear in _PersonalSemesterSubjectScoreHistoryInfo.Keys) { yIndex = gradeYear; // 復學生有可能在相同的成績年級中有多筆學年度資料 List<KeyValuePair<int, int>> allSchoolYearSemesterPair = _PersonalSemesterSubjectScoreHistoryInfo[yIndex]; if (allSchoolYearSemesterPair != null && allSchoolYearSemesterPair.Count>0) schoolYear = allSchoolYearSemesterPair.Select(x => x.Key).Distinct().ToList(); string sYear = string.Empty; foreach (int s in schoolYear.OrderBy(x=>x)) { sYear += s.ToString() + "/"; } sYear = sYear.Substring(0, sYear.Length - 1); schoolRollTable.Tables.Add(sYear.ToDataTable("Y" + yIndex.ToString() + "SchoolYear", "學年度")); Dictionary<int, List<SHSubjectSemesterScoreInfo>> dicSHSubjectSemesterScoreInfos = new Dictionary<int, List<SHSubjectSemesterScoreInfo>>(); foreach (KeyValuePair<int, int> kv in allSchoolYearSemesterPair) { if (!dicSHSubjectSemesterScoreInfos.ContainsKey(kv.Value)) dicSHSubjectSemesterScoreInfos.Add(kv.Value, new List<SHSubjectSemesterScoreInfo>()); dicSHSubjectSemesterScoreInfos[kv.Value] = dataPool.GetPersonalSemesterSubjectScoreInfo(student.ID, kv.Key, kv.Value); } // 學年學分制排序上下學期與學年成績 if (allSchoolYearSemesterPair.Count > 1 && templateNumber != 3 && templateNumber != 4) { dicSHSubjectSemesterScoreInfos[2] = dataPool.SortSHSubjectSemesterScore(dicSHSubjectSemesterScoreInfos[1], dicSHSubjectSemesterScoreInfos[2]); } foreach (KeyValuePair<int, int> kv in allSchoolYearSemesterPair) { ProduceSHSemesterScoreData(student, schoolRollTable, yIndex, kv.Key, kv.Value, dataPool, dicSHSubjectSemesterScoreInfos[kv.Value]); } // 學年成績 List<SHSubjectYearScoreInfo> pSHSubjectYearScoreInfo = dataPool.GetPersonalYearSubjectScoreInfo(dicSHSubjectSemesterScoreInfos); ProduceSHYearScoreData(student, schoolRollTable, yIndex, pSHSubjectYearScoreInfo); } foreach (int gradeYear in _PersonalSemesterSubjectScoreHistoryInfo.Keys) { yIndex = gradeYear; string prefix = "Y" + yIndex + "S"; List<string> mergeSubjects = new List<string>(); if (schoolRollTable.Tables.Contains(prefix + "1Subject") || schoolRollTable.Tables.Contains(prefix + "2Subject")) { string mergeSubject = string.Empty; int j = 0; if (schoolRollTable.Tables.Contains(prefix + "1Subject")) { foreach (DataRow dr in schoolRollTable.Tables[prefix + "1Subject"].Rows) { string s1Level = string.Empty; string s2Level = string.Empty; if (schoolRollTable.Tables.Contains(prefix + "2Level")) s2Level = (schoolRollTable.Tables[prefix + "2Level"].Rows.Count < (j + 1)) ? "" : schoolRollTable.Tables[prefix + "2Level"].Rows[j]["級別"].ToString(); if (schoolRollTable.Tables.Contains(prefix + "1Level")) s1Level = (schoolRollTable.Tables[prefix + "1Level"].Rows.Count < (j + 1)) ? "" : schoolRollTable.Tables[prefix + "1Level"].Rows[j]["級別"].ToString(); string subjectName = dr["科目名稱"].ToString(); if (string.IsNullOrWhiteSpace(subjectName)) { int rowIndex = dr.Table.Rows.IndexOf(dr); if (rowIndex > 0) subjectName = schoolRollTable.Tables[prefix + "2Subject"].Rows[rowIndex]["科目名稱"].ToString(); } mergeSubject = subjectName + " " + (string.IsNullOrWhiteSpace(Util.NumberToRomanChar(s1Level)) ? Util.NumberToRomanChar(s1Level) : Util.NumberToRomanChar(s1Level) + ",") + Util.NumberToRomanChar(s2Level); if (mergeSubject.EndsWith(",")) mergeSubject = mergeSubject.Substring(0, mergeSubject.Length - 1); mergeSubjects.Add(mergeSubject); j++; } } else { if (schoolRollTable.Tables.Contains(prefix + "2Subject")) { for (int k = j; k < schoolRollTable.Tables[prefix + "2Subject"].Rows.Count; k++) { mergeSubject = schoolRollTable.Tables[prefix + "2Subject"].Rows[k]["科目名稱"].ToString() + " " + Util.NumberToRomanChar(schoolRollTable.Tables[prefix + "2Level"].Rows[k]["級別"].ToString()); mergeSubjects.Add(mergeSubject); } } } if (schoolRollTable.Tables.Contains(prefix + "1Subject") && schoolRollTable.Tables.Contains(prefix + "2Subject")) { if (schoolRollTable.Tables[prefix + "2Subject"].Rows.Count > schoolRollTable.Tables[prefix + "1Subject"].Rows.Count) { for (int k = j; k < schoolRollTable.Tables[prefix + "2Subject"].Rows.Count; k++) { mergeSubject = schoolRollTable.Tables[prefix + "2Subject"].Rows[k]["科目名稱"].ToString() + " " + Util.NumberToRomanChar(schoolRollTable.Tables[prefix + "2Level"].Rows[k]["級別"].ToString()); mergeSubjects.Add(mergeSubject); } } } } schoolRollTable.Tables.Add(mergeSubjects.ToDataTable("Y" + yIndex.ToString() + "MergedSubject", "合併級別科目名稱")); } } #endregion #region 學期學分累計資料 if (_PersonalSemesterSubjectScoreHistoryInfo != null && _PersonalSemesterSubjectScoreHistoryInfo.Count > 0) { decimal? AccumulatedTotalCredit = 0; decimal? AccumulatedAcquiredCredit = 0; foreach (int gradeYear in _PersonalSemesterSubjectScoreHistoryInfo.Keys.OrderBy(x=>x)) { decimal? TotalCredit = 0; decimal? AcquiredCredit = 0; foreach (KeyValuePair<int, int> sh in _PersonalSemesterSubjectScoreHistoryInfo[gradeYear]) { TotalCredit += _SHSemesterScore.Where(x => (x.SchoolYear == sh.Key && x.Semester == sh.Value)).Where(x => x.Credit != null).Sum(x => x.Credit); AcquiredCredit += _SHSemesterScore.Where(x => (x.SchoolYear == sh.Key && x.Semester == sh.Value)).Where(x => x.Pass.HasValue && x.Pass.Value).Sum(x => x.Credit); AccumulatedTotalCredit += _SHSemesterScore.Where(x => (x.SchoolYear == sh.Key && x.Semester == sh.Value)).Where(x => x.Credit != null).Sum(x => x.Credit); AccumulatedAcquiredCredit += _SHSemesterScore.Where(x => (x.SchoolYear == sh.Key && x.Semester == sh.Value)).Where(x => x.Pass.HasValue && x.Pass.Value).Sum(x => x.Credit); string prefix = "Y" + gradeYear.ToString() + "S" + sh.Value; schoolRollTable.Tables.Add(_SHSemesterScore.Where(x => (x.SchoolYear == sh.Key && x.Semester == sh.Value)).Where(x => x.Credit != null).Sum(x => x.Credit).ToDataTable(prefix + "TotalCredit", "學期應得學分")); schoolRollTable.Tables.Add(_SHSemesterScore.Where(x => (x.SchoolYear == sh.Key && x.Semester == sh.Value)).Where(x => x.Pass.HasValue && x.Pass.Value).Sum(x => x.Credit).ToDataTable(prefix + "AcquiredCredit", "學期實得學分")); schoolRollTable.Tables.Add(_SHSemesterScore.Where(x => (x.SchoolYear < sh.Key) || ((x.SchoolYear == sh.Key) && (x.Semester <= sh.Value))).Sum(x => x.Credit).ToDataTable(prefix + "AccumulatedTotalCredit", "學期累計應得學分")); schoolRollTable.Tables.Add(_SHSemesterScore.Where(x => (x.SchoolYear < sh.Key) || ((x.SchoolYear == sh.Key) && (x.Semester <= sh.Value))).Where(x => x.Pass.HasValue && x.Pass.Value).Sum(x => x.Credit).ToDataTable(prefix + "AccumulatedAcquiredCredit", "學期累計實得學分")); if (schoolRollTable.Tables.Contains("Y" + gradeYear.ToString() + "TotalCredit")) schoolRollTable.Tables.Remove("Y" + gradeYear.ToString() + "TotalCredit"); schoolRollTable.Tables.Add(TotalCredit.ToDataTable("Y" + gradeYear.ToString() + "TotalCredit", "學年應得學分")); if (schoolRollTable.Tables.Contains("Y" + gradeYear.ToString() + "AcquiredCredit")) schoolRollTable.Tables.Remove("Y" + gradeYear.ToString() + "AcquiredCredit"); schoolRollTable.Tables.Add(AcquiredCredit.ToDataTable("Y" + gradeYear.ToString() + "AcquiredCredit", "學年實得學分")); if (schoolRollTable.Tables.Contains("Y" + gradeYear.ToString() + "AccumulatedTotalCredit")) schoolRollTable.Tables.Remove("Y" + gradeYear.ToString() + "AccumulatedTotalCredit"); schoolRollTable.Tables.Add(AccumulatedTotalCredit.ToDataTable("Y" + gradeYear.ToString() + "AccumulatedTotalCredit", "學年累計應得學分")); if (schoolRollTable.Tables.Contains("Y" + gradeYear.ToString() + "AccumulatedAcquiredCredit")) schoolRollTable.Tables.Remove("Y" + gradeYear.ToString() + "AccumulatedAcquiredCredit"); schoolRollTable.Tables.Add(AccumulatedAcquiredCredit.ToDataTable("Y" + gradeYear.ToString() + "AccumulatedAcquiredCredit", "學年累計實得學分")); } } } #endregion #region 學期學業成績資料 List<SHSemesterEntryScoreRecord> _SHSemesterEntryScoreRecords = dataPool.GetSemesterEntryScoreInfo(student.ID); Dictionary<int, List<KeyValuePair<int, int>>> _SHSemesterEntryScoreHistory = dataPool.GetSemesterEntryScoreHistory(student.ID); if (_SHSemesterEntryScoreRecords.Count > 0 && _SHSemesterEntryScoreHistory.Count > 0) { string prefix = string.Empty; int yIndex = 0; int sIndex = 0; foreach (SHSemesterEntryScoreRecord sr in _SHSemesterEntryScoreRecords) { yIndex = sr.GradeYear; if (!_SHSemesterEntryScoreHistory.ContainsKey(yIndex)) continue; if (_SHSemesterEntryScoreHistory[yIndex].Where(x => (x.Key == sr.SchoolYear && x.Value == sr.Semester)).Count() == 0) continue; sIndex = sr.Semester; prefix = "Y" + yIndex + "S" + sIndex; // 學業 if (sr.Scores.ContainsKey("學業")) { schoolRollTable.Tables.Add(sr.Scores["學業"].ToDataTable(prefix + "AcademicScore", "學業成績")); SHRankingInfo rank = sr.ClassRating.Find(x => x.Name.Equals("學業")); schoolRollTable.Tables.Add((rank == null ? "" : rank.Ranking.ToString()).ToDataTable(prefix + "AcademicClassRank", "學業成績班級排名")); rank = sr.DeptRating.Find(x => x.Name.Equals("學業")); schoolRollTable.Tables.Add((rank == null ? "" : rank.Ranking.ToString()).ToDataTable(prefix + "AcademicDepartmentRank", "學業成績科排名")); rank = sr.YearRating.Find(x => x.Name.Equals("學業")); schoolRollTable.Tables.Add((rank == null ? "" : rank.Ranking.ToString()).ToDataTable(prefix + "AcademicGradeRank", "學業成績年級排名")); } // 體育 if (sr.Scores.ContainsKey("體育")) { schoolRollTable.Tables.Add(sr.Scores["體育"].ToDataTable(prefix + "PhysicalScore", "體育成績")); } // 健康與護理 if (sr.Scores.ContainsKey("健康與護理")) { schoolRollTable.Tables.Add(sr.Scores["健康與護理"].ToDataTable(prefix + "HealthScore", "健康與護理成績")); } // 國防通識 if (sr.Scores.ContainsKey("國防通識")) { schoolRollTable.Tables.Add(sr.Scores["國防通識"].ToDataTable(prefix + "NationalDefenseScore", "國防通識成績")); } // 實習科目 if (sr.Scores.ContainsKey("實習科目")) { schoolRollTable.Tables.Add(sr.Scores["實習科目"].ToDataTable(prefix + "PracticeScore", "實習科目成績")); } // 專業科目 if (sr.Scores.ContainsKey("專業科目")) { schoolRollTable.Tables.Add(sr.Scores["專業科目"].ToDataTable(prefix + "SpecializationScore", "專業科目成績")); } } } #endregion #region 學年學業成績資料 List<SHSchoolYearEntryScoreRecord> _SHYearEntryScoreRecords = dataPool.GetYearEntryScoreInfo(student.ID); Dictionary<int, int> _SHYearEntryScoreHistory = dataPool.GetYearEntryScoreHistory(student.ID); if (_SHYearEntryScoreRecords.Count > 0 && _SHYearEntryScoreHistory.Count > 0) { string prefix = string.Empty; int yIndex = 0; foreach (SHSchoolYearEntryScoreRecord sr in _SHYearEntryScoreRecords) { if (!_SHYearEntryScoreHistory.ContainsValue(sr.SchoolYear)) continue; yIndex = sr.GradeYear; prefix = "Y" + yIndex.ToString(); // 學業 if (sr.Scores.ContainsKey("學業")) { schoolRollTable.Tables.Add(sr.Scores["學業"].ToDataTable(prefix + "AcademicScore", "學業成績")); SHRankingInfo rank = sr.ClassRating.Find(x => x.Name.Equals("學業")); schoolRollTable.Tables.Add((rank == null ? "" : rank.Ranking.ToString()).ToDataTable(prefix + "AcademicClassRank", "學業成績班級排名")); rank = sr.DeptRating.Find(x => x.Name.Equals("學業")); schoolRollTable.Tables.Add((rank == null ? "" : rank.Ranking.ToString()).ToDataTable(prefix + "AcademicDepartmentRank", "學業成績科排名")); rank = sr.YearRating.Find(x => x.Name.Equals("學業")); schoolRollTable.Tables.Add((rank == null ? "" : rank.Ranking.ToString()).ToDataTable(prefix + "AcademicGradeRank", "學業成績年級排名")); } // 體育 if (sr.Scores.ContainsKey("體育")) { schoolRollTable.Tables.Add(sr.Scores["體育"].ToDataTable(prefix + "PhysicalScore", "體育成績")); } // 健康與護理 if (sr.Scores.ContainsKey("健康與護理")) { schoolRollTable.Tables.Add(sr.Scores["健康與護理"].ToDataTable(prefix + "HealthScore", "健康與護理成績")); } // 國防通識 if (sr.Scores.ContainsKey("國防通識")) { schoolRollTable.Tables.Add(sr.Scores["國防通識"].ToDataTable(prefix + "NationalDefenseScore", "國防通識成績")); } // 實習科目 if (sr.Scores.ContainsKey("實習科目")) { schoolRollTable.Tables.Add(sr.Scores["實習科目"].ToDataTable(prefix + "PracticeScore", "實習科目成績")); } // 專業科目 if (sr.Scores.ContainsKey("專業科目")) { schoolRollTable.Tables.Add(sr.Scores["專業科目"].ToDataTable(prefix + "SpecializationScore", "專業科目成績")); } } } #endregion #region 德行評量(導師評語)資料 List<SHMoralScoreRecord> _SHMoralScoreRecords = dataPool.GetMoralScore(student.ID); if (_SHMoralScoreRecords != null && _SHMoralScoreRecords.Count > 0) _SHMoralScoreRecords = _SHMoralScoreRecords.OrderBy(x => x.SchoolYear).ThenBy(x => x.Semester).ToList(); // 德行評量沒有成績年級,採用「科目學期成績」的學期歷程 if (_PersonalSemesterSubjectScoreHistoryInfo != null && _PersonalSemesterSubjectScoreHistoryInfo.Count > 0 && _SHMoralScoreRecords != null && _SHMoralScoreRecords.Count > 0) { foreach (SHMoralScoreRecord sr in _SHMoralScoreRecords) { int yIndex = 0; foreach (int gradeYear in _PersonalSemesterSubjectScoreHistoryInfo.Keys) { List<KeyValuePair<int, int>> kvs = _PersonalSemesterSubjectScoreHistoryInfo[gradeYear]; if (kvs.Count > 0 && kvs.Where(x => (x.Key == sr.SchoolYear && x.Value == sr.Semester)).Count() > 0) { yIndex = gradeYear; break; } } if (yIndex == 0) continue; string moralScore = string.Empty; int sIndex = sr.Semester; string prefix = "Y" + yIndex + "S" + sIndex; // 德行評量選項:1-->導師評語。2-->文字評量。3-->2者皆要 // 導師評語 if (textScoreOption == 1 || textScoreOption == 3) if (sr.Comment.Trim() != "") moralScore = sr.Comment + ";"; if (textScoreOption == 2 || textScoreOption == 3) { // 文字評量 XDocument doc = XDocument.Parse("<root>" + sr.TextScore.InnerXml + "</root>"); foreach (XElement e in doc.Document.Descendants("Morality")) { if (e.Value.ToString().Trim() == "") continue; moralScore += e.Attribute("Face").Value + ":" + e.Value + ";"; } } if (moralScore.EndsWith(";")) moralScore = moralScore.Substring(0, moralScore.Length - 1); if (schoolRollTable.Tables.Contains(prefix + "MoralScore")) schoolRollTable.Tables.Remove(prefix + "MoralScore"); schoolRollTable.Tables.Add(moralScore.ToDataTable(prefix + "MoralScore", "德行評量")); } } #endregion #region 畢業成績資訊(含學業成績、實習成績、畢業規定總學分,其餘累計學分於次項統計) SHGradScoreRecord srs = dataPool.GetGradScore(student.ID); if (srs != null) { if (srs.Entries.Count > 0) { // 學業成績 if (srs.Entries.ContainsKey("學業")) schoolRollTable.Tables.Add(srs.Entries["學業"].Score.ToString().ToDataTable("GraduationAcademicScore", "學業成績")); // 實習成績 if (srs.Entries.ContainsKey("實習科目")) schoolRollTable.Tables.Add(srs.Entries["實習科目"].Score.ToString().ToDataTable("GraduationPracticeScore", "實習成績")); } } schoolRollTable.Tables.Add(dataPool.GetGraduationDeservedCredit(student.ID).ToDataTable("GraduationDeservedCredit", "畢業規定總學分")); #endregion #region 畢業成績資訊(累計學分) if (_SHSemesterScore != null && _SHSemesterScore.Count > 0 && _PersonalSemesterSubjectScoreHistoryInfo != null && _PersonalSemesterSubjectScoreHistoryInfo.Count > 0) { List<KeyValuePair<int, int>> kvs = new List<KeyValuePair<int, int>>(); foreach (int index in _PersonalSemesterSubjectScoreHistoryInfo.Keys) _PersonalSemesterSubjectScoreHistoryInfo[index].ForEach(x => kvs.Add(x)); decimal? graduationDecidesRequiredAccumulatedCredit = 0; decimal? graduationDecidesRequiredAcquiredCredit = 0; decimal? graduationSchoolRequiredAcquiredCredit = 0; decimal? graduationOptionalAcquiredCredit = 0; decimal? graduationSchoolRequiredAccumulatedCredit = 0; decimal? graduationOptionalAccumulatedCredit = 0; decimal? graduationAcquiredCredit = 0; foreach(SHSubjectSemesterScoreInfo x in _SHSemesterScore) { if (kvs.Where(y => (y.Key == x.SchoolYear && y.Value == x.Semester)).Count() > 0) { if (!String.IsNullOrEmpty(x.RequiredBy) && x.RequiredBy.Substring(0, 1) == "部" && x.Required.HasValue && x.Required == true) graduationDecidesRequiredAccumulatedCredit += (x.Credit.HasValue ? x.Credit.Value : 0); if (!String.IsNullOrEmpty(x.RequiredBy) && x.RequiredBy.Substring(0, 1) == "部" && x.Required.HasValue && x.Required == true && ((x.Pass.HasValue ? x.Pass.Value : false) == true)) graduationDecidesRequiredAcquiredCredit += (x.Credit.HasValue ? x.Credit.Value : 0); if (!String.IsNullOrEmpty(x.RequiredBy) && x.RequiredBy.Substring(0, 1) == "校" && x.Required.HasValue && x.Required == true && ((x.Pass.HasValue ? x.Pass.Value : false) == true)) graduationSchoolRequiredAcquiredCredit += (x.Credit.HasValue ? x.Credit.Value : 0); if (!String.IsNullOrEmpty(x.RequiredBy) && x.RequiredBy.Substring(0, 1) == "校" && x.Required.HasValue && x.Required == false && ((x.Pass.HasValue ? x.Pass.Value : false) == true)) graduationOptionalAcquiredCredit += (x.Credit.HasValue ? x.Credit.Value : 0); if (!String.IsNullOrEmpty(x.RequiredBy) && x.RequiredBy.Substring(0, 1) == "校" && x.Required.HasValue && x.Required == true) graduationSchoolRequiredAccumulatedCredit += (x.Credit.HasValue ? x.Credit.Value : 0); if (!String.IsNullOrEmpty(x.RequiredBy) && x.RequiredBy.Substring(0, 1) == "校" && x.Required.HasValue && x.Required == false) graduationOptionalAccumulatedCredit += (x.Credit.HasValue ? x.Credit.Value : 0); if (((x.Pass.HasValue ? x.Pass.Value : false) == true)) graduationAcquiredCredit += (x.Credit.HasValue ? x.Credit.Value : 0); //schoolRollTable.Tables.Add(_SHSemesterScore.Where(x => !String.IsNullOrEmpty(x.RequiredBy)).Where(x => x.RequiredBy.Substring(0, 1) == "校").Where(x => x.Required.HasValue).Where(x => x.Required == true).Sum(x => x.Credit).ToDataTable("GraduationSchoolRequiredAcquiredCredit", "校訂必修實得學分")); //schoolRollTable.Tables.Add(_SHSemesterScore.Where(x => !String.IsNullOrEmpty(x.RequiredBy)).Where(x => x.RequiredBy.Substring(0, 1) == "校").Where(x => x.Required.HasValue).Where(x => x.Required == false).Sum(x => x.Credit).ToDataTable("GraduationOptionalAcquiredCredit", "校訂選修實得學分")); //schoolRollTable.Tables.Add(_SHSemesterScore.Where(x => x.Pass.HasValue).Where(x => (bool)x.Pass).Sum(x => x.Credit).ToDataTable("GraduationAcquiredCredit", "畢業獲得總學分")); //_SHSemesterScore.Where(x => !String.IsNullOrEmpty(x.RequiredBy)).Where(x => x.RequiredBy.Substring(0, 1) == "部").Where(x => x.Required.HasValue).Where(x => x.Required == true).Sum(x => x.Credit); //decimal? graduationDecidesRequiredAcquiredCredit = _SHSemesterScore.Where(x => !String.IsNullOrEmpty(x.RequiredBy)).Where(x => x.RequiredBy.Substring(0, 1) == "部").Where(x => x.Required.HasValue).Where(x => x.Required == true).Where(x => ((x.Pass.HasValue ? x.Pass.Value : false) == true)).Sum(x => x.Credit); } } if (graduationDecidesRequiredAccumulatedCredit.HasValue) schoolRollTable.Tables.Add(graduationDecidesRequiredAccumulatedCredit.ToDataTable("GraduationDecidesRequiredAccumulatedCredit", "部定必修應得學分")); if (graduationDecidesRequiredAcquiredCredit.HasValue) schoolRollTable.Tables.Add(graduationDecidesRequiredAcquiredCredit.ToDataTable("GraduationDecidesRequiredAcquiredCredit", "部定必修實得學分")); if (graduationDecidesRequiredAccumulatedCredit.HasValue) { if (graduationDecidesRequiredAcquiredCredit.HasValue && graduationDecidesRequiredAccumulatedCredit.Value != 0M) schoolRollTable.Tables.Add((Math.Round(((graduationDecidesRequiredAcquiredCredit.Value * 100) / graduationDecidesRequiredAccumulatedCredit.Value), 1).ToString() + "%").ToDataTable("GraduationDecidesRequiredCreditPassingRate", "部定必修及格率")); //schoolRollTable.Tables.Add((((graduationDecidesRequiredAcquiredCredit.Value) / graduationDecidesRequiredAccumulatedCredit.Value)).ToDataTable("GraduationDecidesRequiredCreditPassingRate", "部定必修及格率")); else schoolRollTable.Tables.Add("".ToDataTable("GraduationDecidesRequiredCreditPassingRate", "部定必修及格率")); } if (graduationSchoolRequiredAcquiredCredit.HasValue) schoolRollTable.Tables.Add(graduationSchoolRequiredAcquiredCredit.ToDataTable("GraduationSchoolRequiredAcquiredCredit", "校定必修實得學分")); if (graduationOptionalAcquiredCredit.HasValue) schoolRollTable.Tables.Add(graduationOptionalAcquiredCredit.ToDataTable("GraduationOptionalAcquiredCredit", "校定選修實得學分")); if (graduationSchoolRequiredAccumulatedCredit.HasValue) schoolRollTable.Tables.Add(graduationSchoolRequiredAccumulatedCredit.ToDataTable("GraduationSchoolRequiredAccumulatedCredit", "校定必修應得學分")); if (graduationOptionalAccumulatedCredit.HasValue) schoolRollTable.Tables.Add(graduationOptionalAccumulatedCredit.ToDataTable("GraduationOptionalAccumulatedCredit", "校定選修應得學分")); if (graduationAcquiredCredit.HasValue) schoolRollTable.Tables.Add(graduationAcquiredCredit.ToDataTable("GraduationAcquiredCredit", "畢業獲得總學分")); } #endregion #region 專業(實習)科目及格學分與累計學分 // 專業科目及格學分 schoolRollTable.Tables.Add(dataPool.GetProSubjectAccquiredCredit(student.ID).ToDataTable("GraduationSpecializationAcquiredCredit", "專業科目及格學分")); // 專業科目累計學分 schoolRollTable.Tables.Add(dataPool.GetProSubjectAccumulatedCredit(student.ID).ToDataTable("GraduationSpecializationAccumulatedCredit", "專業科目累計學分")); // 實習科目累計學分與及格學分 List<SHSubjectSemesterScoreInfo> _SHSubjectSemesterScoreInfo = dataPool.GetPersonalAllSemesterSubjectScoreInfo(student.ID); if (_SHSubjectSemesterScoreInfo != null) { List<KeyValuePair<int, int>> kvs = new List<KeyValuePair<int, int>>(); foreach (int index in _PersonalSemesterSubjectScoreHistoryInfo.Keys) _PersonalSemesterSubjectScoreHistoryInfo[index].ForEach(x => kvs.Add(x)); decimal proAccumulatedCredit = 0; decimal proAccquiredCredit = 0; decimal specializationAccumulatedCredit = 0; decimal specializationAcquiredCredit = 0; foreach (SHSubjectSemesterScoreInfo sss in _SHSubjectSemesterScoreInfo) { if (kvs.Where(y => (y.Key == sss.SchoolYear && y.Value == sss.Semester)).Count() > 0) { if (sss.Entry == "實習科目") { if (sss.Credit.HasValue && sss.Pass.HasValue && sss.Pass.Value) if (sss.Credit.HasValue) proAccquiredCredit += sss.Credit.Value; if (sss.Credit.HasValue) proAccumulatedCredit += sss.Credit.Value; } if (sss.Entry == "專業科目") { if (sss.Credit.HasValue && sss.Pass.HasValue && sss.Pass.Value) if (sss.Credit.HasValue) specializationAcquiredCredit += sss.Credit.Value; if (sss.Credit.HasValue) specializationAccumulatedCredit += sss.Credit.Value; } } } schoolRollTable.Tables.Add(proAccquiredCredit.ToDataTable("GraduationPracticeAcquiredCredit", "實習科目及格學分")); schoolRollTable.Tables.Add(proAccumulatedCredit.ToDataTable("GraduationPracticeAccumulatedCredit", "實習科目累計學分")); // 若科目分項成績有設定「專業科目」則採計此公式 if (specializationAccumulatedCredit > 0) { if (schoolRollTable.Tables.Contains("GraduationSpecializationAcquiredCredit")) schoolRollTable.Tables.Remove("GraduationSpecializationAcquiredCredit"); if (schoolRollTable.Tables.Contains("GraduationSpecializationAccumulatedCredit")) schoolRollTable.Tables.Remove("GraduationSpecializationAccumulatedCredit"); // 專業科目及格學分 schoolRollTable.Tables.Add(specializationAcquiredCredit.ToDataTable("GraduationSpecializationAcquiredCredit", "專業科目及格學分")); // 專業科目累計學分 schoolRollTable.Tables.Add(specializationAccumulatedCredit.ToDataTable("GraduationSpecializationAccumulatedCredit", "專業科目累計學分")); } } #endregion #region 獎懲相抵未滿三大過判讀資料 schoolRollTable.Tables.Add((dataPool.NotExceedThreeMajorDemerits(student.ID) ? "是" : "否").ToDataTable("NotExceedThreeMajorDemerits", "獎懲相抵未滿三大過")); #endregion #region 學年重讀或升級判讀資料 if (_PersonalYearSubjectScoreHistoryInfo != null) { foreach (KeyValuePair<int, int> kv in _PersonalYearSubjectScoreHistoryInfo) { bool retainInTheSameGrade = dataPool.RetainInTheSameGrade(student.ID, kv); schoolRollTable.Tables.Add((retainInTheSameGrade ? "重讀" : "升級").ToDataTable("Y" + kv.Key.ToString() + "RetainInTheSameGrade", "升級或應重讀判斷")); } } #endregion # region 學生異動資料 List<SHUpdateRecordRecord> shurrs = dataPool.GetUpdateRecord(student.ID); if (shurrs != null && shurrs.Count > 0) { // 入學異動(新生與他校轉入依據異動日期遞減排序,取第一筆)// 入學異動 // 異動代碼首碼為「0」者:新生異動 // 異動代碼前3碼為「101」且為進校學籍表:它校轉入 // 異動代碼前3碼為「111」且為日校、高職學籍表:它校轉入 //var enrollUpdateRecords = from updateRecords in shurrs // where (updateRecords.UpdateCode.Substring(0, 1) == "0" || ((templateNumber == 5 || templateNumber == 6) && updateRecords.UpdateCode.Substring(0, 3) == "101") || ((templateNumber != 5 && templateNumber != 6) && updateRecords.UpdateCode.Substring(0, 3) == "111")) // orderby updateRecords.UpdateDate descending // select updateRecords; // 入學異動(新生與他校轉入依據異動日期遞減排序,取第一筆) // 異動代碼首碼為「0」者:新生異動 // 異動代碼首碼為「1」者:他校轉入 // 異動代碼首碼為「2」者:本校學籍增加 // 異動代碼首碼為「3」者:本校學籍減少 // 異動代碼首碼為「4」者:學籍更正 var enrollUpdateRecords = from updateRecords in shurrs where (updateRecords.UpdateCode.Substring(0, 1) == "0" || updateRecords.UpdateCode.Substring(0, 1) == "1") orderby updateRecords.UpdateDate descending select updateRecords; DataTable EnrollRecordTable = new DataTable("EnrollUpdateRecord"); EnrollRecordTable.Columns.Add("EnrollUpdateRecord"); foreach (SHUpdateRecordRecord u in enrollUpdateRecords) { DataRow pRow = EnrollRecordTable.NewRow(); string graduateSchool = ((u.UpdateCode.Substring(0, 1) == "0") ? (u.GraduateSchoolLocationCode + " " + u.GraduateSchool) : u.PreviousSchool); //|| u.UpdateCode.Substring(0, 1) == "1" pRow["EnrollUpdateRecord"] = graduateSchool; EnrollRecordTable.Rows.Add(pRow); pRow = EnrollRecordTable.NewRow(); pRow["EnrollUpdateRecord"] = u.UpdateCode + " " + u.UpdateDescription; EnrollRecordTable.Rows.Add(pRow); pRow = EnrollRecordTable.NewRow(); pRow["EnrollUpdateRecord"] = u.ADDate + "\n" + u.ADNumber; EnrollRecordTable.Rows.Add(pRow); break; } schoolRollTable.Tables.Add(EnrollRecordTable); // 畢業異動 var graduateUpdateRecords = from updateRecords in shurrs where (updateRecords.UpdateCode.Substring(0, 1) == "5") select updateRecords; DataTable GraduateRecordTable = new DataTable("GraduateUpdateRecord"); GraduateRecordTable.Columns.Add("GraduateUpdateRecord"); foreach (SHUpdateRecordRecord u in graduateUpdateRecords) { DataRow pRow = GraduateRecordTable.NewRow(); pRow["GraduateUpdateRecord"] = u.GraduateCertificateNumber; GraduateRecordTable.Rows.Add(pRow); pRow = GraduateRecordTable.NewRow(); pRow["GraduateUpdateRecord"] = u.ADDate + " " + u.ADNumber; GraduateRecordTable.Rows.Add(pRow); break; } schoolRollTable.Tables.Add(GraduateRecordTable); // 學籍異動 var otherUpdateRecords = from updateRecords in shurrs where (updateRecords.UpdateCode.Substring(0, 1) != "0" && updateRecords.UpdateCode.Substring(0, 1) != "1" && updateRecords.UpdateCode.Substring(0, 1) != "5") orderby updateRecords.UpdateDate select updateRecords; DataTable OtherUpdateRecordTable = new DataTable("OtherUpdateRecord"); OtherUpdateRecordTable.Columns.Add("其它異動日期"); OtherUpdateRecordTable.Columns.Add("其它異動事項"); OtherUpdateRecordTable.Columns.Add("其它異動文號"); foreach (SHUpdateRecordRecord u in otherUpdateRecords) { //if ((templateNumber == 5 || templateNumber == 6) && u.UpdateCode.Substring(0, 3) == "101") // continue; //if ((templateNumber != 5 && templateNumber != 6) && u.UpdateCode.Substring(0, 3) == "111") // continue; DataRow pRow = OtherUpdateRecordTable.NewRow(); pRow["其它異動日期"] = u.UpdateDate; pRow["其它異動事項"] = u.UpdateCode + " " + u.UpdateDescription; pRow["其它異動文號"] = u.ADDate + " " + u.ADNumber; OtherUpdateRecordTable.Rows.Add(pRow); } schoolRollTable.Tables.Add(OtherUpdateRecordTable); } #endregion #region 報表列印日期 schoolRollTable.Tables.Add((DateTime.Today.Year - 1911).ConvertToChineseNumber().ToDataTable("PrintYear", "報表列印日期之民國年")); schoolRollTable.Tables.Add(DateTime.Today.Month.ConvertToChineseNumber().ToDataTable("PrintMonth", "報表列印日期之月份")); schoolRollTable.Tables.Add(DateTime.Today.Day.ConvertToChineseNumber().ToDataTable("PrintDay", "報表列印日期之日")); #endregion return schoolRollTable; }