Example #1
0
        /// <summary>
        /// Writes the billing items.
        /// </summary>
        /// <param name="billingDoc">The billing doc.</param>
        private void WriteBillingItems(TextDocument billingDoc)
        {
            if (billingDoc != null)
            {
                foreach (IContent content in billingDoc.Content)
                {
                    if (content is Table)
                    {
                        Table  itemTable         = (Table)content;
                        double priceTotal        = 0;
                        int    r                 = 0;
                        string lastCellStyleName = "";
                        foreach (DataRow dr in this._tblItems.Rows)
                        {
                            Row itemRow = new Row(itemTable);
                            int c       = 0;
                            foreach (object obj in dr.ItemArray)
                            {
                                lastCellStyleName = "c" + r.ToString() + c.ToString();
                                Cell cell = new Cell(itemTable.Document, lastCellStyleName);
                                ((CellStyle)cell.Style).CellProperties.Padding      = "0.2cm";
                                ((CellStyle)cell.Style).CellProperties.BorderBottom = "0.002cm solid #000000";
                                Paragraph           p  = ParagraphBuilder.CreateParagraphWithCustomStyle(billingDoc, "p" + r.ToString() + c.ToString());
                                ParagraphProperties pp = ((ParagraphStyle)p.Style).ParagraphProperties;
                                if (pp != null)
                                {
                                    if (c == 1)
                                    {
                                        pp.Alignment = TextAlignments.center.ToString();
                                    }
                                    if (c > 1)
                                    {
                                        pp.Alignment = TextAlignments.end.ToString();
                                    }
                                }
                                TextProperties tp = ((ParagraphStyle)p.Style).TextProperties;
                                if (tp != null)
                                {
                                    tp.Bold     = "bold";
                                    tp.FontName = FontFamilies.Arial;
                                    tp.FontSize = "11pt";
                                    if (c < 2)
                                    {
                                        tp.Italic = "italic";
                                    }
                                }
                                if (c == 4)
                                {
                                    priceTotal += Double.Parse(obj.ToString());
                                }
                                p.TextContent.Add(new SimpleText(billingDoc, obj.ToString()));
                                cell.Content.Add(p);
                                itemRow.Cells.Add(cell);
                                c++;
                            }
                            itemTable.Rows.Add(itemRow);
                            r++;
                        }

                        Row priceTotalRow = new Row(itemTable);
                        for (int i = 0; i < 4; i++)
                        {
                            priceTotalRow.Cells.Add(new Cell(itemTable.Document));
                        }

                        Cell      cell1 = new Cell(itemTable.Document, lastCellStyleName);
                        Paragraph p1    = ParagraphBuilder.CreateParagraphWithCustomStyle(billingDoc, "ppricetotal");
                        ((ParagraphStyle)p1.Style).ParagraphProperties.Alignment = TextAlignments.end.ToString();
                        ((ParagraphStyle)p1.Style).TextProperties.Bold           = "bold";
                        ((ParagraphStyle)p1.Style).TextProperties.FontSize       = "11pt";
                        ((ParagraphStyle)p1.Style).TextProperties.FontName       = FontFamilies.Arial;
                        p1.TextContent.Add(new SimpleText(billingDoc, priceTotal.ToString()));
                        cell1.Content.Add(p1);
                        priceTotalRow.Cells.Add(cell1);
                        itemTable.Rows.Add(priceTotalRow);
                    }
                }
            }
        }