コード例 #1
0
        public override void InitializeExport(SmartSchool.API.PlugIn.Export.ExportWizard wizard)
        {
            SmartSchool.API.PlugIn.VirtualCheckBox filterRepeat = new SmartSchool.API.PlugIn.VirtualCheckBox("自動略過重讀成績", true);
            wizard.Options.Add(filterRepeat);
            // 2022-01 Cynthia 移除"體育", "國防通識", "健康與護理",
            wizard.ExportableFields.AddRange("學年度", "成績年級", "學業", "實習科目", "專業科目", "德行");
            AccessHelper _AccessHelper = new AccessHelper();

            wizard.ExportPackage += delegate(object sender, SmartSchool.API.PlugIn.Export.ExportPackageEventArgs e)
            {
                List <StudentRecord> students = _AccessHelper.StudentHelper.GetStudents(e.List);
                _AccessHelper.StudentHelper.FillSchoolYearEntryScore(filterRepeat.Checked, students);
                foreach (StudentRecord stu in students)
                {
                    Dictionary <int, List <SchoolYearEntryScoreInfo> > schoolYearEntryScoreList = new Dictionary <int, List <SchoolYearEntryScoreInfo> >();
                    foreach (SchoolYearEntryScoreInfo var in stu.SchoolYearEntryScoreList)
                    {
                        if (!schoolYearEntryScoreList.ContainsKey(var.SchoolYear))
                        {
                            schoolYearEntryScoreList.Add(var.SchoolYear, new List <SchoolYearEntryScoreInfo>());
                        }
                        schoolYearEntryScoreList[var.SchoolYear].Add(var);
                    }
                    foreach (int sy in schoolYearEntryScoreList.Keys)
                    {
                        RowData row = new RowData();
                        row.ID = stu.StudentID;
                        row.Add("學年度", "" + sy);
                        foreach (SchoolYearEntryScoreInfo var in schoolYearEntryScoreList[sy])
                        {
                            if (!row.ContainsKey("成績年級"))
                            {
                                row.Add("成績年級", "" + var.GradeYear);
                            }
                            if (e.ExportFields.Contains(var.Entry))
                            {
                                row.Add(var.Entry, "" + var.Score);
                            }
                        }
                        e.Items.Add(row);
                    }
                }
            };
        }
コード例 #2
0
        public override void InitializeExport(SmartSchool.API.PlugIn.Export.ExportWizard wizard)
        {
            SmartSchool.API.PlugIn.VirtualCheckBox filterRepeat = new SmartSchool.API.PlugIn.VirtualCheckBox("自動略過重讀成績", true);
            wizard.Options.Add(filterRepeat);

            // 2018/8 穎驊註解,經過討論後, 先暫時將 ischool類別2 排名的概念拿掉,因為目前的結構 無法區隔類別1、類別2,待日後設計完整
            //wizard.ExportableFields.AddRange("學年度", "學期", "成績年級", "學業", "體育", "國防通識", "健康與護理", "實習科目", "專業科目", "學業(原始)", "體育(原始)", "國防通識(原始)", "健康與護理(原始)", "實習科目(原始)", "專業科目(原始)", "德行", "學業成績班排名", "學業成績班排名母數", "學業成績科排名", "學業成績科排名母數", "學業成績校排名", "學業成績校排名母數", "學業成績排名類別1", "學業成績類1排名", "學業成績類1排名母數", "學業成績排名類別2", "學業成績類2排名", "學業成績類2排名母數");

            wizard.ExportableFields.AddRange("學年度", "學期", "成績年級", "學業", "體育", "國防通識", "健康與護理", "實習科目", "專業科目", "學業(原始)", "體育(原始)", "國防通識(原始)", "健康與護理(原始)", "實習科目(原始)", "專業科目(原始)", "德行", "學業成績班排名", "學業成績班排名母數", "學業成績科排名", "學業成績科排名母數", "學業成績校排名", "學業成績校排名母數", "學業成績排名類別1", "學業成績類1排名", "學業成績類1排名母數");
            AccessHelper _AccessHelper = new AccessHelper();

            wizard.ExportPackage += delegate(object sender, SmartSchool.API.PlugIn.Export.ExportPackageEventArgs e)
            {
                List <StudentRecord> students = _AccessHelper.StudentHelper.GetStudents(e.List);



                Dictionary <string, List <StudSemsEntryRating> > StudSemsEntryRatingDict = new Dictionary <string, List <StudSemsEntryRating> >();
                StudSemsEntryRatingDict = Utility.GetStudSemsEntryRatingByStudentID(e.List);

                _AccessHelper.StudentHelper.FillSemesterEntryScore(filterRepeat.Checked, students);
                foreach (StudentRecord stu in students)
                {
                    Dictionary <int, Dictionary <int, List <SemesterEntryScoreInfo> > > semesterEntryScoreList = new Dictionary <int, Dictionary <int, List <SemesterEntryScoreInfo> > >();
                    foreach (SemesterEntryScoreInfo var in stu.SemesterEntryScoreList)
                    {
                        if (!semesterEntryScoreList.ContainsKey(var.SchoolYear))
                        {
                            semesterEntryScoreList.Add(var.SchoolYear, new Dictionary <int, List <SemesterEntryScoreInfo> >());
                        }
                        if (!semesterEntryScoreList[var.SchoolYear].ContainsKey(var.Semester))
                        {
                            semesterEntryScoreList[var.SchoolYear].Add(var.Semester, new List <SemesterEntryScoreInfo>());
                        }
                        semesterEntryScoreList[var.SchoolYear][var.Semester].Add(var);
                    }
                    foreach (int sy in semesterEntryScoreList.Keys)
                    {
                        foreach (int se in semesterEntryScoreList[sy].Keys)
                        {
                            RowData row = new RowData();
                            row.ID = stu.StudentID;
                            row.Add("學年度", "" + sy);
                            row.Add("學期", "" + se);
                            foreach (SemesterEntryScoreInfo var in semesterEntryScoreList[sy][se])
                            {
                                if (!row.ContainsKey("成績年級"))
                                {
                                    row.Add("成績年級", "" + var.GradeYear);
                                }
                                if (e.ExportFields.Contains(var.Entry))
                                {
                                    row.Add(var.Entry, "" + var.Score);
                                }
                            }

                            //處理學業成績排名資料

                            if (StudSemsEntryRatingDict.ContainsKey(stu.StudentID))
                            {
                                foreach (var record in StudSemsEntryRatingDict[stu.StudentID])
                                {
                                    if (record.SchoolYear == "" + sy && record.Semester == "" + se)
                                    {
                                        row.Add("學業成績班排名", "" + record.ClassRank);
                                        row.Add("學業成績班排名母數", "" + record.ClassCount);
                                        row.Add("學業成績科排名", "" + record.DeptRank);
                                        row.Add("學業成績科排名母數", "" + record.DeptCount);
                                        row.Add("學業成績校排名", "" + record.YearRank);
                                        row.Add("學業成績校排名母數", "" + record.YearCount);

                                        row.Add("學業成績排名類別1", "" + record.Group1);
                                        row.Add("學業成績類1排名", "" + record.Group1Rank);
                                        row.Add("學業成績類1排名母數", "" + record.Group1Count);

                                        // 2018/8 穎驊註解,經過討論後, 先暫時將 ischool類別2 排名的概念拿掉,因為目前的結構 無法區隔類別1、類別2,待日後設計完整

                                        //row.Add("學業成績排名類別2", "" + record.Group2);
                                        //row.Add("學業成績類2排名", "" + record.Group2Rank);
                                        //row.Add("學業成績類2排名母數", "" + record.Group2Count);
                                    }
                                }
                            }


                            e.Items.Add(row);
                        }
                    }
                }
            };
        }
