///// <summary> ///// 寫入科目 ///// </summary> ///// <param name="cell"></param> ///// <param name="subject"></param> //private void WriteSubject(Cell cell, SubjectRow subject) //{ // Write(cell, subject.Subject); // Row row = cell.ParentRow; // int shift = row.IndexOf(cell) + 1; // int fields = 3; // foreach (SemesterData sems in subject.Scores.Keys) // { // ScoreData data = subject.Scores[sems]; // int index = -1; // if (_map.SemesterMapping.ContainsKey(sems)) // index = _map.SemesterMapping[sems]; // if (index < 0) continue; // index = index * fields + shift; // PeriodCredit pcObj = new PeriodCredit(); // pcObj.Parse(data.GetPeriodCredit()); // string pcDisplay = string.Empty; // if (PrintPeriod && PrintCredit) // pcDisplay = "" + pcObj.Period + "/" + pcObj.Credit; // else if (PrintPeriod) // pcDisplay = "" + pcObj.Period; // else if (PrintCredit) // pcDisplay = "" + pcObj.Credit; // Write(row.Cells[index], pcDisplay); // Write(row.Cells[index + 1], data.Score); // Write(row.Cells[index + 2], data.GetDegree()); // } //} private void WriteSubject(Cell cell, Dictionary <SemesterData, ScoreData> dictionary) { Row row = cell.ParentRow; int shift = row.IndexOf(cell) + 1; int fields = 3; foreach (SemesterData sems in dictionary.Keys) { ScoreData data = dictionary[sems]; int index = -1; if (_map.SemesterMapping.ContainsKey(sems)) { index = _map.SemesterMapping[sems]; } if (index < 0) { continue; } index = index * fields + shift; WordHelper.Write(row.Cells[index], GetPeriodCredit(data.GetPeriodCredit()), _builder); WordHelper.Write(row.Cells[index + 1], data.Score, _builder); WordHelper.Write(row.Cells[index + 2], GetDegree(data.Score), _builder); } }
/// <summary> /// 寫入領域 Rows /// </summary> private void FillDomainRows() { Cell cell = _cell; Row row = _cell.ParentRow; Table table = row.ParentTable; int deleteIndex = table.IndexOf(row); int rowIndex = table.IndexOf(row); int SubjCount = 0; foreach (DomainRow domainRow in _manager.DomainRows) { SubjCount = 0; // 透過對照表查詢領域是否需要展開 bool display = DomainSubjectExpand.展開; if (_domains.ContainsKey(domainRow.Domain)) { display = _domains[domainRow.Domain]; } // 不展開,列印領域 if (display == DomainSubjectExpand.展開) { if (domainRow.Scores.Count <= 0) { continue; } table.Rows.Add(row.Clone(true)); Row tempRow = table.LastRow; WordHelper.MergeHorizontalCell(tempRow.Cells[0], 2); WordHelper.Write(tempRow.Cells[0], (string.IsNullOrEmpty(domainRow.Domain) ? "彈性課程" : domainRow.Domain), _builder); WriteDomain(tempRow.Cells[1], domainRow); } // 展開,列印科目 else { int subjectCount = 0; foreach (string subject in domainRow.SubjectScores.Keys) { subjectCount++; table.Rows.Add(row.Clone(true)); Row tempRow = table.LastRow; WordHelper.Write(tempRow.Cells[1], subject, _builder); WriteSubject(tempRow.Cells[1], domainRow.SubjectScores[subject]); } SubjCount = subjectCount; // 當只有領域成績沒有科目成績時 if (subjectCount > 0) { Row startRow = table.Rows[table.Rows.Count - subjectCount]; WordHelper.Write(startRow.Cells[0], (string.IsNullOrEmpty(domainRow.Domain) ? "彈性課程" : domainRow.Domain), _builder); if (subjectCount > 1) { WordHelper.MergeVerticalCell(startRow.Cells[0], subjectCount); } } } // 畢業成績 if (_StudGradScore.Domains.ContainsKey(domainRow.Domain)) { Row tmpRow = table.Rows[table.Rows.Count - SubjCount]; // 當科目數 >=1 if (SubjCount >= 1) { WordHelper.MergeVerticalCell(tmpRow.Cells[20], SubjCount); WordHelper.MergeVerticalCell(tmpRow.Cells[21], SubjCount); } else { tmpRow = table.LastRow; } //Row tmpRow = table.LastRow; if (_StudGradScore.Domains[domainRow.Domain].Score.HasValue) { // 分數 WordHelper.Write(tmpRow.Cells[20], _StudGradScore.Domains[domainRow.Domain].Score.Value.ToString(), _builder); // 等第 WordHelper.Write(tmpRow.Cells[21], DegreeMapper.GetDegreeByScore(_StudGradScore.Domains[domainRow.Domain].Score.Value), _builder); } } } table.Rows[deleteIndex].Remove(); // 畫底出線 foreach (Cell c in table.LastRow.Cells) { c.CellFormat.Borders.Bottom.LineWidth = 1.5; } //bool hasScore = false; //Cell cell = _cell; //Cell gradCell1 = GetMoveRightCell(cell, GraduateShift); //Cell gradCell2 = GetMoveRightCell(cell, GraduateShift + 1); //int first_row_index = _cell.ParentRow.ParentTable.IndexOf(_cell.ParentRow); //foreach (DomainRow row in _manager.DomainRows) //{ // // 透過對照表查詢領域是否需要展開 // bool display = DomainSubjectExpand.展開; // if (_domains.ContainsKey(row.Domain)) // display = _domains[row.Domain]; // hasScore = true; // //int count = row.Count; // Write(cell, string.IsNullOrEmpty(row.Domain) ? "彈性課程" : row.Domain); // // 不展開,列印領域 // if (display == DomainSubjectExpand.不展開) // { // MergeVerticalCell(cell, count); // MergeVerticalCell(gradCell1, count); // MergeVerticalCell(gradCell2, count); // } // // 展開,列印科目 // else // { // Cell subjectCell = GetMoveRightCell(cell, 1); // foreach (SubjectRow subjectRow in row.SubjectRows) // { // WriteSubject(subjectCell, subjectRow); // subjectCell = GetMoveDownCell(subjectCell, 1); // if (subjectCell == null) break; // } // } // cell = GetMoveDownCell(cell, count); // gradCell1 = GetMoveDownCell(gradCell1, count); // gradCell2 = GetMoveDownCell(gradCell2, count); // if (cell == null) break; //} //if (hasScore) //{ // do // { // cell.CellFormat.VerticalMerge = CellMerge.Previous; // cell = GetMoveDownCell(cell, 1); // gradCell1.CellFormat.VerticalMerge = CellMerge.Previous; // gradCell1 = GetMoveDownCell(gradCell1, 1); // gradCell2.CellFormat.VerticalMerge = CellMerge.Previous; // gradCell2 = GetMoveDownCell(gradCell2, 1); // } // while (cell != null); //} }