Пример #1
0
        public void SetAttendance(AutoSummaryRecord asr)
        {
            string key = asr.SchoolYear + "_" + asr.Semester;

            if (!AttendanceObjDic.ContainsKey(key))
            {
                AttendanceObjDic.Add(key, new AttendanceObj());
            }

            AttendanceObj ao = AttendanceObjDic[key];

            foreach (AbsenceCountRecord acr in asr.AbsenceCounts)
            {
                if (Global.AbsenceSetDic["事病假"].Contains(acr.Name))
                {
                    ao.Excused += acr.Count;
                }
                if (Global.AbsenceSetDic["曠課"].Contains(acr.Name))
                {
                    ao.Unexcused += acr.Count;
                }
                if (Global.AbsenceSetDic["遲到"].Contains(acr.Name))
                {
                    ao.Tardy += acr.Count;
                }
            }
        }
Пример #2
0
        private void _BW_DoWork(object sender, DoWorkEventArgs e)
        {
            //取得學生資料
            Dictionary <string, StudentObj> StudentDic = Data.Get(_Students);

            if (StudentDic == null)
            {
                return;
            }

            //開始列印
            Workbook wb = new Workbook(new MemoryStream(Properties.Resources.template));

            foreach (string id in StudentDic.Keys)
            {
                StudentObj student = StudentDic[id];

                wb.Worksheets.AddCopy(0);
                //2017/9/29,羿均,因應worksheet名稱不能超過30個字元。如果學生姓名 + ID超過 30 個字元,扣除ID字元長度,剩下的字元長度來顯示學生姓名。
                string name = "";
                if (student.StudentRecord.Name.Length + id.Length > 30)
                {
                    for (int i = 0; i < 30 - id.Length; i++)
                    {
                        name += student.StudentRecord.Name[i];
                    }
                }
                else
                {
                    name = student.StudentRecord.Name;
                }

                wb.Worksheets[wb.Worksheets.Count - 1].Name = name + id;

                Cells cs = wb.Worksheets[wb.Worksheets.Count - 1].Cells;

                //列印差異標題
                if (_IsLowGrade)
                {
                    cs[0, 12].PutValue("學生學籍記錄表(一~六年級)");
                    cs[3, 2].PutValue("Bilingual Department Transcript of Records(Grade 1~6)");
                }
                else
                {
                    cs[0, 12].PutValue("學生學籍記錄表(七~十二年級)");
                    cs[3, 2].PutValue("Bilingual Department Transcript of Records(Grade 7~12)");
                }

                //列印學生基本資料
                // 2016/5/2 穎驊筆記,因應實驗高中方要增加成績欄位,因此將表格從原本橫式B4,變成直式B4,因此以下全部填寫欄位位子有所更動。

                cs[4, 2].PutValue(student.StudentRecord.StudentNumber);
                cs[4, 8].PutValue(student.StudentRecord.Name);
                cs[4, 13].PutValue(student.StudentRecord.EnglishName);
                cs[7, 2].PutValue(student.StudentRecord.Birthday.HasValue ? student.StudentRecord.Birthday.Value.ToShortDateString() : "");
                cs[7, 9].PutValue(student.ParentRecord.CustodianName);
                cs[7, 14].PutValue(student.ParentRecord.CustodianRelationship);
                cs[7, 17].PutValue(student.AddressRecord.MailingAddress);
                cs[8, 2].PutValue(student.StudentRecord.Gender);
                cs[8, 11].PutValue(student.EntranceRecord == null ? string.Empty : student.EntranceRecord.ADDate);
                cs[8, 15].PutValue(student.Entrance == null ? "西元        年        月        日" : student.Entrance.Value.ToString("西元  yyyy  年   MM   月   dd   日"));
                cs[8, 22].PutValue(student.Leaving == null ? "西元        年        月        日" : student.Leaving.Value.ToString("西元  yyyy  年   MM   月   dd   日"));
                cs[9, 2].PutValue(student.StudentRecord.Nationality);
                cs[9, 11].PutValue(student.EntranceRecord == null ? string.Empty : student.EntranceRecord.ADNumber);

                int startGrade = 1;
                int endGrade   = 6;
                if (!_IsLowGrade)
                {
                    startGrade = 7;
                    endGrade   = 12;
                }

                int columnIndex = 3;
                //列印指定年級資料
                for (int i = startGrade; i <= endGrade; i++)
                {
                    int schoolYear = student.GradeToSchoolYear[i];
                    //學年度標題
                    cs[11, columnIndex].PutValue(string.Format("{0}年級({1}學年度)", i, schoolYear == 0 ? "  " : schoolYear + ""));
                    cs[12, columnIndex].PutValue(string.Format("Gr.{0}Sch.  Yr.{1}-{2}", i, schoolYear == 0 ? "20__" : schoolYear + 1911 + "", schoolYear == 0 ? "20__" : schoolYear + 1912 + ""));

                    //科目成績
                    int           rowIndex    = 14;
                    List <string> subjectList = i <= 6 ? student.SubjectList6 : student.SubjectList12;
                    foreach (string subj in subjectList)
                    {
                        cs[rowIndex, 1].PutValue(subj);
                        string     key = schoolYear + "_" + subj;
                        SubjectObj so  = student.SubjectObjDic.ContainsKey(key) ? student.SubjectObjDic[key] : new SubjectObj();
                        cs[rowIndex, columnIndex].PutValue(so.GetPeriod() + "");
                        cs[rowIndex, columnIndex + 1].PutValue(so.MidtemScore + "");
                        cs[rowIndex, columnIndex + 2].PutValue(so.FinalScore + "");
                        cs[rowIndex, columnIndex + 3].PutValue(so.GetAvg() + "");

                        rowIndex++;
                    }

                    //學期平均
                    string syKey = schoolYear + "";
                    if (student.AvgObjDic.ContainsKey(syKey))
                    {
                        cs[59, columnIndex + 1].PutValue(student.AvgObjDic[syKey].MidtermAvg + "");
                        cs[59, columnIndex + 2].PutValue(student.AvgObjDic[syKey].FinalAvg + "");
                        cs[59, columnIndex + 3].PutValue(student.AvgObjDic[syKey].GetAvg() + "");
                    }

                    //出缺勤
                    rowIndex = 60;
                    string key1 = schoolYear + "_1";
                    if (student.AttendanceObjDic.ContainsKey(key1))
                    {
                        AttendanceObj ao = student.AttendanceObjDic[key1];
                        cs[rowIndex, columnIndex + 1].PutValue(ao.TotalDay == 0 ? "" : ao.TotalDay + "");
                        cs[rowIndex + 1, columnIndex + 1].PutValue(ao.Excused == 0 ? "" : ao.Excused + "");
                        cs[rowIndex + 2, columnIndex + 1].PutValue(ao.Unexcused == 0 ? "" : ao.Unexcused + "");
                        int totalAbsence = ao.Excused + ao.Unexcused;
                        cs[rowIndex + 3, columnIndex + 1].PutValue(totalAbsence == 0 ? "" : totalAbsence + "");
                        cs[rowIndex + 4, columnIndex + 1].PutValue(ao.Tardy == 0 ? "" : ao.Tardy + "");
                    }
                    string key2 = schoolYear + "_2";
                    if (student.AttendanceObjDic.ContainsKey(key2))
                    {
                        AttendanceObj ao = student.AttendanceObjDic[key2];
                        cs[rowIndex, columnIndex + 2].PutValue(ao.TotalDay == 0 ? "" : ao.TotalDay + "");
                        cs[rowIndex + 1, columnIndex + 2].PutValue(ao.Excused == 0 ? "" : ao.Excused + "");
                        cs[rowIndex + 2, columnIndex + 2].PutValue(ao.Unexcused == 0 ? "" : ao.Unexcused + "");
                        int totalAbsence = ao.Excused + ao.Unexcused;
                        cs[rowIndex + 3, columnIndex + 2].PutValue(totalAbsence == 0 ? "" : totalAbsence + "");
                        cs[rowIndex + 4, columnIndex + 2].PutValue(ao.Tardy == 0 ? "" : ao.Tardy + "");
                    }

                    columnIndex += 4;
                }
            }

            wb.Worksheets.RemoveAt(0);
            wb.Worksheets.ActiveSheetIndex = 0;
            e.Result = wb;
        }