コード例 #1
0
ファイル: Program.cs プロジェクト: ischoolinc/JHEvaluation
        public static void Main()
        {
            Global.Params = ModuleLoader.GetDeployParametsers(typeof(Program), "Mode=KaoHsiung");

            //學生學期成績
            string key = "JHSchool.Student.Detail0050";

            if (FISCA.Permission.UserAcl.Current[key].Editable || FISCA.Permission.UserAcl.Current[key].Viewable)
            {
                K12.Presentation.NLDPanels.Student.AddDetailBulider(new DetailBulider <SemesterScoreItem>());
            }

            JHSchool.SF.Evaluation.SemesterScoreEditor.RegisterHandler(delegate(string studentId)
            {
                SemesterScoreEditor form;
                form = new SemesterScoreEditor(JHStudent.SelectByID(studentId));
                return(form.ShowDialog());
            });
            JHSchool.SF.Evaluation.SemesterScoreEditor.RegisterHandler(delegate(string studentId, int schoolYear, int semester)
            {
                SemesterScoreEditor form;
                form = new SemesterScoreEditor(JHStudent.SelectByID(studentId), JHSemesterScore.SelectBySchoolYearAndSemester(studentId, schoolYear, semester));
                return(form.ShowDialog());
            });
        }
コード例 #2
0
        /// <summary>
        /// 載入多筆學生學期成績(依學年度學期篩選)(一般生)
        /// </summary>
        /// <param name="SchoolYear"></param>
        /// <param name="Semester"></param>
        /// <param name="StudentIDList"></param>
        public static void LoadSemesterScoreRecord(int SchoolYear, int Semester, List <string> ClassIDList, List <string> notRankStudentIDList)
        {
            _ClassStudCount.Clear();
            List <JHClassRecord> ClassRecList  = JHClass.SelectByIDs(ClassIDList);
            List <string>        StudentIDList = new List <string>();

            foreach (JHClassRecord ClassRec in ClassRecList)
            {
                foreach (JHStudentRecord studRec in ClassRec.Students)
                {
                    if (studRec.Status == K12.Data.StudentRecord.StudentStatus.一般 && !notRankStudentIDList.Contains(studRec.ID))//剔除不排名學生
                    {
                        StudentIDList.Add(studRec.ID);

                        if (_ClassStudCount.ContainsKey(studRec.Class.ID))
                        {
                            _ClassStudCount[studRec.Class.ID]++;
                        }
                        else
                        {
                            _ClassStudCount.Add(studRec.Class.ID, 1);
                        }
                    }
                }
            }

            // 取得多筆學生學年度學期成績
            _SemesterScoreRecordList = JHSemesterScore.SelectBySchoolYearAndSemester(StudentIDList, SchoolYear, Semester);
        }
コード例 #3
0
        /// <summary>
        /// (Network Access)將目前學期的資料填入到 Courses、SCAttends 變數中。
        /// </summary>
        private void FillCurrentSemesterData()
        {
            SemesterScores = new Dictionary <string, JHSemesterScoreRecord>();
            List <JHSemesterScoreRecord> records = JHSemesterScore.SelectBySchoolYearAndSemester(Students.ToKeys(), Sems.SelectedSchoolYear, Sems.SelectedSemester);

            foreach (JHSemesterScoreRecord each in records)
            {
                if (SemesterScores.ContainsKey(each.RefStudentID))
                {
                    throw new ArgumentException(string.Format("學生編號{0},同一學期有兩筆成績?", each.RefStudentID));
                }

                SemesterScores.Add(each.RefStudentID, each);
            }
        }
コード例 #4
0
        private List <JHSemesterScoreRecord> ReadSemesterScore()
        {
            List <string> studIds = Students.Values.ToKeys();
            FunctionSpliter <string, JHSemesterScoreRecord> spliter = new FunctionSpliter <string, JHSemesterScoreRecord>(100, Util.MaxThread);

            spliter.Function = delegate(List <string> studIdPart)
            {
                return(JHSemesterScore.SelectBySchoolYearAndSemester(studIdPart, null, null));
            };
            spliter.ProgressChange = delegate(int progress)
            {
                Reporter.Feedback("讀取學期成績資料...", Util.CalculatePercentage(studIds.Count, progress));
            };
            return(spliter.Execute(studIds));
        }
