Пример #1
0
        private void SetLog()
        {
            sbLog = new StringBuilder();
            Dictionary <string, SHSCETakeRecord> delDic = new Dictionary <string, SHSCETakeRecord>();

            foreach (SHSCETakeRecord sce in _deleteScoreList)
            {
                if (!delDic.ContainsKey(sce.RefStudentID + "_" + sce.RefCourseID))
                {
                    delDic.Add(sce.RefStudentID + "_" + sce.RefCourseID, sce);
                }
            }

            foreach (SHSCETakeRecord sce in _addScoreList)
            {
                SHStudentRecord student = SHStudent.SelectByID(sce.RefStudentID);
                SHCourseRecord  course  = SHCourse.SelectByID(sce.RefCourseID);
                string          exam    = (examDict.ContainsKey(sce.RefExamID) ? examDict[sce.RefExamID] : "<未知的試別>");

                if (delDic.ContainsKey(sce.RefStudentID + "_" + sce.RefCourseID))
                {
                    string classname = student.Class != null ? student.Class.Name : "";
                    string seatno    = student.SeatNo.HasValue ? student.SeatNo.Value.ToString() : "";
                    sbLog.AppendLine(string.Format("班級「{0}」座號「{1}」姓名「{2}」在試別「{3}」課程「{4}」將成績「{5}」修改為「{6}」。", classname, seatno, student.Name, course.Name, exam, delDic[sce.RefStudentID + "_" + sce.RefCourseID].Score, sce.Score));
                }
                else
                {
                    string classname = student.Class != null ? student.Class.Name : "";
                    string seatno    = student.SeatNo.HasValue ? student.SeatNo.Value.ToString() : "";
                    sbLog.AppendLine(string.Format("班級「{0}」座號「{1}」姓名「{2}」在「{3}」課程「{4}」新增成績「{5}」。", classname, seatno, student.Name, course.Name, exam, sce.Score));
                }
            }

            FISCA.LogAgent.ApplicationLog.Log("讀卡系統", "評量成績", sbLog.ToString());
        }
Пример #2
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            // 初始化資料
            SHUpdateRecordRecord updateRec = new SHUpdateRecordRecord();
            // 取得學生ID
            // 先清DAL Cache
            List <string> rmIDs = new List <string> ();

            rmIDs.Add(PrimaryKey);
            SHStudent.RemoveByIDs(rmIDs);
            SHStudentRecord studRec = SHStudent.SelectByID(PrimaryKey);

            // 取得最後一筆異動資料,備查使用。
            List <SHUpdateRecordRecord> UpdList = (from rec in SHUpdateRecord.SelectByStudentID(PrimaryKey) where rec.ID != updateRec.ID && rec.ADDate.Trim() != "" orderby DateTime.Parse(rec.ADDate) descending, int.Parse(rec.ID) descending select rec).ToList();

            if (UpdList.Count > 0)
            {
                updateRec.LastADDate     = UpdList[0].ADDate;
                updateRec.LastADNumber   = UpdList[0].ADNumber;
                updateRec.LastUpdateCode = UpdList[0].UpdateCode;
            }

            updateRec.StudentID     = studRec.ID;
            updateRec.StudentNumber = studRec.StudentNumber;
            updateRec.StudentName   = studRec.Name;
            updateRec.IDNumber      = studRec.IDNumber;
            if (studRec.Birthday.HasValue)
            {
                updateRec.Birthdate = studRec.Birthday.Value.ToShortDateString();
            }
            updateRec.Gender = studRec.Gender;
            if (studRec.Department != null)
            {
                updateRec.Department = studRec.Department.FullName;
            }

            // 取得學生學籍特殊身分代碼
            updateRec.SpecialStatus = DAL.DALTransfer.GetSpecialCode(studRec.ID);

            updateRec.UpdateDate = DateTime.Now.ToShortDateString();
            if (updateRec == null)
            {
                return;
            }
            UpdateRecordItemForm form = new UpdateRecordItemForm(UpdateRecordItemForm.actMode.新增, updateRec, PrimaryKey);

            form.ShowDialog();
        }
Пример #3
0
        // 載入系統預設學年度學期
        private void SetDefaultSchoolYearSemester()
        {
            int sy, sm;

            if (int.TryParse(K12.Data.School.DefaultSchoolYear, out sy))
            {
                intSchoolYear.Value = sy;
            }
            else
            {
                intSchoolYear.IsEmpty = true;
            }

            if (int.TryParse(K12.Data.School.DefaultSemester, out sm))
            {
                intSemester.Value = sm;
            }
            else
            {
                intSemester.IsEmpty = true;
            }


            // 取得年級,如果學生狀態是延修生,年級顯示延修生,如果不是就依照原本年級顯示
            SHStudentRecord studRec = SHStudent.SelectByID(_StudentID);

            if (studRec.Class != null)
            {
                if (studRec.Class.GradeYear.HasValue)
                {
                    if (cbxGradeYear.Text == "")
                    {
                        if (studRec.Status == K12.Data.StudentRecord.StudentStatus.延修)
                        {
                            cbxGradeYear.Text = "延修生";
                        }
                        else
                        {
                            cbxGradeYear.Text = studRec.Class.GradeYear.Value.ToString();
                        }
                    }
                }
            }
        }
Пример #4
0
        private void wizardPage3_FinishButtonClick(object sender, CancelEventArgs e)
        {
            StringBuilder   desc = new StringBuilder("");
            SHStudentRecord stu  = SHStudent.SelectByID(mStudentID);

            desc.AppendLine("學生姓名:" + stu.Name + " ");

            if (office2007StyleRadioButton1.Checked)
            {
                desc.AppendLine("姓名由「" + stu.Name + "」變更為「" + textBoxX1.Text + "」");
                stu.Name = textBoxX1.Text;
            }
            if (office2007StyleRadioButton2.Checked)
            {
                desc.AppendLine("身分證號由「" + stu.IDNumber + "」變更為「" + textBoxX1.Text + "」");
                stu.IDNumber = textBoxX1.Text;
            }
            if (office2007StyleRadioButton3.Checked)
            {
                desc.AppendLine("學號由「" + stu.StudentNumber + "」變更為「" + textBoxX1.Text + "」");
                stu.StudentNumber = textBoxX1.Text;
            }
            if (office2007StyleRadioButton4.Checked)
            {
                desc.AppendLine("生日由「" + stu.Birthday + "」變更為「" + textBoxX1.Text + "」");
                stu.Birthday = K12.Data.DateTimeHelper.Parse(textBoxX1.Text);
            }
            if (office2007StyleRadioButton5.Checked)
            {
                desc.AppendLine("性別由「" + stu.Gender + "」變更為「" + textBoxX1.Text + "」");
                stu.Gender = textBoxX1.Text;
            }

            this.Close();
//            CurrentUser.Instance.AppLog.Write(EntityType.Student, "學籍更正", mStudentID, desc.ToString(), "", "");
            SHStudent.Update(stu);

            this.updateRecordInfo1.Save();
            //          SmartSchool.Broadcaster.Events.Items["學生/資料變更"].Invoke(mStudentID);
        }
