Represents a column of a table.
Inheritance: DocumentObject
Exemplo n.º 1
0
 /// <summary>
 /// Initializes a new instance of the Columns class containing columns of the specified widths.
 /// </summary>
 public Columns(params Unit[] widths)
 {
     foreach (Unit width in widths)
     {
         Column clm = new Column();
         clm.Width = width;
         Add(clm);
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Adds a new column to the columns collection. Allowed only before any row was added.
        /// </summary>
        public Column AddColumn()
        {
            if (Table.Rows.Count > 0)
                throw new InvalidOperationException("Cannot add column because rows collection is not empty.");

            Column column = new Column();
            Add(column);
            return column;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Parses the keyword «\column».
        /// </summary>
        private void ParseColumn(Column column)
        {
            Debug.Assert(column != null);
            Debug.Assert(Symbol == Symbol.Column);

            ReadCode();
            if (Symbol == Symbol.BracketLeft)
                ParseAttributes(column);

            // Read empty content
            if (Symbol == Symbol.BraceLeft)
            {
                ReadCode();
                AssertSymbol(Symbol.BraceRight);
                ReadCode();
            }
        }
Exemplo n.º 4
0
        public void createRowForLunch(Document document, Table table, Column column, int propId, Row row2)
        {
            float nettoSum = 0;
            float bruttoSum = 0;
            var extra = (from r in _ctx.PropMenuPosition
                         where r.Id_proposition == propId
                         select r).ToList();

            for (int i = 0; i < extra.Count; i++)
            {
                //Create table columns
                table.Rows.Height = 3;
                Row row = table.AddRow();

                string netto = ComputeNettoPrice((float)extra[i].BruttoPrice, (float)(extra[i].Vat)).ToString();

                row.Borders.Top.Visible = false;
                row.Cells[0].Shading.Color = Colors.LightGray;
                row.Cells[2].Shading.Color = Colors.LightGray;
                row.Cells[3].Shading.Color = Colors.LightGray;
                row.Cells[6].Shading.Color = Colors.LightGray;
                row.Cells[7].Shading.Color = Colors.LightGray;
                row.Cells[1].Format.Alignment = ParagraphAlignment.Center;
                row.Cells[2].Format.Alignment = ParagraphAlignment.Center;
                row.Cells[3].Format.Alignment = ParagraphAlignment.Center;
                row.Cells[4].Format.Alignment = ParagraphAlignment.Center;
                row.Cells[5].Format.Alignment = ParagraphAlignment.Center;
                row.Cells[6].Format.Alignment = ParagraphAlignment.Center;
                row.Cells[7].Format.Alignment = ParagraphAlignment.Center;

                row.Cells[1].VerticalAlignment = MigraDoc.DocumentObjectModel.Tables.VerticalAlignment.Center;
                row.Cells[2].VerticalAlignment = MigraDoc.DocumentObjectModel.Tables.VerticalAlignment.Center;
                row.Cells[3].VerticalAlignment = MigraDoc.DocumentObjectModel.Tables.VerticalAlignment.Center;
                row.Cells[4].VerticalAlignment = MigraDoc.DocumentObjectModel.Tables.VerticalAlignment.Center;
                row.Cells[5].VerticalAlignment = MigraDoc.DocumentObjectModel.Tables.VerticalAlignment.Center;
                row.Cells[6].VerticalAlignment = MigraDoc.DocumentObjectModel.Tables.VerticalAlignment.Center;
                row.Cells[7].VerticalAlignment = MigraDoc.DocumentObjectModel.Tables.VerticalAlignment.Center;

                row.Cells[0].AddParagraph(extra[i].TypeOfService);
                row.Cells[1].AddParagraph(Convert.ToDecimal(extra[i].BruttoPrice.ToString()).ToString("#,##0.00") + " zł");
                row.Cells[2].AddParagraph(Convert.ToDecimal(netto.ToString()).ToString("#,##0.00") + " zł");
                row.Cells[3].AddParagraph(extra[i].Vat.ToString() + "%");
                row.Cells[4].AddParagraph(extra[i].Amount.ToString());
                row.Cells[5].AddParagraph(extra[i].Days.ToString());
                row.Cells[6].AddParagraph(Convert.ToDecimal(((float)extra[i].Days * (float)extra[i].Amount * float.Parse(netto)).ToString()).ToString("#,##0.00") + " zł");
                row.Cells[7].AddParagraph(Convert.ToDecimal(((float)extra[i].Days * (float)extra[i].Amount * (float)extra[i].BruttoPrice).ToString()).ToString("#,##0.00") + " zł");
                nettoSum += (float)extra[i].Days * (float)extra[i].Amount * float.Parse(netto);
                bruttoSum += (float)extra[i].Days * (float)extra[i].Amount * (float)extra[i].BruttoPrice;

            }

            orderBruttoSum += bruttoSum;
            orderNettoSum += nettoSum;

            row2 = table.AddRow();
            row2.Cells[6].Format.Alignment = ParagraphAlignment.Center;
            row2.Cells[7].Format.Alignment = ParagraphAlignment.Center;
            row2.Cells[0].Shading.Color = Colors.LightGray;
            row2.Cells[0].Format.Font.Bold = true;
            row2.Cells[0].AddParagraph("PODSUMOWANIE");
            row2.Cells[1].MergeRight = 4;
            row2.Cells[6].AddParagraph(Convert.ToDecimal(nettoSum.ToString()).ToString("#,##0.00") + " zł");
            row2.Cells[7].AddParagraph(Convert.ToDecimal(bruttoSum.ToString()).ToString("#,##0.00") + " zł");
        }
Exemplo n.º 5
0
 /// <summary>
 /// Resets the cached values.
 /// </summary>
 internal override void ResetCachedValues()
 {
     this.row = null;
       this.clm = null;
 }
Exemplo n.º 6
0
        /// <summary>
        /// Inserts a magic glue column to avoid PageBreaks at the first "rowCountTop" and the last "rowCountBottom" of a Table.
        /// </summary>
        /// <param name="table"></param>
        /// <param name="insertAtIndex"></param>
        /// <param name="rowCountTop">For example 3 for rounded corners Row, Header Row and first content Row.</param>
        /// <param name="rowCountBottom">For example 2 for last content Row and rounded corners Row.</param>
        public static void InsertGlueColumn(Table table, int insertAtIndex, int rowCountTop, int rowCountBottom)
        {
            if (table.Columns.Count == 0)
                return;

            int glueColumnIndex = insertAtIndex + 1;
            Unit glueColumnWidth = Unit.FromPoint(0.1);

            Column glueColumn = new Column();
            glueColumn.Width = glueColumnWidth;

            if (table.Columns[insertAtIndex].Width > glueColumnWidth)
                table.Columns[insertAtIndex].Width -= glueColumnWidth;
            table.Columns.InsertObject(glueColumnIndex, glueColumn);

            foreach (Row row in table.Rows)
            {
                if (row.Cells.Count > glueColumnIndex)
                    row.Cells.InsertObject(glueColumnIndex, new Cell());
            }

            int mergeTop = rowCountTop - 1;
            if (mergeTop < table.Rows.Count)
                table.Rows[0].Cells[glueColumnIndex].MergeDown = mergeTop;

            int mergeBottom = rowCountBottom - 1;
            if (table.Rows.Count - 1 - mergeBottom >= 0)
                table.Rows[table.Rows.Count - 1 - mergeBottom].Cells[glueColumnIndex].MergeDown = mergeBottom;
        }
    // generate pdf file
    private string GeneratePDFFile(string customerID)
    {
        Document document = new Document();

        document.DefaultPageSetup.TopMargin    = "1cm";
        document.DefaultPageSetup.LeftMargin   = "1cm";
        document.DefaultPageSetup.RightMargin  = "1cm";
        document.DefaultPageSetup.BottomMargin = "1cm";
        Section section = document.AddSection();

        // insert logo
        MigraDoc.DocumentObjectModel.Shapes.Image logo = section.AddImage(@"C:\Sales Call Report\Exco_logo.png");
        //MigraDoc.DocumentObjectModel.Shapes.Image logo = section.AddImage(@"\\10.0.0.6\Shopdata\Development\tiger\Exco_logo.png");

        logo.LockAspectRatio = true;
        logo.ScaleHeight     = 0.5;
        section.AddParagraph().AddLineBreak();
        // add title
        Paragraph paragraph = section.AddParagraph("Sales Call Report");

        paragraph.Format.Font.Color = Colors.Black;
        paragraph.Format.Font.Bold  = true;
        paragraph.Format.Font.Size  = "30";
        paragraph.Format.Alignment  = ParagraphAlignment.Center;
        section.AddParagraph(DateTime.Now.ToString("MM-dd-yyyy HH:mm:ss")).Format.Alignment = ParagraphAlignment.Center;;
        // add customer information
        string   query           = "select bvadr1, bvadr2, bvadr3, bvadr4, bvtelp, bvfax, bvcont, bvemal from cmsdat.cust where bvcust like '" + customerID + "'";
        string   customerAdd1    = string.Empty;
        string   customerAdd2    = string.Empty;
        string   customerAdd3    = string.Empty;
        string   customerAdd4    = string.Empty;
        string   customerTel     = string.Empty;
        string   customerFax     = string.Empty;
        string   customerContact = string.Empty;
        string   customerEmail   = string.Empty;
        ExcoODBC database        = ExcoODBC.Instance;

        database.Open(Database.CMSDAT);
        OdbcDataReader reader = database.RunQuery(query);

        if (reader.Read())
        {
            customerAdd1    = reader["bvadr1"].ToString().Trim();
            customerAdd2    = reader["bvadr2"].ToString().Trim();
            customerAdd3    = reader["bvadr3"].ToString().Trim();
            customerAdd4    = reader["bvadr4"].ToString().Trim();
            customerTel     = reader["bvtelp"].ToString().Trim();
            customerFax     = reader["bvfax"].ToString().Trim();
            customerContact = reader["bvcont"].ToString().Trim();
            customerEmail   = reader["bvemal"].ToString().Trim().Replace("mailto:", "");
        }
        else
        {
            throw new Exception("Getting customer information failed!");
        }
        reader.Close();
        paragraph = section.AddParagraph();
        paragraph.AddText(CustomerList.Text);
        paragraph.AddLineBreak();
        if (customerContact.Length > 0)
        {
            paragraph.AddText("Contact Person: " + customerContact);
            paragraph.AddLineBreak();
        }
        if (customerAdd1.Length > 0)
        {
            paragraph.AddText(customerAdd1);
            paragraph.AddLineBreak();
        }
        if (customerAdd2.Length > 0)
        {
            paragraph.AddText(customerAdd2);
            paragraph.AddLineBreak();
        }
        if (customerAdd3.Length > 0)
        {
            paragraph.AddText(customerAdd3);
            paragraph.AddLineBreak();
        }
        if (customerAdd4.Length > 0)
        {
            paragraph.AddText(customerAdd4);
            paragraph.AddLineBreak();
        }
        if (customerTel.Length > 0)
        {
            paragraph.AddText("Tel: " + customerTel);
            paragraph.AddLineBreak();
        }
        if (customerFax.Length > 0)
        {
            paragraph.AddText("Fax: " + customerFax);
            paragraph.AddLineBreak();
        }
        if (customerEmail.Length > 0)
        {
            paragraph.AddText("Email: " + customerEmail);
            paragraph.AddLineBreak();
        }
        // add sales person information
        query = "select Email, FirstName, LastName from tiger.dbo.[user] where UserName like '" + User.Identity.Name + "'";
        string salesEmail = string.Empty;
        string salesName  = string.Empty;

        database.Open(Database.DECADE_MARKHAM);
        reader = database.RunQuery(query);
        if (reader.Read())
        {
            salesEmail = reader["Email"].ToString().Trim();
            salesName  = reader["FirstName"].ToString().Trim() + " " + reader["LastName"].ToString().Trim();
        }
        else
        {
            throw new Exception("Getting sales information failed!");
        }
        reader.Close();
        // add sales call report information
        section.AddParagraph().AddLineBreak();
        MigraDoc.DocumentObjectModel.Tables.Table table = section.AddTable();
        table.Format.Alignment    = ParagraphAlignment.Center;
        table.Style               = "Table";
        table.Borders.Width       = 1;
        table.Borders.Color       = Colors.Black;
        table.Borders.Width       = 0.25;
        table.Borders.Left.Width  = 0.5;
        table.Borders.Right.Width = 0.5;
        table.Rows.LeftIndent     = 0;
        MigraDoc.DocumentObjectModel.Tables.Column column = table.AddColumn("3.5cm");
        column.Format.Alignment = ParagraphAlignment.Center;
        column = table.AddColumn("3cm");
        column.Format.Alignment = ParagraphAlignment.Center;
        column = table.AddColumn("3cm");
        column.Format.Alignment = ParagraphAlignment.Center;
        column = table.AddColumn("3cm");
        column.Format.Alignment = ParagraphAlignment.Center;
        column = table.AddColumn("3cm");
        column.Format.Alignment = ParagraphAlignment.Center;
        column = table.AddColumn("3cm");
        column.Format.Alignment = ParagraphAlignment.Center;
        MigraDoc.DocumentObjectModel.Tables.Row row = table.AddRow();
        row.Cells[0].AddParagraph("Sales");
        row.Cells[0].Format.Font.Bold = true;
        row.Cells[1].MergeRight       = 1;
        row.Cells[1].AddParagraph(salesName);
        row.Cells[3].AddParagraph("Email");
        row.Cells[3].Format.Font.Bold = true;
        row.Cells[4].MergeRight       = 1;
        row.Cells[4].AddParagraph(salesEmail);
        row = table.AddRow();
        row.Cells[0].AddParagraph("Visit");
        row.Cells[0].Format.Font.Bold = true;
        row.Cells[1].MergeRight       = 1;
        row.Cells[1].AddParagraph(DateText.Text);
        row.Cells[3].AddParagraph("Follow Up");
        row.Cells[3].Format.Font.Bold = true;
        row.Cells[4].MergeRight       = 1;
        row.Cells[4].AddParagraph(FollowUpText.Text);
        row = table.AddRow();
        row.Cells[0].AddParagraph("Number of Presses");
        row.Cells[0].Format.Font.Bold = true;
        row.Cells[1].AddParagraph(PressText.Text);
        row.Cells[2].AddParagraph("Est. Die Exp./Mn");
        row.Cells[2].Format.Font.Bold = true;
        row.Cells[3].AddParagraph(ExpenseText.Text);
        row.Cells[4].AddParagraph("Other Suppliers");
        row.Cells[4].Format.Font.Bold = true;
        row.Cells[5].AddParagraph(SupplierText.Text);
        row = table.AddRow();
        row.Cells[0].AddParagraph("Attendee's");
        row.Cells[0].Format.Font.Bold = true;
        row.Cells[1].MergeRight       = 4;
        row.Cells[1].AddParagraph(AttendeeText.Text);
        row = table.AddRow();
        row.Cells[0].AddParagraph("Purpose of Visit");
        row.Cells[0].Format.Font.Bold = true;
        row.Cells[1].MergeRight       = 4;
        row.Cells[1].AddParagraph(AdjustWordWrap(PurposeText.Text));
        row.Cells[1].Format.Alignment = ParagraphAlignment.Left;
        row = table.AddRow();
        row.Cells[0].AddParagraph("Addtional Information");
        row.Cells[0].Format.Font.Bold = true;
        row.Cells[1].MergeRight       = 4;
        row.Cells[1].AddParagraph(AdjustWordWrap(InformationText.Text));
        row.Cells[1].Format.Alignment = ParagraphAlignment.Left;
        row = table.AddRow();
        row.Cells[0].AddParagraph("How can ETS Increase Business");
        row.Cells[0].Format.Font.Bold = true;
        row.Cells[1].MergeRight       = 4;
        row.Cells[1].AddParagraph(AdjustWordWrap(IncreaseText.Text));
        row.Cells[1].Format.Alignment = ParagraphAlignment.Left;
        // render pdf
        PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(false, PdfFontEmbedding.Always);

        pdfRenderer.Document = document;
        pdfRenderer.RenderDocument();
        filesubPath = @"sales call report by " + User.Identity.Name + " at " + DateTime.Now.ToString("yyyy-MM-dd HH.mm.ss") + ".pdf";
        //string filePath = @"C:\Sales Call Report\" + filesubPath;
        //string filePath = @"\\10.0.0.6\Shopdata\Development\tiger\Sales Call Report\sales call report by " + User.Identity.Name + " at " + DateTime.Now.ToString("yyyy-MM-dd HH.mm.ss") + ".pdf";
        //string filePath = @"C:\Sales Call Report\" + filesubPath;
        string filePath = Server.MapPath("~/Sales Call Report PDF/" + filesubPath);

        if (Directory.Exists(Server.MapPath("~/Sales Call Report PDF/")))
        {
            if (File.Exists(filePath))
            {
                File.Delete(filePath);
            }
        }
        else
        {
            Directory.CreateDirectory(Server.MapPath("~/Sales Call Report PDF/"));
        }

        pdfRenderer.PdfDocument.Save(filePath);

        return(filePath);
    }