コード例 #5
0
        private void MasterWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            //1.Goup By 可選擇的科目清單。
            //2.寫入成績資料到 ReportStudent 上。



            int schoolYear = Semester.SelectedSchoolYear;
            int semester   = Semester.SelectedSemester;
            FunctionSpliter <string, JHSemesterScoreRecord> selectData = new FunctionSpliter <string, JHSemesterScoreRecord>(1000, 5);

            selectData.Function = delegate(List <string> ps)
            {
                return(JHSemesterScore.SelectBySchoolYearAndSemester(ps, schoolYear, semester));
            };
            List <JHSemesterScoreRecord> semsScores = selectData.Execute(AllStudents.ToKeys());

            GroupBySubjects(semsScores);

            //先把學生身上的成績、排名相關資料清掉。
            foreach (ReportStudent each in AllStudents)
            {
                each.Clear();
                each.Scores.Add(Utilities.SubjectToken, new ScoreCollection()); //科目成績。
                each.Scores.Add(Utilities.DomainToken, new ScoreCollection());  //領域成績。
                each.Scores.Add(Utilities.SummaryToken, new ScoreCollection()); //運算後的成績。
            }

            //將成績填到學生身上。
            Dictionary <string, ReportStudent> dicAllStudent = AllStudents.ToDictionary();

            foreach (JHSemesterScoreRecord eachScore in semsScores)
            {
                //如果找不到該學生,跳到下一筆。
                if (!dicAllStudent.ContainsKey(eachScore.RefStudentID))
                {
                    continue;
                }

                ReportStudent student = dicAllStudent[eachScore.RefStudentID];

                //科目成績。
                foreach (SubjectScore each in eachScore.Subjects.Values)
                {
                    // 初始執
                    decimal ss = -1;

                    if (Perference.UserSelScoreType == "原始成績")
                    {
                        if (each.ScoreOrigin.HasValue)
                        {
                            ss = each.ScoreOrigin.Value;
                        }
                    }

                    if (Perference.UserSelScoreType == "原始補考擇優")
                    {
                        // 成績
                        if (each.Score.HasValue && each.Score.Value > ss)
                        {
                            ss = each.Score.Value;
                        }
                    }

                    //                    if (!each.Score.HasValue) continue; //沒有分數不處理。

                    if (ss == -1)
                    {
                        continue;
                    }

                    if (!each.Credit.HasValue || each.Credit.Value < 0)
                    {
                        continue;                                                  //沒有節數不處理。 //2021-07 要求權重0也要印出
                    }
                    if (!student.Scores[Utilities.SubjectToken].Contains(each.Subject))
                    {
                        student.Scores[Utilities.SubjectToken].Add(each.Subject, ss, each.Credit.Value);

                        if (Perference.UserSelScoreType == "原始補考擇優" && each.ScoreMakeup.HasValue)
                        {
                            student.Scores[Utilities.DomainToken].AddReExam(each.Subject, each.ScoreMakeup.Value);
                        }
                    }
                }

                //領域成績。
                foreach (DomainScore each in eachScore.Domains.Values)
                {
                    decimal dd = -1;
                    if (Perference.UserSelScoreType == "原始成績")
                    {
                        if (each.ScoreOrigin.HasValue)
                        {
                            dd = each.ScoreOrigin.Value;
                        }
                    }

                    if (Perference.UserSelScoreType == "原始補考擇優")
                    {
                        if (each.Score.HasValue && each.Score.Value > dd)
                        {
                            dd = each.Score.Value;
                        }
                    }

                    //if (!each.Score.HasValue) continue;
                    if (dd == -1)
                    {
                        continue;
                    }

                    if (!each.Credit.HasValue || each.Credit.Value < 0)
                    {
                        continue;                                                 //2021-07 要求權重0也要印出
                    }
                    if (!student.Scores[Utilities.DomainToken].Contains(each.Domain))
                    {
                        student.Scores[Utilities.DomainToken].Add(each.Domain, dd, each.Credit.Value);

                        if (Perference.UserSelScoreType == "原始補考擇優" && each.ScoreMakeup.HasValue)
                        {
                            student.Scores[Utilities.DomainToken].AddReExam(each.Domain, each.ScoreMakeup.Value);
                        }
                    }
                }

                //運算後成績是在使用者按下列印時才計算。
                //因為需要依據使用者選擇的科目進行計算。
            }
        }