Пример #5
0
        protected override void OnSaveButtonClick(EventArgs e)
        {
            _BeforeEnrollmentRecord.School         = txtSchool.Text;
            _BeforeEnrollmentRecord.SchoolLocation = txtSchoolLocation.Text;
            _BeforeEnrollmentRecord.ClassName      = txtClass.Text;
            int intSeatNo;

            if (string.IsNullOrEmpty(txtSeatNo.Text))
            {
                _BeforeEnrollmentRecord.SeatNo = null;
            }
            else
            {
                if (int.TryParse(txtSeatNo.Text, out intSeatNo))
                {
                    _BeforeEnrollmentRecord.SeatNo = intSeatNo;
                }
                else
                {
                    epSeatNo.SetError(txtSeatNo, "請填入數字.");
                    return;
                }
            }


            _BeforeEnrollmentRecord.Memo = txtMemo.Text;

            int GSchoolYear;

            if (string.IsNullOrEmpty(txtGraduateSchoolYear.Text))
            {
                _BeforeEnrollmentRecord.GraduateSchoolYear = null;
            }
            else
            {
                if (int.TryParse(txtGraduateSchoolYear.Text, out GSchoolYear))
                {
                    _BeforeEnrollmentRecord.GraduateSchoolYear = GSchoolYear.ToString();
                }
                else
                {
                    epSeatNo.SetError(txtGraduateSchoolYear, "請填入數字.");
                    return;
                }
            }

            SHBeforeEnrollment.Update(_BeforeEnrollmentRecord);
            listener.Reset();
            SaveButtonVisible   = false;
            CancelButtonVisible = SaveButtonVisible;

            prlp.SetAfterSaveText("學校名稱", txtSchool.Text);
            prlp.SetAfterSaveText("所在地", txtSchoolLocation.Text);
            prlp.SetAfterSaveText("班級", txtClass.Text);
            prlp.SetAfterSaveText("座號", txtSeatNo.Text);
            prlp.SetAfterSaveText("備註", txtMemo.Text);
            prlp.SetAfterSaveText("國中畢業學年度", txtGraduateSchoolYear.Text);
            prlp.SetActionBy("學籍", "學生前級畢業資訊");
            prlp.SetAction("修改學生前級畢業資訊");
            SHStudentRecord studRec = SHStudent.SelectByID(PrimaryKey);

            prlp.SetDescTitle("學生姓名:" + studRec.Name + ",學號:" + studRec.StudentNumber + ",");
            prlp.SaveLog("", "", "student", PrimaryKey);
        }