コード例 #3
0
        public override void InitializeExport(SmartSchool.API.PlugIn.Export.ExportWizard wizard)
        {
            AccessHelper helper = new AccessHelper();

            Dictionary<string, CLUBRecord> AllClubDic = new Dictionary<string, CLUBRecord>();
            Dictionary<string, List<string>> SemesterClub = new Dictionary<string, List<string>>();
            //社團基本資料
            List<CLUBRecord> ClubList = helper.Select<CLUBRecord>();
            foreach (CLUBRecord each in ClubList)
            {
                if (!AllClubDic.ContainsKey(each.UID))
                {
                    AllClubDic.Add(each.UID, each);
                }

                string SchoolYearSemester = each.SchoolYear.ToString().PadLeft(3, ' ') + "学年度 第" + each.Semester.ToString() + "学期";

                if (!SemesterClub.ContainsKey(SchoolYearSemester))
                {
                    //學年度學期名稱/當學期的社團課程ID清單
                    SemesterClub.Add(SchoolYearSemester, new List<string>());
                }

                SemesterClub[SchoolYearSemester].Add(each.UID);
            }

            var FiltedSemester = School.DefaultSchoolYear.ToString().PadLeft(3, ' ') + "学年度 第" + School.DefaultSemester + "学期";
            List<string> list = new List<string>();

            foreach (string item in SemesterClub.Keys)
            {
                list.Add(item);
            }
            list.Sort();
            if (list.Count > 0 && !list.Contains(FiltedSemester))
                FiltedSemester = list[0];

            foreach (string item in list)
            {
                SmartSchool.API.PlugIn.VirtualRadioButton radioSem = new VirtualRadioButton(item);
                wizard.Options.Add(radioSem);
                if (item == FiltedSemester)
                    radioSem.Checked = true;
                radioSem.CheckedChanged += delegate(object sender1, EventArgs e1)
                {
                    var target = sender1 as SmartSchool.API.PlugIn.VirtualRadioButton;
                    if (target.Checked)
                        FiltedSemester = target.Text;
                };
                //MenuButton mb = e.VirtualButtons[item];
                //mb.AutoCheckOnClick = true;
                //mb.AutoCollapseOnClick = true;
                //mb.Checked = (item == FiltedSemester);
                //mb.Tag = item;
                //mb.CheckedChanged += delegate(object sender1, EventArgs e1)
                //{
                //    MenuButton mb1 = sender1 as MenuButton;
                //    SetClubList(mb1.Text);
                //    FiltedSemester = FilterMenu.Text = mb1.Text;
                //    mb1.Checked = true;
                //};
            }

            wizard.ExportableFields.AddRange(new string[]{
                "班级",
                "学号",
                "姓名",
                "学籍号",
                "性别",
                "第一阶段",
                "第二阶段"
            });
            wizard.ExportPackage += (sender, e) =>
            {
                Dictionary<string, CLUBRecord> ClubRefIDList = new Dictionary<string, CLUBRecord>();
                //List<CLUBRecord> CLUBRecordList = helper.Select<CLUBRecord>(string.Format("uid in ('{0}')", string.Join("','", e.List)));
                //foreach (CLUBRecord record in CLUBRecordList)
                //{
                //    if (!ClubRefIDList.ContainsKey(record.UID))
                //    {
                //        ClubRefIDList.Add(record.UID, record);
                //    }
                //}
                foreach (CLUBRecord each in ClubList)
                {
                    string SchoolYearSemester = each.SchoolYear.ToString().PadLeft(3, ' ') + "学年度 第" + each.Semester.ToString() + "学期";
                    if (FiltedSemester == SchoolYearSemester)
                    {
                        ClubRefIDList.Add(each.UID, each);
                    }
                }

                string ClubIdString = string.Join("','", ClubRefIDList.Keys);
                List<SCJoin> Scjoin = helper.Select<SCJoin>(string.Format("ref_club_id in ('{0}') and ref_student_id in ('{1}')", ClubIdString, string.Join("','", e.List)));

                Dictionary<string, List<SCJoin>> StudentScjoinDic = new Dictionary<string, List<SCJoin>>();
                foreach (SCJoin join in Scjoin)
                {
                    if (!StudentScjoinDic.ContainsKey(join.RefStudentID))
                    {
                        StudentScjoinDic.Add(join.RefStudentID, new List<SCJoin>());
                    }
                    StudentScjoinDic[join.RefStudentID].Add(join);
                }

                var studentList = K12.Data.Student.SelectByIDs(e.List);
                foreach (var stuRec in studentList)
                {
                    RowData row = new RowData();

                    foreach (string field in e.ExportFields)
                    {
                        if (wizard.ExportableFields.Contains(field))
                        {
                            switch (field)
                            {
                                case "班级":
                                    row.Add(field, stuRec.Class == null ? "" : stuRec.Class.Name);
                                    break;
                                case "学号":
                                    row.Add(field, "" + stuRec.SeatNo);
                                    break;
                                case "姓名":
                                    row.Add(field, "" + stuRec.Name);
                                    break;
                                case "学籍号":
                                    row.Add(field, "" + stuRec.StudentNumber);
                                    break;
                                case "性别":
                                    row.Add(field, "" + stuRec.Gender);
                                    break;
                                case "第一阶段":
                                    if (StudentScjoinDic.ContainsKey(stuRec.ID))
                                    {
                                        foreach (var item in StudentScjoinDic[stuRec.ID])
                                        {
                                            if (item.Phase == 1)
                                            {
                                                if (row.ContainsKey(field))
                                                    row[field] += "," + ClubRefIDList[item.RefClubID].ClubName;
                                                else
                                                    row.Add(field, ClubRefIDList[item.RefClubID].ClubName);
                                            }
                                        }
                                    }
                                    break;
                                case "第二阶段":
                                    if (StudentScjoinDic.ContainsKey(stuRec.ID))
                                    {
                                        foreach (var item in StudentScjoinDic[stuRec.ID])
                                        {
                                            if (item.Phase == 1 && ClubRefIDList[item.RefClubID].FullPhase.HasValue && ClubRefIDList[item.RefClubID].FullPhase.Value == true)
                                            {
                                                if (row.ContainsKey(field))
                                                    row[field] += ",--";
                                                else
                                                    row.Add(field, "--");
                                            }
                                            if (item.Phase == 2)
                                            {
                                                if (row.ContainsKey(field))
                                                    row[field] += "," + ClubRefIDList[item.RefClubID].ClubName;
                                                else
                                                    row.Add(field, ClubRefIDList[item.RefClubID].ClubName);
                                            }
                                        }
                                    }
                                    break;
                            }
                        }
                    }
                    e.Items.Add(row);
                }
            };
        }
