Esempio n. 1
0
 // 更新
 private void Update(object item)
 {
     try
     {
         List <JHLeaveInfoRecord> UpdatePackage = (List <JHLeaveInfoRecord>)item;
         JHLeaveIfno.Update(UpdatePackage);
     }
     catch (Exception ex)
     {
     }
 }
Esempio n. 2
0
        /// <summary>
        /// 取得學生畢業資訊
        /// </summary>
        /// <param name="StudentIDList"></param>
        /// <returns></returns>
        public static Dictionary <string, JHLeaveInfoRecord> GetStudentLeaveInfoDic(List <string> StudentIDList)
        {
            Dictionary <string, JHLeaveInfoRecord> StudLIR = new Dictionary <string, JHLeaveInfoRecord>();

            foreach (JHLeaveInfoRecord rec in JHLeaveIfno.SelectByStudentIDs(StudentIDList))
            {
                if (!StudLIR.ContainsKey(rec.RefStudentID))
                {
                    StudLIR.Add(rec.RefStudentID, rec);
                }
            }
            return(StudLIR);
        }
Esempio n. 3
0
        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)
            {
                // 取得畢業相關資訊
                List <JHLeaveInfoRecord> JHLeaveInfoRecordList = JHLeaveIfno.SelectByStudentIDs(e.List);

                foreach (JHLeaveInfoRecord lir in JHLeaveInfoRecordList)
                {
                    RowData row = new RowData();
                    row.ID = lir.RefStudentID;

                    foreach (string field in e.ExportFields)
                    {
                        if (wizard.ExportableFields.Contains(field))
                        {
                            switch (field)
                            {
                            case "畢業學年度":
                                if (lir.SchoolYear.HasValue)
                                {
                                    row.Add(field, lir.SchoolYear.Value.ToString());
                                }
                                break;

                            case "畢業資格":
                                row.Add(field, lir.Reason);
                                break;

                            case "畢業證書字號":
                                row.Add(field, lir.DiplomaNumber);
                                break;

                            case "畢業相關訊息":
                                row.Add(field, lir.Memo);
                                break;
                            }
                        }
                    }
                    e.Items.Add(row);
                }

                PermRecLogProcess prlp = new PermRecLogProcess();
                prlp.SaveLog("學生.匯出畢業資訊", "匯出", "共匯出" + K12.Presentation.NLDPanels.Student.SelectedSource.Count + "筆學生類別資料.");
            };
        }
Esempio n. 4
0
        public void SetStudent(JHStudentRecord student, List <SemesterHistoryItem> semesterHistoryList)
        {
            ClearField();
            // 學期歷程
            _semesterHistoryList = semesterHistoryList;
            JHParentRecord  parent  = JHParent.SelectByStudent(student);
            JHPhoneRecord   phone   = JHPhone.SelectByStudent(student);
            JHAddressRecord address = JHAddress.SelectByStudent(student);
            string          tmpStr  = "      ";

            JHLeaveInfoRecord leave   = JHLeaveIfno.SelectByStudent(student);
            string            number1 = string.Empty;
            string            number2 = string.Empty;

            if (leave != null)
            {
                if (leave.Reason == "畢業")
                {
                    number1 = leave.DiplomaNumber;
                }
                else if (leave.Reason == "修業")
                {
                    number2 = leave.DiplomaNumber;
                }
            }

            string base64 = K12.Data.Photo.SelectGraduatePhoto(student.ID);

            _data["姓名"]      = student.Name;
            _data["性別"]      = student.Gender;
            _data["身分證字號"]   = student.IDNumber;
            _data["學號"]      = student.StudentNumber;
            _data["班級"]      = (student.Class != null ? student.Class.Name : "");
            _data["座號"]      = "" + student.SeatNo;
            _data["出生"]      = DateConvert.ChineseUnitDate(DateConvert.CDate(student.Birthday.HasValue ? student.Birthday.Value.ToShortDateString() : ""));
            _data["出生地"]     = student.BirthPlace;
            _data["家長或監護人"]  = (parent != null) ? parent.Custodian.Name : "";
            _data["關係"]      = (parent != null) ? parent.Custodian.Relationship : "";
            _data["聯絡電話"]    = (phone != null) ? "" + phone.Contact : "";
            _data["戶籍電話"]    = (phone != null) ? "" + phone.Permanent : "";
            _data["戶籍地址"]    = (address != null) ? address.Permanent.ToString() : "";
            _data["通訊處"]     = (address != null) ? address.Mailing.ToString() : "";
            _data["行動電話"]    = (phone != null) ? "" + phone.Cell : "";
            _data["畢業證書字號"]  = number1;
            _data["修業證明書字號"] = number2;
            _data["照片"]      = base64;
            _data["簽呈"]      = "承辦人員:" + Global.TransferName + tmpStr + "註冊組長:" + Global.RegManagerName + tmpStr + "教務主任:" + JHSchoolInfo.EduDirectorName + tmpStr + "校長:" + JHSchoolInfo.ChancellorChineseName;
            // 處理服務學習時數
            if (Global._SLRDict.ContainsKey(student.ID))
            {
                foreach (SemesterHistoryItem shi in _semesterHistoryList)
                {
                    string key = shi.SchoolYear + "_" + shi.Semester;
                    if (Global._SLRDict[student.ID].ContainsKey(key))
                    {
                        string val = Global._SLRDict[student.ID][key];

                        if ((shi.GradeYear == 1 || shi.GradeYear == 7) && shi.Semester == 1)
                        {
                            _data["SLR1A"] = val;
                        }

                        if ((shi.GradeYear == 1 || shi.GradeYear == 7) && shi.Semester == 2)
                        {
                            _data["SLR1B"] = val;
                        }

                        if ((shi.GradeYear == 2 || shi.GradeYear == 8) && shi.Semester == 1)
                        {
                            _data["SLR2A"] = val;
                        }

                        if ((shi.GradeYear == 2 || shi.GradeYear == 8) && shi.Semester == 2)
                        {
                            _data["SLR2B"] = val;
                        }

                        if ((shi.GradeYear == 3 || shi.GradeYear == 9) && shi.Semester == 1)
                        {
                            _data["SLR3A"] = val;
                        }

                        if ((shi.GradeYear == 3 || shi.GradeYear == 9) && shi.Semester == 2)
                        {
                            _data["SLR3B"] = val;
                        }
                    }
                }
            }
            _builder.Document.MailMerge.Execute(GetFieldName(), GetFieldValue());
        }
