protected override void DoDelete(JHTagConfigRecord record) { int use_count = 0; foreach (JHStudentTagRecord rec in JHStudentTag.SelectAll()) { if (rec.RefTagID == record.ID) { use_count++; } } string msg; if (use_count > 0) { msg = string.Format("目前有「{0}」位學生使用此類別,您確定要刪除此類別嗎?", use_count); } else { msg = "您確定要刪除此類別嗎?"; } if (FISCA.Presentation.Controls.MsgBox.Show(msg, MessageBoxButtons.YesNo) == DialogResult.Yes) { PermRecLogProcess prlp = new PermRecLogProcess(); prlp.SaveLog("學籍.類別管理", "類別管理刪除類別", "刪除 " + record.Category + " 類別,名稱:" + record.FullName); JHTagConfig.Delete(record); } }
// 新增 private void Insert(object item) { try { List <JHStudentTagRecord> InsertPackage = (List <JHStudentTagRecord>)item; JHStudentTag.Insert(InsertPackage); } catch (Exception ex) { } }
// 更新 private void Update(object item) { try { List <JHStudentTagRecord> UpdatePackage = (List <JHStudentTagRecord>)item; JHStudentTag.Update(UpdatePackage); } catch (Exception ex) { } }
public static List <StudInfoEntity> GetStudentEntityList(List <string> StudentIDList) { Dictionary <string, string> StudTagDic = new Dictionary <string, string>(); Dictionary <string, string> StudItemDic = new Dictionary <string, string>(); Global._tempPhomeDict.Clear(); // 取得對照表 XmlDocument doc = StudSBTManager.GetDataFormSystem(); if (doc != null) { if (doc.SelectSingleNode("Data") != null) { foreach (XmlElement xe in doc.SelectSingleNode("Data")) { string StudTags = xe.GetAttribute("StudTag").Trim(); StudTags = StudTags.Replace(',', ','); StudTags = StudTags.Replace(':', ':'); string[] StudTagsArr = StudTags.Split(','); if (!string.IsNullOrEmpty(StudTags)) { foreach (string str in StudTagsArr) { if (!StudTagDic.ContainsKey(str)) { StudTagDic.Add(str, xe.GetAttribute("FieldName") + xe.GetAttribute("ItemName")); } } } if (!string.IsNullOrEmpty(xe.GetAttribute("FieldName")) && !string.IsNullOrEmpty(xe.GetAttribute("ItemName"))) { string Item = xe.GetAttribute("FieldName") + xe.GetAttribute("ItemName"); if (!StudItemDic.ContainsKey(Item)) { StudItemDic.Add(Item, xe.GetAttribute("ItemValue")); } } } } } List <StudInfoEntity> StudInfoEntityList = new List <StudInfoEntity>(); // 建立相關讀取用到資訊 Dictionary <string, JHLeaveInfoRecord> LeaveInfoRecordDic = new Dictionary <string, JHLeaveInfoRecord>(); Dictionary <string, List <string> > StudentTagRecordDic = new Dictionary <string, List <string> >(); Dictionary <string, JHPhoneRecord> PhoneRecordDic = new Dictionary <string, JHPhoneRecord>(); Dictionary <string, JHParentRecord> ParentRecordDic = new Dictionary <string, JHParentRecord>(); Dictionary <string, JHAddressRecord> AddressRecordDic = new Dictionary <string, JHAddressRecord>(); // 畢業資訊 foreach (JHLeaveInfoRecord lir in JHLeaveIfno.SelectByStudentIDs(StudentIDList)) { if (!LeaveInfoRecordDic.ContainsKey(lir.RefStudentID)) { LeaveInfoRecordDic.Add(lir.RefStudentID, lir); } } // 學生 Tag foreach (JHStudentTagRecord str in JHStudentTag.SelectByStudentIDs(StudentIDList)) { string strS = str.FullName; if (StudentTagRecordDic.ContainsKey(str.RefStudentID)) { StudentTagRecordDic[str.RefStudentID].Add(strS); } else { List <string> strList = new List <string>(); strList.Add(strS); StudentTagRecordDic.Add(str.RefStudentID, strList); } } // 電話資訊 foreach (JHPhoneRecord pr in JHPhone.SelectByStudentIDs(StudentIDList)) { if (!PhoneRecordDic.ContainsKey(pr.RefStudentID)) { PhoneRecordDic.Add(pr.RefStudentID, pr); } if (!Global._tempPhomeDict.ContainsKey(pr.RefStudentID)) { Global._tempPhomeDict.Add(pr.RefStudentID, new Dictionary <string, string>()); } Global._tempPhomeDict[pr.RefStudentID].Add("戶籍電話", pr.Permanent); Global._tempPhomeDict[pr.RefStudentID].Add("聯絡電話", pr.Contact); } // 父母及監護人資訊 foreach (JHParentRecord pr in JHParent.SelectByStudentIDs(StudentIDList)) { if (!ParentRecordDic.ContainsKey(pr.RefStudentID)) { ParentRecordDic.Add(pr.RefStudentID, pr); } if (!Global._tempPhomeDict.ContainsKey(pr.RefStudentID)) { Global._tempPhomeDict.Add(pr.RefStudentID, new Dictionary <string, string>()); } Global._tempPhomeDict[pr.RefStudentID].Add("父親電話", pr.FatherPhone); Global._tempPhomeDict[pr.RefStudentID].Add("母親電話", pr.MotherPhone); Global._tempPhomeDict[pr.RefStudentID].Add("監護人電話", pr.CustodianPhone); } // 地址 foreach (JHAddressRecord ar in JHAddress.SelectByStudentIDs(StudentIDList)) { if (!AddressRecordDic.ContainsKey(ar.RefStudentID)) { AddressRecordDic.Add(ar.RefStudentID, ar); } } foreach (JHStudentRecord studRec in JHStudent.SelectByIDs(StudentIDList)) { if (studRec.Status == K12.Data.StudentRecord.StudentStatus.一般 || studRec.Status == K12.Data.StudentRecord.StudentStatus.輟學) { StudInfoEntity sie = new StudInfoEntity(); // 初始 sie.ClassName = sie.SeatNo = string.Empty; if (studRec.Class != null) { sie.ClassName = string.Format("{0:00}", studRec.Class.Name); } sie.Gender = studRec.Gender; sie.IDNumber = studRec.IDNumber; sie.Name = studRec.Name; if (studRec.SeatNo.HasValue) { sie.SeatNo = string.Format("{0:00}", studRec.SeatNo.Value); } sie.StudentID = studRec.ID; sie.StudentNumber = string.Format("{0:00000000}", studRec.StudentNumber); // 填入資料 if (!string.IsNullOrEmpty(JHSchool.Data.JHSchoolInfo.Code)) { string strSchoolCode = JHSchoolInfo.Code; if (strSchoolCode.Length >= 6) { strSchoolCode = strSchoolCode.Substring(0, 6); } sie.SetDataCellEntity("學校代碼", 6, strSchoolCode); sie.SetDataCellEntity("畢業學校代碼", 6, strSchoolCode); } string strNum; if (sie.StudentNumber.Length >= 8) { strNum = sie.StudentNumber.Substring(0, 8); } else { strNum = sie.StudentNumber; for (int i = 0; i < (8 - sie.StudentNumber.Length); i++) { strNum = "0" + strNum; } } sie.SetDataCellEntity("學號", 8, strNum); if (!string.IsNullOrEmpty(sie.ClassName)) { if (sie.ClassName.Length >= 3) { sie.ClassName = sie.ClassName.Substring(1, 2); } if (sie.ClassName.Length >= 2) { sie.SetDataCellEntity("班級", 2, sie.ClassName.Substring(0, 2)); } else { sie.SetDataCellEntity("班級", 2, "0" + sie.ClassName); } } if (!string.IsNullOrEmpty(sie.SeatNo)) { if (sie.SeatNo.Length > 0) { sie.SetDataCellEntity("座號", 2, sie.SeatNo.Substring(0, 2)); } else { sie.SetDataCellEntity("座號", 2, "0" + sie.SeatNo); } } string StudName = sie.Name.Trim(); if (StudName.Length == 2) { StudName = StudName.Substring(0, 1) + " " + StudName.Substring(1, 1); } sie.SetDataCellEntity("學生姓名", 20, StudName); sie.SetDataCellEntity("身分證號", 10, sie.IDNumber); if (studRec.Gender == "男") { sie.SetDataCellEntity("性別", 1, "1"); } if (studRec.Gender == "女") { sie.SetDataCellEntity("性別", 1, "2"); } if (studRec.Birthday.HasValue) { sie.SetDataCellEntity("出生年", 2, string.Format("{0:00}", studRec.Birthday.Value.Year - 1911)); sie.SetDataCellEntity("出生月", 2, string.Format("{0:00}", studRec.Birthday.Value.Month)); sie.SetDataCellEntity("出生日", 2, string.Format("{0:00}", studRec.Birthday.Value.Day)); } if (LeaveInfoRecordDic.ContainsKey(studRec.ID)) { if (LeaveInfoRecordDic[studRec.ID].SchoolYear.HasValue) { sie.SetDataCellEntity("畢業年度", 2, LeaveInfoRecordDic[studRec.ID].SchoolYear.Value + ""); } if (LeaveInfoRecordDic[studRec.ID].Reason == "畢業") { sie.SetDataCellEntity("畢肄業", 1, "1"); } if (LeaveInfoRecordDic[studRec.ID].Reason == "修業") { sie.SetDataCellEntity("畢肄業", 1, "0"); } } if (ParentRecordDic.ContainsKey(studRec.ID)) { string ParentName = ParentRecordDic[studRec.ID].CustodianName.Trim(); if (ParentName.Length == 2) { ParentName = ParentName.Substring(0, 1) + " " + ParentName.Substring(1, 1); } sie.SetDataCellEntity("家長姓名", 20, ParentName); //// 戶籍 //string strPhone=ParentRecordDic[studRec.ID].CustodianPhone.Replace ("(",""); //strPhone = strPhone.Replace(")", ""); //strPhone = strPhone.Replace("-", ""); string strPhone = ""; if (Global._tempPhomeDict.ContainsKey(sie.StudentID)) { if (Global._tempPhomeDict[sie.StudentID].ContainsKey(Global.SelectPhoneType)) { strPhone = Global._tempPhomeDict[sie.StudentID][Global.SelectPhoneType].Replace("(", "");; strPhone = strPhone.Replace(")", ""); strPhone = strPhone.Replace("-", ""); } } sie.SetDataCellEntity("緊急連絡電話", 20, strPhone); } if (AddressRecordDic.ContainsKey(studRec.ID)) { string strAddress = ""; if (_UseMailAddress) { sie.SetDataCellEntity("郵遞區號", 3, AddressRecordDic[studRec.ID].MailingZipCode); strAddress = AddressRecordDic[studRec.ID].MailingCounty + AddressRecordDic[studRec.ID].MailingTown + AddressRecordDic[studRec.ID].MailingDistrict + AddressRecordDic[studRec.ID].MailingArea + AddressRecordDic[studRec.ID].MailingDetail; } else { sie.SetDataCellEntity("郵遞區號", 3, AddressRecordDic[studRec.ID].PermanentZipCode); strAddress = AddressRecordDic[studRec.ID].PermanentCounty + AddressRecordDic[studRec.ID].PermanentTown + AddressRecordDic[studRec.ID].PermanentDistrict + AddressRecordDic[studRec.ID].PermanentArea + AddressRecordDic[studRec.ID].PermanentDetail; } sie.SetDataCellEntity("地址", 80, strAddress); } if (PhoneRecordDic.ContainsKey(studRec.ID)) { sie.SetDataCellEntity("手機", 10, PhoneRecordDic[studRec.ID].Cell); } // default value sie.SetDataCellEntity("學生身分", 1, "0"); sie.SetDataCellEntity("身心障礙", 1, "0"); sie.SetDataCellEntity("中低收入戶", 1, "0"); sie.SetDataCellEntity("低收入戶", 1, "0"); sie.SetDataCellEntity("失業勞工子女", 1, "0"); if (StudentTagRecordDic.ContainsKey(studRec.ID)) { foreach (string str in StudentTagRecordDic[studRec.ID]) { if (StudTagDic.ContainsKey(str)) { if (StudItemDic.ContainsKey(StudTagDic[str])) { if (StudTagDic[str].IndexOf("學生身分") > -1) { sie.SetDataCellEntity("學生身分", 1, StudItemDic[StudTagDic[str]]); } if (StudTagDic[str].IndexOf("身心障礙") > -1) { sie.SetDataCellEntity("身心障礙", 1, StudItemDic[StudTagDic[str]]); } if (StudTagDic[str].IndexOf("低收入戶") == 0) { sie.SetDataCellEntity("低收入戶", 1, StudItemDic[StudTagDic[str]]); } //if (StudTagDic[str].IndexOf("中低收入戶") > -1) // sie.SetDataCellEntity("中低收入戶", 1, StudItemDic[StudTagDic[str]]); if (StudTagDic[str].IndexOf("失業勞工子女") > -1) { sie.SetDataCellEntity("失業勞工子女", 1, StudItemDic[StudTagDic[str]]); } } } } } StudInfoEntityList.Add(sie); } } return(StudInfoEntityList); }
private void _writeWorker_DoWork(object sender, DoWorkEventArgs e) { #region 寫入離校資訊 try { List <JHLeaveInfoRecord> leaveInfoRecordList = new List <JHLeaveInfoRecord>(); foreach (JHLeaveInfoRecord record in JHLeaveIfno.SelectByStudentIDs(_students.AsKeyList())) { if (!_passList.ContainsKey(record.RefStudentID)) { continue; } leaveInfoRecordList.Add(record); if (_passList[record.RefStudentID] == true) { record.Reason = "畢業"; record.Memo = string.Empty; } else { record.Reason = "修業"; StringBuilder builder = new StringBuilder(); _result[record.RefStudentID].Sort(); foreach (ResultDetail rd in _result[record.RefStudentID]) { string semester = rd.GradeYear + (rd.Semester.Equals("1") ? "上" : "下") + ":"; string details = string.Empty; foreach (string detail in rd.Details) { details += detail + ","; } if (details.EndsWith(",")) { details = details.Substring(0, details.Length - 1); } builder.AppendLine(semester + details); } record.Memo = builder.ToString(); } // 系統目前預設學年度 int SchoolYear; int.TryParse(JHSchool.School.DefaultSchoolYear, out SchoolYear); record.SchoolYear = SchoolYear; } JHLeaveIfno.Update(leaveInfoRecordList); } catch (Exception ex) { BugReporter.ReportException(ex, false); } #endregion #region 寫入類別(Tags) string FailurePrefix = "未達畢業標準"; try { List <JHTagConfigRecord> tagList = JHTagConfig.SelectByCategory(K12.Data.TagCategory.Student); TagConfigRecordComparer tagComparer = new TagConfigRecordComparer(); StudentTagRecordComparer studentTagComparer = new StudentTagRecordComparer(); #region 製作各種未達畢業標準的標籤 List <JHTagConfigRecord> tagConfigRecordList = new List <JHSchool.Data.JHTagConfigRecord>(); foreach (StudentRecord student in _students) { //如果學生通過畢業審查 if (_passList[student.ID]) { continue; } //如果審查結果沒有該學生編號則跳到下一筆 (這應該不會發生才對) if (!_result.ContainsKey(student.ID)) { continue; } List <ResultDetail> rdList = _result[student.ID]; foreach (ResultDetail rd in rdList) { foreach (string msg in rd.Messages) { JHTagConfigRecord tagConfigRecord = new JHTagConfigRecord(); tagConfigRecord.Prefix = FailurePrefix; tagConfigRecord.Name = msg; tagConfigRecord.Category = "Student"; if (!tagList.Contains(tagConfigRecord, tagComparer)) { tagConfigRecordList.Add(tagConfigRecord); tagList.Add(tagConfigRecord); //foreach (string tag_id in JHSchool.Data.TagConfig.Insert(tagConfigRecord)) //{ // if (!tagIDs.ContainsKey(tagConfigRecord.FullName)) // tagIDs.Add(tagConfigRecord.FullName, tag_id); //} } } } } JHTagConfig.Insert(tagConfigRecordList); tagList = JHTagConfig.SelectByCategory(K12.Data.TagCategory.Student); #endregion #region 貼上標籤 List <JHStudentTagRecord> studentTagsList = new List <JHStudentTagRecord>(); List <JHStudentTagRecord> deleteList = new List <JHStudentTagRecord>(); foreach (StudentRecord student in _students) { //如果學生通過畢業審查,應該把標籤拿下來 if (_passList[student.ID]) { foreach (JHStudentTagRecord student_tag in JHStudentTag.SelectByStudentID(student.ID)) { if (student_tag.Prefix == FailurePrefix) { deleteList.Add(student_tag); } } continue; } if (!_result.ContainsKey(student.ID)) { continue; } Dictionary <string, JHStudentTagRecord> studentTags = new Dictionary <string, JHStudentTagRecord>(); foreach (JHStudentTagRecord student_tag in JHStudentTag.SelectByStudentID(student.ID)) { if (!studentTags.ContainsKey(student_tag.RefTagID)) { studentTags.Add(student_tag.RefTagID, student_tag); } } List <ResultDetail> rdList = _result[student.ID]; foreach (ResultDetail rd in rdList) { foreach (string msg in rd.Messages) { string fullname = FailurePrefix + ":" + msg; foreach (JHTagConfigRecord record in tagList) { if (record.FullName == fullname && !studentTags.ContainsKey(record.ID)) { JHStudentTagRecord r = new JHStudentTagRecord(); r.RefTagID = record.ID; r.RefEntityID = student.ID; if (!studentTagsList.Contains(r, studentTagComparer)) { studentTagsList.Add(r); } } } } } } JHStudentTag.Insert(studentTagsList); JHStudentTag.Delete(deleteList); #endregion } catch (Exception ex) { BugReporter.ReportException(ex, false); } #endregion }
public override void InitializeExport(SmartSchool.API.PlugIn.Export.ExportWizard wizard) { wizard.ExportableFields.AddRange(ExportItemList); wizard.ExportPackage += delegate(object sender, SmartSchool.API.PlugIn.Export.ExportPackageEventArgs e) { // 學生類別組合 Dictionary <string, DAL.StudentTagEntity> StudTagDict = new Dictionary <string, JHSchool.Permrec.ImportExport.StudentTag.DAL.StudentTagEntity>(); // 取得學生類別 foreach (JHStudentTagRecord studTagRec in JHStudentTag.SelectByStudentIDs(e.List)) { if (StudTagDict.ContainsKey(studTagRec.RefStudentID)) { StudTagDict[studTagRec.RefStudentID].AddPrefixName(studTagRec.Prefix, studTagRec.Name); } else { DAL.StudentTagEntity stn = new JHSchool.Permrec.ImportExport.StudentTag.DAL.StudentTagEntity(); stn.StudentID = studTagRec.RefStudentID; stn.AddPrefixName(studTagRec.Prefix, studTagRec.Name); StudTagDict.Add(studTagRec.RefStudentID, stn); } } // 讀取組合後的學生類別 foreach (DAL.StudentTagEntity ste in StudTagDict.Values) { foreach (KeyValuePair <string, List <string> > data in ste.GetPrefixNameDic()) { // 當群組空白 string key = string.Empty; if (data.Key != " ") { key = data.Key; } // 類別名稱 foreach (string str in data.Value) { RowData row = new RowData(); foreach (string field in e.ExportFields) { row.ID = ste.StudentID; if (field == "群組") { row.Add(field, key); } if (field == "類別名稱") { row.Add(field, str); } } e.Items.Add(row); } } } PermRecLogProcess prlp = new PermRecLogProcess(); prlp.SaveLog("學生.匯出類別", "匯出", "共匯出" + StudTagDict.Values.Count + "筆學生類別資料."); }; }
public override void InitializeImport(SmartSchool.API.PlugIn.Import.ImportWizard wizard) { Dictionary <string, JHStudentRecord> students = new Dictionary <string, JHStudentRecord>(); Dictionary <string, List <JHStudentTagRecord> > StudTagRecDic = new Dictionary <string, List <JHStudentTagRecord> > (); Dictionary <string, Dictionary <string, string> > StudTagNameDic = DAL.DALTransfer.GetStudentTagNameDic(); // 取得可加入學生 TagName wizard.PackageLimit = 3000; wizard.ImportableFields.AddRange(ImportItemList); wizard.ValidateStart += delegate(object sender, SmartSchool.API.PlugIn.Import.ValidateStartEventArgs e) { // 取得學生資料 foreach (JHStudentRecord studRec in JHStudent.SelectByIDs(e.List)) { if (!students.ContainsKey(studRec.ID)) { students.Add(studRec.ID, studRec); StudTagRecDic.Add(studRec.ID, new List <JHStudentTagRecord>()); } } // 取得學生類別 foreach (JHStudentTagRecord studTag in JHStudentTag.SelectByStudentIDs(students.Keys)) { //if (!StudTagRecDic.ContainsKey(studTag.RefStudentID)) //{ // List<JHStudentTagRecord> rec = new List<JHStudentTagRecord> (); // rec.Add(studTag ); // StudTagRecDic.Add(studTag.RefStudentID,rec); //} //else if (StudTagRecDic.ContainsKey(studTag.RefStudentID)) { StudTagRecDic[studTag.RefStudentID].Add(studTag); } } }; wizard.ValidateRow += delegate(object sender, SmartSchool.API.PlugIn.Import.ValidateRowEventArgs e) { int i = 0; // 檢查學生是否存在 JHStudentRecord studRec = null; if (students.ContainsKey(e.Data.ID)) { studRec = students[e.Data.ID]; } else { e.ErrorMessage = "沒有這位學生" + e.Data.ID; return; } // 驗證資料 foreach (string field in e.SelectFields) { string value = e.Data[field].Trim(); // 驗證$無法匯入 if (value.IndexOf('$') > -1) { e.ErrorFields.Add(field, "儲存格有$無法匯入."); break; } if (field == "類別名稱") { if (string.IsNullOrEmpty(value)) { e.ErrorFields.Add(field, "不允許空白"); } } } }; 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 <JHStudentTagRecord> InsertList = new List <JHStudentTagRecord>(); // List<JHStudentTagRecord> UpdateList = new List<JHStudentTagRecord>(); // 放需要新增的學生類別 Dictionary <string, List <string> > NeedAddPrefixName = new Dictionary <string, List <string> >(); // 檢查用 List List <string> CheckStudTagName = new List <string>(); foreach (KeyValuePair <string, Dictionary <string, string> > data in StudTagNameDic) { foreach (KeyValuePair <string, string> data1 in data.Value) { CheckStudTagName.Add(data.Key + data1.Key); } } // 檢查類別是否已經存在 foreach (string id in id_Rows.Keys) { if (!StudTagRecDic.ContainsKey(id)) { continue; } foreach (RowData data in id_Rows[id]) { string strPrefix = string.Empty, strName = string.Empty; if (data.ContainsKey("群組")) { strPrefix = data["群組"]; } if (data.ContainsKey("類別名稱")) { strName = data["類別名稱"]; } string FullName = strPrefix + strName; // 需要新增的, if (!CheckStudTagName.Contains(FullName)) { CheckStudTagName.Add(FullName); if ((NeedAddPrefixName.ContainsKey(strPrefix))) { NeedAddPrefixName[strPrefix].Add(strName); } else { List <string> Names = new List <string>(); Names.Add(strName); NeedAddPrefixName.Add(strPrefix, Names); } } } } // 新增至學生類別管理 List <JHTagConfigRecord> Recs = new List <JHTagConfigRecord>(); foreach (KeyValuePair <string, List <string> > data in NeedAddPrefixName) { foreach (string data1 in data.Value) { JHTagConfigRecord rec = new JHTagConfigRecord(); rec.Category = "Student"; rec.Prefix = data.Key; rec.Name = data1; rec.Color = System.Drawing.Color.White; Recs.Add(rec); } } JHTagConfig.Insert(Recs); StudTagNameDic.Clear(); // 重新取得 StudTagNameDic = DAL.DALTransfer.GetStudentTagNameDic(); foreach (string id in id_Rows.Keys) { if (!StudTagRecDic.ContainsKey(id)) { continue; } foreach (RowData data in id_Rows[id]) { string strPrefix = string.Empty, strName = string.Empty; if (data.ContainsKey("群組")) { strPrefix = data["群組"]; } if (data.ContainsKey("類別名稱")) { strName = data["類別名稱"]; } // 欄位有在 Tag Prefix 內 bool isInsert = true; foreach (JHStudentTagRecord rec in StudTagRecDic[id]) { if (rec.Prefix == strPrefix && rec.Name == strName) { isInsert = false; break; } } if (isInsert) { // 學生類別管理名稱對照 if (StudTagNameDic.ContainsKey(strPrefix)) { if (StudTagNameDic[strPrefix].ContainsKey(strName)) { JHStudentTagRecord StudTag = new JHStudentTagRecord(); StudTag.RefEntityID = id; StudTag.RefTagID = StudTagNameDic[strPrefix][strName]; InsertList.Add(StudTag); } } } } } try { if (InsertList.Count > 0) { Insert(InsertList); } //if (UpdateList.Count > 0) // Update(UpdateList); JHSchool.PermRecLogProcess prlp = new JHSchool.PermRecLogProcess(); prlp.SaveLog("學生.匯入類別", "匯入學生類別", "匯入學生類別:共新增" + InsertList.Count + "筆資料"); JHSchool.Student.Instance.SyncAllBackground(); JHSchool.StudentTag.Instance.SyncAllBackground(); JHSchool.Data.JHStudent.RemoveAll(); JHSchool.Data.JHStudent.SelectAll(); } catch (Exception ex) {} }; }