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); } } } } }
private void Insert(object item) { try { List <SHUpdateRecordRecord> InsertPackage = (List <SHUpdateRecordRecord>)item; SHUpdateRecord.Insert(InsertPackage); } catch (Exception ex) { FISCA.Presentation.Controls.MsgBox.Show("新增資料發生異常."); } }
private void Update(object item) { try { List <SHUpdateRecordRecord> UpdatePackage = (List <SHUpdateRecordRecord>)item; SHUpdateRecord.Update(UpdatePackage); } catch (Exception ex) { FISCA.Presentation.Controls.MsgBox.Show("更新資料發生異常."); } }
/// <summary> /// 設定學生異動記錄 核准日期與文號 /// </summary> /// <param name="ADDate"></param> /// <param name="ADNumber"></param> /// <param name="studURIDList"></param> public static void SetStudsUpdateRecADdata(string ADDate, string ADNumber, List <string> studURIDList) { // 取得異動 ID List <SHUpdateRecordRecord> updateRecs = SHUpdateRecord.SelectByIDs(studURIDList); foreach (SHUpdateRecordRecord rec in updateRecs) { rec.ADDate = ADDate; rec.ADNumber = ADNumber; } // 更新異動資料 SHUpdateRecord.Update(updateRecs); }
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(); }
void ImportNewStudentsUpdateRecord_BeginValidate(object sender, BeginValidateEventArgs e) { #region 整理異動代號及類別對照 updateCodeMapping = new Dictionary <string, string>(); foreach (SHUpdateCodeMappingInfo var in SHUpdateCodeMapping.SelectAll()) { if (!updateCodeMapping.ContainsKey(var.Code)) { updateCodeMapping.Add(var.Code, var.Type); } } #endregion _NewStudentUpdateRecordInfoList = new Dictionary <string, SHUpdateRecordRecord>(); List <SHStudentRecord> students = SHStudent.SelectByIDs(e.List); foreach (SHStudentRecord stu in students) { if (!_NewStudentUpdateRecordInfoList.ContainsKey(stu.ID)) { _NewStudentUpdateRecordInfoList.Add(stu.ID, null); } else { _NewStudentUpdateRecordInfoList[stu.ID] = null; } foreach (SHUpdateRecordRecord uinfo in SHUpdateRecord.SelectByStudentID(stu.ID)) { if (uinfo.UpdateType == Type) { _NewStudentUpdateRecordInfoList[stu.ID] = uinfo; break; } } } }
private void btnRemove_Click(object sender, EventArgs e) { if (lstRecord.SelectedItems.Count < 1) { MsgBox.Show("您必須先選擇一筆資料"); } if (lstRecord.SelectedItems.Count == 1) { SHUpdateRecordRecord record = lstRecord.SelectedItems[0].Tag as SHUpdateRecordRecord; if (MsgBox.Show("您確定將此筆異動資料永久刪除?", "確認", MessageBoxButtons.OKCancel) == DialogResult.OK) { try { // 刪除異動記錄 SHUpdateRecord.Delete(record); } catch (Exception ex) { MsgBox.Show("異動資料刪除失敗:" + ex.Message); } } } }
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) { } }; }
void BGWorker_DoWork(object sender, DoWorkEventArgs e) { _StudUpateRecList = SHUpdateRecord.SelectByStudentID(PrimaryKey); }
public override string Import(List <IRowStream> Rows) { _InsertRecList.Clear(); _UpdateRecList.Clear(); // 取得 Rows內學號 List <string> StudentNumberList = new List <string>(); foreach (IRowStream ir in Rows) { if (ir.Contains("學號")) { StudentNumberList.Add(ir.GetValue("學號")); } } // 透過學號去取得學生ID Dictionary <string, string> StudNumDict = DAL.FDQuery.GetStudenNumberStatusDictByStudentNumber(StudentNumberList); List <string> StudentIDList = new List <string>(); foreach (IRowStream ir in Rows) { if (ir.Contains("學號") && ir.Contains("狀態")) { string key = ir.GetValue("學號") + "_" + ir.GetValue("狀態"); if (StudNumDict.ContainsKey(key)) { StudentIDList.Add(StudNumDict[key]); } } } List <string> updateCodeList = Utility.UITool.GetUpdateCodeListByUpdateType("轉入異動"); // 取得轉入異動資料 List <SHUpdateRecordRecord> updateRecList = (from data in SHUpdateRecord.SelectByStudentIDs(StudentIDList) where updateCodeList.Contains(data.UpdateCode) select data).ToList(); int totalCount = 0; // 判斷更新或新增 foreach (IRowStream ir in Rows) { totalCount++; this.ImportProgress = totalCount; bool isInsert = true; SHUpdateRecordRecord UpdateRec = null; string StudentID = ""; if (ir.Contains("學號") && ir.Contains("狀態")) { string key = ir.GetValue("學號") + "_" + ir.GetValue("狀態"); if (StudNumDict.ContainsKey(key)) { StudentID = StudNumDict[key]; } } if (string.IsNullOrEmpty(StudentID)) { continue; } DateTime dt; DateTime.TryParse(ir.GetValue("異動日期"), out dt); foreach (SHUpdateRecordRecord rec in updateRecList.Where(x => x.StudentID == StudentID)) { string updateCode = string.Format("{0:000}", int.Parse(ir.GetValue("異動代碼").Trim())); if (rec.UpdateCode.Trim() == updateCode) { DateTime dt1; DateTime.TryParse(rec.UpdateDate, out dt1); if (dt.ToShortDateString() == dt1.ToShortDateString()) { isInsert = false; UpdateRec = rec; } } } if (isInsert || UpdateRec == null) { UpdateRec = new SHUpdateRecordRecord(); } UpdateRec.StudentID = StudentID; if (isInsert) { int sy, ss; // 學年度 if (ir.Contains("學年度")) { if (int.TryParse(ir.GetValue("學年度"), out sy)) { UpdateRec.SchoolYear = sy; } if (string.IsNullOrEmpty(ir.GetValue("學年度"))) { UpdateRec.SchoolYear = null; } } // 學期 if (ir.Contains("學期")) { if (int.TryParse(ir.GetValue("學期"), out ss)) { UpdateRec.Semester = ss; } if (string.IsNullOrEmpty(ir.GetValue("學期"))) { UpdateRec.Semester = null; } } // 異動年級 if (ir.Contains("異動年級")) { UpdateRec.GradeYear = ir.GetValue("異動年級"); } // 異動代碼 UpdateRec.UpdateCode = string.Format("{0:000}", int.Parse(ir.GetValue("異動代碼").Trim())); // 原因及事項 if (ir.Contains("原因及事項")) { UpdateRec.UpdateDescription = ir.GetValue("原因及事項"); } // 異動日期 UpdateRec.UpdateDate = dt.ToShortDateString(); // 備註 if (ir.Contains("備註")) { UpdateRec.Comment = ir.GetValue("備註"); } // 班別 if (ir.Contains("班別")) { UpdateRec.ClassType = ir.GetValue("班別"); } // 科別 if (ir.Contains("科別")) { UpdateRec.Department = ir.GetValue("科別"); } // 特殊身分代碼 if (ir.Contains("特殊身分代碼")) { UpdateRec.SpecialStatus = ir.GetValue("特殊身分代碼"); } // 入學資格證明文件 if (ir.Contains("入學資格證明文件")) { UpdateRec.GraduateDocument = ir.GetValue("入學資格證明文件"); } // 異動姓名 if (ir.Contains("異動姓名")) { UpdateRec.StudentName = ir.GetValue("異動姓名"); } // 異動學號 if (ir.Contains("異動學號")) { UpdateRec.StudentNumber = ir.GetValue("異動學號"); } // 異動身分證字號 if (ir.Contains("異動身分證字號")) { UpdateRec.IDNumber = ir.GetValue("異動身分證字號"); } // 異動生日 if (ir.Contains("異動生日")) { DateTime dtd; if (DateTime.TryParse(ir.GetValue("異動生日"), out dtd)) { UpdateRec.Birthdate = dtd.ToShortDateString(); } if (string.IsNullOrEmpty(ir.GetValue("異動生日"))) { UpdateRec.Birthdate = ""; } } // 異動身分證註記 if (ir.Contains("異動身分證註記")) { UpdateRec.IDNumberComment = ir.GetValue("異動身分證註記"); } // 異動性別 if (ir.Contains("異動性別")) { UpdateRec.Gender = ir.GetValue("異動性別"); } // 原就讀學校 if (ir.Contains("原就讀學校")) { UpdateRec.PreviousSchool = ir.GetValue("原就讀學校"); } // 原就讀學號 if (ir.Contains("原就讀學號")) { UpdateRec.PreviousStudentNumber = ir.GetValue("原就讀學號"); } // 原就讀科別 if (ir.Contains("原就讀科別")) { UpdateRec.PreviousDepartment = ir.GetValue("原就讀科別"); } // 原就讀年級 if (ir.Contains("原就讀年級")) { UpdateRec.PreviousGradeYear = ir.GetValue("原就讀年級"); } // 原就讀學期 if (ir.Contains("原就讀學期")) { UpdateRec.PreviousSemester = ir.GetValue("原就讀學期"); } // 原就讀備查日期 if (ir.Contains("原就讀備查日期")) { DateTime dta; if (DateTime.TryParse(ir.GetValue("原就讀備查日期"), out dta)) { UpdateRec.PreviousSchoolLastADDate = dta.ToShortDateString(); } if (string.IsNullOrEmpty(ir.GetValue("原就讀備查日期"))) { UpdateRec.PreviousSchoolLastADDate = ""; } } // 原就讀備查文號 if (ir.Contains("原就讀備查文號")) { UpdateRec.PreviousSchoolLastADNumber = ir.GetValue("原就讀備查文號"); } // 核准日期 if (ir.Contains("核准日期")) { DateTime dta; if (DateTime.TryParse(ir.GetValue("核准日期"), out dta)) { UpdateRec.ADDate = dta.ToShortDateString(); } if (string.IsNullOrEmpty(ir.GetValue("核准日期"))) { UpdateRec.ADDate = ""; } } // 核准文號 if (ir.Contains("核准文號")) { UpdateRec.ADNumber = ir.GetValue("核准文號"); } //轉入身分別代碼 if (ir.Contains("轉入身分別代碼")) { UpdateRec.Comment2 = ir.GetValue("轉入身分別代碼"); } } else { // 更新有勾選 int sy, ss; // 學年度 if (ir.Contains("學年度") && mOption.SelectedFields.Contains("學年度")) { if (int.TryParse(ir.GetValue("學年度"), out sy)) { UpdateRec.SchoolYear = sy; } if (string.IsNullOrEmpty(ir.GetValue("學年度"))) { UpdateRec.SchoolYear = null; } } // 學期 if (ir.Contains("學期") && mOption.SelectedFields.Contains("學期")) { if (int.TryParse(ir.GetValue("學期"), out ss)) { UpdateRec.Semester = ss; } if (string.IsNullOrEmpty(ir.GetValue("學期"))) { UpdateRec.Semester = null; } } // 異動年級 if (ir.Contains("異動年級") && mOption.SelectedFields.Contains("異動年級")) { UpdateRec.GradeYear = ir.GetValue("異動年級"); } //// 異動代碼 //UpdateRec.UpdateCode = ir.GetValue("異動代碼").Trim(); // 原因及事項 if (ir.Contains("原因及事項") && mOption.SelectedFields.Contains("原因及事項")) { UpdateRec.UpdateDescription = ir.GetValue("原因及事項"); } //// 異動日期 //UpdateRec.UpdateDate = dt.ToShortDateString(); // 備註 if (ir.Contains("備註") && mOption.SelectedFields.Contains("備註")) { UpdateRec.Comment = ir.GetValue("備註"); } // 班別 if (ir.Contains("班別") && mOption.SelectedFields.Contains("班別")) { UpdateRec.ClassType = ir.GetValue("班別"); } // 科別 if (ir.Contains("科別") && mOption.SelectedFields.Contains("科別")) { UpdateRec.Department = ir.GetValue("科別"); } // 特殊身分代碼 if (ir.Contains("特殊身分代碼") && mOption.SelectedFields.Contains("特殊身分代碼")) { UpdateRec.SpecialStatus = ir.GetValue("特殊身分代碼"); } // 入學資格證明文件 if (ir.Contains("入學資格證明文件") && mOption.SelectedFields.Contains("入學資格證明文件")) { UpdateRec.GraduateDocument = ir.GetValue("入學資格證明文件"); } // 異動姓名 if (ir.Contains("異動姓名") && mOption.SelectedFields.Contains("異動姓名")) { UpdateRec.StudentName = ir.GetValue("異動姓名"); } // 異動學號 if (ir.Contains("異動學號") && mOption.SelectedFields.Contains("異動學號")) { UpdateRec.StudentNumber = ir.GetValue("異動學號"); } // 異動身分證字號 if (ir.Contains("異動身分證字號") && mOption.SelectedFields.Contains("異動身分證字號")) { UpdateRec.IDNumber = ir.GetValue("異動身分證字號"); } // 異動生日 if (ir.Contains("異動生日") && mOption.SelectedFields.Contains("異動生日")) { DateTime dtd; if (DateTime.TryParse(ir.GetValue("異動生日"), out dtd)) { UpdateRec.Birthdate = dtd.ToShortDateString(); } if (string.IsNullOrEmpty(ir.GetValue("異動生日"))) { UpdateRec.Birthdate = ""; } } // 異動身分證註記 if (ir.Contains("異動身分證註記") && mOption.SelectedFields.Contains("異動身分證註記")) { UpdateRec.IDNumberComment = ir.GetValue("異動身分證註記"); } // 異動性別 if (ir.Contains("異動性別") && mOption.SelectedFields.Contains("異動性別")) { UpdateRec.Gender = ir.GetValue("異動性別"); } // 原就讀學校 if (ir.Contains("原就讀學校") && mOption.SelectedFields.Contains("原就讀學校")) { UpdateRec.PreviousSchool = ir.GetValue("原就讀學校"); } // 原就讀學號 if (ir.Contains("原就讀學號") && mOption.SelectedFields.Contains("原就讀學號")) { UpdateRec.PreviousStudentNumber = ir.GetValue("原就讀學號"); } // 原就讀科別 if (ir.Contains("原就讀科別") && mOption.SelectedFields.Contains("原就讀科別")) { UpdateRec.PreviousDepartment = ir.GetValue("原就讀科別"); } // 原就讀年級 if (ir.Contains("原就讀年級") && mOption.SelectedFields.Contains("原就讀年級")) { UpdateRec.PreviousGradeYear = ir.GetValue("原就讀年級"); } // 原就讀學期 if (ir.Contains("原就讀學期") && mOption.SelectedFields.Contains("原就讀學期")) { UpdateRec.PreviousSemester = ir.GetValue("原就讀學期"); } // 原就讀備查日期 if (ir.Contains("原就讀備查日期") && mOption.SelectedFields.Contains("原就讀備查日期")) { DateTime dta; if (DateTime.TryParse(ir.GetValue("原就讀備查日期"), out dta)) { UpdateRec.PreviousSchoolLastADDate = dta.ToShortDateString(); } if (string.IsNullOrEmpty(ir.GetValue("原就讀備查日期"))) { UpdateRec.PreviousSchoolLastADDate = ""; } } // 原就讀備查文號 if (ir.Contains("原就讀備查文號") && mOption.SelectedFields.Contains("原就讀備查文號")) { UpdateRec.PreviousSchoolLastADNumber = ir.GetValue("原就讀備查文號"); } // 核准日期 if (ir.Contains("核准日期") && mOption.SelectedFields.Contains("核准日期")) { DateTime dta; if (DateTime.TryParse(ir.GetValue("核准日期"), out dta)) { UpdateRec.ADDate = dta.ToShortDateString(); } if (string.IsNullOrEmpty(ir.GetValue("核准日期"))) { UpdateRec.ADDate = ""; } } // 核准文號 if (ir.Contains("核准文號") && mOption.SelectedFields.Contains("核准文號")) { UpdateRec.ADNumber = ir.GetValue("核准文號"); } // 轉入身分別代碼 if (ir.Contains("轉入身分別代碼") && mOption.SelectedFields.Contains("轉入身分別代碼")) { UpdateRec.Comment2 = ir.GetValue("轉入身分別代碼"); } } if (isInsert) { _InsertRecList.Add(UpdateRec); } else { _UpdateRecList.Add(UpdateRec); } } // 執行更新或新增 if (_InsertRecList.Count > 0) { SHUpdateRecord.Insert(_InsertRecList); } if (_UpdateRecList.Count > 0) { SHUpdateRecord.Update(_UpdateRecList); } return(""); }
void _bgWorkerRun_DoWork(object sender, DoWorkEventArgs e) { // 處理資料 try { _bgWorkerRun.ReportProgress(1); // 刪除舊資料 List <SHUpdateRecordRecord> _oldDataList = _StudHasGraduateRecDict.Values.ToList(); SHUpdateRecord.Delete(_oldDataList); int SchoolYear = int.Parse(K12.Data.School.DefaultSchoolYear); int Semester = int.Parse(K12.Data.School.DefaultSemester); _bgWorkerRun.ReportProgress(10); foreach (string sid in _StudentIDList) { if (!_StudentDict.ContainsKey(sid)) { continue; } SHUpdateRecordRecord rec = new SHUpdateRecordRecord(); // 學年度 rec.SchoolYear = SchoolYear; // 學期 rec.Semester = Semester; rec.StudentID = sid; string ClassName = ""; string DeptName = ""; // 年級 if (_ClassRecDict.ContainsKey(_StudentDict[sid].RefClassID)) { if (_ClassRecDict[_StudentDict[sid].RefClassID].GradeYear.HasValue) { rec.GradeYear = _ClassRecDict[_StudentDict[sid].RefClassID].GradeYear.Value.ToString(); // 班級名稱 ClassName = _ClassRecDict[_StudentDict[sid].RefClassID].Name; // 科別名稱 if (_DeptRecDict.ContainsKey(_ClassRecDict[_StudentDict[sid].RefClassID].RefDepartmentID)) { DeptName = _DeptRecDict[_ClassRecDict[_StudentDict[sid].RefClassID].RefDepartmentID].FullName; } } else { rec.GradeYear = ""; } } // 畢業代碼 rec.UpdateCode = "501"; // 原因及事項 rec.UpdateDescription = "畢業"; // 異動日期 rec.UpdateDate = _UpdateDate.ToShortDateString(); // 姓名 rec.StudentName = _StudentDict[sid].Name; // 學號 rec.StudentNumber = _StudentDict[sid].StudentNumber; // 身分證字號 rec.IDNumber = _StudentDict[sid].IDNumber; // 生日 if (_StudentDict[sid].Birthday.HasValue) { rec.Birthdate = _StudentDict[sid].Birthday.Value.ToShortDateString(); } // 性別 rec.Gender = _StudentDict[sid].Gender; if (_StudLastupdateRecDict.ContainsKey(sid)) { // 備查日期 rec.LastADDate = _StudLastupdateRecDict[sid].ADDate; // 備查文號 rec.LastADNumber = _StudLastupdateRecDict[sid].ADNumber; // 最後異動代碼 rec.LastUpdateCode = _StudLastupdateRecDict[sid].UpdateCode; } // 畢業證書字號 if (_LeaveInfoRecordDict.ContainsKey(sid)) { rec.GraduateCertificateNumber = _LeaveInfoRecordDict[sid].DiplomaNumber; rec.Department = DeptName; rec.ExpectGraduateSchoolYear = SchoolYear.ToString(); _LeaveInfoRecordDict[sid].SchoolYear = SchoolYear; _LeaveInfoRecordDict[sid].ClassName = ClassName; _LeaveInfoRecordDict[sid].DepartmentName = DeptName; } _InsertDataList.Add(rec); } _bgWorkerRun.ReportProgress(70); // 新增資料 if (_InsertDataList.Count > 0) { SHUpdateRecord.Insert(_InsertDataList); } // 更新畢業離校資訊 離校學年度、離校科別、離校班級 SHLeaveInfo.Update(_LeaveInfoRecordDict.Values.ToList()); _bgWorkerRun.ReportProgress(99); } catch (Exception ex) { e.Result = ex; e.Cancel = true; } }
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 _bgWorker_DoWork(object sender, DoWorkEventArgs e) { Document doc = new Document(); Document template = null; if (radioButton1.Checked == true) { //選擇預設範本時的動作 template = new Document(new MemoryStream(defalutTemplate)); } else if (radioButton2.Checked == true) { //選擇自訂範本時的動作 //School.Configuration.Remove(cd); //return; string str = cd["CustomizeTemplate"]; if (template == null) { try { template = (new Document(new MemoryStream(Convert.FromBase64String(str)))).Clone(); } catch (Exception ex) { throw new InvalidOperationException("尚未上傳自訂樣板"); //MsgBox.Show("尚未上傳自訂樣板"); //return; } //template = new Document(new MemoryStream(defalutTemplate)); } } else { MsgBox.Show(""); return; } //取得文號、字號、學年度學期取得 string No1 = textBoxX1.Text; string No2 = textBoxX2.Text; int schoolYear = int.Parse(K12.Data.School.DefaultSchoolYear); int semester = int.Parse(K12.Data.School.DefaultSemester); //取得學校名稱 string DSNSName = SHSchool.Data.SHSchoolInfo.ChineseName; string Principal = K12.Data.School.Configuration["學校資訊"].PreviousData.SelectSingleNode("ChancellorChineseName").InnerText; #region 取得選取學生 List <SHStudentRecord> studentAll = SHStudent.SelectByIDs(studentIds); List <SHUpdateRecordRecord> updateRecord = SHUpdateRecord.SelectByStudentIDs(studentIds); Dictionary <string, StudentObj> dic = new Dictionary <string, StudentObj>(); foreach (SHUpdateRecordRecord urr in updateRecord) { if (dic.ContainsKey(urr.StudentID)) { SHUpdateRecordRecord old = dic[urr.StudentID].URR; int newSchoolYear = urr.SchoolYear.HasValue ? urr.SchoolYear.Value : 0; int newSemester = urr.Semester.HasValue ? urr.Semester.Value : 0; int oldSchoolYear = old.SchoolYear.HasValue ? old.SchoolYear.Value : 0; int oldSemester = old.Semester.HasValue ? old.Semester.Value : 0; if (newSchoolYear > oldSchoolYear) { dic[urr.StudentID].URR = urr; } else if (newSchoolYear == oldSchoolYear) { if (newSemester > oldSemester) { dic[urr.StudentID].URR = urr; } } } if (updateCode.Contains(urr.UpdateCode) && !dic.ContainsKey(urr.StudentID)) { dic.Add(urr.StudentID, new StudentObj()); dic[urr.StudentID].URR = urr; } } foreach (SHStudentRecord sr in studentAll) { if (dic.ContainsKey(sr.ID)) { dic[sr.ID].Student = sr; } } #endregion Dictionary <string, object> merge = new Dictionary <string, object>(); string serverTime = GetServerTime(); foreach (StudentObj obj in dic.Values) { Document perPage = template.Clone(); merge.Clear(); merge.Add("起始時間", dateTimeInput1.Value.ToString("yyyy年MM月dd日")); merge.Add("訖末時間", dateTimeInput2.Value.ToString("yyyy年MM月dd日")); merge.Add("編字", No1); merge.Add("編號", No2); merge.Add("年級", schoolYear); merge.Add("學期", semester); merge.Add("學校名稱", DSNSName); merge.Add("校長姓名", Principal); merge.Add("列印日期", serverTime); merge.Add("學生姓名", obj.Student.Name); merge.Add("學號", obj.Student.StudentNumber); merge.Add("休學年級", obj.URR.GradeYear); merge.Add("休學學期", obj.URR.Semester); merge.Add("科系", obj.URR == null ? string.Empty : obj.URR.Department); merge.Add("休學事由", obj.URR == null ? string.Empty : obj.URR.UpdateDescription); perPage.MailMerge.Execute(merge.Keys.ToArray <string>(), merge.Values.ToArray <object>()); perPage.MailMerge.RemoveEmptyParagraphs = true; perPage.MailMerge.DeleteFields(); doc.Sections.Add(doc.ImportNode(perPage.Sections[0], true)); } doc.Sections.RemoveAt(0); e.Result = doc; }
/// <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"); // 新生保留代碼 List <string> chkCodeList1 = new List <string>(); chkCodeList1.Add("601"); chkCodeList1.Add("602"); chkCodeList1.Add("603"); chkCodeList1.Add("604"); // 借讀代碼 List <string> chkCodeList2 = new List <string>(); chkCodeList2.Add("701"); chkCodeList2.Add("702"); chkCodeList2.Add("703"); // 取得異動代碼資料 XElement elms = DAL.DALTransfer.GetUpdateCodeList(); List <string> CodeList = new List <string> (); // 取得非刪除學生 List <string> StudentIDList = utility.GetStudentIDListNot256(); // 透過異動代碼取沒有核准文號異動記錄,學生狀態非刪除。 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 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 chkCodeList1.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 chkCodeList2.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; } // 轉換成符合名冊異動格式 _StudUpdateRecDocList = DAL.DALTransfer.ConvertSHUpdateRecToStudUpdateRec(updatRecList); }
void _bgWorker_DoWork(object sender, DoWorkEventArgs e) { _bgWorker.ReportProgress(1); // 取得部別、班別對照 ConfigData cd = new ConfigData(); Dictionary <string, List <ConfigDataItem> > cdDict = cd.GetConfigDataItemDict(); Dictionary <string, string> DepMappingDict = new Dictionary <string, string>(); Dictionary <string, string> ClsMappingDict = new Dictionary <string, string>(); Dictionary <string, string> DeptMappingDict = new Dictionary <string, string>(); Dictionary <string, string> ClassNoMappingDict = new Dictionary <string, string>(); Dictionary <string, string> ClassIDNameDict = new Dictionary <string, string>(); Dictionary <string, List <string> > StudTagNameDict = new Dictionary <string, List <string> >(); List <SHStudentTagRecord> SHStudentTagRecordList = SHStudentTag.SelectByStudentIDs(_StudentIDList); // 取得學期對照班級座號轉成大學繁星班代 Dictionary <string, string> StudentSHClassSeatNoDict = Utility.GetStudentClassCodeSeatNo(_StudentIDList, _SchoolYear, _Semester, true); // 取得學生科別名稱 Dictionary <string, string> StudeDeptNameDict = Utility.GetStudDeptNameDict(_StudentIDList, _SchoolYear, _Semester); // 取得學生異動資料 List <SHUpdateRecordRecord> SHUpdateRecordRecordList = SHUpdateRecord.SelectByStudentIDs(_StudentIDList); Dictionary <string, List <SHUpdateRecordRecord> > SHUpdateRecordRecordDict = new Dictionary <string, List <SHUpdateRecordRecord> >(); // 沒有核准日期文號不排入,並符合所選的學年度學期 foreach (SHUpdateRecordRecord urRec in SHUpdateRecordRecordList) { if (string.IsNullOrWhiteSpace(urRec.ADDate) || string.IsNullOrWhiteSpace(urRec.ADNumber)) { continue; } if (urRec.SchoolYear.HasValue && urRec.Semester.HasValue) { if (urRec.SchoolYear <= _SchoolYear && urRec.Semester <= _Semester) { if (!SHUpdateRecordRecordDict.ContainsKey(urRec.StudentID)) { SHUpdateRecordRecordDict.Add(urRec.StudentID, new List <SHUpdateRecordRecord>()); } SHUpdateRecordRecordDict[urRec.StudentID].Add(urRec); } } } // 取得學生類別 foreach (SHStudentTagRecord TRec in SHStudentTagRecordList) { if (!StudTagNameDict.ContainsKey(TRec.RefStudentID)) { StudTagNameDict.Add(TRec.RefStudentID, new List <string>()); } StudTagNameDict[TRec.RefStudentID].Add(TRec.FullName); } _bgWorker.ReportProgress(20); foreach (SHClassRecord rec in SHClass.SelectAll()) { ClassIDNameDict.Add(rec.ID, rec.Name); } // 部別對照 if (cdDict.ContainsKey("部別代碼")) { foreach (ConfigDataItem cdi in cdDict["部別代碼"]) { if (!DepMappingDict.ContainsKey(cdi.TargetName)) { DepMappingDict.Add(cdi.TargetName, cdi.Value); } } } // 班別對照 if (cdDict.ContainsKey("班別代碼")) { foreach (ConfigDataItem cdi in cdDict["班別代碼"]) { if (!ClsMappingDict.ContainsKey(cdi.TargetName)) { ClsMappingDict.Add(cdi.TargetName, cdi.Value); } } } // 科別對照 DeptMappingDict = Utility.GetDepartmetDict(); // 班級代碼對照 ClassNoMappingDict = Utility.GetLHClassCodeDict(); _bgWorker.ReportProgress(40); // 取得學生本資料 List <SHStudentRecord> StudentRecordList = SHStudent.SelectByIDs(_StudentIDList); List <StudentBaseRec> StudentBaseRecList = new List <StudentBaseRec>(); // 整理資料 foreach (SHStudentRecord studRec in StudentRecordList) { // 身分證號,出生日期,所屬學校代碼,科/班/學程別代碼,部別,班別,班級座號代碼 StudentBaseRec sbr = new StudentBaseRec(); sbr.StudentNumber = studRec.StudentNumber; sbr.IDNumber = studRec.IDNumber.ToUpper(); sbr.BirthDate = Utility.ConvertChDateString(studRec.Birthday); sbr.SchoolCode = _SchoolCode; sbr.Name = studRec.Name; if (studRec.Gender == "男") { sbr.GenderCode = "1"; } if (studRec.Gender == "女") { sbr.GenderCode = "2"; } // 科/班/學程別代碼 sbr.DCLCode = ""; if (StudeDeptNameDict.ContainsKey(studRec.ID)) { string name = StudeDeptNameDict[studRec.ID]; if (DeptMappingDict.ContainsKey(name)) { sbr.DCLCode = DeptMappingDict[name]; } } // 部別 sbr.DepCode = _DepCode; // 班別 sbr.ClCode = _ClassCode; if (StudTagNameDict.ContainsKey(studRec.ID)) { foreach (string str in StudTagNameDict[studRec.ID]) { if (DepMappingDict.ContainsKey(str)) { sbr.DepCode = DepMappingDict[str]; } if (ClsMappingDict.ContainsKey(str)) { sbr.ClCode = ClsMappingDict[str]; } } } // 班級座號代碼 sbr.ClassSeatCode = ""; if (StudentSHClassSeatNoDict.ContainsKey(studRec.ID)) { sbr.ClassSeatCode = StudentSHClassSeatNoDict[studRec.ID]; if (sbr.ClassSeatCode.Length == 5) { sbr.ClassCode = sbr.ClassSeatCode.Substring(0, 3); } } else { //如果學年度學期和系統預設相同 if (K12.Data.School.DefaultSchoolYear == _SchoolYear.ToString() && K12.Data.School.DefaultSemester == _Semester.ToString()) { if (ClassIDNameDict.ContainsKey(studRec.RefClassID)) { string cName = ClassIDNameDict[studRec.RefClassID]; if (ClassNoMappingDict.ContainsKey(cName) && studRec.SeatNo.HasValue) { sbr.ClassSeatCode = ClassNoMappingDict[cName] + string.Format("{0:00}", studRec.SeatNo.Value); sbr.ClassCode = ClassNoMappingDict[cName]; } } } } // 處理異動相關 if (SHUpdateRecordRecordDict.ContainsKey(studRec.ID)) { // 排序 List <SHUpdateRecordRecord> UrDataList = (from data in SHUpdateRecordRecordDict[studRec.ID] orderby DateTime.Parse(data.ADDate) descending, int.Parse(data.ID) descending select data).ToList(); if (UrDataList.Count > 0) { SHUpdateRecordRecord rec = UrDataList[0]; sbr.PermrecCode = rec.UpdateCode; DateTime dt = DateTime.Parse(rec.UpdateDate); sbr.PermrecDate = Utility.ConvertChDateString(dt); sbr.OrBirthDate = "-1"; sbr.OrIDNumber = "-1"; sbr.Remak1 = rec.IDNumberComment; sbr.SpCode = rec.SpecialStatus; } foreach (SHUpdateRecordRecord rec in UrDataList) { // 再次檢查身分證與生日是否有差異 int iUcode = int.Parse(rec.UpdateCode); if (iUcode > 400 && iUcode < 411) { if (rec.IDNumber.ToUpper() != studRec.IDNumber.ToUpper()) { sbr.OrIDNumber = rec.IDNumber.ToUpper(); } if (studRec.Birthday.HasValue) { if (studRec.Birthday.Value.ToShortDateString() != rec.Birthdate) { DateTime dto = DateTime.Parse(rec.Birthdate); sbr.OrBirthDate = Utility.ConvertChDateString(dto); } } } } } StudentBaseRecList.Add(sbr); } _bgWorker.ReportProgress(80); // 排序 班級座號代碼 StudentBaseRecList = (from data in StudentBaseRecList orderby data.ClassSeatCode ascending select data).ToList(); // 統計人數 Dictionary <string, StudentBaseRecCount> StudentBaseRecCountDict = new Dictionary <string, StudentBaseRecCount>(); foreach (StudentBaseRec rec in StudentBaseRecList) { string key = rec.ClCode + rec.DCLCode + rec.DepCode + rec.ClassCode; if (!StudentBaseRecCountDict.ContainsKey(key)) { StudentBaseRecCount sbrc = new StudentBaseRecCount(); sbrc.ClassCode = rec.ClassCode; sbrc.ClCode = rec.ClCode; sbrc.DCLCode = rec.DCLCode; sbrc.DepCode = rec.DepCode; sbrc.DocType = _DocType; sbrc.SchoolCode = _SchoolCode; sbrc.SchoolYear = _SchoolYear; sbrc.Semester = _Semester; sbrc.StudentCount = 0; StudentBaseRecCountDict.Add(key, sbrc); } StudentBaseRecCountDict[key].StudentCount++; } List <StudentBaseRecCount> StudentBaseRecCountList = new List <StudentBaseRecCount>(); foreach (string Key in StudentBaseRecCountDict.Keys) { StudentBaseRecCountList.Add(StudentBaseRecCountDict[Key]); } // 排序,依班級代碼 StudentBaseRecCountList = (from data in StudentBaseRecCountList orderby data.ClassCode ascending select data).ToList(); // 填值到 Excel _wb = new Workbook(new MemoryStream(Properties.Resources.學生資料名冊樣板_非國教署主管學校_)); Worksheet wst1 = _wb.Worksheets["學生資料名冊封面"]; Worksheet wst2 = _wb.Worksheets["學生資料名冊"]; int rowIdx = 1; foreach (StudentBaseRecCount sbrc in StudentBaseRecCountList) { //學校代碼 0,學年度 1,學期 2,名冊別 3,科/班/學程別代碼 4,年級班級代碼 5,部別 6,班別 7,班級人數 8 wst1.Cells[rowIdx, 0].PutValue(sbrc.SchoolCode); wst1.Cells[rowIdx, 1].PutValue(sbrc.SchoolYear); wst1.Cells[rowIdx, 2].PutValue(sbrc.Semester); wst1.Cells[rowIdx, 3].PutValue(sbrc.DocType); wst1.Cells[rowIdx, 4].PutValue(sbrc.DCLCode); wst1.Cells[rowIdx, 5].PutValue(sbrc.ClassCode); wst1.Cells[rowIdx, 6].PutValue(sbrc.DepCode); wst1.Cells[rowIdx, 7].PutValue(sbrc.ClCode); wst1.Cells[rowIdx, 8].PutValue(sbrc.StudentCount); rowIdx++; } rowIdx = 1; foreach (StudentBaseRec sbr in StudentBaseRecList) { // 學號 0,身分證號 1,註1 2,姓名 3,性別代碼 4,出生日期 5,所屬學校代碼 6,科/班/學程別代碼 7,部別 8, //班別 9,班級座號代碼 10,特殊身分代碼 11,原身分證號 12,原出生日期 13,學籍狀態代碼 14,學籍狀態生效日期 15 wst2.Cells[rowIdx, 0].PutValue(sbr.StudentNumber); wst2.Cells[rowIdx, 1].PutValue(sbr.IDNumber); wst2.Cells[rowIdx, 2].PutValue(sbr.Remak1); wst2.Cells[rowIdx, 3].PutValue(sbr.Name); wst2.Cells[rowIdx, 4].PutValue(sbr.GenderCode); wst2.Cells[rowIdx, 5].PutValue(sbr.BirthDate); wst2.Cells[rowIdx, 6].PutValue(sbr.SchoolCode); wst2.Cells[rowIdx, 7].PutValue(sbr.DCLCode); wst2.Cells[rowIdx, 8].PutValue(sbr.DepCode); wst2.Cells[rowIdx, 9].PutValue(sbr.ClCode); wst2.Cells[rowIdx, 10].PutValue(sbr.ClassSeatCode); wst2.Cells[rowIdx, 11].PutValue(sbr.SpCode); wst2.Cells[rowIdx, 12].PutValue(sbr.OrIDNumber); wst2.Cells[rowIdx, 13].PutValue(sbr.OrBirthDate); wst2.Cells[rowIdx, 14].PutValue(sbr.PermrecCode); wst2.Cells[rowIdx, 15].PutValue(sbr.PermrecDate); rowIdx++; } _bgWorker.ReportProgress(100); }
/// <summary> /// 產生新生異動(傳入學生編號、異動日期、異動代碼、班別) /// </summary> /// <param name="StudentIDList"></param> /// <param name="UpdateDate"></param> /// <param name="UpdateCode"></param> /// <param name="ClassType"></param> /// <returns></returns> public bool Run(List <string> StudentIDList, string UpdateDate, string UpdateCode, string UpdateDesc, string ClassType) { bool pass = true; List <SHBeforeEnrollmentRecord> befRecList = SHBeforeEnrollment.SelectByStudentIDs(StudentIDList); Dictionary <string, DAL.SchoolData> schoolDataDict = new Dictionary <string, DAL.SchoolData> (); foreach (XElement elm in BL.Get.JHSchoolList().Elements("學校")) { DAL.SchoolData sd = new DAL.SchoolData(); sd.SchoolCode = elm.Attribute("代碼").Value; sd.SchoolLocation = elm.Attribute("所在地").Value; sd.SchoolName = elm.Attribute("名稱").Value; sd.SchoolLocationCode = elm.Attribute("所在地代碼").Value; if (sd.SchoolCode.Length > 3) { sd.SchoolType = sd.SchoolCode.Substring(2, 1); } string s1 = elm.Attribute("所在地").Value + elm.Attribute("名稱").Value; if (!schoolDataDict.ContainsKey(s1)) { schoolDataDict.Add(s1, sd); } if (!schoolDataDict.ContainsKey(sd.SchoolName)) { schoolDataDict.Add(sd.SchoolName, sd); } } int SchoolYear = 0, Semester = 0; int.TryParse(K12.Data.School.DefaultSchoolYear, out SchoolYear); int.TryParse(K12.Data.School.DefaultSemester, out Semester); List <string> _CheckCodeList = (from data in _UpdateCodeList select data.Substring(0, 3)).ToList(); List <SHUpdateRecordRecord> insertData = new List <SHUpdateRecordRecord>(); List <SHUpdateRecordRecord> WaitDeleteData = new List <SHUpdateRecordRecord>(); // 取得學生資料 List <SHStudentRecord> studRecList = SHStudent.SelectByIDs(StudentIDList); List <string> SIDList = new List <string>(); // 取得已有新生異動 foreach (SHUpdateRecordRecord rec in SHUpdateRecord.SelectByStudentIDs(StudentIDList)) { if (_CheckCodeList.Contains(rec.UpdateCode)) { WaitDeleteData.Add(rec); if (!SIDList.Contains(rec.StudentID)) { SIDList.Add(rec.StudentID); } } } bool checkdelData = true; // 已有資料是否覆蓋 if (SIDList.Count > 0) { WarningForm wf = new WarningForm(); wf.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; wf.SetStudentCount(SIDList.Count); wf.SetStudRec(studRecList); wf.SetUpdateRecList(WaitDeleteData); if (wf.ShowDialog() == System.Windows.Forms.DialogResult.Cancel) { checkdelData = false; pass = false; } } // 清掉舊資料 if (checkdelData) { SHUpdateRecord.Delete(WaitDeleteData); } // 取得新生異動 foreach (SHStudentRecord studRec in studRecList) { // 不刪除代表不需要新增,所以略過 if (checkdelData == false) { if (SIDList.Contains(studRec.ID)) { continue; } } SHUpdateRecordRecord NewUpdateRec = new SHUpdateRecordRecord(); if (SchoolYear > 0) { NewUpdateRec.SchoolYear = SchoolYear; } if (Semester > 0) { NewUpdateRec.Semester = Semester; } if (studRec.Class != null) { if (studRec.Class.GradeYear.HasValue) { NewUpdateRec.GradeYear = studRec.Class.GradeYear.Value.ToString(); } } NewUpdateRec.GraduateComment = ""; NewUpdateRec.UpdateCode = UpdateCode; NewUpdateRec.UpdateDescription = UpdateDesc; NewUpdateRec.UpdateDate = UpdateDate; NewUpdateRec.ClassType = ClassType; NewUpdateRec.SpecialStatus = DAL.DALTransfer.GetSpecialCode(studRec.ID); if (studRec.Department != null) { NewUpdateRec.Department = studRec.Department.FullName; } NewUpdateRec.StudentID = studRec.ID; NewUpdateRec.StudentName = studRec.Name; NewUpdateRec.StudentNumber = studRec.StudentNumber; NewUpdateRec.IDNumber = studRec.IDNumber; if (studRec.Birthday.HasValue) { NewUpdateRec.Birthdate = studRec.Birthday.Value.ToShortDateString(); } NewUpdateRec.Gender = studRec.Gender; if (int.Parse(UpdateCode) > 5) { NewUpdateRec.GraduateComment = "1"; } foreach (SHBeforeEnrollmentRecord brfRec in befRecList) { if (brfRec.RefStudentID == NewUpdateRec.StudentID) { NewUpdateRec.GraduateSchool = brfRec.School; NewUpdateRec.GraduateSchoolYear = brfRec.GraduateSchoolYear; // 用學校名稱解析 if (!string.IsNullOrEmpty(brfRec.School)) { string key = brfRec.SchoolLocation.Replace("台", "臺") + brfRec.School.Trim(); if (schoolDataDict.ContainsKey(key)) { NewUpdateRec.GraduateSchoolCode = schoolDataDict[key].SchoolCode; NewUpdateRec.GraduateSchoolLocationCode = schoolDataDict[key].SchoolLocationCode; } } } } insertData.Add(NewUpdateRec); } // 新增異動 SHUpdateRecord.Insert(insertData); return(pass); }
void _bgw_DoWork(object sender, DoWorkEventArgs e) { Document document = new Document(); Byte[] template = (custConfigs[current].Template != null) //單頁範本 ? custConfigs[current].Template.ToBinary() : new Campus.Report.ReportTemplate(Properties.Resources.證明書範本, Campus.Report.TemplateType.Word).ToBinary(); List <string> ids = K12.Presentation.NLDPanels.Student.SelectedSource; List <SHStudentRecord> srl = SHStudent.SelectByIDs(ids); //離校資訊 Dictionary <string, SHLeaveInfoRecord> dshlir = SHLeaveInfo.SelectByStudentIDs(ids).ToDictionary(x => x.RefStudentID, x => x); //畢業異動 Dictionary <string, SHUpdateRecordRecord> dshurr = new Dictionary <string, SHUpdateRecordRecord>(); foreach (SHUpdateRecordRecord shurr in SHUpdateRecord.SelectByStudentIDs(ids)) { if (shurr.UpdateCode == "501") { if (dshurr.ContainsKey(shurr.StudentID)) { if (dshurr[shurr.StudentID].UpdateDate.CompareTo(shurr.UpdateDate) == 1) { dshurr[shurr.StudentID] = shurr; } } else { dshurr.Add(shurr.StudentID, shurr); } } } //入學照片 Dictionary <string, string> dphoto_p = K12.Data.Photo.SelectFreshmanPhoto(K12.Presentation.NLDPanels.Student.SelectedSource); Dictionary <string, string> dphoto_g = K12.Data.Photo.SelectGraduatePhoto(K12.Presentation.NLDPanels.Student.SelectedSource); //科別中英文對照表 Dictionary <string, string> dic_dept_ch_en = new Dictionary <string, string>(); XmlElement Data = SmartSchool.Customization.Data.SystemInformation.Configuration["科別中英文對照表"]; foreach (XmlElement var in Data) { if (!dic_dept_ch_en.ContainsKey(var.GetAttribute("Chinese"))) { dic_dept_ch_en.Add(var.GetAttribute("Chinese"), var.GetAttribute("English")); } } Dictionary <string, object> mailmerge = new Dictionary <string, object>(); string 校內字號 = textBoxX1.Text, 校內字號英文 = textBoxX2.Text, 校長姓名 = "", 校長姓名英文 = ""; if (K12.Data.School.Configuration["學校資訊"] != null && K12.Data.School.Configuration["學校資訊"].PreviousData.SelectSingleNode("ChancellorChineseName") != null) { 校長姓名 = K12.Data.School.Configuration["學校資訊"].PreviousData.SelectSingleNode("ChancellorChineseName").InnerText; } if (K12.Data.School.Configuration["學校資訊"] != null && K12.Data.School.Configuration["學校資訊"].PreviousData.SelectSingleNode("ChancellorChineseName") != null) { 校長姓名英文 = K12.Data.School.Configuration["學校資訊"].PreviousData.SelectSingleNode("ChancellorEnglishName").InnerText; } Document each; foreach (SHStudentRecord sr in srl) { mailmerge.Clear(); mailmerge.Add("學校全銜", School.ChineseName); mailmerge.Add("學校英文全銜", School.EnglishName); mailmerge.Add("目前學期", School.DefaultSemester); mailmerge.Add("目前學年度", School.DefaultSchoolYear); mailmerge.Add("校長姓名", 校長姓名); mailmerge.Add("校長姓名英文", 校長姓名英文); mailmerge.Add("民國年", DateTime.Today.Year - 1911); mailmerge.Add("英文年", DateTime.Today.Year); mailmerge.Add("月", DateTime.Today.Month); mailmerge.Add("英文月", DateTime.Today.ToString("MMMM", new System.Globalization.CultureInfo("en-US"))); mailmerge.Add("英文月3", DateTime.Today.ToString("MMM", new System.Globalization.CultureInfo("en-US"))); mailmerge.Add("日上標", daySuffix(DateTime.Today.Day.ToString())); mailmerge.Add("日", DateTime.Today.Day); mailmerge.Add("校內字號", 校內字號); mailmerge.Add("校內字號英文", 校內字號英文); #region 學生資料 mailmerge.Add("學生姓名", sr.Name); mailmerge.Add("學生英文姓名", sr.EnglishName); mailmerge.Add("學生身分證號", sr.IDNumber); SHClassRecord tmpcr; if ((tmpcr = sr.Class) != null) { mailmerge.Add("學生目前班級", tmpcr.Name); mailmerge.Add("學生目前年級", tmpcr.GradeYear); if (tmpcr.Department != null) { mailmerge.Add("學生目前科別", tmpcr.Department.Name); } } mailmerge.Add("學生目前座號", sr.StudentNumber); if (sr.Birthday.HasValue) { mailmerge.Add("學生生日民國年", sr.Birthday.Value.Year - 1911); mailmerge.Add("學生生日英文年", sr.Birthday.Value.Year); mailmerge.Add("學生生日月", sr.Birthday.Value.Month); mailmerge.Add("學生生日英文月", sr.Birthday.Value.ToString("MMMM", new System.Globalization.CultureInfo("en-US"))); mailmerge.Add("學生生日英文月3", sr.Birthday.Value.ToString("MMM", new System.Globalization.CultureInfo("en-US"))); mailmerge.Add("學生生日上標", daySuffix(sr.Birthday.Value.Day.ToString())); mailmerge.Add("學生生日日", sr.Birthday.Value.Day); } if (dphoto_p.ContainsKey(sr.ID)) { mailmerge.Add("入學照片1吋", dphoto_p[sr.ID]); mailmerge.Add("入學照片2吋", dphoto_p[sr.ID]); } if (dphoto_g.ContainsKey(sr.ID)) { mailmerge.Add("畢業照片1吋", dphoto_g[sr.ID]); mailmerge.Add("畢業照片2吋", dphoto_g[sr.ID]); } //畢業資訊 if (dshlir.ContainsKey(sr.ID)) { mailmerge["畢業資訊西元年"] = dshlir[sr.ID].SchoolYear + 1911; mailmerge["畢業資訊學年度"] = dshlir[sr.ID].SchoolYear; mailmerge["畢業資訊證書字號"] = dshlir[sr.ID].DiplomaNumber; mailmerge["畢業資訊證書字號數字"] = getCertificateNumberNumber(dshlir[sr.ID].DiplomaNumber); mailmerge["畢業資訊科別中文"] = dshlir[sr.ID].DepartmentName; string tmp_dept = dshlir[sr.ID].DepartmentName; mailmerge["畢業資訊科別英文"] = (tmp_dept != null && dic_dept_ch_en.ContainsKey(tmp_dept)) ? dic_dept_ch_en[tmp_dept] : ""; } //畢業異動 if (dshurr.ContainsKey(sr.ID)) { //int ExpectGraduateSchoolYear; //if (int.TryParse(dshurr[sr.ID].ExpectGraduateSchoolYear, out ExpectGraduateSchoolYear)) // mailmerge["畢業異動西元年"] = ExpectGraduateSchoolYear + 1911; if (!string.IsNullOrEmpty(dshurr[sr.ID].UpdateDate)) { int ADYear; int.TryParse(dshurr[sr.ID].UpdateDate.Split('/')[0], out ADYear); mailmerge["畢業異動西元年"] = ADYear; int republicYaer; if (ADYear > 1911) { republicYaer = ADYear - 1911; mailmerge["畢業異動民國年"] = republicYaer; } int UpdateDateMonth; int.TryParse(dshurr[sr.ID].UpdateDate.Split('/')[1], out UpdateDateMonth); int UpdateDateDate; int.TryParse(dshurr[sr.ID].UpdateDate.Split('/')[2], out UpdateDateDate); mailmerge["畢業異動月"] = UpdateDateMonth; mailmerge["畢業異動日"] = UpdateDateDate; } mailmerge["畢業異動學年度"] = dshurr[sr.ID].ExpectGraduateSchoolYear; mailmerge["畢業異動證書字號"] = dshurr[sr.ID].GraduateCertificateNumber; mailmerge["畢業異動證書字號數字"] = getCertificateNumberNumber(dshurr[sr.ID].GraduateCertificateNumber); mailmerge["畢業異動科別中文"] = dshurr[sr.ID].Department; string tmp_dept = dshurr[sr.ID].Department; mailmerge["畢業異動科別英文"] = (tmp_dept != null && dic_dept_ch_en.ContainsKey(tmp_dept)) ? dic_dept_ch_en[tmp_dept] : ""; } #endregion each = new Document(new MemoryStream(template)); //each.MailMerge.CleanupOptions = Aspose.Words.Reporting.MailMergeCleanupOptions.RemoveUnusedFields; each.MailMerge.FieldMergingCallback = new merge(); each.MailMerge.Execute(mailmerge.Keys.ToArray(), mailmerge.Values.ToArray()); each.MailMerge.DeleteFields(); document.Sections.Add(document.ImportNode(each.FirstSection, true)); } document.Sections.RemoveAt(0); e.Result = document; }
/// <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 ExportUpdateRecord_ExportPackage(object sender, ExportPackageEventArgs e) { for (int i = 0; i < e.List.Count; i++) { foreach (SHUpdateRecordRecord var in SHUpdateRecord.SelectByStudentID(e.List[i])) { if (var.UpdateType != Type) { continue; } RowData row = new RowData(); row.ID = e.List[i]; foreach (string field in e.ExportFields) { if (ExportableFields.Contains(field)) { switch (field) { case "班別": row.Add(field, var.ClassType); break; case "特殊身份代碼": row.Add(field, var.SpecialStatus); break; case "異動科別": row.Add(field, var.Department); break; case "年級": row.Add(field, var.GradeYear); break; case "異動學號": row.Add(field, var.StudentNumber); break; case "異動姓名": row.Add(field, var.StudentName); break; case "身分證號": row.Add(field, var.IDNumber); break; case "註1": row.Add(field, var.IDNumberComment); break; case "性別": row.Add(field, var.Gender); break; case "生日": row.Add(field, var.Birthdate); break; case "異動種類": row.Add(field, var.UpdateType); break; case "異動代碼": row.Add(field, var.UpdateCode); break; case "異動日期": row.Add(field, var.UpdateDate); break; case "原因及事項": row.Add(field, var.UpdateDescription); break; case "新學號": row.Add(field, var.NewStudentNumber); break; case "更正後資料": row.Add(field, var.NewData); break; case "轉入前學生資料-科別": row.Add(field, var.PreviousDepartment); break; case "轉入前學生資料-年級": row.Add(field, var.PreviousGradeYear); break; case "轉入前學生資料-學校": row.Add(field, var.PreviousSchool); break; case "轉入前學生資料-(備查日期)": row.Add(field, var.PreviousSchoolLastADDate); break; case "轉入前學生資料-(備查文號)": row.Add(field, var.PreviousSchoolLastADNumber); break; case "轉入前學生資料-學號": row.Add(field, var.PreviousStudentNumber); break; case "入學資格-畢業國中": row.Add(field, var.GraduateSchool); break; case "入學資格-畢業國中所在地代碼": row.Add(field, var.GraduateSchoolLocationCode); break; case "入學資格-畢業國中年度": row.Add(field, var.GraduateSchoolYear); break; case "入學資格-註2": row.Add(field, var.GraduateComment); break; case "最後異動代碼": row.Add(field, var.LastUpdateCode); break; case "畢(結)業證書字號": row.Add(field, var.GraduateCertificateNumber); break; case "舊班別": row.Add(field, var.OldClassType); break; case "舊科別代碼": row.Add(field, var.OldDepartmentCode); break; case "備查日期": row.Add(field, var.LastADDate); break; case "備查文號": row.Add(field, var.LastADNumber); break; case "核准日期": row.Add(field, var.ADDate); break; case "核准文號": row.Add(field, var.ADNumber); break; case "備註": row.Add(field, var.Comment); break; } } } e.Items.Add(row); } } }
void _bgWorkerLoad_DoWork(object sender, DoWorkEventArgs e) { // 取得就學生畢業異動資料 _StudHasGraduateRecDict.Clear(); List <SHUpdateRecordRecord> recList = SHUpdateRecord.SelectByStudentIDs(_StudentIDList); foreach (SHUpdateRecordRecord rec in recList) { // 不是畢業異動跳過 if (rec.UpdateCode != "501") { continue; } if (!_StudHasGraduateRecDict.ContainsKey(rec.StudentID)) { _StudHasGraduateRecDict.Add(rec.StudentID, rec); } } // 取得最後一筆異動 _StudLastupdateRecDict.Clear(); foreach (string sid in _StudentIDList) { List <SHUpdateRecordRecord> recL = (from data in recList where data.StudentID == sid && data.ADDate.Trim() != "" orderby DateTime.Parse(data.ADDate) descending, int.Parse(data.ID) descending select data).ToList(); if (recL.Count > 0) { SHUpdateRecordRecord r1 = recL[0]; if (!_StudLastupdateRecDict.ContainsKey(r1.StudentID)) { _StudLastupdateRecDict.Add(r1.StudentID, r1); } } } // 學生資料 _StudentDict.Clear(); foreach (SHStudentRecord rec in SHStudent.SelectByIDs(_StudentIDList)) { _StudentDict.Add(rec.ID, rec); } // 畢業證書 _LeaveInfoRecordDict.Clear(); foreach (SHLeaveInfoRecord rec in SHLeaveInfo.SelectByStudentIDs(_StudentIDList)) { if (!_LeaveInfoRecordDict.ContainsKey(rec.RefStudentID)) { _LeaveInfoRecordDict.Add(rec.RefStudentID, rec); } } // 班級 _ClassRecDict.Clear(); foreach (SHClassRecord rec in SHClass.SelectAll()) { if (!_ClassRecDict.ContainsKey(rec.ID)) { _ClassRecDict.Add(rec.ID, rec); } } // 科別 _DeptRecDict.Clear(); foreach (SHDepartmentRecord rec in SHDepartment.SelectAll()) { if (!_DeptRecDict.ContainsKey(rec.ID)) { _DeptRecDict.Add(rec.ID, rec); } } }
void _bgWorkerRun_DoWork(object sender, DoWorkEventArgs e) { // 處理資料 try { _bgWorkerRun.ReportProgress(1); // 刪除舊資料 List <SHUpdateRecordRecord> _oldDataList = _StudHasGraduateRecDict.Values.ToList(); SHUpdateRecord.Delete(_oldDataList); int SchoolYear = int.Parse(K12.Data.School.DefaultSchoolYear); int Semester = int.Parse(K12.Data.School.DefaultSemester); // 學籍身分對照表 Dictionary <string, List <string> > StudPermCodeMappingDict = utility.GetPermCodeMappingDict(); // 取得學生類別對照 Dictionary <string, List <string> > StudentTagDict = utility.GetStudentFullNameDictByStudentIDs(_StudentIDList); _bgWorkerRun.ReportProgress(10); foreach (string sid in _StudentIDList) { if (!_StudentDict.ContainsKey(sid)) { continue; } SHUpdateRecordRecord rec = new SHUpdateRecordRecord(); // 學年度 rec.SchoolYear = SchoolYear; // 學期 rec.Semester = Semester; rec.StudentID = sid; string ClassName = ""; string DeptName = ""; // 年級 if (_ClassRecDict.ContainsKey(_StudentDict[sid].RefClassID)) { if (_ClassRecDict[_StudentDict[sid].RefClassID].GradeYear.HasValue) { rec.GradeYear = _ClassRecDict[_StudentDict[sid].RefClassID].GradeYear.Value.ToString(); // 班級名稱 ClassName = _ClassRecDict[_StudentDict[sid].RefClassID].Name; } else { rec.GradeYear = ""; } } string depID = _StudentDict[sid].DepartmentID; // 科別名稱 if (_DeptRecDict.ContainsKey(depID)) { DeptName = _DeptRecDict[depID].FullName; } //// 科別名稱 //if (_DeptRecDict.ContainsKey(_ClassRecDict[_StudentDict[sid].RefClassID].RefDepartmentID)) // DeptName = _DeptRecDict[_ClassRecDict[_StudentDict[sid].RefClassID].RefDepartmentID].FullName; // 畢業代碼 rec.UpdateCode = "501"; // 原因及事項 rec.UpdateDescription = "畢業"; // 異動日期 rec.UpdateDate = _UpdateDate.ToShortDateString(); // 姓名 rec.StudentName = _StudentDict[sid].Name; // 學號 rec.StudentNumber = _StudentDict[sid].StudentNumber; // 身分證字號 rec.IDNumber = _StudentDict[sid].IDNumber; // 生日 if (_StudentDict[sid].Birthday.HasValue) { rec.Birthdate = _StudentDict[sid].Birthday.Value.ToShortDateString(); } // 性別 rec.Gender = _StudentDict[sid].Gender; if (_StudLastupdateRecDict.ContainsKey(sid)) { // 備查日期 rec.LastADDate = _StudLastupdateRecDict[sid].ADDate; // 備查文號 rec.LastADNumber = _StudLastupdateRecDict[sid].ADNumber; // 最後異動代碼 rec.LastUpdateCode = _StudLastupdateRecDict[sid].UpdateCode; } // 畢業證書字號 if (_LeaveInfoRecordDict.ContainsKey(sid)) { rec.GraduateCertificateNumber = _LeaveInfoRecordDict[sid].DiplomaNumber; rec.Department = DeptName; rec.ExpectGraduateSchoolYear = SchoolYear.ToString(); _LeaveInfoRecordDict[sid].SchoolYear = SchoolYear; _LeaveInfoRecordDict[sid].ClassName = ClassName; _LeaveInfoRecordDict[sid].DepartmentName = DeptName; } // 學生特殊身分代碼 if (StudentTagDict.ContainsKey(sid)) { List <string> codeList = new List <string>(); foreach (string fullName in StudentTagDict[sid]) { if (StudPermCodeMappingDict.ContainsKey(fullName)) { foreach (string code in StudPermCodeMappingDict[fullName]) { if (!codeList.Contains(code)) { codeList.Add(code); } } } } if (codeList.Count > 0) { codeList.Sort(); rec.SpecialStatus = string.Join(",", codeList.ToArray()); } } _InsertDataList.Add(rec); } _bgWorkerRun.ReportProgress(70); // 新增資料 if (_InsertDataList.Count > 0) { SHUpdateRecord.Insert(_InsertDataList); } // 更新畢業離校資訊 離校學年度、離校科別、離校班級 SHLeaveInfo.Update(_LeaveInfoRecordDict.Values.ToList()); _bgWorkerRun.ReportProgress(99); } catch (Exception ex) { e.Result = ex; e.Cancel = true; } }
public override void InitializeExport(SmartSchool.API.PlugIn.Export.ExportWizard wizard) { wizard.ExportableFields.AddRange(_ExportList); wizard.ExportPackage += delegate(object sender, SmartSchool.API.PlugIn.Export.ExportPackageEventArgs e) { // 取得異動代碼 XElement _UpdateCode = DAL.DALTransfer.GetUpdateCodeList(); List <string> UpdateCodeList = (from elm in _UpdateCode.Elements("異動") where elm.Element("分類").Value == "新生異動" select elm.Element("代號").Value).ToList(); // 取得學生新生異動 List <SHUpdateRecordRecord> updateRecList = (from data in SHUpdateRecord.SelectByStudentIDs(e.List) where UpdateCodeList.Contains(data.UpdateCode) select data).ToList(); Dictionary <string, string> StudentStatusDict = DAL.FDQuery.GetAllStudentStatus1Dict(); foreach (SHUpdateRecordRecord rec in updateRecList) { RowData row = new RowData(); row.ID = rec.StudentID; foreach (string field in e.ExportFields) { if (wizard.ExportableFields.Contains(field)) { switch (field) { case "學年度": if (rec.SchoolYear.HasValue) { row.Add(field, rec.SchoolYear.Value.ToString()); } break; case "學期": if (rec.Semester.HasValue) { row.Add(field, rec.Semester.Value.ToString()); } break; case "年級": row.Add(field, rec.GradeYear); break; case "異動代碼": row.Add(field, rec.UpdateCode); break; case "原因及事項": row.Add(field, rec.UpdateDescription); break; case "異動日期": row.Add(field, rec.UpdateDate); break; case "備註": row.Add(field, rec.Comment); break; case "班別": row.Add(field, rec.ClassType); break; case "科別": row.Add(field, rec.Department); break; case "特殊身分代碼": row.Add(field, rec.SpecialStatus); break; case "入學資格證明文件": row.Add(field, rec.GraduateDocument); break; case "異動姓名": row.Add(field, rec.StudentName); break; case "異動學號": row.Add(field, rec.StudentNumber); break; case "異動身分證字號": row.Add(field, rec.IDNumber); break; case "異動生日": row.Add(field, rec.Birthdate); break; case "異動身分證註記": row.Add(field, rec.IDNumberComment); break; case "異動性別": row.Add(field, rec.Gender); break; case "畢業國中": row.Add(field, rec.GraduateSchool); break; case "畢業國中所在地代碼": row.Add(field, rec.GraduateSchoolLocationCode); break; case "畢業國中學校代碼": row.Add(field, rec.GraduateSchoolCode); break; case "國中畢業學年度": row.Add(field, rec.GraduateSchoolYear); break; case "畢業國中入學資格註記": row.Add(field, rec.GraduateComment); break; case "核准日期": row.Add(field, rec.ADDate); break; case "核准文號": row.Add(field, rec.ADNumber); break; case "狀態": if (StudentStatusDict.ContainsKey(rec.StudentID)) { row.Add(field, StudentStatusDict[rec.StudentID]); } break; } } } e.Items.Add(row); } }; }
void ImportNewStudentsUpdateRecord_DataImport(object sender, DataImportEventArgs e) { Dictionary <string, string> fieldNameMapping = new Dictionary <string, string>(); #region 建立匯入欄位名稱跟Xml內欄位對照表 fieldNameMapping.Add("Department", "異動科別"); fieldNameMapping.Add("GradeYear", "年級"); fieldNameMapping.Add("StudentNumber", "異動學號"); fieldNameMapping.Add("StudentName", "異動姓名"); fieldNameMapping.Add("IDNumber", "身分證號"); fieldNameMapping.Add("Gender", "性別"); fieldNameMapping.Add("Birthdate", "生日"); fieldNameMapping.Add("UpdateCode", "異動代碼"); fieldNameMapping.Add("UpdateDate", "異動日期"); fieldNameMapping.Add("UpdateDescription", "原因及事項"); fieldNameMapping.Add("NewStudentNumber", "新學號"); fieldNameMapping.Add("PreviousDepartment", "轉入前學生資料-科別"); fieldNameMapping.Add("PreviousGradeYear", "轉入前學生資料-年級"); fieldNameMapping.Add("PreviousSchool", "轉入前學生資料-學校"); fieldNameMapping.Add("PreviousSchoolLastADDate", "轉入前學生資料-(備查日期)"); fieldNameMapping.Add("PreviousSchoolLastADNumber", "轉入前學生資料-(備查文號)"); fieldNameMapping.Add("PreviousStudentNumber", "轉入前學生資料-學號"); fieldNameMapping.Add("GraduateSchool", "入學資格-畢業國中"); fieldNameMapping.Add("GraduateSchoolLocationCode", "入學資格-畢業國中所在地代碼"); fieldNameMapping.Add("LastUpdateCode", "最後異動代碼"); fieldNameMapping.Add("GraduateCertificateNumber", "畢(結)業證書字號"); fieldNameMapping.Add("LastADDate", "備查日期"); fieldNameMapping.Add("LastADNumber", "備查文號"); fieldNameMapping.Add("ADDate", "核准日期"); fieldNameMapping.Add("ADNumber", "核准文號"); fieldNameMapping.Add("Comment", "備註"); fieldNameMapping.Add("ClassType", "班別"); fieldNameMapping.Add("SpecialStatus", "特殊身份代碼"); fieldNameMapping.Add("IDNumberComment", "註1"); fieldNameMapping.Add("OldClassType", "舊班別"); fieldNameMapping.Add("OldDepartmentCode", "舊科別代碼"); fieldNameMapping.Add("GraduateSchoolYear", "入學資格-畢業國中年度"); fieldNameMapping.Add("GraduateComment", "入學資格-註2"); #endregion List <SHUpdateRecordRecord> InsertUpdateRecords = new List <SHUpdateRecordRecord>(); List <SHUpdateRecordRecord> UpdateUpdateRecords = new List <SHUpdateRecordRecord>(); bool insert = false, update = false; foreach (RowData row in e.Items) { if (_NewStudentUpdateRecordInfoList.ContainsKey(row.ID)) { if (_NewStudentUpdateRecordInfoList[row.ID] == null) { insert = true; #region 新增 SHUpdateRecordRecord InsertUpdateRecord = new SHUpdateRecordRecord(); InsertUpdateRecord.StudentID = row.ID; foreach (string field in fieldNameMapping.Keys) { string fieldname = fieldNameMapping[field]; PropertyInfo Property = InsertUpdateRecord.GetType().GetProperty(field, System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance); if (Property != null) { Property.SetValue(InsertUpdateRecord, row.ContainsKey(fieldname) ? row[fieldname] : string.Empty, null); } } InsertUpdateRecords.Add(InsertUpdateRecord); #endregion } else { update = true; #region 修改 SHUpdateRecordRecord UpdateUpdateRecord = new SHUpdateRecordRecord(); UpdateUpdateRecord.ID = _NewStudentUpdateRecordInfoList[row.ID].ID; UpdateUpdateRecord.StudentID = row.ID; foreach (string field in fieldNameMapping.Keys) { string fieldname = fieldNameMapping[field]; PropertyInfo Property = UpdateUpdateRecord.GetType().GetProperty(field, System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance); if (Property != null) { Property.SetValue(UpdateUpdateRecord, row.ContainsKey(fieldname) ? row[fieldname] : string.Empty, null); } } UpdateUpdateRecords.Add(UpdateUpdateRecord); #endregion } } } if (insert) { try { SHUpdateRecord.Insert(InsertUpdateRecords); } catch (Exception ve) { } } if (update) { try { SHUpdateRecord.Update(UpdateUpdateRecords); } catch (Exception ve) { } } }