Esempio n. 5
0
        public override void InitializeImport(SmartSchool.API.PlugIn.Import.ImportWizard wizard)
        {
            // 學生
            Dictionary <string, JHStudentRecord> students = new Dictionary <string, JHStudentRecord>();

            // 畢業資訊
            Dictionary <string, JHLeaveInfoRecord> StudJHLeaveInfoRecordDic = new Dictionary <string, JHLeaveInfoRecord>();


            // 可匯入項目
            List <string> ImportItemList = new List <string>();

            ImportItemList.Add("畢業學年度");
            ImportItemList.Add("畢業資格");
            ImportItemList.Add("畢業證書字號");
            ImportItemList.Add("畢業相關訊息");

            // 取得可加入學生 TagName
            wizard.PackageLimit = 3000;
            wizard.ImportableFields.AddRange(ImportItemList);
            wizard.RequiredFields.AddRange();
            wizard.ValidateStart += delegate(object sender, SmartSchool.API.PlugIn.Import.ValidateStartEventArgs e)
            {
                // 取得學生資料
                students = JHStudent.SelectByIDs(e.List).ToDictionary(x => x.ID);
                // 取得畢業資訊
                StudJHLeaveInfoRecordDic = JHLeaveIfno.SelectByStudentIDs(e.List).ToDictionary(x => x.RefStudentID);
            };

            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;
                }
            };

            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 <JHLeaveInfoRecord> UpdateList = new List <JHLeaveInfoRecord>();

                foreach (string id in id_Rows.Keys)
                {
                    if (StudJHLeaveInfoRecordDic.ContainsKey(id))
                    {
                        foreach (RowData data in id_Rows[id])
                        {
                            foreach (string field in e.ImportFields)
                            {
                                if (field == "畢業學年度")
                                {
                                    int SchoolYear;
                                    if (int.TryParse(data[field], out SchoolYear))
                                    {
                                        StudJHLeaveInfoRecordDic[id].SchoolYear = SchoolYear;
                                    }
                                    else
                                    {
                                        StudJHLeaveInfoRecordDic[id].SchoolYear = null;
                                    }
                                }

                                if (field == "畢業資格")
                                {
                                    StudJHLeaveInfoRecordDic[id].Reason = data[field];
                                }

                                if (field == "畢業證書字號")
                                {
                                    StudJHLeaveInfoRecordDic[id].DiplomaNumber = data[field];
                                }

                                if (field == "畢業相關訊息")
                                {
                                    StudJHLeaveInfoRecordDic[id].Memo = data[field];
                                }
                            }
                        }
                    }
                }

                UpdateList = StudJHLeaveInfoRecordDic.Values.ToList();

                try
                {
                    if (UpdateList.Count > 0)
                    {
                        Update(UpdateList);
                    }

                    JHSchool.PermRecLogProcess prlp = new JHSchool.PermRecLogProcess();
                    prlp.SaveLog("學生.匯入畢業資訊", "匯入學生畢業資訊", "匯入學生畢業資訊:共更新:" + UpdateList.Count + "筆資料");
                    JHSchool.Student.Instance.SyncAllBackground();
                    JHSchool.StudentTag.Instance.SyncAllBackground();
                    JHSchool.Data.JHStudent.RemoveAll();
                    JHSchool.Data.JHStudent.SelectAll();
                }
                catch (Exception ex) { }
            };
        }
