Example #1
0
        private void 修改學年度學期ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            List<DisciplineRecord> list = new List<DisciplineRecord>();
            foreach (DataGridViewRow row in dataGridViewX1.SelectedRows)
            {
                DisciplineRecord jhd = (DisciplineRecord)row.Tag;
                list.Add(jhd);
            }

            SetValueSchoolYearSemester ssy = new SetValueSchoolYearSemester();
            DialogResult dr = ssy.ShowDialog();
            if (dr == System.Windows.Forms.DialogResult.Yes)
            {
                StringBuilder sb = new StringBuilder();
                sb.AppendLine("已進行批次修改獎懲資料之學年度/學期:");
                sb.AppendLine(string.Format("以下所選取資料已指定為學年度「{0}」學期「{1}」", ssy._schoolYear.ToString(), ssy._semester.ToString()));

                foreach (DisciplineRecord each in list)
                {
                    if (each.MeritFlag == "0")
                    {
                        sb.Append("懲戒資料:");
                        sb.Append("學生「" + each.Student.Name + "」");
                        sb.Append("懲戒日期「" + each.OccurDate.ToShortDateString() + "」");
                        sb.Append("原學年「" + each.SchoolYear.ToString() + "」");
                        sb.AppendLine("原學期「" + each.Semester.ToString() + "」");
                    }
                    else if (each.MeritFlag == "1")
                    {
                        sb.Append("獎勵資料:");
                        sb.Append("學生「" + each.Student.Name + "」");
                        sb.Append("獎勵日期「" + each.OccurDate.ToShortDateString() + "」");
                        sb.Append("原學年「" + each.SchoolYear.ToString() + "」");
                        sb.AppendLine("原學期「" + each.Semester.ToString() + "」");
                    }

                    each.SchoolYear = ssy._schoolYear;
                    each.Semester = ssy._semester;
                }
                Discipline.Update(list);

                ApplicationLog.Log("獎懲批次修改", "更新", sb.ToString());

                FISCA.Presentation.Controls.MsgBox.Show("儲存成功!");
                btnRefresh_Click(null, null);
            }
            else
            {
                FISCA.Presentation.Controls.MsgBox.Show("未修改!");
            }
        }
Example #2
0
        private bool CheckMerit(DisciplineRecord JH, List<string> li)
        {
            #region 處理資料是否顯示
            List<string> st = new List<string>();
            st.Clear();

            if (JH.MeritFlag == "1")
            {
                if (JH.MeritA > 0)
                {
                    st.Add("大功");
                }
                if (JH.MeritB > 0)
                {
                    st.Add("小功");
                }
                if (JH.MeritC > 0)
                {
                    st.Add("嘉獎");
                }
            }
            else if (JH.MeritFlag == "0")
            {
                if (JH.DemeritA > 0)
                {
                    st.Add("大過");
                }
                if (JH.DemeritB > 0)
                {
                    st.Add("小過");
                }
                if (JH.DemeritC > 0)
                {
                    st.Add("警告");
                }
            }

            foreach (string each in st)
            {
                if (li.Contains(each))
                {
                    return false; //傳出false就是包含內容
                }
            }
            return true;
            #endregion
        }
Example #3
0
        private void 批次增加前置詞ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            List<DisciplineRecord> list = new List<DisciplineRecord>();
            foreach (DataGridViewRow row in dataGridViewX1.SelectedRows)
            {
                DisciplineRecord jhd = (DisciplineRecord)row.Tag;
                list.Add(jhd);
            }

            ChangeResonBatch ssy = new ChangeResonBatch(list);
            DialogResult dr = ssy.ShowDialog();

            if (dr == System.Windows.Forms.DialogResult.Yes)
            {
                btnRefresh_Click(null, null); //更新畫面資料
            }
        }
Example #4
0
        //排序
        private int SortByClassAndSeatNo(DisciplineRecord attendX, DisciplineRecord attendy)
        {
            StudentRecord x = attendX.Student;
            StudentRecord y = attendy.Student;
            string 班級名稱1 = (x.Class == null ? "" : x.Class.Name) + "::";
            string 座號1 = (x.SeatNo.HasValue ? x.SeatNo.Value.ToString().PadLeft(2, '0') : "") + "::";
            string 班級名稱2 = (y.Class == null ? "" : y.Class.Name) + "::";
            string 座號2 = (y.SeatNo.HasValue ? y.SeatNo.Value.ToString().PadLeft(2, '0') : "") + "::";
            string 日期1 = attendX.OccurDate.ToShortDateString();
            string 日期2 = attendy.OccurDate.ToShortDateString();
            班級名稱1 += 座號1;
            班級名稱1 += 日期1;

            班級名稱2 += 座號2;
            班級名稱2 += 日期2;

            return 班級名稱1.CompareTo(班級名稱2);
        }
