private void _loader_DoWork(object sender, DoWorkEventArgs e) { _StudUpdateRecList.Clear(); // 讀取學生資料 if (students.Count == 0) { foreach (SHStudentRecord var in SHStudent.SelectAll()) { students.Add(var.ID, var); } } // 讀取異動資料 foreach (SHUpdateRecordRecord UpdateRec in SHUpdateRecord.SelectAll()) { DateTime UpdateDate; if (DateTime.TryParse(UpdateRec.UpdateDate, out UpdateDate)) { if (UpdateDate.Date >= dtStart.Value.Date && UpdateDate.Date <= dtEnd.Value.Date) { if (_typeForm.CodeList.Contains(UpdateRec.UpdateCode)) { _StudUpdateRecList.Add(UpdateRec); } } } } }
/// <summary> /// 依學生學號資料 /// 取得學生的日常生活表現資料 /// </summary> private List <SHMoralScoreRecord> GetMoralScoreList(List <Campus.DocumentValidator.IRowStream> Rows) { //學號清單 List <string> StudentNumberList = new List <string>(); foreach (IRowStream Row in Rows) { string StudentNumber = Row.GetValue("學號"); if (!StudentNumberList.Contains(StudentNumber)) { StudentNumberList.Add(StudentNumber); } } //比對學號&取得學生Record List <SHStudentRecord> importStudRecList = new List <SHStudentRecord>(); foreach (SHStudentRecord each in SHStudent.SelectAll()) { if (each.Status == StudentRecord.StudentStatus.刪除) //狀態為刪除者排除 { continue; } if (StudentNumberList.Contains(each.StudentNumber)) //包含於匯入資料"學號清單之學生 { importStudRecList.Add(each); //建立學號比對學生Record字典 if (!StudentRecordByStudentNumber.ContainsKey(each.StudentNumber)) { StudentRecordByStudentNumber.Add(each.StudentNumber, each); } } } //取得學生ID List <string> StudentIDList = importStudRecList.Select(x => x.ID).ToList(); //一次取得學生日常生活表現清單 return(SHMoralScore.SelectByStudentIDs(StudentIDList)); }
/// <summary> /// 取得異動資料並且轉換成名冊用異動 /// </summary> public void UpdateRecConvertUpdateRecDoc(UpdateRecBatchType urbt) { _UpdateRecBatchType = urbt; // 學生異動資料 List <SHUpdateRecordRecord> updatRecList = new List <SHUpdateRecordRecord> (); // 延修生異動代號 List <string> ExtendCodeList = new List <string>(); ExtendCodeList.Add("235"); ExtendCodeList.Add("236"); // 取得異動代碼資料 XElement elms = DAL.DALTransfer.GetUpdateCodeList(); List <string> CodeList = new List <string> (); // 取得非刪除學生 List <string> StudentIDList = (from data in SHStudent.SelectAll() where data.Status != K12.Data.StudentRecord.StudentStatus.刪除 select data.ID).ToList(); // 透過異動代碼取沒有核准文號異動記錄,學生狀態非刪除。 switch (_UpdateRecBatchType) { case UpdateRecBatchType.新生名冊: // 取得新生異動代碼 CodeList = (from elm in elms.Elements("異動") where elm.Element("分類").Value == "新生異動" select elm.Element("代號").Value).ToList(); updatRecList = (from data in SHUpdateRecord.SelectByUpdateCodes(CodeList) where StudentIDList.Contains(data.StudentID) && data.GradeYear != "延修生" && data.ADNumber.Trim() == "" select data).ToList(); break; case UpdateRecBatchType.畢業名冊: // 取得畢業異動代碼 CodeList = (from elm in elms.Elements("異動") where elm.Element("分類").Value == "畢業異動" select elm.Element("代號").Value).ToList(); updatRecList = (from data in SHUpdateRecord.SelectByUpdateCodes(CodeList) where StudentIDList.Contains(data.StudentID) && data.GradeYear != "延修生" && data.ADNumber.Trim() == "" select data).ToList(); break; case UpdateRecBatchType.學籍異動名冊: // 取得學籍異動代碼 CodeList = (from elm in elms.Elements("異動") where elm.Element("分類").Value == "學籍異動" select elm.Element("代號").Value).ToList(); updatRecList = (from data in SHUpdateRecord.SelectByUpdateCodes(CodeList) where StudentIDList.Contains(data.StudentID) && data.GradeYear != "延修生" && data.ADNumber.Trim() == "" select data).ToList(); break; case UpdateRecBatchType.轉入學生名冊: // 取得轉入異動代碼 CodeList = (from elm in elms.Elements("異動") where elm.Element("分類").Value == "轉入異動" select elm.Element("代號").Value).ToList(); updatRecList = (from data in SHUpdateRecord.SelectByUpdateCodes(CodeList) where StudentIDList.Contains(data.StudentID) && data.GradeYear != "延修生" && data.ADNumber.Trim() == "" select data).ToList(); break; case UpdateRecBatchType.延修生名冊: // 規則:只取得異動代碼為延修且年級是延修生。 CodeList = (from elm in elms.Elements("異動") where ExtendCodeList.Contains(elm.Element("代號").Value) select elm.Element("代號").Value).ToList(); updatRecList = (from data in SHUpdateRecord.SelectByUpdateCodes(CodeList) where StudentIDList.Contains(data.StudentID) && data.GradeYear == "延修生" && data.ADNumber.Trim() == "" select data).ToList(); break; case UpdateRecBatchType.延修生畢業名冊: // 規則:畢業異動代碼且年級是延修生。 CodeList = (from elm in elms.Elements("異動") where elm.Element("分類").Value == "畢業異動" select elm.Element("代號").Value).ToList(); updatRecList = (from data in SHUpdateRecord.SelectByUpdateCodes(CodeList) where StudentIDList.Contains(data.StudentID) && data.GradeYear == "延修生" && data.ADNumber.Trim() == "" select data).ToList(); break; case UpdateRecBatchType.延修生學籍異動名冊: // 規則:學籍異動代碼(不包含延修生異動代碼)且年級是延修生。 foreach (string code in (from elm in elms.Elements("異動") where elm.Element("分類").Value == "學籍異動" select elm.Element("代號").Value).ToList()) { if (!ExtendCodeList.Contains(code)) { CodeList.Add(code); } } //CodeList = (from elm in elms.Elements("異動") where elm.Element("分類").Value == "學籍異動" select elm.Element("代號").Value).ToList(); updatRecList = (from data in SHUpdateRecord.SelectByUpdateCodes(CodeList) where StudentIDList.Contains(data.StudentID) && data.GradeYear == "延修生" && data.ADNumber.Trim() == "" select data).ToList(); break; } // 轉換成符合名冊異動格式 _StudUpdateRecDocList = DAL.DALTransfer.ConvertSHUpdateRecToStudUpdateRec(updatRecList); }
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(); } } }
public DataRationalityMessage Execute() { RATList.Clear(); DataRationalityMessage Message = new DataRationalityMessage(); List <string> Err_StudentIDList = new List <string>(); try { // 取得學生基本 List <SHStudentRecord> StudRecListAll = SHStudent.SelectAll(); Dictionary <string, SHStudentRecord> StudRecDict = new Dictionary <string, SHStudentRecord>(); foreach (SHStudentRecord rec in StudRecListAll) { if (rec.Status == K12.Data.StudentRecord.StudentStatus.一般 || rec.Status == K12.Data.StudentRecord.StudentStatus.延修) { StudRecDict.Add(rec.ID, rec); } } Err_StudentIDList = StudRecDict.Keys.ToList(); // 檢查並取得資料,status 1 一般,2 延俢 if (Err_StudentIDList.Count > 0) { // 取得學生科目成績 List <SHSemesterScoreRecord> SHSemScoreList = SHSemesterScore.SelectByStudentIDs(Err_StudentIDList); // 學生科目成績索引,StudentID, Dictionary <string, List <ssSHSubjectScore> > SHSubjScoreDict = new Dictionary <string, List <ssSHSubjectScore> >(); foreach (SHSemesterScoreRecord SemsRec in SHSemScoreList) { if (!SHSubjScoreDict.ContainsKey(SemsRec.RefStudentID)) { SHSubjScoreDict.Add(SemsRec.RefStudentID, new List <ssSHSubjectScore>()); } foreach (SHSubjectScore ss in SemsRec.Subjects.Values) { ssSHSubjectScore sss = new ssSHSubjectScore(); sss.ss = ss; sss.SchoolYear = SemsRec.SchoolYear.ToString(); sss.Semester = SemsRec.Semester.ToString(); sss.GradeYear = SemsRec.GradeYear.ToString(); SHSubjScoreDict[SemsRec.RefStudentID].Add(sss); } } Dictionary <string, List <ssSHSubjectScore> > ssSubjDict = new Dictionary <string, List <ssSHSubjectScore> >(); // 檢查 科目名稱及級別重覆 foreach (string studID in SHSubjScoreDict.Keys) { ssSubjDict.Clear(); foreach (ssSHSubjectScore ss1 in SHSubjScoreDict[studID]) { string key = ss1.ss.Subject; if (ss1.ss.Level.HasValue) { key += ss1.ss.Subject + ss1.ss.Level.Value; } if (!ssSubjDict.ContainsKey(key)) { ssSubjDict.Add(key, new List <ssSHSubjectScore>()); } ssSubjDict[key].Add(ss1); } if (StudRecDict.ContainsKey(studID)) { foreach (string ssid in ssSubjDict.Keys) { // 有相同2個以上 if (ssSubjDict[ssid].Count > 1) { foreach (ssSHSubjectScore ssScore in ssSubjDict[ssid]) { SubjectNameDb snb = new SubjectNameDb(); snb.學生系統編號 = studID; snb.科目名稱 = ssScore.ss.Subject; snb.科目級別 = ""; if (ssScore.ss.Level.HasValue) { snb.科目級別 = ssScore.ss.Level.Value.ToString(); } snb.座號 = ""; if (StudRecDict[studID].SeatNo.HasValue) { snb.座號 = StudRecDict[studID].SeatNo.Value.ToString(); } if (StudRecDict[studID].Class != null) { snb.班級 = StudRecDict[studID].Class.Name; } snb.學生姓名 = StudRecDict[studID].Name; snb.學年度 = ssScore.SchoolYear; snb.學期 = ssScore.Semester; snb.年級 = ssScore.GradeYear; snb.學號 = StudRecDict[studID].StudentNumber; RATList.Add(snb); } } } } } } } catch (Exception ex) { Message.Message = ex.Message; return(Message); } StringBuilder sb = new StringBuilder(); sb.AppendLine("(學期科目名稱+科目級別)有重覆紀錄筆數: " + RATList.Count + " 筆"); Message.Message = sb.ToString(); // 排序 var SortedRATRecords = from RATRecord in RATList orderby RATRecord.學號, RATRecord.班級, K12.Data.Int.ParseAllowNull(RATRecord.座號), RATRecord.科目名稱, RATRecord.科目級別, RATRecord.學年度, RATRecord.學期 select RATRecord; Message.Data = SortedRATRecords.ToList(); return(Message); }
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(); } }