コード例 #6
0
        public ImportStartupForm()
        {
            // 每次開啟,就重新載入 代碼對照
            KaoHsiung.ReaderScoreImport_DomainMakeUp.Mapper.ClassCodeMapper.Instance.Reload();
            KaoHsiung.ReaderScoreImport_DomainMakeUp.Mapper.ExamCodeMapper.Instance.Reload();
            KaoHsiung.ReaderScoreImport_DomainMakeUp.Mapper.DomainCodeMapper.Instance.Reload();

            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)
            {
                //將錯誤訊息刪光,以便重新統計
                msgList.Clear();


                #region Worker DoWork
                _worker.ReportProgress(0, "檢查讀卡文字格式…");

                #region 檢查文字檔
                ValidateTextFiles  vtf      = new ValidateTextFiles(intStudentNumberLenght.Value);
                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 取得驗證需要的資料
                JHCourse.RemoveAll();
                _worker.ReportProgress(0, "取得學生資料…");
                List <JHStudentRecord> studentList = GetInSchoolStudents();

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

                //紀錄現在所有txt 上 的學號,以處理重覆學號學號問題
                List <string> s_numbers = new List <string>();


                foreach (var dr in drCollection)
                {
                    if (studentNumberToStudentIDs.ContainsKey(dr.StudentNumber))
                    {
                        s_ids.Add(studentNumberToStudentIDs[dr.StudentNumber]);
                    }
                    else
                    {
                        //學號不存在系統中,下面的Validator 會進行處理
                    }

                    //2017/1/8 穎驊註解, 原本的程式碼並沒有驗證學號重覆的問題,且無法在他Validator 的處理邏輯加入,故在此驗證
                    if (!s_numbers.Contains(dr.StudentNumber))
                    {
                        s_numbers.Add(dr.StudentNumber);
                    }
                    else
                    {
                        msgList.Add("學號:" + dr.StudentNumber + ",資料重覆,請檢察資料來源txt是否有重覆填寫的學號資料。");
                    }
                }

                studentList.Clear();

                _worker.ReportProgress(0, "取得學期領域成績…");
                List <JHSemesterScoreRecord> jhssr_list = JHSemesterScore.SelectBySchoolYearAndSemester(s_ids, SchoolYear, Semester);

                #endregion

                #region 註冊驗證
                _worker.ReportProgress(0, "載入驗證規則…");
                _rawDataValidator.Register(new DomainCodeValidator());
                _rawDataValidator.Register(new ClassCodeValidator());
                _rawDataValidator.Register(new ExamCodeValidator());

                SCValidatorCreator scCreator = new SCValidatorCreator(JHStudent.SelectByIDs(s_ids));
                _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(0, "進行驗證中…");


                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 取得學生的評量成績
                _duplicateMakeUpScoreList.Clear();
                _updateMakeUpScoreList.Clear();

                //Dictionary<string, JHSCETakeRecord> sceList = new Dictionary<string, JHSCETakeRecord>();
                //FunctionSpliter<string, JHSCETakeRecord> spliterSCE = new FunctionSpliter<string, JHSCETakeRecord>(300, 3);
                //spliterSCE.Function = delegate(List<string> part)
                //{
                //    return JHSCETake.Select(null, null, null, null, part);
                //};
                //foreach (JHSCETakeRecord 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, JHExamRecord> examTable = new Dictionary<string, JHExamRecord>();
                //Dictionary<string, JHSCAttendRecord> scaTable = new Dictionary<string, JHSCAttendRecord>();

                //foreach (JHExamRecord exam in examList)
                //    if (!examTable.ContainsKey(exam.Name))
                //        examTable.Add(exam.Name, exam);

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

                //2018/1/8 穎驊新增
                //填寫補考成績
                foreach (DataRecord dr in drCollection)
                {
                    // 利用學號 將學生的isd 對應出來
                    string s_id = studentNumberToStudentIDs[dr.StudentNumber];

                    // 紀錄學生是否有學期成績,如果連學期成績都沒有,本補考成績將會無法匯入(因為不合理)
                    bool haveSemesterRecord = false;

                    foreach (JHSemesterScoreRecord jhssr in jhssr_list)
                    {
                        if (jhssr.RefStudentID == s_id)
                        {
                            haveSemesterRecord = true;

                            if (jhssr.Domains.ContainsKey(dr.Domain))
                            {
                                // 假如原本已經有補考成績,必須將之加入waring_list,讓使用者決定是否真的要覆蓋
                                if (jhssr.Domains[dr.Domain].ScoreMakeup != null)
                                {
                                    string warning = "學號:" + dr.StudentNumber + "學生,在學年度: " + SchoolYear + ",學期: " + Semester + ",領域: " + dr.Domain + "已有補考成績: " + jhssr.Domains[dr.Domain].ScoreMakeup + ",本次匯入將會將其覆蓋取代。";

                                    _duplicateMakeUpScoreList.Add(jhssr);

                                    if (!msg_DuplicatedDict.ContainsKey(s_id))
                                    {
                                        msg_DuplicatedDict.Add(s_id, warning);
                                    }
                                    else
                                    {
                                    }

                                    jhssr.Domains[dr.Domain].ScoreMakeup = dr.Score;

                                    _updateMakeUpScoreList.Add(jhssr);
                                }
                                else
                                {
                                    jhssr.Domains[dr.Domain].ScoreMakeup = dr.Score;

                                    _updateMakeUpScoreList.Add(jhssr);
                                }
                            }
                            else
                            {
                                // 2018/1/8 穎驊註解,針對假如該學生在當學期成績卻沒有其領域成績時,跳出提醒,因為正常情境是領域成績計算出來不及格,才需要補考。
                                msgList.Add("學號:" + dr.StudentNumber + "學生,在學年度:" + SchoolYear + ",學期:" + Semester + ",並無領域:" + dr.Domain + "成績,請先至學生上確認是否已有結算資料。");
                            }
                        }
                    }

                    if (!haveSemesterRecord)
                    {
                        msgList.Add("學號:" + dr.StudentNumber + "學生,在學年度:" + SchoolYear + ",學期:" + Semester + ",並無學期成績,請先至學生上確認是否已有結算資料。");
                    }
                }

                if (msgList.Count > 0)
                {
                    e.Result = msgList;
                    return;
                }

                #endregion

                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 (_duplicateMakeUpScoreList.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.ProgressChanged += delegate(object sender, ProgressChangedEventArgs e)
            //{
            //    counter += double.Parse("" + e.ProgressPercentage);
            //    FISCA.Presentation.MotherForm.SetStatusBarMessage("成績上傳中…", (int)(counter * 100f / (double)_addScoreList.Count));
            //};
            _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, "產生警告訊息...");

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

                WarningForm form  = new WarningForm();
                int         count = 0;
                foreach (JHSemesterScoreRecord sce in _duplicateMakeUpScoreList)
                {
                    form.Add(sce.RefStudentID, sce.Student.Name, msg_DuplicatedDict[sce.RefStudentID]);
                    _warn.ReportProgress((int)(count * 100 / _duplicateMakeUpScoreList.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>();
        }
コード例 #7
0
        private void BgWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            List <ClassRecord> classRecords = K12.Data.Class.SelectByIDs(ClassIDList);


            List <StudentRecord>         studentRecords    = K12.Data.Student.SelectByClassIDs(ClassIDList);
            List <JHSemesterScoreRecord> semesterScoreList = JHSemesterScore.SelectBySchoolYearAndSemester(studentRecords.Select(x => x.ID).ToList(), selSchoolYear, selSemester);

            Dictionary <string, ClassRecord> classIdToRecord = new Dictionary <string, ClassRecord>();

            //班級名稱對照
            foreach (ClassRecord cr in classRecords)
            {
                if (!classIdToRecord.ContainsKey(cr.ID))
                {
                    classIdToRecord.Add(cr.ID, cr);
                }
            }

            //學生物件整理
            List <StudentObj> stuObjs = new List <StudentObj>();

            foreach (StudentRecord s in studentRecords)
            {
                StudentObj obj = new StudentObj(s);
                obj.ClassRecord = classIdToRecord.ContainsKey(s.RefClassID) ? classIdToRecord[s.RefClassID] : new ClassRecord();
                stuObjs.Add(obj);
            }

            stuObjs.Sort(delegate(StudentObj x, StudentObj y)
            {
                string x1 = x.ClassRecord.DisplayOrder.PadLeft(3, '0');
                string xx = (x.ClassRecord.GradeYear + "").PadLeft(3, '0');
                xx       += x1 == "000" ? "999" : x1;
                xx       += x.ClassRecord.Name.PadLeft(20, '0');
                xx       += (x.StudentRecord.SeatNo + "").PadLeft(3, '0');

                string y1 = y.ClassRecord.DisplayOrder.PadLeft(3, '0');
                string yy = (y.ClassRecord.GradeYear + "").PadLeft(3, '0');
                yy       += y1 == "000" ? "999" : y1;
                yy       += y.ClassRecord.Name.PadLeft(20, '0');
                yy       += (y.StudentRecord.SeatNo + "").PadLeft(3, '0');

                return(xx.CompareTo(yy));
            });

            // 領域補對照
            Dictionary <string, Dictionary <string, DomainScore> > MakeUpDomainDic = new Dictionary <string, Dictionary <string, DomainScore> >();

            // 科目補考對照
            Dictionary <string, Dictionary <string, SubjectScore> > MakeUpSubjDic = new Dictionary <string, Dictionary <string, SubjectScore> >();

            // 處理需要補考學期成績
            foreach (JHSemesterScoreRecord JHssr in semesterScoreList)
            {
                //領域
                foreach (KeyValuePair <string, DomainScore> item in JHssr.Domains)
                {
                    if (item.Value.Score.HasValue && item.Value.Score.Value < 60)
                    {
                        if (!MakeUpDomainDic.ContainsKey(JHssr.RefStudentID))
                        {
                            MakeUpDomainDic.Add(JHssr.RefStudentID, new Dictionary <string, DomainScore>());
                        }

                        MakeUpDomainDic[JHssr.RefStudentID].Add(item.Key, item.Value);
                    }
                }

                //科目
                foreach (string subj in JHssr.Subjects.Keys)
                {
                    SubjectScore ss = JHssr.Subjects[subj];
                    if (JHssr.Subjects[subj].Score.HasValue && JHssr.Subjects[subj].Score.Value < 60)
                    {
                        if (!MakeUpSubjDic.ContainsKey(JHssr.RefStudentID))
                        {
                            MakeUpSubjDic.Add(JHssr.RefStudentID, new Dictionary <string, SubjectScore>());
                        }

                        //科目名稱不應該有重覆
                        MakeUpSubjDic[JHssr.RefStudentID].Add(subj, ss);
                    }
                }
            }

            // templae
            Workbook  wb     = null;
            Worksheet wst    = null;
            int       rowIdx = 1;

            // 使用領域
            if (userSelectDoamin)
            {
                wb     = new Workbook(new MemoryStream(Properties.Resources.匯出學期領域成績_領域));
                wst    = wb.Worksheets[0];
                rowIdx = 1;

                if (MakeUpDomainDic.Count > 0)
                {
                    foreach (StudentObj so in stuObjs)
                    {
                        //只列印一般生
                        if (so.StudentRecord.Status != StudentRecord.StudentStatus.一般)
                        {
                            continue;
                        }

                        if (MakeUpDomainDic.ContainsKey(so.StudentRecord.ID))
                        {
                            foreach (string dName in MakeUpDomainDic[so.StudentRecord.ID].Keys)
                            {
                                // 學號 0
                                wst.Cells[rowIdx, 0].PutValue(so.StudentRecord.StudentNumber);

                                // 班級 1
                                wst.Cells[rowIdx, 1].PutValue(so.ClassRecord.Name);

                                // 座號 2
                                if (so.StudentRecord.SeatNo.HasValue)
                                {
                                    wst.Cells[rowIdx, 2].PutValue(so.StudentRecord.SeatNo.Value);
                                }

                                // 姓名 3
                                wst.Cells[rowIdx, 3].PutValue(so.StudentRecord.Name);

                                // 領域 4
                                wst.Cells[rowIdx, 4].PutValue(dName);
                                // 學年度 5
                                wst.Cells[rowIdx, 5].PutValue(selSchoolYear);

                                // 學期 6
                                wst.Cells[rowIdx, 6].PutValue(selSemester);

                                // 補考成績 7
                                if (MakeUpDomainDic[so.StudentRecord.ID][dName].ScoreMakeup.HasValue)
                                {
                                    wst.Cells[rowIdx, 7].PutValue(MakeUpDomainDic[so.StudentRecord.ID][dName].ScoreMakeup.Value);
                                }

                                rowIdx++;
                            }
                        }
                    }
                }
                e.Result = wb;
            }
            else
            {
                wb     = new Workbook(new MemoryStream(Properties.Resources.匯出學期科目成績_科目));
                wst    = wb.Worksheets[0];
                rowIdx = 1;

                if (MakeUpSubjDic.Count > 0)
                {
                    foreach (StudentObj so in stuObjs)
                    {
                        //只列印一般生
                        if (so.StudentRecord.Status != StudentRecord.StudentStatus.一般)
                        {
                            continue;
                        }

                        if (MakeUpSubjDic.ContainsKey(so.StudentRecord.ID))
                        {
                            foreach (string sName in MakeUpSubjDic[so.StudentRecord.ID].Keys)
                            {
                                // 學號 0
                                wst.Cells[rowIdx, 0].PutValue(so.StudentRecord.StudentNumber);

                                // 班級 1
                                wst.Cells[rowIdx, 1].PutValue(so.ClassRecord.Name);

                                // 座號 2
                                if (so.StudentRecord.SeatNo.HasValue)
                                {
                                    wst.Cells[rowIdx, 2].PutValue(so.StudentRecord.SeatNo.Value);
                                }

                                // 姓名 3
                                wst.Cells[rowIdx, 3].PutValue(so.StudentRecord.Name);

                                // 領域 4
                                wst.Cells[rowIdx, 4].PutValue(MakeUpSubjDic[so.StudentRecord.ID][sName].Domain);

                                // 科目 5
                                wst.Cells[rowIdx, 5].PutValue(MakeUpSubjDic[so.StudentRecord.ID][sName].Subject);

                                // 學年度 6
                                wst.Cells[rowIdx, 6].PutValue(selSchoolYear);

                                // 學期 7
                                wst.Cells[rowIdx, 7].PutValue(selSemester);

                                // 補考成績 8
                                if (MakeUpSubjDic[so.StudentRecord.ID][sName].ScoreMakeup.HasValue)
                                {
                                    wst.Cells[rowIdx, 8].PutValue(MakeUpSubjDic[so.StudentRecord.ID][sName].ScoreMakeup.Value);
                                }

                                rowIdx++;
                            }
                        }
                    }
                }

                e.Result = wb;
            }
        }
コード例 #8
0
        private void MasterWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            //1.Goup By 可選擇的科目清單。
            //2.寫入成績資料到 ReportStudent 上。

            int schoolYear = Semester.SelectedSchoolYear;
            int semester   = Semester.SelectedSemester;
            FunctionSpliter <string, JHSemesterScoreRecord> selectData = new FunctionSpliter <string, JHSemesterScoreRecord>(1000, 5);

            selectData.Function = delegate(List <string> ps)
            {
                return(JHSemesterScore.SelectBySchoolYearAndSemester(ps, schoolYear, semester));
            };
            List <JHSemesterScoreRecord> semsScores = selectData.Execute(AllStudents.ToKeys());

            GroupBySubjects(semsScores);

            //先把學生身上的成績、排名相關資料清掉。
            foreach (ReportStudent each in AllStudents)
            {
                each.Clear();
                each.Scores.Add(Utilities.SubjectToken, new ScoreCollection()); //科目成績。
                each.Scores.Add(Utilities.DomainToken, new ScoreCollection());  //領域成績。
                each.Scores.Add(Utilities.SummaryToken, new ScoreCollection()); //運算後的成績。
            }

            //將成績填到學生身上。
            Dictionary <string, ReportStudent> dicAllStudent = AllStudents.ToDictionary();

            foreach (JHSemesterScoreRecord eachScore in semsScores)
            {
                //如果找不到該學生,跳到下一筆。
                if (!dicAllStudent.ContainsKey(eachScore.RefStudentID))
                {
                    continue;
                }

                ReportStudent student = dicAllStudent[eachScore.RefStudentID];

                //科目成績。
                foreach (SubjectScore each in eachScore.Subjects.Values)
                {
                    if (!each.Score.HasValue)
                    {
                        continue;                       //沒有分數不處理。
                    }
                    if (!each.Credit.HasValue || each.Credit.Value <= 0)
                    {
                        continue;                                                   //沒有節數不處理。
                    }
                    if (!student.Scores[Utilities.SubjectToken].Contains(each.Subject))
                    {
                        student.Scores[Utilities.SubjectToken].Add(each.Subject, each.Score.Value, each.Credit.Value);
                    }
                }

                //領域成績。
                foreach (DomainScore each in eachScore.Domains.Values)
                {
                    if (!each.Score.HasValue)
                    {
                        continue;
                    }
                    if (!each.Credit.HasValue || each.Credit.Value <= 0)
                    {
                        continue;
                    }

                    student.Scores[Utilities.DomainToken].Add(each.Domain, each.Score.Value, each.Credit.Value);
                }

                //運算後成績是在使用者按下列印時才計算。
                //因為需要依據使用者選擇的科目進行計算。
            }
        }
コード例 #9
0
ファイル: Global.cs プロジェクト: ischoolinc/JHEvaluation
        /// <summary>
        /// 匯出合併欄位總表Word
        /// </summary>
        public static void ExportMappingFieldWord()
        {
            #region 儲存檔案
            string inputReportName = "學期成績單合併欄位總表";
            string reportName      = inputReportName;

            string path = Path.Combine(System.Windows.Forms.Application.StartupPath, "Reports");
            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            path = Path.Combine(path, reportName + ".doc");

            if (File.Exists(path))
            {
                int i = 1;
                while (true)
                {
                    string newPath = Path.GetDirectoryName(path) + "\\" + Path.GetFileNameWithoutExtension(path) + (i++) + Path.GetExtension(path);
                    if (!File.Exists(newPath))
                    {
                        path = newPath;
                        break;
                    }
                }
            }

            Document tempDoc = new Document(new MemoryStream(Properties.Resources.學期成績單合併欄位總表));

            try
            {
                #region 動態產生合併欄位
                // 讀取總表檔案並動態加入合併欄位
                Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(tempDoc);
                builder.MoveToDocumentEnd();

                List <string> plist = K12.Data.PeriodMapping.SelectAll().Select(x => x.Type).Distinct().ToList();
                List <string> alist = K12.Data.AbsenceMapping.SelectAll().Select(x => x.Name).ToList();
                builder.Writeln();
                builder.Writeln();
                builder.Writeln("缺曠動態產生合併欄位");
                builder.StartTable();

                builder.InsertCell();
                builder.Write("缺曠名稱與合併欄位");
                builder.EndRow();

                foreach (string pp in plist)
                {
                    foreach (string aa in alist)
                    {
                        string key = pp.Replace(" ", "_") + "_" + aa.Replace(" ", "_");

                        builder.InsertCell();
                        builder.Write(key);
                        builder.InsertCell();
                        builder.InsertField("MERGEFIELD " + key + " \\* MERGEFORMAT ", "«" + key + "»");
                        builder.EndRow();
                    }
                }

                builder.EndTable();

                builder.Writeln();
                builder.Writeln("缺曠總計(不分節次類型)合併欄位");
                builder.StartTable();

                foreach (string aa in alist)
                {
                    string key = aa.Replace(" ", "_") + "總計";
                    builder.InsertCell();
                    builder.Write(key);
                    builder.InsertCell();
                    builder.InsertField("MERGEFIELD " + key + " \\* MERGEFORMAT ", "«" + key + "»");
                    builder.EndRow();
                }
                builder.EndTable();


                // 日常生活表現
                builder.Writeln();
                builder.Writeln();
                builder.Writeln("日常生活表現評量");
                builder.StartTable();
                builder.InsertCell();
                builder.Write("分類");
                builder.InsertCell();
                builder.Write("名稱");
                builder.InsertCell();
                builder.Write("建議內容");
                builder.EndRow();

                foreach (string key in DLBehaviorRef.Keys)
                {
                    builder.InsertCell();
                    builder.Write(key);
                    builder.InsertCell();
                    builder.InsertField("MERGEFIELD " + key + "_Name" + " \\* MERGEFORMAT ", "«" + key + "名稱»");
                    builder.InsertCell();
                    // 新竹版沒有
                    if (key != "日常生活表現程度")
                    {
                        builder.InsertField("MERGEFIELD " + key + "_Description" + " \\* MERGEFORMAT ", "«" + key + "建議內容»");
                    }

                    builder.EndRow();
                }
                builder.EndTable();

                // 日常生活表現
                builder.Writeln();
                builder.Writeln();
                builder.Writeln("日常生活表現評量子項目");
                builder.StartTable();
                builder.InsertCell();
                builder.Write("項目");
                builder.InsertCell();
                builder.Write("指標");
                builder.InsertCell();
                builder.Write("表現程度");
                builder.EndRow();

                for (int i = 1; i <= 7; i++)
                {
                    builder.InsertCell();
                    builder.InsertField("MERGEFIELD " + "日常生活表現程度_Item_Name" + i + " \\* MERGEFORMAT ", "«項目" + i + "»");
                    builder.InsertCell();
                    builder.InsertField("MERGEFIELD " + "日常生活表現程度_Item_Index" + i + " \\* MERGEFORMAT ", "«指標" + i + "»");
                    builder.InsertCell();
                    builder.InsertField("MERGEFIELD " + "日常生活表現程度_Item_Degree" + i + " \\* MERGEFORMAT ", "«表現" + i + "»");
                    builder.EndRow();
                }

                builder.EndTable();



                // 動態計算領域
                List <JHSemesterScoreRecord> SemesterScoreRecordList = JHSemesterScore.SelectBySchoolYearAndSemester(_SelStudentIDList, _SelSchoolYear, _SelSemester);

                // 領域名稱
                List <string> DomainNameList = new List <string>();

                foreach (JHSemesterScoreRecord SemsScore in SemesterScoreRecordList)
                {
                    foreach (string dn in SemsScore.Domains.Keys)
                    {
                        if (!DomainNameList.Contains(dn))
                        {
                            DomainNameList.Add(dn);
                        }
                    }
                }
                DomainNameList.Sort(new StringComparer("語文", "數學", "社會", "自然與生活科技", "健康與體育", "藝術與人文", "綜合活動"));
                DomainNameList.Add("彈性課程");

                List <string> m1  = new List <string>();
                List <string> m2a = new List <string>();
                List <string> m2b = new List <string>();

                m1.Add("班排名");
                m1.Add("年排名");
                m1.Add("類別1排名");
                m1.Add("類別2排名");

                m2a.Add("rank");
                m2a.Add("matrix_count");
                m2a.Add("pr");
                m2a.Add("percentile");
                m2a.Add("avg_top_25");
                m2a.Add("avg_top_50");
                m2a.Add("avg");
                m2a.Add("avg_bottom_50");
                m2a.Add("avg_bottom_25");
                m2a.Add("pr_88");
                m2a.Add("pr_75");
                m2a.Add("pr_50");
                m2a.Add("pr_25");
                m2a.Add("pr_12");
                m2a.Add("std_dev_pop");
                m2b.Add("level_gte100");
                m2b.Add("level_90");
                m2b.Add("level_80");
                m2b.Add("level_70");
                m2b.Add("level_60");
                m2b.Add("level_50");
                m2b.Add("level_40");
                m2b.Add("level_30");
                m2b.Add("level_20");
                m2b.Add("level_10");
                m2b.Add("level_lt10");


                // 領域排名 排名、母數、五標
                foreach (string dName in DomainNameList)
                {
                    builder.Writeln();
                    builder.Writeln();
                    string dn = dName + "領域成績排名 排名、母數、五標";
                    builder.Writeln(dn);
                    builder.StartTable();
                    builder.InsertCell();
                    builder.Write("名稱");
                    builder.InsertCell();
                    builder.Write("排名");
                    builder.InsertCell();
                    builder.Write("排名母數");
                    builder.InsertCell();
                    builder.Write("PR");
                    builder.InsertCell();
                    builder.Write("百分比");
                    builder.InsertCell();
                    builder.Write("頂標");
                    builder.InsertCell();
                    builder.Write("高標");
                    builder.InsertCell();
                    builder.Write("均標");
                    builder.InsertCell();
                    builder.Write("低標");
                    builder.InsertCell();
                    builder.Write("底標");
                    builder.InsertCell();
                    builder.Write("新頂標");
                    builder.InsertCell();
                    builder.Write("新前標");
                    builder.InsertCell();
                    builder.Write("新均標");
                    builder.InsertCell();
                    builder.Write("新後標");
                    builder.InsertCell();
                    builder.Write("新底標");
                    builder.InsertCell();
                    builder.Write("標準差");
                    builder.EndRow();
                    foreach (string m in m1)
                    {
                        builder.InsertCell();
                        builder.Write(m);
                        foreach (string nn in m2a)
                        {
                            string dd = dName + "領域成績_" + m + "_" + nn;
                            builder.InsertCell();
                            builder.InsertField("MERGEFIELD " + dd + " \\* MERGEFORMAT ", "«R»");
                        }
                        builder.EndRow();
                    }

                    builder.EndTable();
                }


                // 領域(原始)排名 排名、母數、五標
                foreach (string dName in DomainNameList)
                {
                    builder.Writeln();
                    builder.Writeln();
                    string dn = dName + "領域成績(原始)排名 排名、母數、五標";
                    builder.Writeln(dn);
                    builder.StartTable();
                    builder.InsertCell();
                    builder.Write("名稱");
                    builder.InsertCell();
                    builder.Write("排名");
                    builder.InsertCell();
                    builder.Write("排名母數");
                    builder.InsertCell();
                    builder.Write("PR");
                    builder.InsertCell();
                    builder.Write("百分比");
                    builder.InsertCell();
                    builder.Write("頂標");
                    builder.InsertCell();
                    builder.Write("高標");
                    builder.InsertCell();
                    builder.Write("均標");
                    builder.InsertCell();
                    builder.Write("低標");
                    builder.InsertCell();
                    builder.Write("底標");
                    builder.InsertCell();
                    builder.Write("新頂標");
                    builder.InsertCell();
                    builder.Write("新前標");
                    builder.InsertCell();
                    builder.Write("新均標");
                    builder.InsertCell();
                    builder.Write("新後標");
                    builder.InsertCell();
                    builder.Write("新底標");
                    builder.InsertCell();
                    builder.Write("標準差");
                    builder.EndRow();
                    foreach (string m in m1)
                    {
                        builder.InsertCell();
                        builder.Write(m);
                        foreach (string nn in m2a)
                        {
                            string dd = dName + "領域成績(原始)_" + m + "_" + nn;
                            builder.InsertCell();
                            builder.InsertField("MERGEFIELD " + dd + " \\* MERGEFORMAT ", "«R»");
                        }
                        builder.EndRow();
                    }

                    builder.EndTable();
                }


                // 領域排名 組距
                foreach (string dName in DomainNameList)
                {
                    builder.Writeln();
                    builder.Writeln();
                    string dn = dName + "領域成績排名 組距";
                    builder.Writeln(dn);
                    builder.StartTable();
                    builder.InsertCell();
                    builder.Write("名稱");
                    builder.InsertCell();
                    builder.Write("100以上");
                    builder.InsertCell();
                    builder.Write("90以上小於100");
                    builder.InsertCell();
                    builder.Write("80以上小於90");
                    builder.InsertCell();
                    builder.Write("70以上小於80");
                    builder.InsertCell();
                    builder.Write("60以上小於70");
                    builder.InsertCell();
                    builder.Write("50以上小於60");
                    builder.InsertCell();
                    builder.Write("40以上小於50");
                    builder.InsertCell();
                    builder.Write("30以上小於40");
                    builder.InsertCell();
                    builder.Write("20以上小於30");
                    builder.InsertCell();
                    builder.Write("10以上小於20");
                    builder.InsertCell();
                    builder.Write("10以下");
                    builder.EndRow();
                    foreach (string m in m1)
                    {
                        builder.InsertCell();
                        builder.Write(m);
                        foreach (string nn in m2b)
                        {
                            string dd = dName + "領域成績_" + m + "_" + nn;
                            builder.InsertCell();
                            builder.InsertField("MERGEFIELD " + dd + " \\* MERGEFORMAT ", "«R»");
                        }
                        builder.EndRow();
                    }

                    builder.EndTable();
                }

                // 領域排名(原始) 組距
                foreach (string dName in DomainNameList)
                {
                    builder.Writeln();
                    builder.Writeln();
                    string dn = dName + "領域成績(原始)排名 組距";
                    builder.Writeln(dn);
                    builder.StartTable();
                    builder.InsertCell();
                    builder.Write("名稱");
                    builder.InsertCell();
                    builder.Write("100以上");
                    builder.InsertCell();
                    builder.Write("90以上小於100");
                    builder.InsertCell();
                    builder.Write("80以上小於90");
                    builder.InsertCell();
                    builder.Write("70以上小於80");
                    builder.InsertCell();
                    builder.Write("60以上小於70");
                    builder.InsertCell();
                    builder.Write("50以上小於60");
                    builder.InsertCell();
                    builder.Write("40以上小於50");
                    builder.InsertCell();
                    builder.Write("30以上小於40");
                    builder.InsertCell();
                    builder.Write("20以上小於30");
                    builder.InsertCell();
                    builder.Write("10以上小於20");
                    builder.InsertCell();
                    builder.Write("10以下");
                    builder.EndRow();
                    foreach (string m in m1)
                    {
                        builder.InsertCell();
                        builder.Write(m);
                        foreach (string nn in m2b)
                        {
                            string dd = dName + "領域成績(原始)_" + m + "_" + nn;
                            builder.InsertCell();
                            builder.InsertField("MERGEFIELD " + dd + " \\* MERGEFORMAT ", "«R»");
                        }
                        builder.EndRow();
                    }

                    builder.EndTable();
                }

                // 領域-科目排名 排名、母數、五標
                foreach (string dName in DomainNameList)
                {
                    builder.Writeln();
                    builder.Writeln();
                    string dn = dName + "領域-科目成績排名 排名、母數、五標";
                    builder.Writeln(dn);
                    builder.StartTable();
                    foreach (string m in m1)
                    {
                        builder.Writeln(m);
                        builder.InsertCell();
                        builder.Write("名稱");
                        builder.InsertCell();
                        builder.Write("排名");
                        builder.InsertCell();
                        builder.Write("排名母數");
                        builder.InsertCell();
                        builder.Write("PR");
                        builder.InsertCell();
                        builder.Write("百分比");
                        builder.InsertCell();
                        builder.Write("頂標");
                        builder.InsertCell();
                        builder.Write("高標");
                        builder.InsertCell();
                        builder.Write("均標");
                        builder.InsertCell();
                        builder.Write("低標");
                        builder.InsertCell();
                        builder.Write("底標");
                        builder.InsertCell();
                        builder.Write("新頂標");
                        builder.InsertCell();
                        builder.Write("新前標");
                        builder.InsertCell();
                        builder.Write("新均標");
                        builder.InsertCell();
                        builder.Write("新後標");
                        builder.InsertCell();
                        builder.Write("新底標");
                        builder.InsertCell();
                        builder.Write("標準差");
                        builder.EndRow();

                        for (int i = 1; i <= 12; i++)
                        {
                            builder.InsertCell();
                            string dsn = dName + "_科目排名名稱" + i;
                            builder.InsertField("MERGEFIELD " + dsn + " \\* MERGEFORMAT ", "«N" + i + "»");
                            foreach (string nn in m2a)
                            {
                                string dd = dName + "_科目成績" + i + "_" + m + "_" + nn;
                                builder.InsertCell();
                                builder.InsertField("MERGEFIELD " + dd + " \\* MERGEFORMAT ", "«R" + i + "»");
                            }
                            builder.EndRow();
                        }
                    }

                    builder.EndTable();
                }

                // 領域-科目排名 排名、母數、五標
                foreach (string dName in DomainNameList)
                {
                    builder.Writeln();
                    builder.Writeln();
                    string dn = dName + "領域-科目成績(原始)排名 排名、母數、五標";
                    builder.Writeln(dn);
                    builder.StartTable();
                    foreach (string m in m1)
                    {
                        builder.Writeln(m);
                        builder.InsertCell();
                        builder.Write("名稱");
                        builder.InsertCell();
                        builder.Write("排名");
                        builder.InsertCell();
                        builder.Write("排名母數");
                        builder.InsertCell();
                        builder.Write("PR");
                        builder.InsertCell();
                        builder.Write("百分比");
                        builder.InsertCell();
                        builder.Write("頂標");
                        builder.InsertCell();
                        builder.Write("高標");
                        builder.InsertCell();
                        builder.Write("均標");
                        builder.InsertCell();
                        builder.Write("低標");
                        builder.InsertCell();
                        builder.Write("底標");
                        builder.InsertCell();
                        builder.Write("新頂標");
                        builder.InsertCell();
                        builder.Write("新前標");
                        builder.InsertCell();
                        builder.Write("新均標");
                        builder.InsertCell();
                        builder.Write("新後標");
                        builder.InsertCell();
                        builder.Write("新底標");
                        builder.InsertCell();
                        builder.Write("標準差");
                        builder.EndRow();

                        for (int i = 1; i <= 12; i++)
                        {
                            builder.InsertCell();
                            string dsn = dName + "_科目排名名稱" + i;
                            builder.InsertField("MERGEFIELD " + dsn + " \\* MERGEFORMAT ", "«N" + i + "»");
                            foreach (string nn in m2a)
                            {
                                string dd = dName + "_科目成績(原始)" + i + "_" + m + "_" + nn;
                                builder.InsertCell();
                                builder.InsertField("MERGEFIELD " + dd + " \\* MERGEFORMAT ", "«R" + i + "»");
                            }
                            builder.EndRow();
                        }
                    }

                    builder.EndTable();
                }

                // 領域-科目排名 組距
                foreach (string dName in DomainNameList)
                {
                    builder.Writeln();
                    builder.Writeln();
                    string dn = dName + "領域-科目成績排名 組距";
                    builder.Writeln(dn);
                    builder.StartTable();
                    foreach (string m in m1)
                    {
                        builder.Writeln(m);
                        builder.InsertCell();
                        builder.Write("名稱");
                        builder.InsertCell();
                        builder.Write("100以上");
                        builder.InsertCell();
                        builder.Write("90以上小於100");
                        builder.InsertCell();
                        builder.Write("80以上小於90");
                        builder.InsertCell();
                        builder.Write("70以上小於80");
                        builder.InsertCell();
                        builder.Write("60以上小於70");
                        builder.InsertCell();
                        builder.Write("50以上小於60");
                        builder.InsertCell();
                        builder.Write("40以上小於50");
                        builder.InsertCell();
                        builder.Write("30以上小於40");
                        builder.InsertCell();
                        builder.Write("20以上小於30");
                        builder.InsertCell();
                        builder.Write("10以上小於20");
                        builder.InsertCell();
                        builder.Write("10以下");
                        builder.EndRow();

                        for (int i = 1; i <= 12; i++)
                        {
                            builder.InsertCell();
                            string dsn = dName + "_科目排名名稱" + i;
                            builder.InsertField("MERGEFIELD " + dsn + " \\* MERGEFORMAT ", "«N" + i + "»");
                            foreach (string nn in m2b)
                            {
                                string dd = dName + "_科目成績" + i + "_" + m + "_" + nn;
                                builder.InsertCell();
                                builder.InsertField("MERGEFIELD " + dd + " \\* MERGEFORMAT ", "«R" + i + "»");
                            }
                            builder.EndRow();
                        }
                    }

                    builder.EndTable();
                }

                // 領域-科目(原始)排名 組距
                foreach (string dName in DomainNameList)
                {
                    builder.Writeln();
                    builder.Writeln();
                    string dn = dName + "領域-科目成績(原始)排名 組距";
                    builder.Writeln(dn);
                    builder.StartTable();
                    foreach (string m in m1)
                    {
                        builder.Writeln(m);
                        builder.InsertCell();
                        builder.Write("名稱");
                        builder.InsertCell();
                        builder.Write("100以上");
                        builder.InsertCell();
                        builder.Write("90以上小於100");
                        builder.InsertCell();
                        builder.Write("80以上小於90");
                        builder.InsertCell();
                        builder.Write("70以上小於80");
                        builder.InsertCell();
                        builder.Write("60以上小於70");
                        builder.InsertCell();
                        builder.Write("50以上小於60");
                        builder.InsertCell();
                        builder.Write("40以上小於50");
                        builder.InsertCell();
                        builder.Write("30以上小於40");
                        builder.InsertCell();
                        builder.Write("20以上小於30");
                        builder.InsertCell();
                        builder.Write("10以上小於20");
                        builder.InsertCell();
                        builder.Write("10以下");
                        builder.EndRow();

                        for (int i = 1; i <= 12; i++)
                        {
                            builder.InsertCell();
                            string dsn = dName + "_科目排名名稱" + i;
                            builder.InsertField("MERGEFIELD " + dsn + " \\* MERGEFORMAT ", "«N" + i + "»");
                            foreach (string nn in m2b)
                            {
                                string dd = dName + "_科目成績(原始)" + i + "_" + m + "_" + nn;
                                builder.InsertCell();
                                builder.InsertField("MERGEFIELD " + dd + " \\* MERGEFORMAT ", "«R" + i + "»");
                            }
                            builder.EndRow();
                        }
                    }

                    builder.EndTable();
                }

                #endregion
                tempDoc.Save(path, SaveFormat.Doc);

                System.Diagnostics.Process.Start(path);
            }
            catch
            {
                System.Windows.Forms.SaveFileDialog sd = new System.Windows.Forms.SaveFileDialog();
                sd.Title    = "另存新檔";
                sd.FileName = reportName + ".doc";
                sd.Filter   = "Word檔案 (*.doc)|*.doc|所有檔案 (*.*)|*.*";
                if (sd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    try
                    {
                        tempDoc.Save(sd.FileName, SaveFormat.Doc);
                    }
                    catch
                    {
                        FISCA.Presentation.Controls.MsgBox.Show("指定路徑無法存取。", "建立檔案失敗", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                        return;
                    }
                }
            }
            #endregion
        }