Example #5
0
        //private string ChengTime(DateTime dt)
        //{
        //    int x = dt.ToString().IndexOf(' ');
        //    string y = dt.ToString().Remove(x);
        //    return y;
        //}

        //private bool IsDateTime(string date)
        //{

        //    DateTime try_value;
        //    if (DateTime.TryParse(date, out try_value))
        //        return true;
        //    return false;
        //}
        #endregion

        private string GetDisciplineString(DisciplineRecord JHDRecord)
        {
            #region 獎懲判斷
            string result = "";
            if (JHDRecord.MeritFlag == "1")
            {
                if (JHDRecord.MeritA > 0)
                {
                    result += string.Format("大功:{0}", JHDRecord.MeritA);
                }

                if (JHDRecord.MeritB > 0)
                {
                    result += string.Format("小功:{0}", JHDRecord.MeritB);
                }

                if (JHDRecord.MeritC > 0)
                {
                    result += string.Format("嘉獎:{0}", JHDRecord.MeritC);
                }
            }
            else if (JHDRecord.MeritFlag == "0")
            {
                if (JHDRecord.Cleared == "是")
                    return "";

                if (JHDRecord.DemeritA > 0)
                {
                    result += string.Format("大過:{0}", JHDRecord.DemeritA);
                }

                if (JHDRecord.DemeritB > 0)
                {
                    result += string.Format("小過:{0}", JHDRecord.DemeritB);
                }

                if (JHDRecord.DemeritC > 0)
                {
                    result += string.Format("警告:{0}", JHDRecord.DemeritC);
                }
            }
            else if (JHDRecord.MeritFlag == "2")
            {
                result = ""; //暫時無留校察看
                //result = "留校察看";
            }

            return result;


            //if (dis.GetText("MeritFlag") == "1") //獎勵
            //{

            //    try
            //    {
            //        XmlElement merit = dis.GetElement("Detail/Discipline/Merit");
            //        if (merit == null)
            //            return "";

            //        int a, b, c;
            //        if (int.TryParse(merit.GetAttribute("A"), out a) && a > 0)
            //        {
            //            result += string.Format("大功:{0}", a);
            //        }

            //        if (int.TryParse(merit.GetAttribute("B"), out b) && b > 0)
            //        {
            //            if (!string.IsNullOrEmpty(result)) result += ",";
            //            result += string.Format("小功:{0}", b);
            //        }

            //        if (int.TryParse(merit.GetAttribute("C"), out c) && c > 0)
            //        {
            //            if (!string.IsNullOrEmpty(result)) result += ",";
            //            result += string.Format("嘉獎:{0}", c);
            //        }
            //    }
            //    catch
            //    {

            //    }

            //}
            //else if (dis.GetText("MeritFlag") == "0") //懲戒
            //{
            //    try
            //    {

            //        //XmlElement demerit = dis.GetElement("Detail/Discipline/Demerit");

            //        //如果Cleared==是,此筆資料忽略
            //        XmlElement demerit = dis.GetElement("Detail/Discipline/Demerit[@Cleared!='是']");
            //        if (demerit == null)
            //            return "";

            //        int a, b, c;
            //        if (int.TryParse(demerit.GetAttribute("A"), out a) && a > 0)
            //        {
            //            result += string.Format("大過:{0}", a);
            //        }
            //        if (int.TryParse(demerit.GetAttribute("B"), out b) && b > 0)
            //        {
            //            if (!string.IsNullOrEmpty(result)) result += ",";
            //            result += string.Format("小過:{0}", b);
            //        }
            //        if (int.TryParse(demerit.GetAttribute("C"), out c) && c > 0)
            //        {
            //            if (!string.IsNullOrEmpty(result)) result += ",";
            //            result += string.Format("警告:{0}", c);
            //        }
            //    }
            //    catch
            //    {

            //    }


            //}
            //else if (dis.GetText("MeritFlag") == "2")
            //{
            //    result = "留校察看";
            //}
            #endregion
        }
        //核可按鈕
        private void btnModify_Click(object sender, EventArgs e)
        {
            int approvedCount = 0, notApprovedCount = 0;

            foreach (DataGridViewRow row in dataGridViewX1.Rows)
            {
                if ((string)row.Cells[colApproved.Index].Value == "可")
                {
                    approvedCount++;
                }
                else if ((string)row.Cells[colApproved.Index].Value == "不可")
                {
                    notApprovedCount++;
                }
            }
            if ((approvedCount + notApprovedCount) == 0)
            {
                return;
            }
            List <string> msg = new List <string>();

            msg.Add("請確認是否儲存以下資料:");
            msg.Add("核可 :\t" + approvedCount + " 筆");
            msg.Add("不核可:\t" + notApprovedCount + " 筆");
            msg.Add("共  :\t" + (approvedCount + notApprovedCount) + " 筆");
            if (dataGridViewX1.Rows.Count == 0 || MsgBox.Show(string.Join("\n", msg), MessageBoxButtons.YesNo, MessageBoxDefaultButton.Button2) == System.Windows.Forms.DialogResult.No)
            {
                return;
            }
            List <DisciplineRecord>        drl  = new List <DisciplineRecord>();
            List <DisciplineRequestRecord> drrl = new List <DisciplineRequestRecord>();
            List <string> log = new List <string>();

            log.Add("學生編號,日期,理由,登錄日期,學年度,學期,類別,大功數,小功數,獎勵數,大過數,小過數,警告數");
            List <string> log2 = new List <string>();

            log2.Add("學生編號,老師編號,日期,理由,類別,大功數,小功數,獎勵數,大過數,小過數,警告數,審查回覆");
            foreach (DataGridViewRow item in dataGridViewX1.Rows)
            {
                DisciplineRequestRecord drr = item.Tag as DisciplineRequestRecord;

                drr.ReturnMessage = "" + item.Cells[8].Value;
                if ((string)item.Cells[9].Value == "可")
                {
                    drr.Status = "1";
                    DisciplineRecord dr = new DisciplineRecord();
                    dr.MeritFlag    = "" + drr.MeritFlag;
                    dr.OccurDate    = drr.OccurDate;
                    dr.Reason       = drr.Reason;
                    dr.RefStudentID = "" + drr.RefStudentId;
                    dr.RegisterDate = DateTime.Now;
                    dr.SchoolYear   = int.Parse(School.DefaultSchoolYear);
                    dr.Semester     = int.Parse(School.DefaultSemester);
                    dr.MeritA       = drr.MeritA;
                    dr.MeritB       = drr.MeritB;
                    dr.MeritC       = drr.MeritC;
                    dr.DemeritA     = drr.DemeritA;
                    dr.DemeritB     = drr.DemeritB;
                    dr.DemeritC     = drr.DemeritC;
                    drl.Add(dr);
                    log.Add(dr.RefStudentID + "," + dr.OccurDate + "," + dr.Reason + "," + dr.RegisterDate + "," + dr.SchoolYear + "," + dr.Semester + "," + dr.MeritFlag + "," + dr.MeritA + "," + dr.MeritB + "," + dr.MeritC + "," + dr.DemeritA + "," + dr.DemeritB + "," + dr.DemeritC);
                    log2.Add(drr.RefStudentId + "," + drr.RefTeacherId + "," + drr.OccurDate + "," + drr.Reason + "," + drr.MeritFlag + "," + drr.MeritA + "," + drr.MeritB + "," + drr.MeritC + "," + drr.DemeritA + "," + drr.DemeritB + "," + drr.DemeritC + "," + drr.ReturnMessage);
                    drrl.Add(drr);
                }
                else if ((string)item.Cells[9].Value == "不可")
                {
                    drr.Status = "2";
                    log2.Add(drr.RefStudentId + "," + drr.RefTeacherId + "," + drr.OccurDate + "," + drr.Reason + "," + drr.MeritFlag + "," + drr.MeritA + "," + drr.MeritB + "," + drr.MeritC + "," + drr.DemeritA + "," + drr.DemeritB + "," + drr.DemeritC + "," + drr.ReturnMessage);
                    drrl.Add(drr);
                }
                else
                {
                }
            }
            if (drl.Count > 0)
            {
                ApplicationLog.Log("核可教師獎懲建議", "新增", "新增獎懲記錄共" + drl.Count + "筆\n明細:\n" + string.Join("\n", log));
            }
            ApplicationLog.Log("核可教師獎懲建議", "核可", "核可教師獎懲建議共" + drrl.Count + "筆\n明細:\n" + string.Join("\n", log2));
            K12.Data.Discipline.Insert(drl);
            tool._A.SaveAll(drrl);

            labelX1.Text = "";
            _rIsDirty    = false;
            itemPanel1.Items.Clear();
            dataGridViewX1.Rows.Clear();
            _lbgw.RunWorkerAsync();
        }