Пример #6
0
        private void btnConfirm_Click(object sender, EventArgs e)
        {
            if (UpdateRecordEditorPanle.Controls.Count > 0)
            {
                IUpdateRecordInfo IU;
                IU             = UpdateRecordEditorPanle.Controls[0] as IUpdateRecordInfo;
                _StudUpdateRec = IU.GetStudUpdateRecord();
                _prlp          = IU.GetLogData();

                int codeInt;
                if (_StudUpdateRec != null)
                {
                    if (int.TryParse(_StudUpdateRec.UpdateCode, out codeInt) && _actMode == actMode.新增)
                    {
                        int icode;
                        List <SHUpdateRecordRecord> UpRec01List = new List <SHUpdateRecordRecord>();
                        // 檢查是否有新生異動
                        foreach (SHUpdateRecordRecord rec in SHUpdateRecord.SelectByStudentID(_StudentID))
                        {
                            if (int.TryParse(rec.UpdateCode, out icode))
                            {
                                if (icode > 0 && icode < 100)
                                {
                                    UpRec01List.Add(rec);
                                }
                            }
                        }
                        if (UpRec01List.Count > 0 && codeInt < 100)
                        {
                            if (FISCA.Presentation.Controls.MsgBox.Show("已有" + UpRec01List.Count + "筆新生異動,是否覆蓋", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == System.Windows.Forms.DialogResult.Yes)
                            {
                                SHUpdateRecord.Delete(UpRec01List);
                            }
                            else
                            {
                                return;
                            }
                        }

                        // 檢查是否有畢業異動
                        List <SHUpdateRecordRecord> UpRec05List = (from data in SHUpdateRecord.SelectByStudentID(_StudentID) where data.UpdateCode == "501" select data).ToList();
                        if (UpRec05List.Count > 0 && codeInt == 501)
                        {
                            if (FISCA.Presentation.Controls.MsgBox.Show("已有" + UpRec01List.Count + "筆畢業異動,是否覆蓋", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == System.Windows.Forms.DialogResult.Yes)
                            {
                                SHUpdateRecord.Delete(UpRec05List);
                            }
                            else
                            {
                                return;
                            }
                        }
                    }
                }

                if (_StudUpdateRec != null)
                {
                    // 儲存學年度學期 年級
                    _StudUpdateRec.SchoolYear = intSchoolYear.Value;
                    _StudUpdateRec.Semester   = intSemester.Value;

                    if (cbxGradeYear.Text == "延修生")
                    {
                        _StudUpdateRec.GradeYear = "延修生";
                    }
                    else
                    {
                        _StudUpdateRec.GradeYear = cbxGradeYear.Text;
                    }

                    // 儲存異動資料
                    string strItemName = "";
                    if (_actMode == actMode.新增)
                    {
                        SHUpdateRecord.Insert(_StudUpdateRec);
                        strItemName = "新增:";
                    }
                    else
                    {
                        SHUpdateRecord.Update(_StudUpdateRec);
                        strItemName = "修改:";
                    }

                    SHStudentRecord studRec = SHStudent.SelectByID(_StudentID);
                    // Log
                    strItemName += "學生姓名:" + studRec.Name + _actMode.ToString();

                    _prlp.SetActionBy("學生", strItemName);
                    _prlp.SaveLog("", ":", "student", _StudentID);
                    _checkSave = true;

                    // 取得 UpdateCode
                    int intUpdateCode;
                    int.TryParse(_StudUpdateRec.UpdateCode, out intUpdateCode);



                    // 學生資料 Cache
                    List <SHStudentRecord> AllStudRec = null;


                    // 復學,學生狀態是非一般,輸入異動代碼是復學,問使用者是否轉成一般。
                    if (intUpdateCode >= 221 && intUpdateCode <= 226 && studRec.Status != K12.Data.StudentRecord.StudentStatus.一般)
                    {
                        if (FISCA.Presentation.Controls.MsgBox.Show("請問是否將學生狀態變更成一般?", "提醒", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                        {
                            if (AllStudRec == null)
                            {
                                AllStudRec = SHStudent.SelectAll();
                            }

                            // 檢查將變更學生狀態
                            // 身分證
                            List <string> studIDNumber = (from stud in AllStudRec where stud.Status == K12.Data.StudentRecord.StudentStatus.一般 && stud.IDNumber == studRec.IDNumber select stud.ID).ToList();
                            // 學號
                            List <string> studNumber = (from stud in AllStudRec where stud.Status == K12.Data.StudentRecord.StudentStatus.一般 && stud.StudentNumber == studRec.StudentNumber select stud.ID).ToList();

                            if (studNumber.Count > 0)
                            {
                                FISCA.Presentation.Controls.MsgBox.Show("在一般狀態有相同的學號:" + studRec.StudentNumber + ",無法變更學生狀態");
                            }

                            if (studIDNumber.Count > 0)
                            {
                                FISCA.Presentation.Controls.MsgBox.Show("在一般狀態有相同的身分證號:" + studRec.IDNumber + ",無法變更學生狀態");
                            }

                            if (studIDNumber.Count == 0 && studNumber.Count == 0)
                            {
                                studRec.Status = K12.Data.StudentRecord.StudentStatus.一般;
                                SHStudent.Update(studRec);
                            }
                        }
                    }

                    // 轉出,學生狀態是一般,輸入異動代碼是轉出,問使用者是否轉成畢業或離校。
                    if (intUpdateCode >= 311 && intUpdateCode <= 316 && studRec.Status == K12.Data.StudentRecord.StudentStatus.一般)
                    {
                        if (FISCA.Presentation.Controls.MsgBox.Show("請問是否將學生狀態變更成畢業或離校?", "提醒", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                        {
                            if (AllStudRec == null)
                            {
                                AllStudRec = SHStudent.SelectAll();
                            }

                            // 檢查將變更學生狀態
                            // 身分證
                            List <string> studIDNumber = (from stud in AllStudRec where stud.Status == K12.Data.StudentRecord.StudentStatus.畢業或離校 && stud.IDNumber == studRec.IDNumber select stud.ID).ToList();
                            // 學號
                            List <string> studNumber = (from stud in AllStudRec where stud.Status == K12.Data.StudentRecord.StudentStatus.畢業或離校 && stud.StudentNumber == studRec.StudentNumber select stud.ID).ToList();

                            if (studNumber.Count > 0)
                            {
                                FISCA.Presentation.Controls.MsgBox.Show("在畢業或離校狀態有相同的學號:" + studRec.StudentNumber + ",無法變更學生狀態");
                            }

                            if (studIDNumber.Count > 0)
                            {
                                FISCA.Presentation.Controls.MsgBox.Show("在畢業或離校狀態有相同的身分證號:" + studRec.IDNumber + ",無法變更學生狀態");
                            }

                            if (studIDNumber.Count == 0 && studNumber.Count == 0)
                            {
                                studRec.Status = K12.Data.StudentRecord.StudentStatus.畢業或離校;
                                SHStudent.Update(studRec);
                            }
                        }
                    }

                    // 休學,學生狀態是一般,輸入異動代碼是休學,問使用者是否轉成休學。
                    if (intUpdateCode >= 341 && intUpdateCode <= 349 && studRec.Status == K12.Data.StudentRecord.StudentStatus.一般)
                    {
                        if (FISCA.Presentation.Controls.MsgBox.Show("請問是否將學生狀態變更成休學?", "提醒", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                        {
                            if (AllStudRec == null)
                            {
                                AllStudRec = SHStudent.SelectAll();
                            }

                            // 檢查將變更學生狀態
                            // 身分證
                            List <string> studIDNumber = (from stud in AllStudRec where stud.Status == K12.Data.StudentRecord.StudentStatus.休學 && stud.IDNumber == studRec.IDNumber select stud.ID).ToList();
                            // 學號
                            List <string> studNumber = (from stud in AllStudRec where stud.Status == K12.Data.StudentRecord.StudentStatus.休學 && stud.StudentNumber == studRec.StudentNumber select stud.ID).ToList();

                            if (studNumber.Count > 0)
                            {
                                FISCA.Presentation.Controls.MsgBox.Show("在休學狀態有相同的學號:" + studRec.StudentNumber + ",無法變更學生狀態");
                            }

                            if (studIDNumber.Count > 0)
                            {
                                FISCA.Presentation.Controls.MsgBox.Show("在休學狀態有相同的身分證號:" + studRec.IDNumber + ",無法變更學生狀態");
                            }


                            if (studIDNumber.Count == 0 && studNumber.Count == 0)
                            {
                                studRec.Status = K12.Data.StudentRecord.StudentStatus.休學;
                                SHStudent.Update(studRec);
                            }
                        }
                    }
                    this.Close();
                    // 畫面同步
                    SmartSchool.StudentRelated.Student.Instance.SyncAllBackground();
                }
            }
        }
Пример #7
0
        static public void Main()
        {
            //資料驗證(學號是否存在系統驗證)
            FactoryProvider.FieldFactory.Add(new FieldValidatorFactory());

            #region 其它

            RibbonBarItem StudentReports = K12.Presentation.NLDPanels.Student.RibbonBarItems["資料統計"];
            //StudentReports["報表"].Image = Properties.Resources.boolean_field_fav_64;
            StudentReports["報表"]["學務相關報表"]["學生獎勵明細"].Enable = Permissions.學生獎勵明細權限;
            StudentReports["報表"]["學務相關報表"]["學生獎勵明細"].Click += delegate
            {
                new SHSchool.Behavior.StudentExtendControls.Reports.學生獎勵明細.Report().Print();
            };

            StudentReports = K12.Presentation.NLDPanels.Student.RibbonBarItems["資料統計"];
            StudentReports["報表"]["學務相關報表"]["歷年功過及出席統計表"].Enable = Permissions.歷年功過及出席統計表權限;
            StudentReports["報表"]["學務相關報表"]["歷年功過及出席統計表"].Click += delegate
            {
                OverTheYearsStatisticsForm form = new OverTheYearsStatisticsForm();
                form.ShowDialog();
            };

            //匯出
            MenuButton rbItemExport = K12.Presentation.NLDPanels.Student.RibbonBarItems["資料統計"]["匯出"]["學務相關匯出"];
            rbItemExport["匯出文字評量"].Enable = Permissions.匯出文字評量權限;
            rbItemExport["匯出文字評量"].Click += delegate
            {
                SmartSchool.API.PlugIn.Export.Exporter exporter = new ExportMoralScore();
                ExportMoralScoreUI wizard = new ExportMoralScoreUI(exporter.Text, exporter.Image);
                exporter.InitializeExport(wizard);
                wizard.ShowDialog();
            };

            MenuButton rbItemImport = K12.Presentation.NLDPanels.Student.RibbonBarItems["資料統計"]["匯入"]["學務相關匯入"];
            rbItemImport["匯入文字評量"].Enable = Permissions.匯入文字評量權限;
            rbItemImport["匯入文字評量"].Click += delegate
            {
                ImportMoralScore wizard = new ImportMoralScore();
                wizard.Execute();
            };

            MenuButton rbItemExport1 = K12.Presentation.NLDPanels.Student.RibbonBarItems["資料統計"]["匯出"]["學務相關匯出"];
            rbItemExport["匯出導師評語"].Enable = Permissions.匯出導師評語權限;
            rbItemExport["匯出導師評語"].Click += delegate
            {
                SmartSchool.API.PlugIn.Export.Exporter exporter = new ExportComment();
                ExportMoralScoreUI wizard = new ExportMoralScoreUI(exporter.Text, exporter.Image);
                exporter.InitializeExport(wizard);
                wizard.ShowDialog();
            };

            MenuButton rbItemImport1 = K12.Presentation.NLDPanels.Student.RibbonBarItems["資料統計"]["匯入"]["學務相關匯入"];
            rbItemImport["匯入導師評語"].Enable = Permissions.匯入導師評語權限;
            rbItemImport["匯入導師評語"].Click += delegate
            {
                ImportComment wizard = new ImportComment();
                wizard.Execute();
            };

            #endregion

            RibbonBarItem rbItem = MotherForm.RibbonBarItems["學生", "學務"];

            rbItem["缺曠"].Image  = Properties.Resources.desk_64;
            rbItem["缺曠"].Enable = (Permissions.缺曠權限 && NLDPanels.Student.SelectedSource.Count >= 1);
            rbItem["缺曠"].Click += delegate
            {
                if (1 == NLDPanels.Student.SelectedSource.Count)
                {
                    SingleEditor editor = new SingleEditor(SHStudent.SelectByID(K12.Presentation.NLDPanels.Student.SelectedSource[0]));
                    editor.ShowDialog();
                }
                else
                {
                    MutiEditor editor = new MutiEditor(K12.Data.Student.SelectByIDs(K12.Presentation.NLDPanels.Student.SelectedSource));
                    editor.ShowDialog();
                }
            };

            rbItem["長假登錄"].Image  = Properties.Resources.desk_clock_64;
            rbItem["長假登錄"].Enable = (Permissions.長假登錄權限 && NLDPanels.Student.SelectedSource.Count >= 1);
            rbItem["長假登錄"].Click += delegate
            {
                if (1 <= NLDPanels.Student.SelectedSource.Count)
                {
                    TestSingleEditor SBStatistics = new TestSingleEditor(K12.Presentation.NLDPanels.Student.SelectedSource);
                    SBStatistics.ShowDialog();
                }
            };

            if (Permissions.缺曠權限)
            {
                K12.Presentation.NLDPanels.Student.ListPaneContexMenu["缺曠"].Image  = Properties.Resources.desk_64;
                K12.Presentation.NLDPanels.Student.ListPaneContexMenu["缺曠"].Enable = (NLDPanels.Student.SelectedSource.Count >= 1);
                K12.Presentation.NLDPanels.Student.ListPaneContexMenu["缺曠"].Click += delegate
                {
                    if (1 == NLDPanels.Student.SelectedSource.Count)
                    {
                        SingleEditor editor = new SingleEditor(SHStudent.SelectByID(K12.Presentation.NLDPanels.Student.SelectedSource[0]));
                        editor.ShowDialog();
                    }
                    else
                    {
                        MutiEditor editor = new MutiEditor(K12.Data.Student.SelectByIDs(K12.Presentation.NLDPanels.Student.SelectedSource));
                        editor.ShowDialog();
                    }
                };
            }

            if (Permissions.長假登錄權限)
            {
                K12.Presentation.NLDPanels.Student.ListPaneContexMenu["長假登錄"].Image  = Properties.Resources.desk_clock_64;
                K12.Presentation.NLDPanels.Student.ListPaneContexMenu["長假登錄"].Enable = (NLDPanels.Student.SelectedSource.Count >= 1);
                K12.Presentation.NLDPanels.Student.ListPaneContexMenu["長假登錄"].Click += delegate
                {
                    if (1 <= NLDPanels.Student.SelectedSource.Count)
                    {
                        TestSingleEditor SBStatistics = new TestSingleEditor(K12.Presentation.NLDPanels.Student.SelectedSource);
                        SBStatistics.ShowDialog();
                    }
                };
            }

            #region 事件

            K12.Presentation.NLDPanels.Student.SelectedSourceChanged += delegate
            {
                StudentReports["報表"]["學務相關報表"]["學生獎勵明細"].Enable = (Permissions.學生獎勵明細權限 && NLDPanels.Student.SelectedSource.Count >= 1);

                if (Permissions.缺曠權限)
                {
                    rbItem["缺曠"].Enable = (NLDPanels.Student.SelectedSource.Count >= 1);
                    K12.Presentation.NLDPanels.Student.ListPaneContexMenu["缺曠"].Enable = (NLDPanels.Student.SelectedSource.Count >= 1);
                }
                if (Permissions.長假登錄權限)
                {
                    rbItem["長假登錄"].Enable = (NLDPanels.Student.SelectedSource.Count >= 1);
                    K12.Presentation.NLDPanels.Student.ListPaneContexMenu["長假登錄"].Enable = (NLDPanels.Student.SelectedSource.Count >= 1);
                }
            };

            #endregion

            #region 學務作業

            RibbonBarItem Process = StuAdmin.Instance.RibbonBarItems["資料統計"];
            //Process["其他"].Image = Properties.Resources.boolean_field_fav_64;
            Process["報表"].Image            = Properties.Resources.paste_64;
            Process["報表"]["獎懲人數統計"].Enable = Permissions.公務統計報表權限;
            Process["報表"]["獎懲人數統計"].Click += delegate
            {
                new SHSchool.Behavior.StuAdminExtendControls.DisciplineStatistics();
            };

            RibbonBarItem TimeSeupt = StuAdmin.Instance.RibbonBarItems["基本設定"];
            TimeSeupt["設定"].Image = Properties.Resources.sandglass_unlock_64;
            TimeSeupt["設定"].Size  = RibbonBarButton.MenuButtonSize.Large;
            //Process["其他"].Image = Properties.Resources.boolean_field_fav_64;
            TimeSeupt["設定"]["開放時間設定"].Enable = Permissions.開放時間設定權限;
            TimeSeupt["設定"]["開放時間設定"].Click += delegate
            {
                new SHSchool.Behavior.StuAdminExtendControls.TeacherDiffOpenConfig().ShowDialog();
            };
            #endregion

            #region 報表

            RibbonBarItem ClassReports2 = K12.Presentation.NLDPanels.Class.RibbonBarItems["資料統計"];
            //ClassReports2["報表"]["學務相關報表"].Image = Properties.Resources.boolean_field_fav_64;
            ClassReports2["報表"]["學務相關報表"]["德行表現特殊學生名單"].Enable = Permissions.德行表現特殊學生名單權限;
            ClassReports2["報表"]["學務相關報表"]["德行表現特殊學生名單"].Click += delegate
            {
                DeXingStatistic statistic = new DeXingStatistic(K12.Presentation.NLDPanels.Class.SelectedSource.ToArray());
                statistic.ShowDialog();
            };

            //RibbonBarItem StudentReports = K12.Presentation.NLDPanels.Student.RibbonBarItems["統計報表"];
            //StudentReports["報表"]["新功能"].Image = Properties.Resources.boolean_field_fav_64;
            //StudentReports["報表"]["新功能"]["懲戒通知單"].Enable = Permissions.學生懲戒通知單權限;
            //StudentReports["報表"]["新功能"]["懲戒通知單"].Click += delegate
            //{
            //    new DisciplineNotification(false);
            //};

            #endregion

            #region 註冊權限

            //Catalog ribbon = RoleAclSource.Instance["學生"]["報表"];
            //ribbon.Add(new RibbonFeature(Permissions.學生懲戒通知單, "懲戒通知單(new)"));

            Catalog ribbon = RoleAclSource.Instance["學生"]["功能按鈕"];
            ribbon.Add(new RibbonFeature(Permissions.缺曠, "缺曠"));
            ribbon.Add(new RibbonFeature(Permissions.長假登錄, "長假登錄"));
            ribbon.Add(new RibbonFeature(Permissions.匯出文字評量, "匯出文字評量"));
            ribbon.Add(new RibbonFeature(Permissions.匯入文字評量, "匯入文字評量"));

            ribbon.Add(new RibbonFeature(Permissions.匯出導師評語, "匯出導師評語"));
            ribbon.Add(new RibbonFeature(Permissions.匯入導師評語, "匯入導師評語"));

            Catalog ribbon1 = RoleAclSource.Instance["學生"]["報表"];
            ribbon1.Add(new RibbonFeature(Permissions.學生獎勵明細, "學生獎勵明細"));
            ribbon1.Add(new RibbonFeature(Permissions.歷年功過及出席統計表, "歷年功過及出席統計表"));

            Catalog ribbon2 = RoleAclSource.Instance["班級"]["報表"];
            ribbon2.Add(new RibbonFeature(Permissions.德行表現特殊學生名單, "德行表現特殊學生名單"));

            //ribbon = RoleAclSource.Instance["班級"]["報表"];
            //ribbon.Add(new RibbonFeature(Permissions.班級懲戒通知單, "懲戒通知單(new)"));

            ribbon = RoleAclSource.Instance["學務作業"]["功能按鈕"];
            ribbon.Add(new RibbonFeature(Permissions.公務統計報表, "公務統計報表"));
            ribbon.Add(new RibbonFeature(Permissions.開放時間設定, "開放時間設定"));

            #endregion
        }
Пример #8
0
        string eveCount;                                //給Log使用


        void bkwNotPassComputer_DoWork(object sender, DoWorkEventArgs e)
        {
            SB = new StringBuilder(); //給Log使用
            SB.AppendLine("詳細資料:");   //給Log使用
            StudIDList.Clear();       //給Log使用

            string        fileName         = (string)((object[])e.Argument)[0];
            List <string> studentFieldList = (List <string>)((object[])e.Argument)[1];
            List <string> exportFieldList  = (List <string>)((object[])e.Argument)[2];
            Dictionary <ManualResetEvent, List <RowData> > Filler = (Dictionary <ManualResetEvent, List <RowData> >)((object[])e.Argument)[3];
            double   totleProgress   = 0.0;
            double   packageProgress = 100.0 / Filler.Count;
            Workbook report          = new Workbook();

            report.Worksheets[0].Name = _Title;
            ((BackgroundWorker)sender).ReportProgress(1, _Title + " 資料整理中...");
            int RowIndex = 0;
            int i        = 0;

            //填表頭
            for (; i < studentFieldList.Count; i++)
            {
                report.Worksheets[0].Cells[0, i].PutValue(studentFieldList[i]);
            }
            for (int j = 0; j < exportFieldList.Count; j++)
            {
                report.Worksheets[0].Cells[0, i + j].PutValue(exportFieldList[j]);
            }
            RowIndex = 1;
            foreach (ManualResetEvent eve in Filler.Keys)
            {
                eve.WaitOne();
                eveCount = Filler[eve].Count.ToString(); //給Log使用

                if (Filler[eve].Count != 0)
                {
                    SHStudentRecord stud = SHStudent.SelectByID(Filler[eve][0].ID);
                }

                if (RowIndex <= 65535)
                {
                    double miniProgress = Filler[eve].Count == 0 ? 1 : packageProgress / Filler[eve].Count;
                    double miniTotle    = 0;
                    foreach (RowData row in Filler[eve])
                    {
                        SHStudentRecord student = null;
                        if (row.ID != "")
                        {
                            if (!StudIDList.Contains(row.ID)) //給Log使用
                            {
                                StudIDList.Add(row.ID);
                            }

                            student = SHStudent.SelectByID(row.ID);
                        }

                        if (student != null)
                        {
                            if (RowIndex <= 65535)
                            {
                                i = 0;
                                for (; i < studentFieldList.Count; i++)
                                {
                                    switch (studentFieldList[i])
                                    {
                                    case "學生系統編號": report.Worksheets[0].Cells[RowIndex, i].PutValue(student.ID); break;

                                    case "學號": report.Worksheets[0].Cells[RowIndex, i].PutValue(student.StudentNumber); break;

                                    case "班級": report.Worksheets[0].Cells[RowIndex, i].PutValue(student.Class == null ? "" : student.Class.Name); break;

                                    case "座號": report.Worksheets[0].Cells[RowIndex, i].PutValue(student.SeatNo); break;

                                    case "姓名": report.Worksheets[0].Cells[RowIndex, i].PutValue(student.Name); break;

                                    default:
                                        break;
                                    }
                                }
                                for (int j = 0; j < exportFieldList.Count; j++)
                                {
                                    report.Worksheets[0].Cells[RowIndex, i + j].PutValue(row.ContainsKey(exportFieldList[j]) ? row[exportFieldList[j]] : "");
                                }
                            }
                            RowIndex++;
                        }
                        miniTotle += miniProgress;
                        ((BackgroundWorker)sender).ReportProgress((int)(totleProgress + miniTotle), _Title + " 處理中...");
                    }
                }
                totleProgress += packageProgress;
                ((BackgroundWorker)sender).ReportProgress((int)(totleProgress), _Title + " 處理中...");
            }
            for (int k = 0; k < studentFieldList.Count + exportFieldList.Count; k++)
            {
                report.Worksheets[0].AutoFitColumn(k, 0, 150);
            }
            report.Worksheets[0].FreezePanes(1, 0, 1, studentFieldList.Count + exportFieldList.Count);
            e.Result = new object[] { report, fileName, RowIndex > 65535 };
        }
Пример #9
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            // 檢查是否要修改學生狀態
            int  UpdateCoodeInt;
            bool UpdateStudStatus = false;

            if (int.TryParse(updateRecordInfo1.UpdateCode, out UpdateCoodeInt))
            {
                string StudIDNumber = "", StudNumber = "";

                SHStudentRecord stud = SHStudent.SelectByID(updateRecordInfo1.StudentID);

                if (stud != null)
                {
                    StudIDNumber = stud.IDNumber;
                    StudNumber   = stud.StudentNumber;
                }


                // 收集檢查用資料
                // 一般
                List <string> tmp01 = new List <string>();
                // 畢業或離校
                List <string> tmp02 = new List <string>();
                // 休學
                List <string> tmp03 = new List <string>();

                foreach (SHStudentRecord studRec in SHStudent.SelectAll())
                {
                    if (studRec.Status == K12.Data.StudentRecord.StudentStatus.一般)
                    {
                        tmp01.Add(studRec.IDNumber);
                        tmp01.Add(studRec.StudentNumber);
                    }

                    if (studRec.Status == K12.Data.StudentRecord.StudentStatus.畢業或離校)
                    {
                        tmp02.Add(studRec.IDNumber);
                        tmp02.Add(studRec.StudentNumber);
                    }

                    if (studRec.Status == K12.Data.StudentRecord.StudentStatus.休學)
                    {
                        tmp03.Add(studRec.IDNumber);
                        tmp03.Add(studRec.StudentNumber);
                    }
                }

                // 復學
                if (UpdateCoodeInt >= 221 && UpdateCoodeInt <= 226)
                {
                    if (MessageBox.Show("請問是否更改學生狀態成 一般?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                    {
                        // 檢查該狀態是否有相同學號或身分證號學生
                        if (tmp01.Contains(StudIDNumber) || tmp01.Contains(StudNumber))
                        {
                            FISCA.Presentation.Controls.MsgBox.Show("在一般狀態已有相同身分證號或學號的學生,無法自動變更狀態。");
                        }
                        else
                        {
                            UpdateStudStatus = true;
                            stud.Status      = K12.Data.StudentRecord.StudentStatus.一般;
                        }
                    }
                }

                // 轉出
                if (UpdateCoodeInt >= 311 && UpdateCoodeInt <= 316)
                {
                    if (MessageBox.Show("請問是否更改學生狀態成 畢業或離校?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                    {
                        // 檢查該狀態是否有相同學號或身分證號學生
                        if (tmp02.Contains(StudIDNumber) || tmp02.Contains(StudNumber))
                        {
                            FISCA.Presentation.Controls.MsgBox.Show("在畢業或離校狀態已有相同身分證號或學號的學生,無法自動變更狀態。");
                        }
                        else
                        {
                            UpdateStudStatus = true;
                            stud.Status      = K12.Data.StudentRecord.StudentStatus.畢業或離校;
                        }
                    }
                }

                // 休學
                if (UpdateCoodeInt >= 341 && UpdateCoodeInt <= 349)
                {
                    if (MessageBox.Show("請問是否更改學生狀態成 休學?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                    {
                        if (MessageBox.Show("請問是否更改學生狀態成 畢業或離校?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                        {
                            // 檢查該狀態是否有相同學號或身分證號學生
                            if (tmp03.Contains(StudIDNumber) || tmp03.Contains(StudNumber))
                            {
                                FISCA.Presentation.Controls.MsgBox.Show("在休學狀態已有相同身分證號或學號的學生,無法自動變更狀態。");
                            }
                            else
                            {
                                UpdateStudStatus = true;
                                stud.Status      = K12.Data.StudentRecord.StudentStatus.休學;
                            }
                        }
                    }
                }
                // 更新學生狀態
                if (UpdateStudStatus)
                {
                    SHStudent.Update(stud);
                    StudentRelated.Student.Instance.SyncAllBackground();
                }
            }
            if (updateRecordInfo1.Save())
            {
                _saved = true;
                if (DataSaved != null)
                {
                    DataSaved(this, null);
                }
                this.Close();
            }
        }
Пример #10
0
        public ImportStartupForm()
        {
            InitializeComponent();
            InitializeSemesters();

            //_effortMapper = new EffortMapper();

            // 載入預設儲存值
            LoadConfigData();

            _worker = new BackgroundWorker();
            _worker.WorkerReportsProgress = true;
            _worker.ProgressChanged      += delegate(object sender, ProgressChangedEventArgs e)
            {
                lblMessage.Text = "" + e.UserState;
            };
            _worker.DoWork += delegate(object sender, DoWorkEventArgs e)
            {
                #region Worker DoWork
                _worker.ReportProgress(0, "訊息:檢查讀卡文字格式…");

                #region 檢查文字檔
                ValidateTextFiles  vtf      = new ValidateTextFiles(StudentNumberMax);
                ValidateTextResult vtResult = vtf.CheckFormat(_files);
                if (vtResult.Error)
                {
                    e.Result = vtResult;
                    return;
                }
                #endregion

                //文字檔轉 RawData
                RawDataCollection rdCollection = new RawDataCollection();
                rdCollection.ConvertFromFiles(_files);

                //RawData 轉 DataRecord
                DataRecordCollection drCollection = new DataRecordCollection();
                drCollection.ConvertFromRawData(rdCollection);

                _rawDataValidator    = new DataValidator <RawData>();
                _dataRecordValidator = new DataValidator <DataRecord>();

                #region 取得驗證需要的資料
                SHCourse.RemoveAll();
                _worker.ReportProgress(5, "訊息:取得學生資料…");

                List <StudentObj> studentList = GetInSchoolStudents();

                List <string> s_ids = new List <string>();
                Dictionary <string, List <string> > studentNumberToStudentIDs = new Dictionary <string, List <string> >();
                foreach (StudentObj student in studentList)
                {
                    string sn = student.StudentNumber;// SCValidatorCreator.GetStudentNumberFormat(student.StudentNumber);
                    if (!studentNumberToStudentIDs.ContainsKey(sn))
                    {
                        studentNumberToStudentIDs.Add(sn, new List <string>());
                    }
                    studentNumberToStudentIDs[sn].Add(student.StudentID);
                }

                foreach (string each in studentNumberToStudentIDs.Keys)
                {
                    if (studentNumberToStudentIDs[each].Count > 1)
                    {
                        //學號重覆
                    }
                }

                foreach (var dr in drCollection)
                {
                    if (studentNumberToStudentIDs.ContainsKey(dr.StudentNumber))
                    {
                        s_ids.AddRange(studentNumberToStudentIDs[dr.StudentNumber]);
                    }
                }

                studentList.Clear();

                _worker.ReportProgress(10, "訊息:取得課程資料…");
                List <SHCourseRecord>    courseList = SHCourse.SelectBySchoolYearAndSemester(SchoolYear, Semester);
                List <SHAEIncludeRecord> aeList     = SHAEInclude.SelectAll();

                //List<JHSCAttendRecord> scaList = JHSCAttend.SelectAll();
                var c_ids = from course in courseList select course.ID;
                _worker.ReportProgress(15, "訊息:取得修課資料…");
                //List<JHSCAttendRecord> scaList2 = JHSCAttend.SelectByStudentIDAndCourseID(s_ids, c_ids.ToList<string>());
                List <SHSCAttendRecord> scaList = new List <SHSCAttendRecord>();
                FunctionSpliter <string, SHSCAttendRecord> spliter = new FunctionSpliter <string, SHSCAttendRecord>(300, 3);
                spliter.Function = delegate(List <string> part)
                {
                    return(SHSCAttend.Select(part, c_ids.ToList <string>(), null, SchoolYear.ToString(), Semester.ToString()));
                };
                scaList = spliter.Execute(s_ids);

                _worker.ReportProgress(20, "訊息:取得試別資料…");
                List <SHExamRecord> examList = SHExam.SelectAll();
                #endregion

                #region 註冊驗證
                _worker.ReportProgress(30, "訊息:載入驗證規則…");
                _rawDataValidator.Register(new SubjectCodeValidator());
                _rawDataValidator.Register(new ClassCodeValidator());
                _rawDataValidator.Register(new ExamCodeValidator());

                SCValidatorCreator scCreator = new SCValidatorCreator(SHStudent.SelectByIDs(s_ids), courseList, scaList);
                _dataRecordValidator.Register(scCreator.CreateStudentValidator());
                _dataRecordValidator.Register(new ExamValidator(examList));
                _dataRecordValidator.Register(scCreator.CreateSCAttendValidator());
                _dataRecordValidator.Register(new CourseExamValidator(scCreator.StudentCourseInfo, aeList, examList));
                #endregion

                #region 進行驗證
                _worker.ReportProgress(45, "訊息:進行驗證中…");
                List <string> msgList = new List <string>();

                foreach (RawData rawData in rdCollection)
                {
                    List <string> msgs = _rawDataValidator.Validate(rawData);
                    msgList.AddRange(msgs);
                }
                if (msgList.Count > 0)
                {
                    e.Result = msgList;
                    return;
                }

                foreach (DataRecord dataRecord in drCollection)
                {
                    List <string> msgs = _dataRecordValidator.Validate(dataRecord);
                    msgList.AddRange(msgs);
                }
                if (msgList.Count > 0)
                {
                    e.Result = msgList;
                    return;
                }
                #endregion

                #region 取得學生的評量成績

                _worker.ReportProgress(65, "訊息:取得學生評量成績…");

                _deleteScoreList.Clear();
                _addScoreList.Clear();
                AddScoreDic.Clear();

                //var student_ids = from student in scCreator.StudentNumberDictionary.Values select student.ID;
                //List<string> course_ids = scCreator.AttendCourseIDs;

                var scaIDs = from sca in scaList select sca.ID;

                Dictionary <string, SHSCETakeRecord>      sceList    = new Dictionary <string, SHSCETakeRecord>();
                FunctionSpliter <string, SHSCETakeRecord> spliterSCE = new FunctionSpliter <string, SHSCETakeRecord>(300, 3);
                spliterSCE.Function = delegate(List <string> part)
                {
                    return(SHSCETake.Select(null, null, null, null, part));
                };
                foreach (SHSCETakeRecord sce in spliterSCE.Execute(scaIDs.ToList()))
                {
                    string key = GetCombineKey(sce.RefStudentID, sce.RefCourseID, sce.RefExamID);
                    if (!sceList.ContainsKey(key))
                    {
                        sceList.Add(key, sce);
                    }
                }

                Dictionary <string, SHExamRecord>     examTable = new Dictionary <string, SHExamRecord>();
                Dictionary <string, SHSCAttendRecord> scaTable  = new Dictionary <string, SHSCAttendRecord>();

                foreach (SHExamRecord exam in examList)
                {
                    if (!examTable.ContainsKey(exam.Name))
                    {
                        examTable.Add(exam.Name, exam);
                    }
                }

                foreach (SHSCAttendRecord sca in scaList)
                {
                    string key = GetCombineKey(sca.RefStudentID, sca.RefCourseID);
                    if (!scaTable.ContainsKey(key))
                    {
                        scaTable.Add(key, sca);
                    }
                }

                _worker.ReportProgress(80, "訊息:成績資料建立…");

                foreach (DataRecord dr in drCollection)
                {
                    SHStudentRecord       student = student = scCreator.StudentNumberDictionary[dr.StudentNumber];
                    SHExamRecord          exam    = examTable[dr.Exam];
                    List <SHCourseRecord> courses = new List <SHCourseRecord>();
                    foreach (SHCourseRecord course in scCreator.StudentCourseInfo.GetCourses(dr.StudentNumber))
                    {
                        if (dr.Subjects.Contains(course.Subject))
                        {
                            courses.Add(course);
                        }
                    }

                    foreach (SHCourseRecord course in courses)
                    {
                        string key = GetCombineKey(student.ID, course.ID, exam.ID);

                        if (sceList.ContainsKey(key))
                        {
                            _deleteScoreList.Add(sceList[key]);
                        }

                        SHSCETakeRecord sh = new SHSCETakeRecord();
                        sh.RefCourseID   = course.ID;
                        sh.RefExamID     = exam.ID;
                        sh.RefSCAttendID = scaTable[GetCombineKey(student.ID, course.ID)].ID;
                        sh.RefStudentID  = student.ID;

                        //轉型Double再轉回decimal,可去掉小數點後的0
                        double  reScore = (double)dr.Score;
                        decimal Score   = decimal.Parse(reScore.ToString());

                        if (Global.StudentDocRemove)
                        {
                            string qq = Score.ToString();
                            if (qq.Contains("."))
                            {
                                string[] kk = qq.Split('.');
                                sh.Score = decimal.Parse(kk[0]);
                            }
                            else
                            {
                                //
                                sh.Score = decimal.Parse(Score.ToString());
                            }
                        }
                        else
                        {
                            sh.Score = decimal.Parse(Score.ToString());
                        }

                        //sceNew.Effort = _effortMapper.GetCodeByScore(dr.Score);

                        //是否有重覆的學生,課程,評量
                        if (!AddScoreDic.ContainsKey(sh.RefStudentID + "_" + course.ID + "_" + exam.ID))
                        {
                            _addScoreList.Add(sh);
                            AddScoreDic.Add(sh.RefStudentID + "_" + course.ID + "_" + exam.ID, sh);
                        }
                    }
                }
                #endregion
                _worker.ReportProgress(100, "訊息:背景作業完成…");
                e.Result = null;
                #endregion
            };
            _worker.RunWorkerCompleted += delegate(object sender, RunWorkerCompletedEventArgs e)
            {
                #region Worker Completed
                if (e.Error == null && e.Result == null)
                {
                    if (!_upload.IsBusy)
                    {
                        //如果學生身上已有成績,則提醒使用者
                        if (_deleteScoreList.Count > 0)
                        {
                            _warn.RunWorkerAsync();
                        }
                        else
                        {
                            lblMessage.Text = "訊息:成績上傳中…";
                            FISCA.Presentation.MotherForm.SetStatusBarMessage("成績上傳中…", 0);
                            counter = 0;
                            _upload.RunWorkerAsync();
                        }
                    }
                }
                else
                {
                    ControlEnable = true;

                    if (e.Error != null)
                    {
                        MsgBox.Show("匯入失敗。" + e.Error.Message);
                        SmartSchool.ErrorReporting.ReportingService.ReportException(e.Error);
                    }
                    else if (e.Result != null && e.Result is ValidateTextResult)
                    {
                        ValidateTextResult    result = e.Result as ValidateTextResult;
                        ValidationErrorViewer viewer = new ValidationErrorViewer();
                        viewer.SetTextFileError(result.LineIndexes, result.ErrorFormatLineIndexes, result.DuplicateLineIndexes);
                        viewer.ShowDialog();
                    }
                    else if (e.Result != null && e.Result is List <string> )
                    {
                        ValidationErrorViewer viewer = new ValidationErrorViewer();
                        viewer.SetErrorLines(e.Result as List <string>);
                        viewer.ShowDialog();
                    }
                }
                #endregion
            };

            _upload = new BackgroundWorker();
            _upload.WorkerReportsProgress = true;
            _upload.ProgressChanged      += new ProgressChangedEventHandler(_upload_ProgressChanged);
            _upload.DoWork += new DoWorkEventHandler(_upload_DoWork);


            _upload.RunWorkerCompleted += new RunWorkerCompletedEventHandler(_upload_RunWorkerCompleted);

            _warn = new BackgroundWorker();
            _warn.WorkerReportsProgress = true;
            _warn.DoWork += delegate(object sender, DoWorkEventArgs e)
            {
                _warn.ReportProgress(0, "產生警告訊息...");

                examDict = new Dictionary <string, string>();
                foreach (SHExamRecord exam in SHExam.SelectAll())
                {
                    if (!examDict.ContainsKey(exam.ID))
                    {
                        examDict.Add(exam.ID, exam.Name);
                    }
                }

                WarningForm form  = new WarningForm();
                int         count = 0;
                foreach (SHSCETakeRecord sce in _deleteScoreList)
                {
                    // 當成績資料是空值跳過
                    //if (sce.Score.HasValue == false && sce.Effort.HasValue == false && string.IsNullOrEmpty(sce.Text))
                    //if (sce.Score == null && string.IsNullOrEmpty(sce.Text))
                    //   continue;

                    count++;


                    SHStudentRecord student = SHStudent.SelectByID(sce.RefStudentID);
                    SHCourseRecord  course  = SHCourse.SelectByID(sce.RefCourseID);
                    string          exam    = (examDict.ContainsKey(sce.RefExamID) ? examDict[sce.RefExamID] : "<未知的試別>");

                    string s = "";
                    if (student.Class != null)
                    {
                        s += student.Class.Name;
                    }
                    if (!string.IsNullOrEmpty("" + student.SeatNo))
                    {
                        s += " " + student.SeatNo + "號";
                    }
                    if (!string.IsNullOrEmpty(student.StudentNumber))
                    {
                        s += " (" + student.StudentNumber + ")";
                    }
                    s += " " + student.Name;

                    string scoreName = sce.RefStudentID + "_" + sce.RefCourseID + "_" + sce.RefExamID;

                    if (AddScoreDic.ContainsKey(scoreName))
                    {
                        form.AddMessage(student.ID, s, string.Format("學生在「{0}」課程「{1}」中已有成績「{2}」將修改為「{3}」。", course.Name, exam, sce.Score, AddScoreDic[scoreName].Score));
                    }
                    else
                    {
                        form.AddMessage(student.ID, s, string.Format("學生在「{0}」課程「{1}」中已有成績「{2}」。", course.Name, exam, sce.Score));
                    }

                    _warn.ReportProgress((int)(count * 100 / _deleteScoreList.Count), "產生警告訊息...");
                }

                e.Result = form;
            };
            _warn.RunWorkerCompleted += delegate(object sender, RunWorkerCompletedEventArgs e)
            {
                WarningForm form = e.Result as WarningForm;

                if (form.ShowDialog() == DialogResult.OK)
                {
                    lblMessage.Text = "訊息:成績上傳中…";
                    FISCA.Presentation.MotherForm.SetStatusBarMessage("成績上傳中…", 0);
                    counter = 0;
                    _upload.RunWorkerAsync();
                }
                else
                {
                    this.DialogResult = DialogResult.Cancel;
                }
            };
            _warn.ProgressChanged += delegate(object sender, ProgressChangedEventArgs e)
            {
                FISCA.Presentation.MotherForm.SetStatusBarMessage("" + e.UserState, e.ProgressPercentage);
            };

            _files           = new List <FileInfo>();
            _addScoreList    = new List <SHSCETakeRecord>();
            _deleteScoreList = new List <SHSCETakeRecord>();
            AddScoreDic      = new Dictionary <string, SHSCETakeRecord>();
            examDict         = new Dictionary <string, string>();
        }