Esempio n. 6
0
        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 void SetStudent(JHStudentRecord student, List <SemesterHistoryItem> semesterHistoryList)
        {
            ClearField();
            // 學期歷程
            _semesterHistoryList = semesterHistoryList;
            //ParentRecord parent = student.GetParent();
            //PhoneRecord phone = student.GetPhone();
            //AddressRecord address = student.GetAddress();

            JHParentRecord  parent  = JHParent.SelectByStudent(student);
            JHPhoneRecord   phone   = JHPhone.SelectByStudent(student);
            JHAddressRecord address = JHAddress.SelectByStudent(student);
            string          base64  = K12.Data.Photo.SelectGraduatePhoto(student.ID);

            // 畢業資訊
            JHLeaveInfoRecord GradeInfo = JHLeaveIfno.SelectByStudentID(student.ID);

            string EnrollSchoolYear = "";

            foreach (JHUpdateRecordRecord rec in JHUpdateRecord.SelectByStudentID(student.ID))
            {
                if (rec.UpdateCode == "1")
                {
                    int sc;
                    if (rec.EnrollmentSchoolYear.Length == 6)
                    {
                        int.TryParse(rec.EnrollmentSchoolYear.Substring(0, 4), out sc);
                        EnrollSchoolYear = (sc - 1911) + rec.EnrollmentSchoolYear.Substring(4, 2);
                    }
                }
            }

            _data["姓名"]     = student.Name;
            _data["性別"]     = student.Gender;
            _data["身分證號"]   = student.IDNumber;
            _data["學號"]     = student.StudentNumber;
            _data["出生日期"]   = Global.CDate(student.Birthday.HasValue ? student.Birthday.Value.ToShortDateString() : "");
            _data["國籍"]     = student.Nationality;
            _data["家長或監護人"] = (parent != null) ? parent.Custodian.Name : "";
            _data["關係"]     = (parent != null) ? parent.Custodian.Relationship : "";
            _data["行動電話"]   = (phone != null) ? phone.Cell : "";
            _data["戶籍電話"]   = (phone != null) ? phone.Permanent : "";
            _data["戶籍地址"]   = (address != null) ? address.Permanent.ToString() : "";
            _data["聯絡電話"]   = (phone != null) ? phone.Contact : "";
            _data["聯絡地址"]   = (address != null) ? address.Mailing.ToString() : "";
            _data["證書字號"]   = GradeInfo.DiplomaNumber;
            _data["入學年月"]   = EnrollSchoolYear;
            _data["照片"]     = base64;

            // 處理服務學習時數
            if (Global._SLRDict.ContainsKey(student.ID))
            {
                foreach (SemesterHistoryItem shi in _semesterHistoryList)
                {
                    string key = shi.SchoolYear + "_" + shi.Semester;
                    if (Global._SLRDict[student.ID].ContainsKey(key))
                    {
                        string val = Global._SLRDict[student.ID][key];

                        if ((shi.GradeYear == 1 || shi.GradeYear == 7) && shi.Semester == 1)
                        {
                            _data["SLR1A"] = val;
                        }

                        if ((shi.GradeYear == 1 || shi.GradeYear == 7) && shi.Semester == 2)
                        {
                            _data["SLR1B"] = val;
                        }

                        if ((shi.GradeYear == 2 || shi.GradeYear == 8) && shi.Semester == 1)
                        {
                            _data["SLR2A"] = val;
                        }

                        if ((shi.GradeYear == 2 || shi.GradeYear == 8) && shi.Semester == 2)
                        {
                            _data["SLR2B"] = val;
                        }

                        if ((shi.GradeYear == 3 || shi.GradeYear == 9) && shi.Semester == 1)
                        {
                            _data["SLR3A"] = val;
                        }

                        if ((shi.GradeYear == 3 || shi.GradeYear == 9) && shi.Semester == 2)
                        {
                            _data["SLR3B"] = val;
                        }
                    }
                }
            }
        }