Example #7
0
        void _BGWDisciplineDetail_DoWork(object sender, DoWorkEventArgs e)
        {
            string reportName = "學生獎勵懲戒記錄明細";

            #region 快取相關資料

            //選擇的學生
            List <StudentRecord> selectedStudents = Student.SelectByIDs(K12.Presentation.NLDPanels.Student.SelectedSource);

            selectedStudents.Sort(new Comparison <StudentRecord>(CommonMethods.ClassSeatNoComparer));

            //紀錄所有學生ID
            List <string> allStudentID = new List <string>();

            //每一位學生的獎懲明細(學生id<字串組合,物件>)
            Dictionary <string, Dictionary <string, DisciplineRecord> > studentDisciplineDetail = new Dictionary <string, Dictionary <string, DisciplineRecord> >();

            //每一位學生的獎懲累計資料(學生id,特殊物件)
            Dictionary <string, DisciplineStatistics> studentDisciplineStatistics = new Dictionary <string, DisciplineStatistics>();

            //紀錄每一種獎懲在報表中的 column index
            Dictionary <string, int> columnTable = new Dictionary <string, int>();

            List <DisciplineRecord> DisciplineList = new List <DisciplineRecord>();

            //取得所有學生ID
            foreach (StudentRecord var in selectedStudents)
            {
                allStudentID.Add(var.ID);
            }

            //初始化
            string[] columnString;
            if (form.checkBoxX2Bool) //使用者已勾選"排除懲戒已銷過資料"
            {
                columnString = new string[] { "大功", "小功", "嘉獎", "大過", "小過", "警告", "留察", "登錄日期", "事由" }
            }
            ;
            else
            {
                columnString = new string[] { "大功", "小功", "嘉獎", "大過", "小過", "警告", "留察", "銷過", "銷過日期", "登錄日期", "事由" }
            };

            int i = 4;
            foreach (string s in columnString)
            {
                columnTable.Add(s, i++);
            }

            #region 取得獎勵懲戒明細
            if (form.SelectDayOrSchoolYear) //依日期
            {
                if (form.SetupTime)         //依發生日期
                {
                    DisciplineList = Discipline.SelectByOccurDate(allStudentID, form.dateTimeInput1.Value, form.dateTimeInput2.Value);
                }
                else //依登錄日期
                {
                    DisciplineList = Discipline.SelectByRegisterDate(allStudentID, form.dateTimeInput1.Value, form.dateTimeInput2.Value);
                }
            }
            else //依學期
            {
                if (form.checkBoxX1Bool) //全部學期列印
                {
                    #region 全部學期列印
                    DisciplineList = Discipline.SelectByStudentIDs(allStudentID);
                    #endregion
                }
                else //指定學期列印
                {
                    #region 指定學期列印
                    foreach (DisciplineRecord each in Discipline.SelectByStudentIDs(allStudentID))
                    {
                        if (each.SchoolYear.ToString() == form.cbSchoolYear.Text && each.Semester.ToString() == form.cbSemester.Text)
                        {
                            DisciplineList.Add(each);
                        }
                    }
                    #endregion
                }
            }
            #endregion

            if (form.checkBoxX2Bool) //使用者已勾選"排除懲戒已銷過資料"
            {
                IsOrRemoveData(DisciplineList);
            }

            if (DisciplineList.Count == 0)
            {
                e.Cancel = true;
                return;
            }

            foreach (DisciplineRecord each in DisciplineList)
            {
                string studentID    = each.RefStudentID;
                string schoolYear   = each.SchoolYear.ToString();
                string semester     = each.Semester.ToString();
                string occurDate    = each.OccurDate.ToShortDateString();
                string reason       = each.Reason;
                string disciplineID = each.ID;
                string sso          = schoolYear + "_" + semester + "_" + occurDate + "_" + disciplineID;


                //初始化累計資料
                if (!studentDisciplineStatistics.ContainsKey(studentID))
                {
                    studentDisciplineStatistics.Add(studentID, new DisciplineStatistics(studentID));
                }

                //每一位學生獎勵懲戒資料
                if (!studentDisciplineDetail.ContainsKey(studentID))
                {
                    studentDisciplineDetail.Add(studentID, new Dictionary <string, DisciplineRecord>());
                }

                if (!studentDisciplineDetail[studentID].ContainsKey(sso))
                {
                    studentDisciplineDetail[studentID].Add(sso, each);
                }

                if (each.MeritFlag == "1")
                {
                    studentDisciplineStatistics[studentID].大功 += each.MeritA.HasValue ? each.MeritA.Value : 0;
                    studentDisciplineStatistics[studentID].小功 += each.MeritB.HasValue ? each.MeritB.Value : 0;
                    studentDisciplineStatistics[studentID].獎  += each.MeritC.HasValue ? each.MeritC.Value : 0;
                }
                else if (each.MeritFlag == "0")
                {
                    if (each.Cleared != "是")
                    {
                        studentDisciplineStatistics[studentID].大過 += each.DemeritA.HasValue ? each.DemeritA.Value : 0;
                        studentDisciplineStatistics[studentID].小過 += each.DemeritB.HasValue ? each.DemeritB.Value : 0;
                        studentDisciplineStatistics[studentID].警告 += each.DemeritC.HasValue ? each.DemeritC.Value : 0;
                    }
                }
                else if (each.MeritFlag == "2") //留察
                {
                }
            }

            #endregion

            #region 產生範本

            Workbook template = new Workbook();
            if (form.checkBoxX2Bool)
            {
                template.Open(new MemoryStream(K12.學生獎懲明細.Properties.Resources.學生獎懲明細_2), FileFormatType.Excel2003);
            }
            else
            {
                template.Open(new MemoryStream(K12.學生獎懲明細.Properties.Resources.學生獎懲明細), FileFormatType.Excel2003);
            }
            Workbook prototype = new Workbook();
            prototype.Copy(template);

            Worksheet ptws = prototype.Worksheets[0];

            int startPage  = 1;
            int pageNumber = 1;

            int columnNumber = 15;

            if (form.checkBoxX2Bool)
            {
                columnNumber = 13;
            }

            //合併標題列
            ptws.Cells.CreateRange(0, 0, 1, columnNumber).Merge();
            ptws.Cells.CreateRange(1, 0, 1, columnNumber).Merge();

            Range ptHeader  = ptws.Cells.CreateRange(0, 4, false);
            Range ptEachRow = ptws.Cells.CreateRange(4, 1, false);

            #endregion

            #region 產生報表

            Workbook wb = new Workbook();
            wb.Copy(prototype);
            Worksheet ws = wb.Worksheets[0];

            int index     = 0;
            int dataIndex = 0;

            int studentCount = 1;

            foreach (StudentRecord studentInfo in selectedStudents)
            {
                string TitleName1 = School.ChineseName + " 個人獎勵懲戒明細";
                string TitleName2 = "班級:" + ((studentInfo.Class == null ? "   " : studentInfo.Class.Name) + "  座號:" + ((studentInfo.SeatNo == null) ? " " : studentInfo.SeatNo.ToString()) + "  姓名:" + studentInfo.Name + "  學號:" + studentInfo.StudentNumber);

                //回報進度
                _BGWDisciplineDetail.ReportProgress((int)(((double)studentCount++ *100.0) / (double)selectedStudents.Count));

                if (!studentDisciplineDetail.ContainsKey(studentInfo.ID))
                {
                    continue;
                }

                //如果不是第一頁,就在上一頁的資料列下邊加黑線
                if (index != 0)
                {
                    ws.Cells.CreateRange(index - 1, 0, 1, columnNumber).SetOutlineBorder(BorderType.BottomBorder, CellBorderType.Medium, Color.Black);
                }

                //複製 Header
                ws.Cells.CreateRange(index, 4, false).Copy(ptHeader);

                dataIndex = index + 4;
                int recordCount = 0;

                //學生Row筆數超過40筆,則添加換行符號,與標頭
                int CountRows = 0;

                Dictionary <string, DisciplineRecord> disciplineDetail = studentDisciplineDetail[studentInfo.ID];

                //取總頁數 , 資料數除以38列(70/38=2)
                int TotlePage = disciplineDetail.Count / 40;
                //目前頁數
                int pageCount = 1;
                //如果還有餘數則+1
                if (disciplineDetail.Count % 40 != 0)
                {
                    TotlePage++;
                }

                //填寫基本資料
                ws.Cells[index, 0].PutValue(TitleName1 + "(" + pageCount.ToString() + "/" + TotlePage.ToString() + ")");
                pageCount++;
                ws.Cells[index + 1, 0].PutValue(TitleName2);

                foreach (string sso in disciplineDetail.Keys)
                {
                    CountRows++;

                    string[] ssoSplit = sso.Split(new string[] { "_" }, StringSplitOptions.RemoveEmptyEntries);

                    //複製每一個 row
                    ws.Cells.CreateRange(dataIndex, 1, false).Copy(ptEachRow);

                    //填寫學生獎懲資料
                    ws.Cells[dataIndex, 0].PutValue(ssoSplit[0]);
                    ws.Cells[dataIndex, 1].PutValue(ssoSplit[1]);
                    ws.Cells[dataIndex, 2].PutValue(ssoSplit[2]);
                    ws.Cells[dataIndex, 3].PutValue(CommonMethods.GetChineseDayOfWeek(DateTime.Parse(ssoSplit[2])));

                    DisciplineRecord record = disciplineDetail[sso];

                    if (record.MeritFlag == "1")
                    {
                        ws.Cells[dataIndex, columnTable["大功"]].PutValue(record.MeritA);
                        ws.Cells[dataIndex, columnTable["小功"]].PutValue(record.MeritB);
                        ws.Cells[dataIndex, columnTable["嘉獎"]].PutValue(record.MeritC);
                    }
                    else if (record.MeritFlag == "0")
                    {
                        if (record.Cleared == "是")
                        {
                            ws.Cells[dataIndex, columnTable["大過"]].PutValue(record.DemeritA);
                            ws.Cells[dataIndex, columnTable["小過"]].PutValue(record.DemeritB);
                            ws.Cells[dataIndex, columnTable["警告"]].PutValue(record.DemeritC);
                            if (!form.checkBoxX2Bool)
                            {
                                ws.Cells[dataIndex, columnTable["銷過"]].PutValue(record.Cleared);
                                ws.Cells[dataIndex, columnTable["銷過日期"]].PutValue(record.ClearDate.HasValue ? record.ClearDate.Value.ToShortDateString() : "");
                            }
                        }
                        else
                        {
                            ws.Cells[dataIndex, columnTable["大過"]].PutValue(record.DemeritA);
                            ws.Cells[dataIndex, columnTable["小過"]].PutValue(record.DemeritB);
                            ws.Cells[dataIndex, columnTable["警告"]].PutValue(record.DemeritC);
                        }
                    }
                    else if (record.MeritFlag == "2")
                    {
                        ws.Cells[dataIndex, columnTable["留察"]].PutValue("是");
                    }

                    ws.Cells[dataIndex, columnTable["事由"]].PutValue(record.Reason);
                    ws.Cells[dataIndex, columnTable["登錄日期"]].PutValue(record.RegisterDate.HasValue ? record.RegisterDate.Value.ToShortDateString() : "");

                    dataIndex++;
                    recordCount++;


                    if (CountRows == 40 && pageCount <= TotlePage)
                    {
                        CountRows = 0;
                        //分頁
                        ws.HPageBreaks.Add(dataIndex, columnNumber);
                        //複製 Header
                        ws.Cells.CreateRange(dataIndex, 4, false).Copy(ptHeader);
                        //填寫基本資料
                        ws.Cells[dataIndex, 0].PutValue(TitleName1 + "(" + pageCount.ToString() + "/" + TotlePage.ToString() + ")");
                        pageCount++; //下一頁使用
                        ws.Cells[dataIndex + 1, 0].PutValue(TitleName2);

                        dataIndex += 4;
                    }
                }

                //獎懲統計資訊
                Range disciplineStatisticsRange = ws.Cells.CreateRange(dataIndex, 0, 1, columnNumber);
                disciplineStatisticsRange.Copy(ptEachRow);
                disciplineStatisticsRange.Merge();
                disciplineStatisticsRange.SetOutlineBorder(BorderType.TopBorder, CellBorderType.Double, Color.Black);
                disciplineStatisticsRange.SetOutlineBorder(BorderType.BottomBorder, CellBorderType.Double, Color.Black);
                disciplineStatisticsRange.RowHeight = 20.0;
                ws.Cells[dataIndex, 0].Style.HorizontalAlignment = TextAlignmentType.Center;
                ws.Cells[dataIndex, 0].Style.VerticalAlignment   = TextAlignmentType.Center;
                ws.Cells[dataIndex, 0].Style.Font.Size           = 10;
                ws.Cells[dataIndex, 0].PutValue("獎勵懲戒總計");
                dataIndex++;

                //獎懲統計內容
                ws.Cells.CreateRange(dataIndex, 0, 1, columnNumber).Copy(ptEachRow);
                ws.Cells.CreateRange(dataIndex, 0, 1, columnNumber).RowHeight = 27.0;
                ws.Cells.CreateRange(dataIndex, 0, 1, columnNumber).Merge();
                ws.Cells[dataIndex, 0].Style.HorizontalAlignment = TextAlignmentType.Center;
                ws.Cells[dataIndex, 0].Style.VerticalAlignment   = TextAlignmentType.Center;
                ws.Cells[dataIndex, 0].Style.Font.Size           = 10;
                ws.Cells[dataIndex, 0].Style.ShrinkToFit         = true;

                StringBuilder        text = new StringBuilder("");
                DisciplineStatistics disciplineStatistics = studentDisciplineStatistics[studentInfo.ID];

                List <string> list = new List <string>();
                if (disciplineStatistics.大功 > 0)
                {
                    list.Add("大功:" + disciplineStatistics.大功);
                }
                if (disciplineStatistics.小功 > 0)
                {
                    list.Add("小功:" + disciplineStatistics.小功);
                }
                if (disciplineStatistics.獎 > 0)
                {
                    list.Add("嘉獎:" + disciplineStatistics.獎);
                }
                if (disciplineStatistics.大過 > 0)
                {
                    list.Add("大過:" + disciplineStatistics.大過);
                }
                if (disciplineStatistics.小過 > 0)
                {
                    list.Add("小過:" + disciplineStatistics.小過);
                }
                if (disciplineStatistics.警告 > 0)
                {
                    list.Add("警告:" + disciplineStatistics.警告);
                }
                text.Append(string.Join(" ", list.ToArray()));

                ws.Cells[dataIndex, 0].PutValue(text.ToString());

                ws.Cells.CreateRange(dataIndex, 0, 1, columnNumber).SetOutlineBorder(BorderType.RightBorder, CellBorderType.Thin, Color.Black);

                dataIndex++;

                //資料列上邊加上黑線
                //ws.Cells.CreateRange(index + 3, 0, 1, columnNumber).SetOutlineBorder(BorderType.BottomBorder, CellBorderType.Thin, Color.Black);

                //表格最右邊加上黑線
                //ws.Cells.CreateRange(index + 2, columnNumber - 1, recordCount + 4, 1).SetOutlineBorder(BorderType.RightBorder, CellBorderType.Thin, Color.Black);

                index = dataIndex;

                //每500頁,增加一個WorkSheet,並於下標顯示(1~500)(501~xxx)
                if (pageNumber < 500)
                {
                    ws.HPageBreaks.Add(index, columnNumber);
                    pageNumber++;
                }
                else
                {
                    ws.Name = startPage + " ~ " + (pageNumber + startPage - 1);
                    ws      = wb.Worksheets[wb.Worksheets.Add()];
                    ws.Copy(prototype.Worksheets[0]);
                    startPage += pageNumber;
                    pageNumber = 1;
                    index      = 0;
                }
            }


            if (dataIndex > 0)
            {
                //最後一頁的資料列下邊加上黑線
                ws.Cells.CreateRange(dataIndex - 1, 0, 1, columnNumber).SetOutlineBorder(BorderType.BottomBorder, CellBorderType.Medium, Color.Black);
                ws.Name = startPage + " ~ " + (pageNumber + startPage - 2);
            }
            else
            {
                wb = new Workbook();
            }


            #endregion

            string path = Path.Combine(Application.StartupPath, "Reports");
            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            path     = Path.Combine(path, reportName + ".xlt");
            e.Result = new object[] { reportName, path, wb };
        }