Ejemplo n.º 1
0
        private void FillDomainRows()
        {
            Cell  cell     = _cell;
            Row   row      = _cell.ParentRow;
            Table table    = row.ParentTable;
            int   rowIndex = table.IndexOf(row);

            foreach (DomainRow domainRow in _manager.DomainRows)
            {
                // 當有領域沒有科目成績
                if (domainRow.SubjectScores.Count <= 0)
                {
                    // 沒有領域成績
                    if (domainRow.Scores.Count <= 0)
                    {
                        continue;
                    }

                    // 當使用者選擇科目又沒科目成績
                    if (_config.DomainSubjectSetup == "Subject" && domainRow.SubjectScores.Count == 0)
                    {
                        continue;
                    }

                    table.Rows.Add(row.Clone(true));
                    Row tempRow = table.LastRow;
                    WordHelper.MergeHorizontalCell(tempRow.Cells[0], 2);
                    Write(tempRow.Cells[0], (string.IsNullOrEmpty(domainRow.Domain) ? "彈性課程" : domainRow.Domain));

                    // 當使用者選科目時,不列印領領域成績
                    if (_config.DomainSubjectSetup == "Domain")
                    {
                        WriteDomain(tempRow.Cells[1], domainRow);
                    }
                }
                else
                {
                    int subjectCount = 0;
                    foreach (string subject in domainRow.SubjectScores.Keys)
                    {
                        subjectCount++;

                        //table.Rows.Insert(rowIndex++, table.Rows[deleteIndex].Clone(true) as Row);
                        //Row tempRow = table.Rows[rowIndex];
                        table.Rows.Add(row.Clone(true));
                        Row tempRow = table.LastRow;

                        Write(tempRow.Cells[1], subject);
                        WriteSubject(tempRow.Cells[1], domainRow.SubjectScores[subject]);
                    }
                    Row startRow = table.Rows[table.Rows.Count - subjectCount];
                    Write(startRow.Cells[0], string.IsNullOrEmpty(domainRow.Domain) ? "彈性課程" : domainRow.Domain);
                    if (subjectCount > 1)
                    {
                        WordHelper.MergeVerticalCell(startRow.Cells[0], subjectCount);
                    }
                }
            }

            row.Remove();

            //Cell typeCell = table.Rows[rowIndex - typeCount + 1].Cells[0];
            //WordHelper.MergeVerticalCell(typeCell, typeCount);
            //Write(typeCell, "缺曠資料");

            //Cell cell = _cell;
            //int first_row_index = _cell.ParentRow.ParentTable.IndexOf(_cell.ParentRow);

            //int count = 0;
            //foreach (DomainRow row in _manager.DomainRows)
            //{
            //    WriteDomain(cell, row);
            //    cell = WordHelper.GetMoveDownCell(cell, 1);

            //    if (cell == null) break;

            //    if (++count == 2)
            //        cell = WordHelper.GetMoveLeftCell(cell, 1);
            //}
        }