コード例 #4
0
        void wizard_ImportPackage(object sender, SmartSchool.API.PlugIn.Import.ImportPackageEventArgs e)
        {
            // 尋找主要Key來判斷,如果有學生系統編號先用系統編號,沒有使用學號,
            Dictionary <string, RowData> RowDataDict          = new Dictionary <string, RowData>();
            Dictionary <string, int>     chkSidDict           = new Dictionary <string, int>();
            Dictionary <string, string>  chkSnumDict          = new Dictionary <string, string>();
            List <JHStudentRecord>       InsertStudentRecList = new List <JHStudentRecord>();
            List <JHStudentRecord>       StudentRecAllList    = JHStudent.SelectAll();

            foreach (JHStudentRecord rec in StudentRecAllList)
            {
                chkSidDict.Add(rec.ID, 0);
                string key = rec.StudentNumber + rec.StatusStr;
                if (!chkSnumDict.ContainsKey(key))
                {
                    chkSnumDict.Add(key, rec.ID);
                }
            }

            // 先處理學生基本資料
            foreach (RowData Row in e.Items)
            {
                string StudentID = "";

                if (Row.ContainsKey("學生系統編號"))
                {
                    string id = Row["學生系統編號"].ToString();
                    if (chkSidDict.ContainsKey(id))
                    {
                        StudentID = id;
                    }
                }

                if (StudentID == "")
                {
                    string ssNum = "", snum = "";
                    if (Row.ContainsKey("學號"))
                    {
                        snum = Row["學號"].ToString();
                        string status = "一般";
                        if (Row.ContainsKey("狀態"))
                        {
                            if (Row["狀態"].ToString() != "")
                            {
                                status = Row["狀態"].ToString();
                            }
                        }
                        ssNum = snum + status;
                    }

                    if (chkSnumDict.ContainsKey(ssNum))
                    {
                        StudentID = chkSnumDict[ssNum];
                    }
                    else
                    {
                        // 新增
                        if (chkSnumDict.ContainsKey(snum + "一般"))
                        {
                            // 有重複
                        }
                        else
                        {
                            // 批次新增
                            JHStudentRecord newRec = new JHStudentRecord();
                            newRec.StudentNumber = snum;
                            newRec.Status        = StudentRecord.StudentStatus.一般;
                            if (Row.ContainsKey("姓名"))
                            {
                                newRec.Name = Row["姓名"].ToString();
                            }

                            InsertStudentRecList.Add(newRec);
                        }
                    }
                }
            }

            // 如有新學生處理新增學生
            if (InsertStudentRecList.Count > 0)
            {
                JHStudent.Insert(InsertStudentRecList);
            }

            // 再次建立索引
            Dictionary <string, JHStudentRecord> StudRecAllDict = new Dictionary <string, JHStudentRecord>();

            StudentRecAllList = JHStudent.SelectAll();
            chkSidDict.Clear();
            chkSnumDict.Clear();
            foreach (JHStudentRecord rec in StudentRecAllList)
            {
                chkSidDict.Add(rec.ID, 0);
                string key = rec.StudentNumber + rec.StatusStr;
                if (!chkSnumDict.ContainsKey(key))
                {
                    chkSnumDict.Add(key, rec.ID);
                }

                StudRecAllDict.Add(rec.ID, rec);
            }

            List <string> StudentIDList = new List <string>();

            //比對
            foreach (RowData Row in e.Items)
            {
                string StudentID = "";

                if (Row.ContainsKey("學生系統編號"))
                {
                    string id = Row["學生系統編號"].ToString();
                    if (chkSidDict.ContainsKey(id))
                    {
                        StudentID = id;
                    }
                }

                if (StudentID == "")
                {
                    string ssNum = "", snum = "";
                    if (Row.ContainsKey("學號"))
                    {
                        snum = Row["學號"].ToString();
                        string status = "一般";
                        if (Row.ContainsKey("狀態"))
                        {
                            if (Row["狀態"].ToString() != "")
                            {
                                status = Row["狀態"].ToString();
                            }
                        }
                        ssNum = snum + status;
                    }

                    if (chkSnumDict.ContainsKey(ssNum))
                    {
                        StudentID = chkSnumDict[ssNum];
                    }
                }

                if (!string.IsNullOrEmpty(StudentID))
                {
                    if (!RowDataDict.ContainsKey(StudentID))
                    {
                        RowDataDict.Add(StudentID, Row);
                    }

                    StudentIDList.Add(StudentID);
                }
            }
            // 取得學生基本、父母監護人、電話、地址、UDT
            List <JHStudentRecord> StudentRecordList = JHStudent.SelectByIDs(StudentIDList);
            Dictionary <string, JHStudentRecord> StudentRecordDict = new Dictionary <string, JHStudentRecord>();

            foreach (JHStudentRecord rec in StudentRecordList)
            {
                if (!StudentRecordDict.ContainsKey(rec.ID))
                {
                    StudentRecordDict.Add(rec.ID, rec);
                }
            }

            List <JHParentRecord> ParentRecordList = JHParent.SelectByStudentIDs(StudentIDList);
            Dictionary <string, JHParentRecord> ParentRecordDict = new Dictionary <string, JHParentRecord>();

            foreach (JHParentRecord rec in ParentRecordList)
            {
                if (!ParentRecordDict.ContainsKey(rec.RefStudentID))
                {
                    ParentRecordDict.Add(rec.RefStudentID, rec);
                }
            }

            List <JHPhoneRecord> PhoneRecordList = JHPhone.SelectByStudentIDs(StudentIDList);
            Dictionary <string, JHPhoneRecord> PhoneRecordDict = new Dictionary <string, JHPhoneRecord>();

            foreach (JHPhoneRecord rec in PhoneRecordList)
            {
                if (!PhoneRecordDict.ContainsKey(rec.RefStudentID))
                {
                    PhoneRecordDict.Add(rec.RefStudentID, rec);
                }
            }

            List <JHAddressRecord> AddressRecordList = JHAddress.SelectByStudentIDs(StudentIDList);
            Dictionary <string, JHAddressRecord> AddressRecordDict = new Dictionary <string, JHAddressRecord>();

            foreach (JHAddressRecord rec in AddressRecordList)
            {
                if (!AddressRecordDict.ContainsKey(rec.RefStudentID))
                {
                    AddressRecordDict.Add(rec.RefStudentID, rec);
                }
            }

            AccessHelper             accHepler             = new AccessHelper();
            string                   qry                   = "ref_student_id in('" + string.Join("','", StudentIDList.ToArray()) + "')";
            List <StudentRecord_Ext> StudentRecord_ExtList = accHepler.Select <StudentRecord_Ext>(qry);
            Dictionary <string, StudentRecord_Ext> StudentRecord_ExtDict = new Dictionary <string, StudentRecord_Ext> ();

            foreach (StudentRecord_Ext rec in StudentRecord_ExtList)
            {
                if (!StudentRecord_ExtDict.ContainsKey(rec.RefStudentID))
                {
                    StudentRecord_ExtDict.Add(rec.RefStudentID, rec);
                }
            }

            // 開始處理
            List <JHStudentRecord>      updateStudentRecList        = new List <JHStudentRecord>();
            List <JHParentRecord>       updateParentRecList         = new List <JHParentRecord>();
            List <JHPhoneRecord>        updatePhoneList             = new List <JHPhoneRecord>();
            List <JHAddressRecord>      updateAddressList           = new List <JHAddressRecord>();
            List <StudentRecord_Ext>    insertStudentRecord_ExtList = new List <StudentRecord_Ext>();
            List <StudentRecord_Ext>    updateStudentRecord_ExtList = new List <StudentRecord_Ext>();
            List <JHClassRecord>        classRecAllList             = JHClass.SelectAll();
            Dictionary <string, string> classNameIDDict             = new Dictionary <string, string>();

            foreach (JHClassRecord rec in classRecAllList)
            {
                classNameIDDict.Add(rec.Name, rec.ID);
            }

            StringBuilder sbLog = new StringBuilder();

            foreach (string StudentID in RowDataDict.Keys)
            {
                RowData rd = RowDataDict[StudentID];

                if (StudentRecordDict.ContainsKey(StudentID))
                {
                    string tt = "學生系統編號:" + StudentID + ",學號:" + StudentRecordDict[StudentID].StudentNumber;
                    if (StudentRecordDict[StudentID].Class != null)
                    {
                        tt += "班級:" + StudentRecordDict[StudentID].Class.Name;
                    }

                    if (StudentRecordDict[StudentID].SeatNo.HasValue)
                    {
                        tt += "座號:" + StudentRecordDict[StudentID].SeatNo.Value;
                    }

                    sbLog.AppendLine(tt);
                    if (rd.ContainsKey("學號"))
                    {
                        string value = rd["學號"].ToString();
                        if (StudentRecordDict[StudentID].StudentNumber != value)
                        {
                            sbLog.AppendLine(string.Format("學號由「{0}」改為「{1}」", StudentRecordDict[StudentID].StudentNumber, value));
                        }
                        StudentRecordDict[StudentID].StudentNumber = value;
                    }
                    if (rd.ContainsKey("班級"))
                    {
                        string value    = rd["班級"].ToString();
                        string oldValue = "";

                        if (StudentRecordDict[StudentID].Class != null)
                        {
                            oldValue = StudentRecordDict[StudentID].Class.Name;
                        }

                        if (oldValue != value)
                        {
                            sbLog.AppendLine(string.Format("班級由「{0}」改為「{1}」", oldValue, value));
                        }

                        if (classNameIDDict.ContainsKey(value))
                        {
                            StudentRecordDict[StudentID].RefClassID = classNameIDDict[value];
                        }
                    }
                    if (rd.ContainsKey("座號"))
                    {
                        string value    = rd["座號"].ToString();
                        string oldValue = "";
                        if (StudentRecordDict[StudentID].SeatNo.HasValue)
                        {
                            oldValue = StudentRecordDict[StudentID].SeatNo.Value.ToString();
                        }

                        if (oldValue != value)
                        {
                            sbLog.AppendLine(string.Format("座號由「{0}」改為「{1}」", oldValue, value));
                        }

                        StudentRecordDict[StudentID].SeatNo = null;
                        int i;
                        if (int.TryParse(value, out i))
                        {
                            StudentRecordDict[StudentID].SeatNo = i;
                        }
                    }
                    if (rd.ContainsKey("姓名"))
                    {
                        string value = rd["姓名"].ToString();
                        if (StudentRecordDict[StudentID].Name != value)
                        {
                            sbLog.AppendLine(string.Format("姓名由「{0}」改為「{1}」", StudentRecordDict[StudentID].Name, value));
                        }

                        StudentRecordDict[StudentID].Name = value;
                    }
                    if (rd.ContainsKey("身分證號"))
                    {
                        string value = rd["身分證號"].ToString();
                        if (StudentRecordDict[StudentID].IDNumber != value)
                        {
                            sbLog.AppendLine(string.Format("身分證號由「{0}」改為「{1}」", StudentRecordDict[StudentID].IDNumber, value));
                        }

                        StudentRecordDict[StudentID].IDNumber = value;
                    }
                    if (rd.ContainsKey("國籍"))
                    {
                        string value = rd["國籍"].ToString();
                        if (StudentRecordDict[StudentID].Nationality != value)
                        {
                            sbLog.AppendLine(string.Format("國籍由「{0}」改為「{1}」", StudentRecordDict[StudentID].Nationality, value));
                        }

                        StudentRecordDict[StudentID].Nationality = value;
                    }
                    if (rd.ContainsKey("出生地"))
                    {
                        string value = rd["出生地"].ToString();
                        if (StudentRecordDict[StudentID].BirthPlace != value)
                        {
                            sbLog.AppendLine(string.Format("出生地由「{0}」改為「{1}」", StudentRecordDict[StudentID].BirthPlace, value));
                        }

                        StudentRecordDict[StudentID].BirthPlace = value;
                    }
                    if (rd.ContainsKey("生日"))
                    {
                        string value    = rd["生日"].ToString();
                        string oldValue = "";
                        if (StudentRecordDict[StudentID].Birthday.HasValue)
                        {
                            oldValue = StudentRecordDict[StudentID].Birthday.Value.ToShortDateString();
                        }

                        if (oldValue != value)
                        {
                            sbLog.AppendLine(string.Format("生日由「{0}」改為「{1}」", oldValue, value));
                        }

                        StudentRecordDict[StudentID].Birthday = null;
                        DateTime dt;
                        if (DateTime.TryParse(value, out dt))
                        {
                            StudentRecordDict[StudentID].Birthday = dt;
                        }
                    }
                    if (rd.ContainsKey("性別"))
                    {
                        string value = rd["性別"].ToString();
                        if (StudentRecordDict[StudentID].Gender != value)
                        {
                            sbLog.AppendLine(string.Format("性別由「{0}」改為「{1}」", StudentRecordDict[StudentID].Gender, value));
                        }
                        StudentRecordDict[StudentID].Gender = value;
                    }
                    if (rd.ContainsKey("英文姓名"))
                    {
                        string value = rd["英文姓名"].ToString();
                        if (StudentRecordDict[StudentID].EnglishName != value)
                        {
                            sbLog.AppendLine(string.Format("英文姓名由「{0}」改為「{1}」", StudentRecordDict[StudentID].EnglishName, value));
                        }
                        StudentRecordDict[StudentID].EnglishName = value;
                    }
                    if (rd.ContainsKey("登入帳號"))
                    {
                        string value = rd["登入帳號"].ToString();
                        if (StudentRecordDict[StudentID].SALoginName != value)
                        {
                            sbLog.AppendLine(string.Format("登入帳號由「{0}」改為「{1}」", StudentRecordDict[StudentID].SALoginName, value));
                        }
                        StudentRecordDict[StudentID].SALoginName = value;
                    }
                    if (rd.ContainsKey("狀態"))
                    {
                        string value    = rd["狀態"].ToString();
                        string oldValue = StudentRecordDict[StudentID].StatusStr;
                        if (oldValue != value)
                        {
                            sbLog.AppendLine(string.Format("狀態由「{0}」改為「{1}」", oldValue, value));
                        }

                        switch (value)
                        {
                        case "":
                        case "一般": StudentRecordDict[StudentID].Status = StudentRecord.StudentStatus.一般; break;

                        case "畢業或離校": StudentRecordDict[StudentID].Status = StudentRecord.StudentStatus.畢業或離校; break;

                        case "休學": StudentRecordDict[StudentID].Status = StudentRecord.StudentStatus.休學; break;

                        case "輟學": StudentRecordDict[StudentID].Status = StudentRecord.StudentStatus.輟學; break;

                        case "刪除": StudentRecordDict[StudentID].Status = StudentRecord.StudentStatus.刪除; break;
                        }
                    }
                }
                // 和班級走
                //if (rd.ContainsKey("年級") && StudentRecordDict.ContainsKey(StudentID)) { string value = rd["年級"].ToString(); }

                StudentRecord_Ext exRec = null;

                bool isNewExRec = false;
                if (StudentRecord_ExtDict.ContainsKey(StudentID))
                {
                    exRec = StudentRecord_ExtDict[StudentID];
                }
                else
                {
                    exRec = new StudentRecord_Ext();
                    exRec.RefStudentID = StudentID;
                    isNewExRec         = true;
                }

                if (rd.ContainsKey("英文別名"))
                {
                    string value = rd["英文別名"].ToString();
                    if (exRec.Nickname != value)
                    {
                        sbLog.AppendLine(string.Format("英文別名由「{0}」改為「{1}」", exRec.Nickname, value));
                    }
                    exRec.Nickname = value;
                }
                if (rd.ContainsKey("居留證號"))
                {
                    string value = rd["居留證號"].ToString();
                    if (exRec.PassportNumber != value)
                    {
                        sbLog.AppendLine(string.Format("居留證號由「{0}」改為「{1}」", exRec.PassportNumber, value));
                    }
                    exRec.PassportNumber = value;
                }
                if (rd.ContainsKey("GivenName"))
                {
                    string value = rd["GivenName"].ToString();
                    if (exRec.GivenName != value)
                    {
                        sbLog.AppendLine(string.Format("GivenName由「{0}」改為「{1}」", exRec.GivenName, value));
                    }

                    exRec.GivenName = value;
                }
                if (rd.ContainsKey("MiddleName"))
                {
                    string value = rd["MiddleName"].ToString();
                    if (exRec.MiddleName != value)
                    {
                        sbLog.AppendLine(string.Format("MiddleName由「{0}」改為「{1}」", exRec.MiddleName, value));
                    }

                    exRec.MiddleName = value;
                }
                if (rd.ContainsKey("FamilyName"))
                {
                    string value = rd["FamilyName"].ToString();
                    if (exRec.FamilyName != value)
                    {
                        sbLog.AppendLine(string.Format("FamilyName由「{0}」改為「{1}」", exRec.FamilyName, value));
                    }

                    exRec.FamilyName = value;
                }
                if (rd.ContainsKey("入學日期"))
                {
                    string value    = rd["入學日期"].ToString();
                    string oldValue = "";
                    if (exRec.EntranceDate.HasValue)
                    {
                        oldValue = exRec.EntranceDate.Value.ToShortDateString();
                    }
                    exRec.EntranceDate = null;
                    if (oldValue != value)
                    {
                        sbLog.AppendLine(string.Format("入學日期由「{0}」改為「{1}」", oldValue, value));
                    }

                    DateTime dt1;
                    if (DateTime.TryParse(value, out dt1))
                    {
                        exRec.EntranceDate = dt1;
                    }
                }
                if (rd.ContainsKey("畢業日期"))
                {
                    string value    = rd["畢業日期"].ToString();
                    string oldValue = "";
                    if (exRec.LeavingDate.HasValue)
                    {
                        oldValue = exRec.LeavingDate.Value.ToShortDateString();
                    }

                    if (oldValue != value)
                    {
                        sbLog.AppendLine(string.Format("畢業日期由「{0}」改為「{1}」", oldValue, value));
                    }

                    exRec.LeavingDate = null;
                    DateTime dt2;
                    if (DateTime.TryParse(value, out dt2))
                    {
                        exRec.LeavingDate = dt2;
                    }
                }


                if (isNewExRec)
                {
                    insertStudentRecord_ExtList.Add(exRec);
                }
                else
                {
                    updateStudentRecord_ExtList.Add(exRec);
                }

                if (ParentRecordDict.ContainsKey(StudentID))
                {
                    if (rd.ContainsKey("父親姓名"))
                    {
                        string value    = rd["父親姓名"].ToString();
                        string oldValue = ParentRecordDict[StudentID].Father.Name;
                        if (oldValue != value)
                        {
                            sbLog.AppendLine(string.Format("父親姓名由「{0}」改為「{1}」", oldValue, value));
                        }
                        ParentRecordDict[StudentID].Father.Name = value;
                    }
                    if (rd.ContainsKey("父親學歷"))
                    {
                        string value    = rd["父親學歷"].ToString();
                        string oldValue = ParentRecordDict[StudentID].Father.EducationDegree;
                        if (oldValue != value)
                        {
                            sbLog.AppendLine(string.Format("父親學歷由「{0}」改為「{1}」", oldValue, value));
                        }
                        ParentRecordDict[StudentID].Father.EducationDegree = value;
                    }
                    if (rd.ContainsKey("父親職業"))
                    {
                        string value    = rd["父親職業"].ToString();
                        string oldValue = ParentRecordDict[StudentID].Father.Job;
                        if (oldValue != value)
                        {
                            sbLog.AppendLine(string.Format("父親職業由「{0}」改為「{1}」", oldValue, value));
                        }
                        ParentRecordDict[StudentID].Father.Job = value;
                    }
                    if (rd.ContainsKey("父親電話"))
                    {
                        string value    = rd["父親電話"].ToString();
                        string oldValue = ParentRecordDict[StudentID].Father.Phone;
                        if (oldValue != value)
                        {
                            sbLog.AppendLine(string.Format("父親電話由「{0}」改為「{1}」", oldValue, value));
                        }

                        ParentRecordDict[StudentID].Father.Phone = value;
                    }

                    if (rd.ContainsKey("父親電子郵件"))
                    {
                        string value    = rd["父親電子郵件"].ToString();
                        string oldValue = ParentRecordDict[StudentID].Father.EMail;
                        if (oldValue != value)
                        {
                            sbLog.AppendLine(string.Format("父親電子郵件由「{0}」改為「{1}」", oldValue, value));
                        }

                        ParentRecordDict[StudentID].Father.EMail = value;
                    }


                    if (rd.ContainsKey("母親姓名"))
                    {
                        string value    = rd["母親姓名"].ToString();
                        string oldValue = ParentRecordDict[StudentID].Mother.Name;
                        if (oldValue != value)
                        {
                            sbLog.AppendLine(string.Format("母親姓名由「{0}」改為「{1}」", oldValue, value));
                        }

                        ParentRecordDict[StudentID].Mother.Name = value;
                    }
                    if (rd.ContainsKey("母親學歷"))
                    {
                        string value    = rd["母親學歷"].ToString();
                        string oldValue = ParentRecordDict[StudentID].Mother.EducationDegree;
                        if (oldValue != value)
                        {
                            sbLog.AppendLine(string.Format("母親學歷由「{0}」改為「{1}」", oldValue, value));
                        }

                        ParentRecordDict[StudentID].Mother.EducationDegree = value;
                    }
                    if (rd.ContainsKey("母親職業"))
                    {
                        string value    = rd["母親職業"].ToString();
                        string oldValue = ParentRecordDict[StudentID].Mother.Job;
                        if (oldValue != value)
                        {
                            sbLog.AppendLine(string.Format("母親職業由「{0}」改為「{1}」", oldValue, value));
                        }

                        ParentRecordDict[StudentID].Mother.Job = value;
                    }
                    if (rd.ContainsKey("母親電話"))
                    {
                        string value    = rd["母親電話"].ToString();
                        string oldValue = ParentRecordDict[StudentID].Mother.Phone;
                        if (oldValue != value)
                        {
                            sbLog.AppendLine(string.Format("母親電話由「{0}」改為「{1}」", oldValue, value));
                        }

                        ParentRecordDict[StudentID].Mother.Phone = value;
                    }

                    if (rd.ContainsKey("母親電子郵件"))
                    {
                        string value    = rd["母親電子郵件"].ToString();
                        string oldValue = ParentRecordDict[StudentID].Mother.EMail;
                        if (oldValue != value)
                        {
                            sbLog.AppendLine(string.Format("母親電子郵件由「{0}」改為「{1}」", oldValue, value));
                        }

                        ParentRecordDict[StudentID].Mother.EMail = value;
                    }


                    if (rd.ContainsKey("監護人姓名"))
                    {
                        string value    = rd["監護人姓名"].ToString();
                        string oldValue = ParentRecordDict[StudentID].Custodian.Name;
                        if (oldValue != value)
                        {
                            sbLog.AppendLine(string.Format("監護人姓名由「{0}」改為「{1}」", oldValue, value));
                        }

                        ParentRecordDict[StudentID].Custodian.Name = value;
                    }
                    if (rd.ContainsKey("監護人電話"))
                    {
                        string value    = rd["監護人電話"].ToString();
                        string oldValue = ParentRecordDict[StudentID].Custodian.Phone;
                        if (oldValue != value)
                        {
                            sbLog.AppendLine(string.Format("監護人電話由「{0}」改為「{1}」", oldValue, value));
                        }

                        ParentRecordDict[StudentID].Custodian.Phone = value;
                    }

                    if (rd.ContainsKey("監護人電子郵件"))
                    {
                        string value    = rd["監護人電子郵件"].ToString();
                        string oldValue = ParentRecordDict[StudentID].Custodian.EMail;
                        if (oldValue != value)
                        {
                            sbLog.AppendLine(string.Format("監護人電子郵件由「{0}」改為「{1}」", oldValue, value));
                        }

                        ParentRecordDict[StudentID].Custodian.EMail = value;
                    }


                    updateParentRecList.Add(ParentRecordDict[StudentID]);
                }

                if (PhoneRecordDict.ContainsKey(StudentID))
                {
                    if (rd.ContainsKey("戶籍電話"))
                    {
                        string value    = rd["戶籍電話"].ToString();
                        string oldValue = PhoneRecordDict[StudentID].Permanent;
                        if (oldValue != value)
                        {
                            sbLog.AppendLine(string.Format("戶籍電話由「{0}」改為「{1}」", oldValue, value));
                        }
                        PhoneRecordDict[StudentID].Permanent = value;
                    }
                    if (rd.ContainsKey("聯絡電話"))
                    {
                        string value    = rd["聯絡電話"].ToString();
                        string oldValue = PhoneRecordDict[StudentID].Contact;
                        if (oldValue != value)
                        {
                            sbLog.AppendLine(string.Format("聯絡電話由「{0}」改為「{1}」", oldValue, value));
                        }

                        PhoneRecordDict[StudentID].Contact = value;
                    }
                    if (rd.ContainsKey("行動電話"))
                    {
                        string value    = rd["行動電話"].ToString();
                        string oldValue = PhoneRecordDict[StudentID].Cell;
                        if (oldValue != value)
                        {
                            sbLog.AppendLine(string.Format("行動電話由「{0}」改為「{1}」", oldValue, value));
                        }

                        PhoneRecordDict[StudentID].Cell = value;
                    }
                    if (rd.ContainsKey("其它電話1"))
                    {
                        string value    = rd["其它電話1"].ToString();
                        string oldValue = PhoneRecordDict[StudentID].Phone1;
                        if (oldValue != value)
                        {
                            sbLog.AppendLine(string.Format("其它電話1由「{0}」改為「{1}」", oldValue, value));
                        }

                        PhoneRecordDict[StudentID].Phone1 = value;
                    }
                    updatePhoneList.Add(PhoneRecordDict[StudentID]);
                }

                if (AddressRecordDict.ContainsKey(StudentID))
                {
                    if (rd.ContainsKey("戶籍:郵遞區號"))
                    {
                        string value    = rd["戶籍:郵遞區號"].ToString();
                        string oldValue = AddressRecordDict[StudentID].Permanent.ZipCode;
                        if (oldValue != value)
                        {
                            sbLog.AppendLine(string.Format("戶籍:郵遞區號由「{0}」改為「{1}」", oldValue, value));
                        }
                        AddressRecordDict[StudentID].Permanent.ZipCode = value;
                    }
                    if (rd.ContainsKey("戶籍:縣市"))
                    {
                        string value    = rd["戶籍:縣市"].ToString();
                        string oldValue = AddressRecordDict[StudentID].Permanent.County;
                        if (oldValue != value)
                        {
                            sbLog.AppendLine(string.Format("戶籍:縣市由「{0}」改為「{1}」", oldValue, value));
                        }

                        AddressRecordDict[StudentID].Permanent.County = value;
                    }
                    if (rd.ContainsKey("戶籍:鄉鎮市區"))
                    {
                        string value    = rd["戶籍:鄉鎮市區"].ToString();
                        string oldValue = AddressRecordDict[StudentID].Permanent.Town;
                        if (oldValue != value)
                        {
                            sbLog.AppendLine(string.Format("戶籍:鄉鎮市區由「{0}」改為「{1}」", oldValue, value));
                        }

                        AddressRecordDict[StudentID].Permanent.Town = value;
                    }
                    if (rd.ContainsKey("戶籍:村里"))
                    {
                        string value    = rd["戶籍:村里"].ToString();
                        string oldValue = AddressRecordDict[StudentID].Permanent.District;
                        if (oldValue != value)
                        {
                            sbLog.AppendLine(string.Format("戶籍:村里由「{0}」改為「{1}」", oldValue, value));
                        }

                        AddressRecordDict[StudentID].Permanent.District = value;
                    }
                    if (rd.ContainsKey("戶籍:鄰"))
                    {
                        string value    = rd["戶籍:鄰"].ToString();
                        string oldValue = AddressRecordDict[StudentID].Permanent.Area;
                        if (oldValue != value)
                        {
                            sbLog.AppendLine(string.Format("戶籍:鄰由「{0}」改為「{1}」", oldValue, value));
                        }

                        AddressRecordDict[StudentID].Permanent.Area = value;
                    }
                    if (rd.ContainsKey("戶籍:其他"))
                    {
                        string value    = rd["戶籍:其他"].ToString();
                        string oldValue = AddressRecordDict[StudentID].Permanent.Detail;
                        if (oldValue != value)
                        {
                            sbLog.AppendLine(string.Format("戶籍:其他由「{0}」改為「{1}」", oldValue, value));
                        }

                        AddressRecordDict[StudentID].Permanent.Detail = value;
                    }
                    if (rd.ContainsKey("聯絡:郵遞區號"))
                    {
                        string value    = rd["聯絡:郵遞區號"].ToString();
                        string oldValue = AddressRecordDict[StudentID].Mailing.ZipCode;
                        if (oldValue != value)
                        {
                            sbLog.AppendLine(string.Format("聯絡:郵遞區號由「{0}」改為「{1}」", oldValue, value));
                        }

                        AddressRecordDict[StudentID].Mailing.ZipCode = value;
                    }
                    if (rd.ContainsKey("聯絡:縣市"))
                    {
                        string value    = rd["聯絡:縣市"].ToString();
                        string oldValue = AddressRecordDict[StudentID].Mailing.County;
                        if (oldValue != value)
                        {
                            sbLog.AppendLine(string.Format("聯絡:縣市由「{0}」改為「{1}」", oldValue, value));
                        }

                        AddressRecordDict[StudentID].Mailing.County = value;
                    }
                    if (rd.ContainsKey("聯絡:鄉鎮市區"))
                    {
                        string value    = rd["聯絡:鄉鎮市區"].ToString();
                        string oldValue = AddressRecordDict[StudentID].Mailing.Town;
                        if (oldValue != value)
                        {
                            sbLog.AppendLine(string.Format("聯絡:鄉鎮市區由「{0}」改為「{1}」", oldValue, value));
                        }

                        AddressRecordDict[StudentID].Mailing.Town = value;
                    }
                    if (rd.ContainsKey("聯絡:村里"))
                    {
                        string value    = rd["聯絡:村里"].ToString();
                        string oldValue = AddressRecordDict[StudentID].Mailing.District;
                        if (oldValue != value)
                        {
                            sbLog.AppendLine(string.Format("聯絡:村里由「{0}」改為「{1}」", oldValue, value));
                        }

                        AddressRecordDict[StudentID].Mailing.District = value;
                    }
                    if (rd.ContainsKey("聯絡:鄰"))
                    {
                        string value    = rd["聯絡:鄰"].ToString();
                        string oldValue = AddressRecordDict[StudentID].Mailing.Area;
                        if (oldValue != value)
                        {
                            sbLog.AppendLine(string.Format("聯絡:鄰由「{0}」改為「{1}」", oldValue, value));
                        }

                        AddressRecordDict[StudentID].Mailing.Area = value;
                    }
                    if (rd.ContainsKey("聯絡:其他"))
                    {
                        string value    = rd["聯絡:其他"].ToString();
                        string oldValue = AddressRecordDict[StudentID].Mailing.Detail;
                        if (oldValue != value)
                        {
                            sbLog.AppendLine(string.Format("聯絡:其他由「{0}」改為「{1}」", oldValue, value));
                        }

                        AddressRecordDict[StudentID].Mailing.Detail = value;
                    }
                    sbLog.AppendLine();
                    updateAddressList.Add(AddressRecordDict[StudentID]);
                }
            }

            // 處理學生資料
            foreach (string key in StudentRecordDict.Keys)
            {
                updateStudentRecList.Add(StudentRecordDict[key]);
            }

            if (updateStudentRecList.Count > 0)
            {
                JHStudent.Update(updateStudentRecList);
            }

            if (updateParentRecList.Count > 0)
            {
                JHParent.Update(updateParentRecList);
            }

            if (updatePhoneList.Count > 0)
            {
                JHPhone.Update(updatePhoneList);
            }

            if (updateAddressList.Count > 0)
            {
                JHAddress.Update(updateAddressList);
            }

            if (insertStudentRecord_ExtList.Count > 0)
            {
                insertStudentRecord_ExtList.SaveAll();
            }

            if (updateStudentRecord_ExtList.Count > 0)
            {
                updateStudentRecord_ExtList.SaveAll();
            }

            FISCA.LogAgent.ApplicationLog.Log("匯入學生基本資料(New)", "匯入", sbLog.ToString());

            // 同步
            JHSchool.Student.Instance.SyncAllBackground();
            JHSchool.Data.JHStudent.RemoveAll();
            JHSchool.Data.JHStudent.SelectAll();
        }