Ejemplo n.º 1
0
 private void txtSeatNo_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyData == Keys.Enter && txtSeatNo.Text != "")
     {
         foreach (JHClassRecord cr in JHClass.SelectAll())
         {
             if (cr.Name == txtClassName.Text)
             {
                 foreach (JHStudentRecord studRec in JHStudent.SelectAll())
                 {
                     // 只加入一般或輟學
                     if (studRec.Status == K12.Data.StudentRecord.StudentStatus.一般 || studRec.Status == K12.Data.StudentRecord.StudentStatus.輟學)
                     {
                         if (studRec.Class != null && studRec.SeatNo.HasValue)
                         {
                             if (studRec.SeatNo.Value.ToString() == txtSeatNo.Text && studRec.Class.Name == txtClassName.Text)
                             {
                                 if (!K12.Presentation.NLDPanels.Student.TempSource.Contains(studRec.ID))
                                 {
                                     List <string> ids = new List <string>();
                                     ids.Add(studRec.ID);
                                     K12.Presentation.NLDPanels.Student.AddToTemp(ids);
                                 }
                                 txtClassName.Focus();
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 2
0
        private void txtSeatNo_TextChanged(object sender, EventArgs e)
        {
            bool pass = false;

            pictureBox2.Visible = false;
            if (txtSeatNo.Text != "")
            {
                foreach (JHClassRecord cr in JHClass.SelectAll())
                {
                    if (cr.Name == txtClassName.Text)
                    {
                        foreach (JHStudentRecord studRec in JHStudent.SelectAll())
                        {
                            if (studRec.Status == K12.Data.StudentRecord.StudentStatus.一般 || studRec.Status == K12.Data.StudentRecord.StudentStatus.輟學)
                            {
                                if (studRec.Class != null && studRec.SeatNo.HasValue)
                                {
                                    if (studRec.Class.Name == txtClassName.Text && studRec.SeatNo.ToString() == txtSeatNo.Text)
                                    {
                                        pass = true;
                                    }
                                }
                            }
                        }
                    }
                }
                if (pass)
                {
                    pictureBox2.Visible = true;
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 取得全部學生的資料(只包含一般、輟學)。
        /// </summary>
        /// <returns></returns>
        public static List <ReportStudent> GetAllStudents(List <ReportStudent> printStudents)
        {
            //2019/2/25 俊緯更新 高雄國中 在校成績證明書 效能問題,原本此處抓取了全部的學生的資料,包含已畢業及離校,現在修改成只抓取在校生及使用者所選取的非在校生的資料
            List <ReportStudent> students = new List <ReportStudent>();

            foreach (JHStudentRecord each in JHStudent.SelectAll())
            {
                if (each.Status == K12.Data.StudentRecord.StudentStatus.一般 ||
                    each.Status == K12.Data.StudentRecord.StudentStatus.輟學)
                {
                    students.Add(new ReportStudent(each));
                }
                else
                {
                    foreach (ReportStudent reportStudent in printStudents)
                    {
                        if (each.ID == reportStudent.StudentID)
                        {
                            students.Add(new ReportStudent(each));
                        }
                    }
                }
            }

            return(students);
        }
Ejemplo n.º 4
0
        public MainForm(List <string> classes)
        {
            InitializeComponent();

            this.MinimumSize = this.Size;
            this.MaximumSize = this.Size;

            cbExam.DisplayMember = "Name";
            cbScore.Items.Add("定期");
            cbScore.Items.Add("平時");
            cbScore.Items.Add("定期加平時平均");
            cbScore.SelectedIndex = 0;

            cbExam.Items.Add("");
            foreach (JHExamRecord exam in JHExam.SelectAll())
            {
                cbExam.Items.Add(exam);
            }
            cbExam.SelectedIndex = 0;

            cbExam.SelectedIndexChanged += new EventHandler(cbExam_SelectedIndexChanged);

            LoadingSubject.Visible = false;
            LoadingDomain.Visible  = false;

            //準備相關學生、班級資料。
            ReportStudent.SetClassMapping(JHClass.SelectAll());
            SelectedClasses = JHClass.SelectByIDs(classes); //要列印成績單的班級清單。
            AllStudents     = JHStudent.SelectAll().ToReportStudent();
        }
Ejemplo n.º 5
0
        public static List <string> GetGradeyearStudents(int gradeYear)
        {
            List <JHStudentRecord> allstudent = JHStudent.SelectAll();

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

            foreach (JHStudentRecord each in allstudent)
            {
                if (each.Status != StudentRecord.StudentStatus.一般)
                {
                    continue;
                }

                JHClassRecord cr = each.Class;

                if (cr == null)
                {
                    continue;
                }
                if (!cr.GradeYear.HasValue)
                {
                    continue;
                }
                if (cr.GradeYear.Value != gradeYear)
                {
                    continue;
                }

                gyStudent.Add(each.ID);
            }

            return(gyStudent);
        }
Ejemplo n.º 6
0
        public MainForm(List <string> classes)
        {
            InitializeComponent();

            //準備相關學生、班級資料。
            ReportStudent.SetClassMapping(JHClass.SelectAll());
            SelectedClasses = JHClass.SelectByIDs(classes); //要列印成績單的班級清單。
            AllStudents     = JHStudent.SelectAll().ToReportStudent();
        }
        public DataRationalityMessage Execute()
        {
            CanAutoCorrectStudentIDs.Clear();
            LogBuilder = new StringBuilder();
            LogBuilder.AppendLine("學生系統編號,身分證號,學號,班級,座號,姓名,狀態,學年度,學期,異動類別,原因及事項,異動日期,轉出後學校");

            DataRationalityMessage Message = new DataRationalityMessage();

            List <JHStudentRecord> Students = JHStudent.SelectAll().Where(x => x.Status == K12.Data.StudentRecord.StudentStatus.一般).ToList();

            List <JHUpdateRecordRecord> UpdateRecords = JHUpdateRecord.SelectByStudentIDs(Students.Select(x => x.ID)).Where(x => x.UpdateCode.Equals("4")).ToList();

            StringBuilder strBuilder = new StringBuilder();

            strBuilder.AppendLine("檢查學生筆數:" + Students.Count);
            strBuilder.AppendLine("問題學生筆數:" + UpdateRecords.Count);

            if (UpdateRecords.Count > 0)
            {
                strBuilder.AppendLine("建議修正方案:");
                strBuilder.AppendLine("1.將學生加入至待處理,手動變更學生的狀態為『畢業或離校』或『刪除』。");
                strBuilder.AppendLine("2.運用本合理性檢查自動修正功能,將學生的狀態批次變更為『刪除』。");
                strBuilder.AppendLine("3.若您運用本合理性檢查自動修正功能,建議先單選1位學生進行嘗試,確認正確變更為『刪除』狀態再進行批次作業。");
            }

            var StudentUpdateRecords = UpdateRecords.Join(Students, UpdateRecord => UpdateRecord.StudentID, Student => Student.ID, (UpdateRecord, Student) =>
                                                          new
            {
                學生系統編號 = Student.ID,
                身分證號   = Student.IDNumber,
                學號     = Student.StudentNumber,
                班級     = Student.Class != null ? Student.Class.Name : string.Empty,
                座號     = K12.Data.Int.GetString(Student.SeatNo),
                姓名     = Student.Name,
                狀態     = Student.StatusStr,
                學年度    = K12.Data.Int.GetString(UpdateRecord.SchoolYear),
                學期     = K12.Data.Int.GetString(UpdateRecord.Semester),
                異動類別   = "轉出",
                原因及事項  = UpdateRecord.UpdateDescription,
                異動日期   = UpdateRecord.UpdateDate,
                轉出後學校  = UpdateRecord.ImportExportSchool,
            });

            foreach (var r in StudentUpdateRecords)
            {
                LogBuilder.AppendLine(r.學生系統編號 + "," + r.身分證號 + "," + r.學號 + "," + r.班級 + "," + r.座號 + "," + r.姓名 + "," + r.狀態 + "," + r.學年度 + "," + r.學期 + "," + r.異動類別 + "," + r.原因及事項 + "," + r.異動日期 + "," + r.轉出後學校);
            }


            Message.Data    = StudentUpdateRecords.ToList();
            Message.Message = strBuilder.ToString();

            CanAutoCorrectStudentIDs.AddRange(UpdateRecords.Select(x => x.StudentID).Distinct());

            return(Message);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 取得全部學生的資料(只包含一般、輟學)。
        /// </summary>
        /// <returns></returns>
        public static List <ReportStudent> GetAllStudents()
        {
            List <ReportStudent> students = new List <ReportStudent>();

            foreach (JHStudentRecord each in JHStudent.SelectAll())
            {
                students.Add(new ReportStudent(each));
            }

            return(students);
        }
Ejemplo n.º 9
0
        private List <JHStudentRecord> GetInSchoolStudents()
        {
            List <JHStudentRecord> list = new List <JHStudentRecord>();

            foreach (JHStudentRecord student in JHStudent.SelectAll())
            {
                if (student.Status == StudentRecord.StudentStatus.一般 ||
                    student.Status == StudentRecord.StudentStatus.輟學)
                {
                    list.Add(student);
                }
            }
            return(list);
        }
Ejemplo n.º 10
0
 private void txtStudentNumber_TextChanged(object sender, EventArgs e)
 {
     pictureBox3.Visible = false;
     if (txtStudentNumber.Text != "")
     {
         foreach (JHStudentRecord studRec in JHStudent.SelectAll())
         {
             if (studRec.StudentNumber == txtStudentNumber.Text)
             {
                 pictureBox3.Visible = true;
             }
         }
     }
 }
Ejemplo n.º 11
0
        /// <summary>
        /// 取得全部學生的資料(只包含一般、輟學)。
        /// </summary>
        /// <returns></returns>
        public static List <ReportStudent> GetAllStudents()
        {
            List <ReportStudent> students = new List <ReportStudent>();

            foreach (JHStudentRecord each in JHStudent.SelectAll())
            {
                if (each.Status == K12.Data.StudentRecord.StudentStatus.一般 ||
                    each.Status == K12.Data.StudentRecord.StudentStatus.輟學)
                {
                    students.Add(new ReportStudent(each));
                }
            }
            return(students);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// 重新載入學生,當不排名類別設定後,學生可以即時反應
        /// </summary>
        private void ReloadAllStudent()
        {
            // 不列入排名學生ID
            Utility.notRankStudentIDList.Clear();
            AllStudents.Clear();

            if (Perference.NotRankTag != null)
            {
                if (!string.IsNullOrEmpty(Perference.NotRankTag))
                {
                    Utility.notRankStudentIDList = Utility.GetNotRankStudentIDList(Perference.NotRankTag);
                }
            }

            AllStudents = JHStudent.SelectAll().ToReportStudent(Utility.notRankStudentIDList);
        }
Ejemplo n.º 13
0
        /// <summary>
        /// 取得一般或輟學學生(有班級與年級)
        /// </summary>
        /// <returns></returns>
        public static List <JHStudentRecord> GetJHStudentRecordListBy1()
        {
            List <JHStudentRecord> studRecList = new List <JHStudentRecord>();

            foreach (JHStudentRecord studRec in JHStudent.SelectAll())
            {
                if (studRec.Status == K12.Data.StudentRecord.StudentStatus.一般 || studRec.Status == K12.Data.StudentRecord.StudentStatus.輟學)
                {
                    if (studRec.Class != null)
                    {
                        if (studRec.Class.GradeYear.HasValue)
                        {
                            studRecList.Add(studRec);
                        }
                    }
                }
            }
            return(studRecList);
        }
Ejemplo n.º 14
0
        private void Initialize()
        {
            _loader                     = new BackgroundWorker();
            _loader.DoWork             += new DoWorkEventHandler(_loader_DoWork);
            _loader.RunWorkerCompleted += new RunWorkerCompletedEventHandler(_loader_RunWorkerCompleted);

            // 設定日期預設值今天
            dtEnd.Value = dtStart.Value = DateTime.Now;

            foreach (JHStudentRecord var in JHStudent.SelectAll())
            {
                // 過濾刪除學生
                if (var.Status == K12.Data.StudentRecord.StudentStatus.刪除)
                {
                    continue;
                }

                students.Add(var.ID, var);
            }
        }
Ejemplo n.º 15
0
 private void txtStudentNumber_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyData == Keys.Enter && txtStudentNumber.Text != "")
     {
         foreach (JHStudentRecord studRec in JHStudent.SelectAll())
         {
             if (studRec.StudentNumber == txtStudentNumber.Text)
             {
                 if (!K12.Presentation.NLDPanels.Student.TempSource.Contains(studRec.ID))
                 {
                     List <string> ids = new List <string>();
                     // 只加入一般或輟學
                     if (studRec.Status == K12.Data.StudentRecord.StudentStatus.一般 || studRec.Status == K12.Data.StudentRecord.StudentStatus.輟學)
                     {
                         ids.Add(studRec.ID);
                         K12.Presentation.NLDPanels.Student.AddToTemp(ids);
                     }
                 }
                 txtStudentNumber.SelectAll();
             }
         }
     }
 }
Ejemplo n.º 16
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();
        }
        public DataRationalityMessage Execute()
        {
            RATRecords.Clear();

            DataRationalityMessage Message = new DataRationalityMessage();

            int UpdateRecordCount = 0;

            //取得學生資料及建立資料物件
            foreach (JHStudentRecord student in JHStudent.SelectAll())
            {
                if (!Dic.ContainsKey(student.ID))
                {
                    Dic.Add(student.ID, new SuperObj_new(student));
                }
            }

            foreach (JHUpdateRecordRecord each in JHUpdateRecord.SelectByStudentIDs(Dic.Keys))
            {
                if (each.UpdateCode == "3")              //轉入異動代碼為"3"
                {
                    if (Dic.ContainsKey(each.StudentID)) //包含於清單內
                    {
                        Dic.Remove(each.StudentID);      //將其移除
                        UpdateRecordCount++;
                    }
                }
            }

            //取得所有懲戒明細,並加入學生資料物件內
            foreach (JHDemeritRecord demerit in JHDemerit.SelectAll())
            {
                if (Dic.ContainsKey(demerit.RefStudentID))
                {
                    Dic[demerit.RefStudentID].DemeritList.Add(demerit);
                }
            }

            //取得(971,972,981,982)自動統計,排除目前學年度/學期
            List <SchoolYearSemester> SysList = new List <SchoolYearSemester>();

            SysList.Add(new SchoolYearSemester(97, 1));
            SysList.Add(new SchoolYearSemester(97, 2));
            SysList.Add(new SchoolYearSemester(98, 1));
            SysList.Add(new SchoolYearSemester(98, 2));
            SysList.Add(new SchoolYearSemester(99, 1));
            SysList.Add(new SchoolYearSemester(99, 2));
            List <AutoSummaryRecord> AutoSummaryList = AutoSummary.Select(Dic.Keys, SysList, SummaryType.Discipline, true);

            foreach (AutoSummaryRecord autoSummary in AutoSummaryList)
            {
                if (!Dic[autoSummary.RefStudentID].AutoSummaryDic.Contains(autoSummary))
                {
                    Dic[autoSummary.RefStudentID].AutoSummaryDic.Add(autoSummary);
                }
            }


            foreach (string each in Dic.Keys)
            {
                //if (Dic[each].IsCleadDmmerit())
                //{
                if (Dic[each].DetailAndSummary(97, 1))
                {
                    SetValue(Dic[each], 97, 1);
                }
                if (Dic[each].DetailAndSummary(97, 2))
                {
                    SetValue(Dic[each], 97, 2);
                }
                if (Dic[each].DetailAndSummary(98, 1))
                {
                    SetValue(Dic[each], 98, 1);
                }
                if (Dic[each].DetailAndSummary(98, 2))
                {
                    SetValue(Dic[each], 98, 2);
                }
                if (Dic[each].DetailAndSummary(99, 1))
                {
                    SetValue(Dic[each], 99, 1);
                }
                if (Dic[each].DetailAndSummary(99, 2))
                {
                    SetValue(Dic[each], 99, 2);
                }
                //}
            }

            //錯誤說明
            StringBuilder strBuilder = new StringBuilder();

            strBuilder.AppendLine("檢查(非明細統計)筆數:" + AutoSummaryList.Count());
            strBuilder.AppendLine("檢查(非明細統計)不為0筆數:" + RATRecords.Count);
            strBuilder.AppendLine("具有(轉入異動)記錄之學生共" + UpdateRecordCount + "名,未列入檢查範圍!");
            strBuilder.AppendLine("(非明細定義於:僅轉入生可以有值)");

            var SortedRATRecords = from RATRecord in RATRecords orderby RATRecord.班級, K12.Data.Int.ParseAllowNull(RATRecord.座號), RATRecord.學年度, RATRecord.學期 select RATRecord;

            Message.Data    = SortedRATRecords.ToList();
            Message.Message = strBuilder.ToString();

            if (RATRecords.Count == 0)
            {
                MsgBox.Show("未檢查到錯誤資料!!");
            }

            return(Message);
        }
Ejemplo n.º 18
0
        protected override void OnSaveButtonClick(EventArgs e)
        {
            DateTime dt;

            //入學日期檢查
            if (!string.IsNullOrEmpty(txtEntranceDate.Text))
            {
                if (DateTime.TryParse(txtEntranceDate.Text, out dt))
                {
                    _errors.SetError(txtEntranceDate, string.Empty);
                }
                else
                {
                    _errors.SetError(txtEntranceDate, "入學日期錯誤,請確認資料。");
                    return;
                }
            }

            //離校日期檢查
            if (!string.IsNullOrEmpty(txtLeavingDate.Text))
            {
                if (DateTime.TryParse(txtLeavingDate.Text, out dt))
                {
                    _errors.SetError(txtLeavingDate, string.Empty);
                }
                else
                {
                    _errors.SetError(txtLeavingDate, "離校日期錯誤,請確認資料。");
                    return;
                }
            }

            SetFormDataToDALRec();

            // 檢查生日


            // 檢查性別
            List <string> checkGender = new List <string>();

            checkGender.Add("男");
            checkGender.Add("");
            checkGender.Add("女");

            if (!checkGender.Contains(cboGender.Text))
            {
                _errors.SetError(cboGender, "性別錯誤,請確認資料。");
                return;
            }

            //DateTime dt;

            if (!string.IsNullOrEmpty(txtBirthDate.Text))
            {
                if (!DateTime.TryParse(txtBirthDate.Text, out dt))
                {
                    _errors.SetError(txtBirthDate, "日期錯誤,請確認資料。");
                    return;
                }
            }
            else
            {
                _StudRec.Birthday = null;
            }

            List <string> checkID  = new List <string>();
            List <string> checkSSN = new List <string>();


            foreach (JHStudentRecord studRec in JHStudent.SelectAll())
            {
                checkID.Add(studRec.SALoginName);
                checkSSN.Add(studRec.IDNumber);
            }
            if (!string.IsNullOrEmpty(_StudRec.SALoginName))
            {
                if (checkID.Contains(_StudRec.SALoginName))
                {
                    if (_defaultLoginID != _StudRec.SALoginName)
                    {
                        _errors.SetError(txtLoginID, "學生登入帳號重覆,請確認資料。");
                        return;
                    }
                }
            }
            if (!string.IsNullOrEmpty(_StudRec.IDNumber))
            {
                if (checkSSN.Contains(_StudRec.IDNumber))
                {
                    if (_defaultIDNumber != _StudRec.IDNumber)
                    {
                        _errors.SetError(txtSSN, "身分證號重覆,請確認資料。");
                        return;
                    }
                }
            }

            //儲存延伸資料
            List <StudentRecord_Ext> list = new List <StudentRecord_Ext>();

            list.Add(_StudRec_Ext);
            if (!string.IsNullOrEmpty(_StudRec_Ext.UID))
            {
                tool._A.UpdateValues(list);
            }
            else
            {
                tool._A.InsertValues(list);
            }

            UpdateUDTData();

            eh(null, EventArgs.Empty);


            JHStudent.Update(_StudRec);
            SetAfterEditLog();
            JHSchool.Student.Instance.SyncDataBackground(PrimaryKey);
            _errors.Clear();
            //BindDataToForm();
        }
        public DataRationalityMessage Execute()
        {
            RATRecs.Clear();

            // 沒成績
            List <CheckStudentSemHistoryScoreRATRec> noScore = new List <CheckStudentSemHistoryScoreRATRec>();
            // 沒學期歷程
            List <CheckStudentSemHistoryScoreRATRec> noHistory = new List <CheckStudentSemHistoryScoreRATRec>();

            // Query: 取得學生有學期成績的學年度、學期
            QueryHelper Helper  = new QueryHelper();
            string      strSQL  = "select ref_student_id,school_year,semester from sems_subj_score where score_info like '%成績%' order by ref_student_id,school_year,semester";
            DataTable   dtScore = Helper.Select(strSQL);
            Dictionary <string, List <string> > studScoreScDict   = new Dictionary <string, List <string> >();
            Dictionary <string, List <string> > studHistoryScDict = new Dictionary <string, List <string> >();

            foreach (DataRow d in dtScore.Rows)
            {
                string ID  = d[0].ToString();
                string val = d[1].ToString() + "," + d[2].ToString();

                if (studScoreScDict.ContainsKey(ID))
                {
                    studScoreScDict[ID].Add(val);
                }
                else
                {
                    List <string> strList = new List <string>();
                    strList.Add(val);
                    studScoreScDict.Add(ID, strList);
                }
            }

            // 取得所有學生
            List <JHStudentRecord> studRecList = JHStudent.SelectAll();

            // 取得學生學習歷程
            Dictionary <string, List <K12.Data.SemesterHistoryItem> > SHistoryDict = new Dictionary <string, List <K12.Data.SemesterHistoryItem> >();

            foreach (JHSemesterHistoryRecord rec in JHSemesterHistory.SelectAll())
            {
                foreach (K12.Data.SemesterHistoryItem shi in rec.SemesterHistoryItems)
                {
                    string val = shi.SchoolYear.ToString() + "," + shi.Semester.ToString();
                    if (studHistoryScDict.ContainsKey(shi.RefStudentID))
                    {
                        studHistoryScDict[shi.RefStudentID].Add(val);
                    }
                    else
                    {
                        List <string> strList = new List <string>();
                        strList.Add(val);
                        studHistoryScDict.Add(shi.RefStudentID, strList);
                    }
                }
            }


            DataRationalityMessage retMsg = new DataRationalityMessage();

            try
            {
                foreach (JHStudentRecord studRec in studRecList)
                {
                    // 依學期歷程為主
                    if (studHistoryScDict.ContainsKey(studRec.ID))
                    {
                        if (studScoreScDict.ContainsKey(studRec.ID))
                        {
                            foreach (string str in studHistoryScDict[studRec.ID])
                            {
                                if (!studScoreScDict[studRec.ID].Contains(str))
                                {
                                    CheckStudentSemHistoryScoreRATRec rec1 = new CheckStudentSemHistoryScoreRATRec();
                                    rec1.身分證號 = studRec.IDNumber;
                                    rec1.姓名   = studRec.Name;
                                    rec1.狀態   = studRec.StatusStr;
                                    if (studRec.SeatNo.HasValue)
                                    {
                                        rec1.座號 = studRec.SeatNo.Value.ToString();
                                    }
                                    if (studRec.Class != null)
                                    {
                                        rec1.班級 = studRec.Class.Name;
                                    }
                                    rec1.說明     = "有學期歷程沒有成績";
                                    rec1.學生系統編號 = studRec.ID;
                                    rec1.學號     = studRec.StudentNumber;
                                    string[] ss = str.Split(',').ToArray();
                                    if (ss.Length > 1)
                                    {
                                        rec1.學年度 = ss[0];
                                        rec1.學期  = ss[1];
                                    }
                                    noScore.Add(rec1);
                                }
                            }
                        }
                    }


                    // 依學期成績為主
                    if (studScoreScDict.ContainsKey(studRec.ID))
                    {
                        if (studHistoryScDict.ContainsKey(studRec.ID))
                        {
                            foreach (string str in studScoreScDict[studRec.ID])
                            {
                                if (!studHistoryScDict[studRec.ID].Contains(str))
                                {
                                    CheckStudentSemHistoryScoreRATRec rec1 = new CheckStudentSemHistoryScoreRATRec();
                                    rec1.身分證號 = studRec.IDNumber;
                                    rec1.姓名   = studRec.Name;
                                    rec1.狀態   = studRec.StatusStr;
                                    if (studRec.SeatNo.HasValue)
                                    {
                                        rec1.座號 = studRec.SeatNo.Value.ToString();
                                    }
                                    if (studRec.Class != null)
                                    {
                                        rec1.班級 = studRec.Class.Name;
                                    }
                                    rec1.說明     = "沒有學期歷程有成績";
                                    rec1.學生系統編號 = studRec.ID;
                                    rec1.學號     = studRec.StudentNumber;
                                    string[] ss = str.Split(',').ToArray();
                                    if (ss.Length > 1)
                                    {
                                        rec1.學年度 = ss[0];
                                        rec1.學期  = ss[1];
                                    }
                                    noHistory.Add(rec1);
                                }
                            }
                        }
                    }
                }
                RATRecs.AddRange(noHistory);
                RATRecs.AddRange(noScore);
                int no;
                var sortedRATRecs = from rec in RATRecs orderby rec.狀態, rec.班級, int.TryParse(rec.座號, out no), rec.學年度, rec.學期 select rec;
                retMsg.Message = "有學期歷程沒有成績共" + noScore.Count + "筆,沒有學期歷程有成績共" + noHistory.Count + "筆。";
                retMsg.Data    = sortedRATRecs.ToList();
            }
            catch (Exception ex)
            {
                retMsg.Message = ex.Message;
                return(retMsg);
            }

            return(retMsg);
        }
        public void ExecuteAutoCorrect(IEnumerable <string> EntityIDs)
        {
            if (!K12.Data.Utility.Utility.IsNullOrEmpty(CanAutoCorrectStudentIDs))
            {
                if (MsgBox.Show("自動修正將依照檢查結果學其狀態變更為『刪除』,強烈建議您務必將檢查結果匯出備份;是否進行自動修正?", "您是否要進行自動修正?", System.Windows.Forms.MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
                {
                    try
                    {
                        //取得要變更為『刪除』狀態的學生編號
                        List <string> AutoCorrectStudentIDs = K12.Data.Utility.Utility.IsNullOrEmpty(EntityIDs) ? CanAutoCorrectStudentIDs : EntityIDs.ToList();

                        //取得所有學生資料
                        List <JHStudentRecord> AllStudent = JHStudent.SelectAll();

                        //取得要變更為『刪除』狀態的學生
                        List <JHStudentRecord> Students = AllStudent.Where(x => AutoCorrectStudentIDs.Contains(x.ID)).ToList();

                        //取得『刪除』狀態的學生
                        List <JHStudentRecord> DeleteStudents = AllStudent.Where(x => x.Status == K12.Data.StudentRecord.StudentStatus.刪除).ToList();

                        #region 檢查『學號』在一般及刪除狀態重覆
                        List <string> RepeatStudentNumber = DeleteStudents.Select(x => x.StudentNumber).Intersect(Students.Select(x => x.StudentNumber)).ToList();

                        if (RepeatStudentNumber.Count > 0)
                        {
                            MsgBox.Show("以下學號" + string.Join(",", RepeatStudentNumber.ToArray()) + "在『一般』及『刪除』狀態重覆,無法變更狀態!");
                            return;
                        }
                        #endregion

                        #region 檢查『身分證號』在一般及刪除狀態重覆
                        List <string> RepeatIDNumber = DeleteStudents.Select(x => x.IDNumber).Intersect(Students.Select(x => x.IDNumber)).ToList();

                        if (RepeatIDNumber.Count > 0)
                        {
                            MsgBox.Show("以下身分證號" + string.Join(",", RepeatIDNumber.ToArray()) + "在『一般』及『刪除』狀態重覆,無法變更狀態!");
                            return;
                        }
                        #endregion

                        #region 檢查『登入帳號』在一般及刪除狀態重覆
                        List <string> RepeatLoginName = DeleteStudents.Select(x => x.SALoginName).Intersect(Students.Select(x => x.SALoginName)).ToList();

                        if (RepeatLoginName.Count > 0)
                        {
                            MsgBox.Show("以下登入帳號" + string.Join(",", RepeatLoginName.ToArray()) + "在『一般』及『刪除』狀態重覆,無法變更狀態!");
                            return;
                        }
                        #endregion

                        Students.ForEach(x => x.Status = K12.Data.StudentRecord.StudentStatus.刪除);

                        int SuccessCount = JHStudent.Update(Students);

                        FISCA.LogAgent.ApplicationLog.Log("資料合理性檢查.一般生轉出異動記錄檢查", "將一般生有轉出異動記錄學生狀態改為『刪除』", LogBuilder.ToString());
                    }
                    catch (Exception e)
                    {
                        SmartSchool.ErrorReporting.ReportingService.ReportException(e);

                        MsgBox.Show(e.Message);
                    }

                    MsgBox.Show("已自動修正完成!");
                }
            }
        }
Ejemplo n.º 21
0
        protected override void OnSaveButtonClick(EventArgs e)
        {
            SetFormDataToDALRec();

            // 檢查生日


            // 檢查性別
            List <string> checkGender = new List <string>();

            checkGender.Add("男");
            checkGender.Add("");
            checkGender.Add("女");

            if (!checkGender.Contains(cboGender.Text))
            {
                _errors.SetError(cboGender, "性別錯誤,請確認資料。");
                return;
            }

            DateTime dt;

            if (!string.IsNullOrEmpty(txtBirthDate.Text))
            {
                if (!DateTime.TryParse(txtBirthDate.Text, out dt))
                {
                    _errors.SetError(txtBirthDate, "日期錯誤,請確認資料。");
                    return;
                }
            }
            else
            {
                _StudRec.Birthday = null;
            }

            List <string> checkID  = new List <string>();
            List <string> checkSSN = new List <string>();


            foreach (JHStudentRecord studRec in JHStudent.SelectAll())
            {
                checkID.Add(studRec.SALoginName);
                checkSSN.Add(studRec.IDNumber);
            }
            if (!string.IsNullOrEmpty(_StudRec.SALoginName))
            {
                if (checkID.Contains(_StudRec.SALoginName))
                {
                    if (_defaultLoginID != _StudRec.SALoginName)
                    {
                        _errors.SetError(txtLoginID, "學生登入帳號重覆,請確認資料。");
                        return;
                    }
                }
            }
            if (!string.IsNullOrEmpty(_StudRec.IDNumber))
            {
                if (checkSSN.Contains(_StudRec.IDNumber))
                {
                    if (_defaultIDNumber != _StudRec.IDNumber)
                    {
                        _errors.SetError(txtSSN, "身分證號重覆,請確認資料。");
                        return;
                    }
                }
            }

            JHStudent.Update(_StudRec);
            SetAfterEditLog();
            Student.Instance.SyncDataBackground(PrimaryKey);
            _errors.Clear();
            //BindDataToForm();
        }
        public Mention_To_Start()
        {
            InitializeComponent();

            // 選擇全部的學生
            List <JHStudentRecord> allstudent = JHStudent.SelectAll();

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

            foreach (JHStudentRecord each in allstudent)
            {
                if (each.Status == 0 && each.Class != null)
                {
                    gyStudent.Add(each.ID);
                }
            }


            StudentIDs = gyStudent;

            // 取得該學校當學年
            _schoolYear = Int32.Parse(K12.Data.School.DefaultSchoolYear);

            //取得該學校當學期 (本程式目前未用到,因為是算學年領域成績)
            _semester = Int32.Parse(K12.Data.School.DefaultSemester);

            StudentList = K12.Data.Student.SelectByIDs(StudentIDs);

            _BW = new BackgroundWorker();

            //  加入所有的領域名稱 (高雄地區國中為九大領域)
            //DomainList.Add("國語文");
            //DomainList.Add("英語");
            DomainList.Add("語文");
            DomainList.Add("數學");
            DomainList.Add("社會");
            DomainList.Add("自然與生活科技");
            DomainList.Add("藝術與人文");
            DomainList.Add("健康與體育");
            DomainList.Add("綜合活動");


            //加入 所有的領域名稱,作為分開各年級數各領域不及格人數用,目前報表輸出,已將國語文、英語合併為"語文"一領域,故註解掉

            //TotalDomainFailCountBook_Grade1.Add("國語文", Chinese_DomainScore_FailedCount);
            //TotalDomainFailCountBook_Grade1.Add("英語", English_DomainScore_FailedCount);
            TotalDomainFailCountBook_Grade1.Add("數學", Math_DomainScore_FailedCount);
            TotalDomainFailCountBook_Grade1.Add("社會", Social_DomainScore_FailedCount);
            TotalDomainFailCountBook_Grade1.Add("自然與生活科技", Nature_Tech_DomainScore_FailedCount);
            TotalDomainFailCountBook_Grade1.Add("藝術與人文", Art_Humanity_DomainScore_FailedCount);
            TotalDomainFailCountBook_Grade1.Add("健康與體育", Hygiene_PE_DomainScore_FailedCount);
            TotalDomainFailCountBook_Grade1.Add("綜合活動", Integrated_Activities_Domain_FailedCount);
            TotalDomainFailCountBook_Grade1.Add("語文", Language_DomainScore_FailedCount);

            //TotalDomainFailCountBook_Grade2.Add("國語文", Chinese_DomainScore_FailedCount);
            //TotalDomainFailCountBook_Grade2.Add("英語", English_DomainScore_FailedCount);
            TotalDomainFailCountBook_Grade2.Add("數學", Math_DomainScore_FailedCount);
            TotalDomainFailCountBook_Grade2.Add("社會", Social_DomainScore_FailedCount);
            TotalDomainFailCountBook_Grade2.Add("自然與生活科技", Nature_Tech_DomainScore_FailedCount);
            TotalDomainFailCountBook_Grade2.Add("藝術與人文", Art_Humanity_DomainScore_FailedCount);
            TotalDomainFailCountBook_Grade2.Add("健康與體育", Hygiene_PE_DomainScore_FailedCount);
            TotalDomainFailCountBook_Grade2.Add("綜合活動", Integrated_Activities_Domain_FailedCount);
            TotalDomainFailCountBook_Grade2.Add("語文", Language_DomainScore_FailedCount);

            //TotalDomainFailCountBook_Grade3.Add("國語文", Chinese_DomainScore_FailedCount);
            //TotalDomainFailCountBook_Grade3.Add("英語", English_DomainScore_FailedCount);
            TotalDomainFailCountBook_Grade3.Add("數學", Math_DomainScore_FailedCount);
            TotalDomainFailCountBook_Grade3.Add("社會", Social_DomainScore_FailedCount);
            TotalDomainFailCountBook_Grade3.Add("自然與生活科技", Nature_Tech_DomainScore_FailedCount);
            TotalDomainFailCountBook_Grade3.Add("藝術與人文", Art_Humanity_DomainScore_FailedCount);
            TotalDomainFailCountBook_Grade3.Add("健康與體育", Hygiene_PE_DomainScore_FailedCount);
            TotalDomainFailCountBook_Grade3.Add("綜合活動", Integrated_Activities_Domain_FailedCount);
            TotalDomainFailCountBook_Grade3.Add("語文", Language_DomainScore_FailedCount);

            //每個年級 人數統計
            EachGradeStudentCount.Add("Grade1", Grade1StudentNumber);
            EachGradeStudentCount.Add("Grade2", Grade2StudentNumber);
            EachGradeStudentCount.Add("Grade3", Grade3StudentNumber);

            //每個年級 有補考紀錄的人數統計
            EachGradeMakeUpStudentCount.Add("Grade1", 0);
            EachGradeMakeUpStudentCount.Add("Grade2", 0);
            EachGradeMakeUpStudentCount.Add("Grade3", 0);

            //每個年級 有補考紀錄、且最終學年成績平均及格(>60分) 的人數統計
            EachGradeMakeUpStudentCount_sucessful.Add("Grade1", 0);
            EachGradeMakeUpStudentCount_sucessful.Add("Grade2", 0);
            EachGradeMakeUpStudentCount_sucessful.Add("Grade3", 0);

            foreach (var sr in StudentList)
            {
                //整理一年級不及格領域累積次數
                if (sr.Class != null && (sr.Class.GradeYear == 1 || sr.Class.GradeYear == 7))
                {
                    EachGradeStudentAccumulatedFailCount_Grade1.Add(sr.ID, 0);
                }

                //整理二年級不及格領域累積次數
                if (sr.Class != null && (sr.Class.GradeYear == 2 || sr.Class.GradeYear == 8))
                {
                    EachGradeStudentAccumulatedFailCount_Grade2.Add(sr.ID, 0);
                }

                //整理三年級不及格領域累積次數
                if (sr.Class != null && (sr.Class.GradeYear == 2 || sr.Class.GradeYear == 9))
                {
                    EachGradeStudentAccumulatedFailCount_Grade3.Add(sr.ID, 0);
                }
            }
        }
Ejemplo n.º 23
0
        /// <summary>
        /// 傳入不包含學生的學生IDList,取得一般或輟學學生
        /// </summary>
        /// <param name="NotInStudentIDList"></param>
        /// <returns></returns>
        public static List <ReportStudent> GetStudentsDef(List <string> NotInStudentIDList)
        {
            List <string> StudentIDList = new List <string>();

            List <ReportStudent> students = new List <ReportStudent>();

            foreach (JHStudentRecord each in JHStudent.SelectAll())
            {
                // 不包含
                if (NotInStudentIDList.Contains(each.ID))
                {
                    continue;
                }

                if (each.Status == K12.Data.StudentRecord.StudentStatus.一般 ||
                    each.Status == K12.Data.StudentRecord.StudentStatus.輟學)
                {
                    ReportStudent rs = new ReportStudent(each);
                    students.Add(rs);
                    StudentIDList.Add(each.ID);
                }
            }

            // 取得學生類別List
            List <StudentTagRecord> StudTagRecList = StudentTag.SelectByStudentIDs(StudentIDList);


            // 取得特種身分學生,加分比
            Dictionary <string, decimal> StudAddWeightDict = DAL.DALTransfer.GetStudentAddWeightFormUDTByStudentTag(StudTagRecList, DAL.DALTransfer._SchoolType);
            // 取得特種身分學生名稱
            Dictionary <string, string> StudSpecTypeDict = DAL.DALTransfer.GetStudentSpcTypeFormUDTByStudentTag(StudTagRecList, DAL.DALTransfer._SchoolType);
            Dictionary <string, K12.Data.UpdateRecordRecord> studUpdateRec = DAL.DALTransfer.GetStudentUpdareDate3ByStudentID(StudentIDList);

            foreach (ReportStudent rs in students)
            {
                // 加分比
                if (StudAddWeightDict.ContainsKey(rs.StudentID))
                {
                    rs.AddWeight = StudAddWeightDict[rs.StudentID];
                }

                // 學生身分
                if (StudSpecTypeDict.ContainsKey(rs.StudentID))
                {
                    rs.SpcStudTypeName = StudSpecTypeDict[rs.StudentID];
                }

                // 轉入學生異動
                if (studUpdateRec.ContainsKey(rs.StudentID))
                {
                    if (studUpdateRec[rs.StudentID] != null)
                    {
                        DateTime dt;

                        if (DateTime.TryParse(studUpdateRec[rs.StudentID].UpdateDate, out dt))
                        {
                            rs.TransUpdateDateStr = (dt.Year - 1911).ToString() + "/" + dt.Month + "/" + dt.Day;
                        }
                        else
                        {
                            rs.TransUpdateDateStr = "";
                        }

                        rs.LastEnterSchoolyear = studUpdateRec[rs.StudentID].SchoolYear;
                        rs.LastEnterSemester   = studUpdateRec[rs.StudentID].Semester;
                        int gr;
                        if (int.TryParse(studUpdateRec[rs.StudentID].GradeYear, out gr))
                        {
                            rs.LastEnterGradeYear = gr;
                        }
                    }
                }
            }
            return(students);
        }