Example #1
0
        protected static pdfTable SubCabRelatorio(pdfDocument myDoc, pdfPage myPage, int top, string Atividade, string GrupoAtv, string Periodicidade)
        {
            String strFont    = "Helvetica";
            int    leftMargin = 30;

            pdfTable myTable = new pdfTable(myDoc, 1, new pdfColor("000000"), 2,
                                            new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, new pdfColor("FFFFFF")),
                                            new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, pdfColor.White));

            myTable.coordX = leftMargin;
            myTable.coordY = getTop(myPage, top);

            // Create Table Row
            pdfTableRow myRow;

            int cl = 0;

            //// Create table's header
            myTable.tableHeader.rowHeight = 20;
            myTable.tableHeader.addColumn(100, predefinedAlignment.csLeft);
            myTable.tableHeader[cl++].addText("Atividade");
            myTable.tableHeader.addColumn(450, predefinedAlignment.csLeft);
            myTable.tableHeader[cl++].addText(Atividade.TrimEnd());
            myRow                 = myTable.createRow();
            myRow.rowStyle        = myTable.rowStyle;
            top                  += 20;
            cl                    = 0;
            myRow                 = myTable.createRow();
            myRow.rowStyle        = myTable.rowStyle;
            myRow[cl].columnAlign = predefinedAlignment.csLeft;
            myRow[cl++].addText("Grupo Atividade");
            myRow[cl++].addText(TiraCaractEspecial(GrupoAtv.TrimEnd()));
            myTable.addRow(myRow);
            top                  += 20;
            cl                    = 0;
            myRow                 = myTable.createRow();
            myRow.rowStyle        = myTable.rowStyle;
            myRow[cl].columnAlign = predefinedAlignment.csLeft;
            myRow[cl++].addText("Periodicidade");
            myRow[cl++].addText(Periodicidade.TrimEnd());
            myTable.addRow(myRow);
            top += 10;
            myPage.addTable(myTable);

            myTable = new pdfTable(myDoc, 1, new pdfColor("000000"), 2,
                                   new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, new pdfColor("FFFFFF")),
                                   new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, pdfColor.White));
            myTable.coordX = leftMargin;
            myTable.coordY = getTop(myPage, top);
            cl             = 0;
            myTable.tableHeader.rowHeight = 20;
            myTable.tableHeader.addColumn(550, predefinedAlignment.csLeft);
            myTable.tableHeader[cl++].addText("ITENS DE ATIVIDADE");

            return(myTable);
        }
        protected void WriteLidSummaryTable(pdfPage myPage, ListView lv)
        {
            pdfTable myTable = new pdfTable(myDoc, 1, pdfColor.Black, 5,
                                            new pdfTableStyle(myDoc.getFontReference(strFont), 12, pdfColor.Black, new pdfColor("d9d1b3")),
                                            new pdfTableStyle(myDoc.getFontReference(strFont), 12, pdfColor.Black, pdfColor.White),
                                            new pdfTableStyle(myDoc.getFontReference(strFont), 12, pdfColor.Black, pdfColor.White));

            myTable.coordX = leftMargin;
            myTable.coordY = GetLineTop(myPage, 23);
            myTable.tableHeader.rowHeight = 25;
            myTable.tableHeader.addColumn(175, predefinedAlignment.csLeft);
            myTable.tableHeader[0].addText("LID Control");
            myTable.tableHeader.addColumn(160, predefinedAlignment.csLeft);
            myTable.tableHeader[1].addText("Current Scenario");
            myTable.tableHeader.addColumn(160, predefinedAlignment.csLeft);
            myTable.tableHeader[2].addText("Baseline Scenario");

            int         tableRowHt = 15;
            pdfTableRow myRow;

            for (int i = 12; i <= 18; i++)
            {
                myRow           = myTable.createRow();
                myRow.rowHeight = tableRowHt;
                for (int j = 0; j < 3; j++)
                {
                    myRow[j].addText(lv.Items[i].SubItems[j].Text);
                }
                myTable.addRow(myRow);
            }
            myPage.addTable(myTable);
            myPage.addText("% of impervious area treated / % of treated area used for LID",
                           leftMargin, bottomMargin + lineHeight, myDoc.getFontReference(strFont), 10);
        }
        public void WriteSummaryResultsPage(string siteName, ListView lv, Image plotImage1,
                                            Image plotImage2, double aspectRatio)
        {
            pdfPage myPage = myDoc.addPage(predefinedPageSize.csSharpPDFFormat);
            int     width  = myPage.width - leftMargin - rightMargin;

            WritePageTitle(myPage, "Summary Results", siteName);

            pdfTable myTable = new pdfTable(myDoc, 1, pdfColor.Black, 5,
                                            new pdfTableStyle(myDoc.getFontReference(strFont), 12, pdfColor.Black, new pdfColor("d9d1b3")),
                                            new pdfTableStyle(myDoc.getFontReference(strFont), 12, pdfColor.Black, pdfColor.White),
                                            new pdfTableStyle(myDoc.getFontReference(strFont), 12, pdfColor.Black, pdfColor.White));

            myTable.coordX = leftMargin;
            myTable.coordY = GetLineTop(myPage, 5);
            myTable.tableHeader.rowHeight = 25;
            myTable.tableHeader.addColumn(225, predefinedAlignment.csLeft);
            myTable.tableHeader[0].addText("Statistic");
            myTable.tableHeader.addColumn(120, predefinedAlignment.csRight);
            myTable.tableHeader[1].addText("Current Scenario");
            myTable.tableHeader.addColumn(120, predefinedAlignment.csRight);
            myTable.tableHeader[2].addText("Baseline Scenario");

            int         tableRowHt = 15;
            pdfTableRow myRow;

            for (int i = 0; i < lv.Items.Count; i++)
            {
                myRow           = myTable.createRow();
                myRow.rowHeight = tableRowHt;
                for (int j = 0; j < 3; j++)
                {
                    myRow[j].addText(lv.Items[i].SubItems[j].Text);
                }
                myTable.addRow(myRow);
            }
            myPage.addTable(myTable);

            int plotWidth  = width / 2;
            int plotHeight = (int)Math.Round((double)plotWidth * aspectRatio);
            int yPos       = bottomMargin + 4 * lineHeight;

            myDoc.addImageReference(plotImage1, "pieChart1");
            myPage.addImage(myDoc.getImageReference("pieChart1"),
                            leftMargin, yPos, plotHeight, plotWidth);
            if (plotImage2 != null)
            {
                myDoc.addImageReference(plotImage2, "pieChart2");
                myPage.addImage(myDoc.getImageReference("pieChart2"),
                                leftMargin + plotWidth, yPos, plotHeight, plotWidth);
            }
            WriteFooter(myPage);
        }
Example #4
0
        protected static void SubCabRelatorio(pdfDocument myDoc, pdfPage myPage, int top, DataRow row)
        {
            String strFont    = "Helvetica";
            int    leftMargin = 30;

            pdfTable myTable = new pdfTable(myDoc, 1, new pdfColor("000000"), 2,
                                            new pdfTableStyle(myDoc.getFontReference(strFont), 9, pdfColor.Black, new pdfColor("FFFFFF")),
                                            new pdfTableStyle(myDoc.getFontReference(strFont), 8, pdfColor.Black, pdfColor.White));

            myTable.coordX = leftMargin;
            myTable.coordY = getTop(myPage, top);

            int cl = 0;

            myTable.tableHeader.rowHeight = 20;

            myTable.tableHeader.addColumn(110, predefinedAlignment.csLeft);
            myTable.tableHeader[cl++].addText("ATIVIDADE");

            myTable.tableHeader.addColumn(60, predefinedAlignment.csCenter);
            myTable.tableHeader[cl++].addText("DATA");

            myTable.tableHeader.addColumn(80, predefinedAlignment.csLeft);
            myTable.tableHeader[cl++].addText("Nº PREVENTIVA");

            myTable.tableHeader.addColumn(90, predefinedAlignment.csLeft);
            myTable.tableHeader[cl++].addText("PERIODICIDADE");

            myTable.tableHeader.addColumn(100, predefinedAlignment.csLeft);
            myTable.tableHeader[cl++].addText("SITUAÇÃO");

            myTable.tableHeader.addColumn(110, predefinedAlignment.csLeft);
            myTable.tableHeader[cl++].addText("TIPO PREVENTIVA");

            top += 20;
            cl   = 0;
            pdfTableRow myRow = myTable.createRow();

            myRow.rowStyle = myTable.rowStyle;

            myRow[cl++].addText(row["cmpDcTipoAtividade"].ToString().TrimEnd());
            myRow[cl++].addText(row["cmpDtReprogramacaoPreventivaAgenda"].ToString().Substring(0, 10));
            myRow[cl++].addText(row["cmpNuPreventivaAgenda"].ToString().TrimEnd());
            myRow[cl++].addText(row["cmpDcPeriodicidade"].ToString().TrimEnd());
            myRow[cl++].addText(row["EstadoManutencaoPreventiva"].ToString().TrimEnd());
            myRow[cl++].addText(row["TPPREVENTIVA"].ToString().TrimEnd());

            myTable.addRow(myRow);

            myPage.addTable(myTable);
        }
        public void WriteSiteSummaryPage(string siteName, ListView lv)
        {
            pdfPage myPage = myDoc.addPage(predefinedPageSize.csSharpPDFFormat);
            int     width  = myPage.width - leftMargin - rightMargin;

            WritePageTitle(myPage, "Site Description", siteName);

            pdfTable myTable = new pdfTable(myDoc, 1, pdfColor.Black, 5,
                                            new pdfTableStyle(myDoc.getFontReference(strFont), 12, pdfColor.Black, new pdfColor("d9d1b3")),
                                            new pdfTableStyle(myDoc.getFontReference(strFont), 12, pdfColor.Black, pdfColor.White),
                                            new pdfTableStyle(myDoc.getFontReference(strFont), 12, pdfColor.Black, pdfColor.White));

            myTable.coordX = leftMargin;
            myTable.coordY = GetLineTop(myPage, 5);
            myTable.tableHeader.rowHeight = 25;
            myTable.tableHeader.addColumn(175, predefinedAlignment.csLeft);
            myTable.tableHeader[0].addText("Parameter");
            myTable.tableHeader.addColumn(160, predefinedAlignment.csLeft);
            myTable.tableHeader[1].addText("Current Scenario");
            myTable.tableHeader.addColumn(160, predefinedAlignment.csLeft);
            myTable.tableHeader[2].addText("Baseline Scenario");

            int         tableRowHt = 15;
            pdfTableRow myRow;

            for (int i = 0; i < lv.Items.Count; i++)
            {
                if (i > 11 && i <= 18)
                {
                    continue;
                }
                myRow           = myTable.createRow();
                myRow.rowHeight = tableRowHt;
                for (int j = 0; j < 3; j++)
                {
                    myRow[j].addText(lv.Items[i].SubItems[j].Text);
                }
                myTable.addRow(myRow);
            }
            myPage.addTable(myTable);
            WriteLidSummaryTable(myPage, lv);
            WriteFooter(myPage);
        }
Example #6
0
        private void ImprimeOsSemValorMaterial(DataTable tblMat)
        {
            pdfTable myTable = CabMaterialSemValor();

            top += 15;
            QtdCaracterLinha = 120;

            foreach (DataRow row in tblMat.Rows)
            {
                // Create Table Row
                int         cl    = 0;
                pdfTableRow myRow = myTable.createRow();
                myRow.rowStyle        = myTable.rowStyle;
                myRow[cl].columnAlign = predefinedAlignment.csLeft;
                myRow[cl++].addText(row["cmpDcItem"].ToString().Trim());

                row["cmpDcMaterialObraGrupo"] = TiraCaractEspecial(row["cmpDcMaterialObraGrupo"].ToString());

                Tamanho   = row["cmpDcMaterialObraGrupo"].ToString().Length;
                QtdLin    = (Tamanho % QtdCaracterLinha == 0 ? Tamanho / QtdCaracterLinha : (Tamanho / QtdCaracterLinha) + 1);
                StrInicio = 0;

                for (int Linha = 1; Linha <= QtdLin; Linha++)
                {
                    StrFim = Linha == QtdLin ? Tamanho - StrInicio : QtdCaracterLinha;
                    if (Linha == 1)
                    {
                        myRow[cl++].addText(row["cmpDcMaterialObraGrupo"].ToString().Substring(StrInicio, StrFim).Trim());
                        myRow[cl++].addText(row["cmpDcUnidade"].ToString().Trim());
                        myRow[cl++].addText(decimal.Parse(row["cmpQtMaterial"].ToString()).ToString("0,0.00"));
                        myTable.addRow(myRow);
                        StrInicio += QtdCaracterLinha;
                        top       += 11;
                    }
                    else
                    {
                        cl                    = 0;
                        myRow                 = myTable.createRow();
                        myRow.rowStyle        = myTable.rowStyle;
                        myRow[cl].columnAlign = predefinedAlignment.csLeft;
                        myRow[cl++].addText("");
                        myRow[cl++].addText(row["cmpDcMaterialObraGrupo"].ToString().Substring(StrInicio, StrFim).Trim());
                        myRow[cl++].addText("");
                        myRow[cl++].addText("");
                        myTable.addRow(myRow);
                        StrInicio += QtdCaracterLinha;
                        top       += 11;
                    }

                    if (top > 730)
                    {
                        myPage.addTable(myTable);

                        myTable = new pdfTable(myDoc, 1, new pdfColor("000000"), 2,
                                               new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, new pdfColor("FFFFFF")),
                                               new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, pdfColor.White));
                        myTable.coordX = leftMargin;
                        myTable.coordY = getTop(myPage, top);;

                        top           += 152;
                        myTable.coordX = leftMargin;
                        myTable.coordY = getTop(myPage, top);;

                        myPage.addText("Pág. " + pg++, leftMargin, 10, myDoc.getFontReference(strFont), 10, pdfColor.Black);

                        // Add a page
                        myPage = myDoc.addPage(predefinedPageSize.csSharpPDFFormat);

                        // Cabeçalho
                        top = 40;
                        CabRelatorio(myDoc, myPage, top, nNuOs, nNuDemanda);
                        top += 70;

                        // Header Text
                        //myPage.addText("Ordem de Serviço", leftMargin, getTop(myPage, 30),
                        //                myDoc.getFontReference(strFont), 15, pdfColor.Black);
                        //top = 40;
                        //myTable = new pdfTable(myDoc, 1, new pdfColor("000000"), 2,
                        //            new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, new pdfColor("FFFFFF")),
                        //            new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, pdfColor.White));

                        //myTable.coordX = leftMargin;
                        //myTable.coordY = getTop(myPage, top);

                        ////// Create table's header
                        //cl = 0;
                        //myTable.tableHeader.rowHeight = 10;
                        //myTable.tableHeader.addColumn(150, predefinedAlignment.csLeft);
                        //myTable.tableHeader[cl++].addText("Nº O.S.");

                        //myTable.tableHeader.addColumn(420, predefinedAlignment.csLeft);
                        //myTable.tableHeader[cl].columnAlign = predefinedAlignment.csLeft;
                        //myTable.tableHeader[cl++].addText(nNuOs.ToString());
                        //myPage.addTable(myTable);

                        //top += nTamLinPixel;

                        myTable = CabMaterialSemValor();
                    }
                }
            }

            myPage.addTable(myTable);
        }
        private void btnGeneratePDF_Click(object sender, EventArgs e)
        {
            // Si un employé est sélectionné
            if (this.dataEmployes.SelectedRows.Count > 0)
            {
                FolderBrowserDialog folderBrowserDialog = new System.Windows.Forms.FolderBrowserDialog();
                DialogResult        result = folderBrowserDialog.ShowDialog();

                if (result == DialogResult.OK)
                {
                    IGestionEmployes
                        gestionEmployes = GestionEmployesBuilderClassFactory.getInterface();

                    string                  folderName       = folderBrowserDialog.SelectedPath;
                    int                     selectedRowIndex = this.dataEmployes.SelectedRows[0].Index;
                    int                     IdUtilisateur    = Convert.ToInt32(this.dataEmployes.Rows[selectedRowIndex].Cells["IdUtilisateur"].Value);
                    object[]                tabInfoUser      = gestionEmployes.findUtilisateur(IdUtilisateur);
                    Utilisateur             utilisateur      = (Utilisateur)tabInfoUser[0];
                    Adresse                 adresse          = (Adresse)tabInfoUser[1];
                    Societe                 societe          = (Societe)tabInfoUser[2];
                    Role                    role             = (Role)tabInfoUser[3];
                    Ville                   ville            = (Ville)tabInfoUser[4];
                    FormModificationEmploye form             = new FormModificationEmploye();

                    // Génération du fichier PDF
                    try
                    {
                        pdfDocument myDoc       = new pdfDocument("Sample Application", "Me", false);
                        pdfPage     myFirstPage = myDoc.addPage(700, 700);
                        myFirstPage.addText("Fiche d'information - " + utilisateur.Prenom.Trim() + " " + utilisateur.Nom.Trim(),
                                            100, 630, predefinedFont.csHelvetica, 30, new pdfColor(predefinedColor.csBlack));
                        /*Table's creation*/
                        pdfTable myTable = new pdfTable();
                        //Set table's border
                        myTable.borderSize  = 0;
                        myTable.borderColor = new pdfColor(predefinedColor.csBlack);
                        /*Create table's header*/
                        myTable.tableHeader.addColumn(new pdfTableColumn("Information", predefinedAlignment.csLeft, 150));
                        myTable.tableHeader.addColumn(new pdfTableColumn("Valeur", predefinedAlignment.csCenter, 250));

                        /*Create table's rows*/
                        pdfTableRow myRow = myTable.createRow();
                        myRow[0].columnValue = "Prénom";
                        myRow[1].columnValue = utilisateur.Prenom.Trim();
                        myTable.addRow(myRow);

                        myRow = myTable.createRow();
                        myRow[0].columnValue = "Nom";
                        myRow[1].columnValue = utilisateur.Nom.Trim();
                        myTable.addRow(myRow);

                        myRow = myTable.createRow();
                        myRow[0].columnValue = "Identifiant";
                        myRow[1].columnValue = utilisateur.Identifiant;
                        myTable.addRow(myRow);

                        myRow = myTable.createRow();
                        myRow[0].columnValue = "Mot de passe";
                        myRow[1].columnValue = utilisateur.MotPasse;
                        myTable.addRow(myRow);

                        myRow = myTable.createRow();
                        myRow[0].columnValue = "Rôle";
                        myRow[1].columnValue = role.CodeRole;
                        myTable.addRow(myRow);

                        myRow = myTable.createRow();
                        myRow[0].columnValue = "Date de début";
                        myRow[1].columnValue = utilisateur.DateDebut.ToShortDateString();
                        myTable.addRow(myRow);

                        myRow = myTable.createRow();
                        myRow[0].columnValue = "Date de fin";
                        myRow[1].columnValue = utilisateur.DateFin.ToShortDateString();
                        myTable.addRow(myRow);

                        myRow = myTable.createRow();
                        myRow[0].columnValue = "Adresse";
                        myRow[1].columnValue = adresse.NumeroRue + " " + adresse.NomRue + ", " + adresse.CodePostal + " " +
                                               ville.CodeVille;
                        myTable.addRow(myRow);

                        myRow = myTable.createRow();
                        myRow[0].columnValue = "Nom de société";
                        myRow[1].columnValue = societe.NomSociete;
                        myTable.addRow(myRow);

                        myRow = myTable.createRow();
                        myRow[0].columnValue = "Description de société";
                        myRow[1].columnValue = societe.DescriptionSociete;
                        myTable.addRow(myRow);

                        myRow = myTable.createRow();
                        myRow[0].columnValue = "Numéro de siret";
                        myRow[1].columnValue = societe.NumeroSiret;
                        myTable.addRow(myRow);

                        /*Set Header's Style*/
                        myTable.tableHeaderStyle = new pdfTableRowStyle(predefinedFont.csHelveticaBold, 12,
                                                                        new pdfColor(predefinedColor.csWhite), new pdfColor(predefinedColor.csRed));
                        /*Set Row's Style*/
                        myTable.rowStyle = new pdfTableRowStyle(predefinedFont.csHelvetica, 10, new pdfColor(predefinedColor.csBlack),
                                                                new pdfColor(predefinedColor.csWhite));
                        /*Set Alternate Row's Style*/
                        myTable.alternateRowStyle = new pdfTableRowStyle(predefinedFont.csHelvetica, 10,
                                                                         new pdfColor(predefinedColor.csBlack), new pdfColor(predefinedColor.csLightGray));
                        /*Set Cellpadding*/
                        myTable.cellpadding = 10;
                        /*Put the table on the page object*/
                        myFirstPage.addTable(myTable, 150, 550);
                        myTable = null;
                        myDoc.createPDF(folderName + "\\FicheInformation.pdf");
                        MessageBox.Show("Le fichier PDF a bien été créé", "Génération de PDF");
                        Process.Start(folderName + "\\FicheInformation.pdf");
                        // Fin de génération du fichier PDF
                    }
                    // Quand il y a une erreur
                    catch (Exception exception)
                    {
                        MessageBox.Show("L'erreur suivante s'est produite : " + exception.Message + "", "Erreur lors de l'éxécution");
                    }
                }
            }
            // Si aucun employé n'est sélectionné
            else
            {
                MessageBox.Show("Sélectionnez un utilisateur.", "Génération fichier PDF");
            }
        }
Example #8
0
        public static pdfDocument ImprimeFechamento(DataTable table, string DataInicial, string DataFinal)
        {
            String strFont    = "Helvetica";
            int    leftMargin = 30;
            int    pg         = 1;
            int    top        = 40;
            //Tamanho da lin em pixel
            int nTamLinPixel = 19;

            // Variaveis de controle para quebra de linha de campos
            int QtdCaracterLinha = 80;
            int Tamanho;
            int QtdLin;
            int StrInicio;
            int StrFim;
            int cl;

            // Adiciona Página
            pdfDocument myDoc  = new pdfDocument("Horizon", "Orion");
            pdfPage     myPage = myDoc.addPage(predefinedPageSize.csSharpPDFFormat);

            string DadosObra = (table.Rows[0]["cmpNoObra"].ToString().Trim() + (table.Rows[0]["cmpNuContrato"] != null ? " -> Contrato nº " + table.Rows[0]["cmpNuContrato"].ToString() : ""));

            CabRelatorio(myDoc, myPage, top, DadosObra, DataInicial, DataFinal);
            top += 30;

            pdfTable myTable = SubCabRelatorio(myDoc, myPage, top);

            top += 10;

            // Imprimir linhas de detalhes
            pdfTableRow myRow = myTable.createRow();

            int cont = 0;

            foreach (DataRow row in table.Rows)
            {
                cl             = 0;
                myRow          = myTable.createRow();
                myRow.rowStyle = myTable.rowStyle;

                myRow[cl++].addText(row["cmpNuOs"].ToString());
                myRow[cl++].addText(row["cmpNoSolicitante"].ToString().TrimEnd());

                row["cmpDcObservacoes"] = TiraCaractEspecial(row["cmpDcObservacoes"].ToString().ToUpper());

                Tamanho = row["cmpDcObservacoes"].ToString().Length;

                if (Tamanho > 0)
                {
                    QtdLin    = (Tamanho % QtdCaracterLinha == 0 ? Tamanho / QtdCaracterLinha : (Tamanho / QtdCaracterLinha) + 1);
                    StrInicio = 0;

                    for (int Linha = 1; Linha <= QtdLin; Linha++)
                    {
                        StrFim = Linha == QtdLin ? Tamanho - StrInicio : QtdCaracterLinha;
                        if (Linha == 1)
                        {
                            myRow[cl++].addText(row["cmpDcObservacoes"].ToString().Substring(StrInicio, StrFim).Trim());
                            if (row["cmpDcLocal"] != null)
                            {
                                cont++;
                                //System.Diagnostics.Debug.WriteLine(cont.ToString());
                                myRow[cl++].addText(TiraCaractEspecial(row["cmpDcLocal"].ToString()));
                            }
                            else
                            {
                                myRow[cl++].addText(" ");
                            }
                            myRow[cl++].addText(row["cmpDtAbertura"].ToString().Substring(0, 10));
                            myRow[cl++].addText(row["cmpDtConclusaoAtendimento"].ToString() == "" ? "" : row["cmpDtConclusaoAtendimento"].ToString().Substring(0, 10));
                        }
                        else
                        {
                            cl             = 0;
                            myRow          = myTable.createRow();
                            myRow.rowStyle = myTable.rowStyle;
                            myRow[cl++].addText("");
                            myRow[cl++].addText("");
                            myRow[cl++].addText(row["cmpDcObservacoes"].ToString().Substring(StrInicio, StrFim).Trim());
                            myRow[cl++].addText("");
                            myRow[cl++].addText("");
                            myRow[cl++].addText("");
                        }
                        myTable.addRow(myRow);
                        StrInicio += QtdCaracterLinha;
                        top       += nTamLinPixel;
                    }
                }
                else
                {
                    myRow[cl++].addText(row["cmpDcDescricaoSolicitacao"].ToString().TrimEnd());
                    myRow[cl++].addText(row["cmpDcLocal"].ToString());
                    myRow[cl++].addText(row["cmpDtAbertura"].ToString().Substring(0, 10));
                    myRow[cl++].addText(row["cmpDtConclusaoAtendimento"].ToString() == "" ? "" : row["cmpDtConclusaoAtendimento"].ToString().Substring(0, 10));
                    myTable.addRow(myRow);
                    top += nTamLinPixel;
                }

                if (top > 1230)
                {
                    myPage.addText("Pág. " + pg++, leftMargin, 10, myDoc.getFontReference(strFont), 10, pdfColor.Black);
                    myPage.addTable(myTable);

                    // Adiciona uma página
                    myPage = myDoc.addPage(predefinedPageSize.csSharpPDFFormat);
                    top    = 30;
                    CabRelatorio(myDoc, myPage, top, DadosObra, DataInicial, DataFinal);
                    top    += 30;
                    myTable = SubCabRelatorio(myDoc, myPage, top);
                    top     = +10;
                }
            }

            if (top < 1230)
            {
                myPage.addText("Pág. " + pg++, leftMargin, 10, myDoc.getFontReference(strFont), 10, pdfColor.Black);
                myPage.addTable(myTable);
            }

            return(myDoc);
        }
Example #9
0
        public static pdfDocument ImprimePlano(DataTable table, string NoObra)
        {
            String strFont    = "Helvetica";
            int    leftMargin = 30;
            int    pg         = 1;
            int    top        = 40;
            //Tamanho da lin em pixel
            int nTamLinPixel = 19;

            // Variaveis de controle para quebra de linha de campos
            int QtdCaracterLinha = 100;
            int Tamanho;
            int QtdLin;
            int StrInicio;
            int StrFim;
            int cl;

            // Adiciona Página
            pdfDocument myDoc  = new pdfDocument("Horizon", "Orion");
            pdfPage     myPage = myDoc.addPage(predefinedPageSize.csSharpPDFFormat);

            string DadosObra = NoObra;

            CabRelatorio(myDoc, myPage, top, DadosObra);
            top += 30;

            pdfTable myTable = SubCabRelatorio(myDoc, myPage, top);

            top += 10;

            string TipoAtividade  = "";
            string GrupoAtividade = "";
            string Periodicidade  = "";

            // Imprimir linhas de detalhes
            pdfTableRow myRow = myTable.createRow();

            try
            {
                foreach (DataRow row in table.Rows)
                {
                    cl             = 0;
                    myRow          = myTable.createRow();
                    myRow.rowStyle = myTable.rowStyle;

                    if (TipoAtividade != row["cmpCoTipoAtividade"].ToString())
                    {
                        row["cmpDcTipoAtividade"] = TiraCaractEspecial(row["cmpDcTipoAtividade"].ToString());
                        myRow[cl++].addText(row["cmpDcTipoAtividade"].ToString().TrimEnd());
                        TipoAtividade = row["cmpCoTipoAtividade"].ToString();
                    }
                    else
                    {
                        myRow[cl++].addText("");
                    }

                    if (GrupoAtividade != row["cmpCoGrupoAtividade"].ToString())
                    {
                        row["cmpDcGrupoAtividade"] = TiraCaractEspecial(row["cmpDcGrupoAtividade"].ToString());
                        myRow[cl++].addText(row["cmpDcGrupoAtividade"].ToString().TrimEnd());
                        GrupoAtividade = row["cmpCoGrupoAtividade"].ToString();
                    }
                    else
                    {
                        myRow[cl++].addText("");
                    }

                    if (Periodicidade != row["cmpCoPeriodicidade"].ToString())
                    {
                        myRow[cl++].addText(row["cmpDcPeriodicidade"].ToString());
                        Periodicidade = row["cmpCoPeriodicidade"].ToString();
                    }
                    else
                    {
                        myRow[cl++].addText("");
                    }

                    row["cmpDcItemAtividadePreventiva"] = TiraCaractEspecial(row["cmpDcItemAtividadePreventiva"].ToString());

                    Tamanho = row["cmpDcItemAtividadePreventiva"].ToString().Length;

                    if (Tamanho > 0)
                    {
                        QtdLin    = (Tamanho % QtdCaracterLinha == 0 ? Tamanho / QtdCaracterLinha : (Tamanho / QtdCaracterLinha) + 1);
                        StrInicio = 0;

                        for (int Linha = 1; Linha <= QtdLin; Linha++)
                        {
                            StrFim = Linha == QtdLin ? Tamanho - StrInicio : QtdCaracterLinha;
                            if (Linha == 1)
                            {
                                myRow[cl++].addText(row["cmpDcItemAtividadePreventiva"].ToString().Substring(StrInicio, StrFim).Trim());
                            }
                            else
                            {
                                cl             = 0;
                                myRow          = myTable.createRow();
                                myRow.rowStyle = myTable.rowStyle;
                                myRow[cl++].addText("");
                                myRow[cl++].addText("");
                                myRow[cl++].addText("");
                                myRow[cl++].addText(row["cmpDcItemAtividadePreventiva"].ToString().Substring(StrInicio, StrFim).Trim());
                            }
                            myTable.addRow(myRow);
                            StrInicio += QtdCaracterLinha;
                            top       += nTamLinPixel;
                        }
                    }
                    //else
                    //{
                    //    myRow[cl++].addText(row["cmpDcDescricaoSolicitacao"].ToString().TrimEnd());
                    //    myRow[cl++].addText(row["cmpDcLocal"].ToString());
                    //    myRow[cl++].addText(row["cmpDtAbertura"].ToString().Substring(0, 10));
                    //    myRow[cl++].addText(row["cmpDtConclusaoAtendimento"].ToString() == "" ? "" : row["cmpDtConclusaoAtendimento"].ToString().Substring(0, 10));
                    //    myTable.addRow(myRow);
                    //    top += nTamLinPixel;
                    //}

                    if (top > 1250)
                    {
                        myPage.addText("Pág. " + pg++, leftMargin, 10, myDoc.getFontReference(strFont), 10, pdfColor.Black);
                        myPage.addTable(myTable);

                        // Adiciona uma página
                        myPage = myDoc.addPage(predefinedPageSize.csSharpPDFFormat);
                        top    = 30;
                        CabRelatorio(myDoc, myPage, top, DadosObra);
                        top    += 30;
                        myTable = SubCabRelatorio(myDoc, myPage, top);
                        top     = +10;
                    }
                }

                if (top < 1250)
                {
                    myPage.addText("Pág. " + pg++, leftMargin, 10, myDoc.getFontReference(strFont), 10, pdfColor.Black);
                    myPage.addTable(myTable);
                }
            }
            catch (Exception ex)
            {
                Global.ShowError(Global.Title, ex);
            }

            return(myDoc);
        }
Example #10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            HzConexao c = new HzConexao(@"192.168.200.170\desenv", "sa", "rona3007", "HzManutencao", "System.Data.SqlClient");

            String strFont      = "Helvetica";
            int    leftMargin   = 30;
            int    topMargin    = 30;
            int    bottomMargin = 30;
            int    lineHeight   = 20;
            int    linesPerPage;

            pdfDocument myDoc = new pdfDocument("Horizon", "Orion");
            // Add a page
            pdfPage myPage = myDoc.addPage(predefinedPageSize.csSharpPDFFormat);

            // Load an image (I was able to load JPEG, GIF, TIFF, and BMP formats)
            //myDoc.addImageReference(Server.MapPath("~/Assets/Images/Sample.gif"), "ex");
            //myPage.addImage(myDoc.getImageReference("ex"), leftMargin, getTop(myPage, 120));

            // Header Text
            myPage.addText("Ordem de Serviço", leftMargin, getTop(myPage, 30),
                           myDoc.getFontReference(strFont), 15, pdfColor.Black);

            // Body Text
            //myPage.addText("Divisão de Administração Predial, Obras e Instalações", leftMargin, getTop(myPage, 50),
            //               myDoc.getFontReference(strFont), 10, pdfColor.Black);
            //myPage.addText("Relatório emitido em: " + DateTime.Now.ToShortDateString(), leftMargin, getTop(myPage, 70),
            //               myDoc.getFontReference(strFont), 10, pdfColor.Black);

            //pdfTable myTable = new pdfTable(myDoc, 1, new pdfColor("000000"), 2,
            //                                new pdfTableStyle(myDoc.getFontReference(strFont),
            //                                10, pdfColor.Black, new pdfColor("d9d1b3")),
            //                                new pdfTableStyle(myDoc.getFontReference(strFont),
            //                                10, pdfColor.Black, pdfColor.White),
            //                                new pdfTableStyle(myDoc.getFontReference(strFont),
            //                                10, pdfColor.Black, pdfColor.White));

            int q   = 0;
            int pg  = 1;
            int top = 40;

            using (DataTable table = c.loadDataTable("select * from HzManutencao..vwATE_OS where cmpIdOS = 1"))
            {
                if (table != null && table.Rows.Count > 0)
                {
                    DataRow r = table.Rows[0];

                    pdfTable myTable = new pdfTable(myDoc, 1, new pdfColor("000000"), 2, new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, new pdfColor("FFFFFF")),
                                                    new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, pdfColor.White));

                    myTable.coordX = leftMargin;
                    myTable.coordY = getTop(myPage, top);

                    //// Create table's header
                    int cl = 0;
                    myTable.tableHeader.rowHeight = 10;
                    myTable.tableHeader.addColumn(150, predefinedAlignment.csLeft);
                    myTable.tableHeader[cl++].addText("Nº O.S.");

                    myTable.tableHeader.addColumn(420, predefinedAlignment.csLeft);
                    myTable.tableHeader[cl].columnAlign = predefinedAlignment.csLeft;
                    myTable.tableHeader[cl++].addText(r["cmpNuOS"].ToString());

                    // Create Table Row
                    pdfTableRow myRow = myTable.createRow();
                    cl    = 0;
                    myRow = myTable.createRow();
                    myRow[cl].columnAlign = predefinedAlignment.csLeft;
                    myRow[cl++].addText("Data Solicitação:");
                    myRow[cl++].addText(r["cmpDtAbertura"].ToString().Trim());
                    myTable.addRow(myRow);

                    cl    = 0;
                    myRow = myTable.createRow();
                    myRow[cl].columnAlign = predefinedAlignment.csLeft;
                    myRow[cl++].addText("Obra:");
                    myRow[cl++].addText(r["cmpNoObra"].ToString().Trim() + (r["cmpNuContrato"] != null ? " -> Contrato nº " + r["cmpNuContrato"].ToString() : ""));
                    myTable.addRow(myRow);

                    cl    = 0;
                    myRow = myTable.createRow();
                    myRow[cl].columnAlign = predefinedAlignment.csLeft;
                    myRow[cl++].addText("Soliciante:");
                    myRow[cl++].addText(r["cmpNoSolicitante"].ToString().Trim());
                    myTable.addRow(myRow);

                    cl    = 0;
                    myRow = myTable.createRow();
                    myRow[cl].columnAlign = predefinedAlignment.csLeft;
                    myRow[cl++].addText("Local:");
                    myRow[cl++].addText(r["cmpDcLocal"].ToString().Trim());
                    myTable.addRow(myRow);

                    cl    = 0;
                    myRow = myTable.createRow();
                    myRow[cl].columnAlign = predefinedAlignment.csLeft;
                    myRow[cl++].addText("Setor:");
                    myRow[cl++].addText(r["cmpNoSetor"].ToString().Trim());
                    myTable.addRow(myRow);

                    cl    = 0;
                    myRow = myTable.createRow();
                    myRow[cl].columnAlign = predefinedAlignment.csLeft;
                    myRow[cl++].addText("Data Início:");
                    myRow[cl++].addText(r["cmpDtInicioAtendimento"].ToString() != "" ? DateTime.Parse(r["cmpDtInicioAtendimento"].ToString()).ToString("dd/MM/yyyy HH:mm") : "");
                    myTable.addRow(myRow);

                    cl    = 0;
                    myRow = myTable.createRow();
                    myRow[cl].columnAlign = predefinedAlignment.csLeft;
                    myRow[cl++].addText("Data Conclusão:");
                    myRow[cl++].addText(r["cmpDtConclusaoAtendimento"].ToString() != "" ? DateTime.Parse(r["cmpDtConclusaoAtendimento"].ToString()).ToString("dd/MM/yyyy HH:mm") : "");
                    myTable.addRow(myRow);

                    cl    = 0;
                    myRow = myTable.createRow();
                    myRow[cl].columnAlign = predefinedAlignment.csLeft;
                    myRow[cl++].addText("Descrição do Serviço:");
                    myRow[cl++].addText(r["cmpDcDescricaoSolicitacao"].ToString().Trim());
                    myTable.addRow(myRow);

                    cl                    = 0;
                    myRow                 = myTable.createRow();
                    myRow.rowHeight       = 50;
                    myRow[cl].columnAlign = predefinedAlignment.csLeft;
                    myRow[cl++].addText("Verificação do Serviço:");
                    myRow[cl++].addText(r["cmpDcObservacaoConclusao"].ToString().Trim());
                    myTable.addRow(myRow);
                    top += 10 * 9;

                    myPage.addTable(myTable);

                    top += 100;
                    myPage.addText("Material Utilizado", leftMargin, this.getTop(myPage, top), myDoc.getFontReference(strFont), 10, pdfColor.Black);
                    top += 12;

                    string sql = "select * from HzManutencao..vwATE_OSMaterial where cmpIdOS = " + r["cmpIdOS"].ToString();
                    using (DataTable tblMat = Global.GetConnection().loadDataTable(sql))
                    {
                        if (tblMat != null && tblMat.Rows.Count > 0)
                        {
                            myTable = new pdfTable(myDoc, 1, new pdfColor("000000"), 2, new pdfTableStyle(myDoc.getFontReference(strFont), 8, pdfColor.Black, new pdfColor("FFFFFF")),
                                                   new pdfTableStyle(myDoc.getFontReference(strFont), 8, pdfColor.Black, pdfColor.White));

                            myTable.coordX = leftMargin;
                            //top = 210;
                            myTable.coordY = getTop(myPage, top);

                            //// Create table's header
                            cl = 0;
                            myTable.tableHeader.rowHeight = 10;
                            myTable.tableHeader.addColumn(350, predefinedAlignment.csLeft);
                            myTable.tableHeader[cl++].addText("Descrição");

                            myTable.tableHeader.addColumn(30, predefinedAlignment.csCenter);
                            myTable.tableHeader[cl].columnAlign = predefinedAlignment.csCenter;
                            myTable.tableHeader[cl++].addText("Unid");

                            myTable.tableHeader.addColumn(50, predefinedAlignment.csRight);
                            myTable.tableHeader[cl].columnAlign = predefinedAlignment.csRight;
                            myTable.tableHeader[cl++].addText("Qtd.");

                            myTable.tableHeader.addColumn(50, predefinedAlignment.csRight);
                            myTable.tableHeader[cl].columnAlign = predefinedAlignment.csRight;
                            myTable.tableHeader[cl++].addText("Preço");

                            myTable.tableHeader.addColumn(90, predefinedAlignment.csRight);
                            myTable.tableHeader[cl].columnAlign = predefinedAlignment.csRight;
                            myTable.tableHeader[cl++].addText("Sub-Total");
                            top += 15;

                            float total = 0f;
                            foreach (DataRow row in tblMat.Rows)
                            {
                                // Create Table Row
                                myRow = myTable.createRow();
                                cl    = 0;
                                myRow = myTable.createRow();
                                myRow[cl].columnAlign = predefinedAlignment.csLeft;
                                myRow[cl++].addText(row["DcMaterial"].ToString().Trim());
                                myRow[cl++].addText(row["cmpDcUnidade"].ToString().Trim());
                                myRow[cl++].addText(decimal.Parse(row["cmpQtMaterial"].ToString()).ToString("0,0.00"));
                                myRow[cl++].addText(decimal.Parse(row["cmpVlMaterial"].ToString()).ToString("0,0.00"));
                                myRow[cl++].addText(decimal.Parse(row["cmpVlSubTotal"].ToString()).ToString("0,0.00"));
                                total += float.Parse(row["cmpVlSubTotal"].ToString());
                                myTable.addRow(myRow);
                                top += 12;
                            }
                            myPage.addTable(myTable);
                            top += 3;

                            myTable = new pdfTable(myDoc, 1, new pdfColor("000000"), 2, new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, new pdfColor("FFFFFF")),
                                                   new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, pdfColor.White));

                            myTable.coordX = leftMargin;
                            myTable.coordY = getTop(myPage, top);

                            //// Create table's header
                            cl = 0;
                            myTable.tableHeader.rowHeight = 10;
                            myTable.tableHeader.addColumn(570, predefinedAlignment.csRight);
                            //IFormatProvider fp = new CultureInfo("pt-BR", true);
                            myTable.tableHeader[cl++].addText("Total: " + total.ToString("0,0.00"));
                            top += 17;
                            myPage.addTable(myTable);
                        }
                    }


                    myTable = new pdfTable(myDoc, 1, new pdfColor("000000"), 2, new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, new pdfColor("FFFFFF")),
                                           new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, pdfColor.White));

                    myTable.coordX = leftMargin;
                    myTable.coordY = getTop(myPage, top);

                    //// Create table's header
                    cl = 0;
                    myTable.tableHeader.rowHeight        = 30;
                    myTable.tableHeader.rowVerticalAlign = predefinedVerticalAlignment.csTop;
                    myTable.tableHeader.addColumn(570, predefinedAlignment.csLeft);
                    myTable.tableHeader[cl].columnVerticalAlign = predefinedVerticalAlignment.csTop;
                    myTable.tableHeader[cl++].addText("Conclusão/Aceite do Solicitante");
                    top += 30;

                    cl                    = 0;
                    myRow                 = myTable.createRow();
                    myRow.rowHeight       = 10;
                    myRow[cl].columnAlign = predefinedAlignment.csLeft;
                    myRow[cl++].addText("Data: " + DateTime.Now.ToShortDateString() + " às " + DateTime.Now.ToShortTimeString());
                    myTable.addRow(myRow);
                    top += 15;

                    cl                    = 0;
                    myRow                 = myTable.createRow();
                    myRow.rowHeight       = 10;
                    myRow[cl].columnAlign = predefinedAlignment.csLeft;
                    myRow[cl++].addText("Satisfeito com o serviço: " + "__Sim         __Não");
                    myTable.addRow(myRow);
                    top += 15;

                    myPage.addTable(myTable);

                    myTable = new pdfTable(myDoc, 1, new pdfColor("000000"), 2, new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, new pdfColor("FFFFFF")),
                                           new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, pdfColor.White));

                    myTable.coordX = leftMargin;
                    myTable.coordY = getTop(myPage, top);

                    cl = 0;
                    myTable.tableHeader.rowHeight        = 50;
                    myTable.tableHeader.rowVerticalAlign = predefinedVerticalAlignment.csBottom;
                    myTable.tableHeader.addColumn(285, predefinedAlignment.csCenter);
                    myTable.tableHeader[cl].columnVerticalAlign = predefinedVerticalAlignment.csBottom;
                    myTable.tableHeader[cl++].addText("De acordo Empresa");

                    myTable.tableHeader.addColumn(285, predefinedAlignment.csCenter);
                    myTable.tableHeader[cl].columnVerticalAlign = predefinedVerticalAlignment.csBottom;
                    myTable.tableHeader[cl].addText("De acordo Gestor");

                    myPage.addTable(myTable);

                    myPage.addText("Pág. " + pg++, leftMargin, 10, myDoc.getFontReference(strFont), 5, pdfColor.Black);
                    //string nomepdf = "c:\\Horizon\\Ocr\\Relatorios\\" + "Relatorio_" + (txtPlacaRelatorio.Text != "" ? txtPlacaRelatorio.Text : "Todas") + "_" + retornaDataRelatorio(txtDataInicial.Text) + "_" + retornaDataRelatorio(txtDataFinal.Text) + ".pdf";
                    string nomepdf = Server.MapPath("pdf" + DateTime.Now.Day.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Year.ToString() + DateTime.Now.Millisecond.ToString() + ".pdf");
                    myDoc.createPDF(nomepdf);
                    System.Diagnostics.Process.Start(nomepdf);
                }
            }
            ++q;

            //if (q == 30)
            //{
            //    myPage.addText("Pág. " + pg++, leftMargin, 10,
            //                    myDoc.getFontReference(strFont), 5, pdfColor.Black);
            //    myPage.addTable(myTable);
            //    myPage = myDoc.addPage(predefinedPageSize.csSharpPDFFormat);
            //    q = 0;
            //    myTable = new pdfTable(myDoc, 1, new pdfColor("000000"), 5,
            //                                    new pdfTableStyle(myDoc.getFontReference(strFont),
            //                                    10, pdfColor.Black, new pdfColor("d9d1b3")),
            //                                    new pdfTableStyle(myDoc.getFontReference(strFont),
            //                                    10, pdfColor.Black, pdfColor.White),
            //                                    new pdfTableStyle(myDoc.getFontReference(strFont),
            //                                    10, pdfColor.Black, pdfColor.White));
            //    myTable.coordX = leftMargin;
            //    myTable.coordY = getTop(myPage, 100);

            //    // Create table's header
            //    myTable.tableHeader.rowHeight = 10;
            //    c = 0;
            //    myTable.tableHeader.addColumn(100, predefinedAlignment.csCenter);
            //    myTable.tableHeader[c++].addText("Placa");
            //    if (rdbAcesso.IsChecked.Value)
            //    {
            //        myTable.tableHeader.addColumn(200, predefinedAlignment.csLeft);
            //        myTable.tableHeader[c++].addText("Nome");
            //    }
            //    myTable.tableHeader.addColumn(150, predefinedAlignment.csCenter);
            //    myTable.tableHeader[c++].addText("Data");
            //    if (rdbAcesso.IsChecked.Value)
            //    {
            //        myTable.tableHeader.addColumn(100, predefinedAlignment.csCenter);
            //        myTable.tableHeader[c].addText("Cancela");
            //    }

            //    myPage.addText("Procuradoria Geral da República", leftMargin, getTop(myPage, 30),
            //                    myDoc.getFontReference(strFont), 20, pdfColor.Black);

            //    // Body Text
            //    myPage.addText("Relatório dos Acessos à Garagem", leftMargin, getTop(myPage, 50),
            //                   myDoc.getFontReference(strFont), 10, pdfColor.Black);
            //    myPage.addText("Relatório emitido em: " + DateTime.Now.ToShortDateString(), leftMargin, getTop(myPage, 70),
            //                   myDoc.getFontReference(strFont), 10, pdfColor.Black);
            //}
        }
Example #11
0
        public virtual int SubCabRelatorio(pdfDocument myDoc, pdfPage myPage, int top, DataRow r)
        {
            String strFont    = "Helvetica";
            int    leftMargin = 30;
            //Tamanho da lin em pixel
            int nTamLinPixel = 19;

            pdfTable myTable = new pdfTable(myDoc, 1, new pdfColor("000000"), 2,
                                            new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, new pdfColor("FFFFFF")),
                                            new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, pdfColor.White));

            myTable.coordX = leftMargin;
            myTable.coordY = getTop(myPage, top);

            //// Create table's header
            int cl = 0;

            myTable.tableHeader.rowHeight = 10;
            myTable.tableHeader.addColumn(150, predefinedAlignment.csLeft);
            myTable.tableHeader[cl++].addText("Descrição do Equipamento");

            myTable.tableHeader.addColumn(400, predefinedAlignment.csLeft);
            myTable.tableHeader[cl].columnAlign = predefinedAlignment.csLeft;
            myTable.tableHeader[cl++].addText(r["cmpDcEquipamentoObra"].ToString());

            top += nTamLinPixel;

            myPage.addTable(myTable);

            myTable = new pdfTable(myDoc, 1, new pdfColor("000000"), 2,
                                   new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, new pdfColor("FFFFFF")),
                                   new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, pdfColor.White));

            myTable.coordX = leftMargin;
            myTable.coordY = getTop(myPage, top);

            //// Create table's header
            cl = 0;
            myTable.tableHeader.rowHeight = 10;
            myTable.tableHeader.addColumn(150, predefinedAlignment.csLeft);
            myTable.tableHeader[cl++].addText("Código do Equipamento");

            myTable.tableHeader.addColumn(125, predefinedAlignment.csLeft);
            myTable.tableHeader[cl].columnAlign = predefinedAlignment.csLeft;
            myTable.tableHeader[cl++].addText(r["CodEquipamento"].ToString().TrimEnd());

            myTable.tableHeader.rowHeight = 10;
            myTable.tableHeader.addColumn(115, predefinedAlignment.csLeft);
            myTable.tableHeader[cl++].addText("Tipo do Equipamento");

            myTable.tableHeader.addColumn(160, predefinedAlignment.csLeft);
            myTable.tableHeader[cl].columnAlign = predefinedAlignment.csLeft;
            myTable.tableHeader[cl++].addText(r["cmpDcTipoAtividade"].ToString().TrimEnd());

            top += nTamLinPixel;
            // Create Table Row - 1ª linha
            pdfTableRow myRow = myTable.createRow();

            myRow = myTable.createRow();
            cl    = 0;
            myRow[cl].columnAlign = predefinedAlignment.csLeft;
            myRow[cl++].addText("Capacidade do Equipamento");
            myRow[cl++].addText(r["DcCapacidade"].ToString().TrimEnd());

            myRow[cl].columnAlign = predefinedAlignment.csLeft;
            myRow[cl++].addText("Marca / Modelo");
            myRow[cl++].addText(r["cmpDcMarcaModeloEquipamento"].ToString().TrimEnd());
            myTable.addRow(myRow);
            top += nTamLinPixel;

            // Create Table Row - 2ª linha
            myRow = myTable.createRow();
            cl    = 0;
            myRow[cl].columnAlign = predefinedAlignment.csLeft;
            myRow[cl++].addText("Número de Série");
            myRow[cl++].addText(r["cmpNuSerieEquipamento"].ToString().TrimEnd());

            myRow[cl].columnAlign = predefinedAlignment.csLeft;
            myRow[cl++].addText("Número do Patrimônio");
            myRow[cl++].addText(r["cmpNuPatrimonio"].ToString().TrimEnd());
            myTable.addRow(myRow);
            top += nTamLinPixel;

            // Create Table Row - 3ª linha
            myRow = myTable.createRow();
            cl    = 0;
            myRow[cl].columnAlign = predefinedAlignment.csLeft;
            myRow[cl++].addText("Pavimento");
            myRow[cl++].addText(r["cmpDcPavimento"].ToString().TrimEnd());

            myRow[cl].columnAlign = predefinedAlignment.csLeft;
            myRow[cl++].addText("Localização");
            myRow[cl++].addText(r["cmpDcLocalEquipamento"].ToString().TrimEnd());
            myTable.addRow(myRow);
            top += nTamLinPixel;

            myPage.addTable(myTable);

            return(top);
        }
Example #12
0
        protected static pdfTable ConclusaoRelatorio(pdfDocument myDoc, pdfPage myPage, int top)
        {
            String strFont    = "Helvetica";
            int    leftMargin = 30;

            pdfTable myTable = new pdfTable(myDoc, 1, new pdfColor("000000"), 2,
                                            new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, new pdfColor("FFFFFF")),
                                            new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, pdfColor.White));

            myTable.coordX = leftMargin;
            myTable.coordY = getTop(myPage, top);
            int cl = 0;

            myTable.tableHeader.rowHeight = 15;
            myTable.tableHeader.addColumn(550, predefinedAlignment.csCenter);
            myTable.tableHeader[cl].addText("Responsável pela Execução dos Serviços");
            myPage.addTable(myTable);

            top    += 15;
            myTable = new pdfTable(myDoc, 1, new pdfColor("000000"), 2,
                                   new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, new pdfColor("FFFFFF")),
                                   new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, pdfColor.White));
            myTable.coordX = leftMargin;
            myTable.coordY = getTop(myPage, top);
            cl             = 0;
            myTable.tableHeader.rowHeight = 15;
            myTable.tableHeader.addColumn(275, predefinedAlignment.csLeft);
            myTable.tableHeader[cl++].addText("Nome do Técnico:");
            myTable.tableHeader.rowHeight = 15;
            myTable.tableHeader.addColumn(275, predefinedAlignment.csLeft);
            myTable.tableHeader[cl++].addText("Data: _____________________________, ____/____/" + DateTime.Now.Year);
            myPage.addTable(myTable);

            top    += 15;
            myTable = new pdfTable(myDoc, 1, new pdfColor("000000"), 2,
                                   new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, new pdfColor("FFFFFF")),
                                   new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, pdfColor.White));
            myTable.coordX = leftMargin;
            myTable.coordY = getTop(myPage, top);
            cl             = 0;
            myTable.tableHeader.rowHeight = 15;
            myTable.tableHeader.addColumn(275, predefinedAlignment.csLeft);
            myTable.tableHeader[cl++].addText("Hora de Entrada: ________________");
            myTable.tableHeader.rowHeight = 15;
            myTable.tableHeader.addColumn(275, predefinedAlignment.csLeft);
            myTable.tableHeader[cl++].addText("Hora da Saída: ______________");
            myPage.addTable(myTable);

            top    += 30;
            myTable = new pdfTable(myDoc, 1, new pdfColor("000000"), 2,
                                   new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, new pdfColor("FFFFFF")),
                                   new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, pdfColor.White));
            myTable.coordX = leftMargin;
            myTable.coordY = getTop(myPage, top);
            cl             = 0;
            myTable.tableHeader.rowHeight = 15;
            myTable.tableHeader.addColumn(550, predefinedAlignment.csCenter);
            myTable.tableHeader[cl].addText("Conclusão / Aceite do Cliente");
            myPage.addTable(myTable);

            top    += 15;
            myTable = new pdfTable(myDoc, 1, new pdfColor("000000"), 2,
                                   new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, new pdfColor("FFFFFF")),
                                   new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, pdfColor.White));

            myTable.coordX = leftMargin;
            myTable.coordY = getTop(myPage, top);
            cl             = 0;
            myTable.tableHeader.rowHeight = 15;
            myTable.tableHeader.addColumn(550, predefinedAlignment.csLeft);
            myTable.tableHeader[cl++].addText("Nome do Cliente:                                                                                                    Data:");

            pdfTableRow myRow;

            cl             = 0;
            myRow          = myTable.createRow();
            myRow.rowStyle = myTable.rowStyle;
            myRow[cl].addText("Satisfeito com o serviço? _________ Sim    _________ Não");
            myTable.addRow(myRow);
            myRow = myTable.createRow();
            myRow[cl].addText("Comentários: ");
            myTable.addRow(myRow);
            myRow = myTable.createRow();
            myRow[cl].addText("");
            myTable.addRow(myRow);
            myRow = myTable.createRow();
            myRow[cl].addText("");
            myTable.addRow(myRow);
            myRow = myTable.createRow();
            myRow[cl].addText("");
            myTable.addRow(myRow);
            myRow = myTable.createRow();
            myRow[cl].addText("");
            myTable.addRow(myRow);
            myRow = myTable.createRow();
            myRow[cl].addText("");
            myTable.addRow(myRow);
            myRow = myTable.createRow();
            myRow[cl].addText("");
            myTable.addRow(myRow);
            myRow = myTable.createRow();
            myRow[cl].addText("");
            myTable.addRow(myRow);

            return(myTable);
        }
Example #13
0
        public static pdfDocument ImprimeResumoOS(DataTable table, string DataInicial, string DataFinal)
        {
            String  strFont    = "Helvetica";
            int     leftMargin = 30;
            int     pg         = 1;
            int     top        = 40;
            TotalOS totalos    = new TotalOS();
            //Tamanho da lin em pixel
            int nTamLinPixel = 19;

            // Variaveis de controle para quebra de linha de campos
            int QtdCaracterLinha = 120;
            int Tamanho;
            int QtdLin;
            int StrInicio;
            int StrFim;
            int cl;

            // Adiciona Página
            pdfDocument myDoc  = new pdfDocument("Horizon", "Orion");
            pdfPage     myPage = myDoc.addPage(predefinedPageSize.csSharpPDFFormat);

            string   DadosObra = (table.Rows[0]["cmpNoObra"].ToString().Trim() + (table.Rows[0]["cmpNuContrato"] != null ? " -> Contrato nº " + table.Rows[0]["cmpNuContrato"].ToString() : ""));
            pdfTable myTable   = CabRelatorio(myDoc, myPage, top, DadosObra, DataInicial, DataFinal);

            // Imprimir linhas de detalhes
            pdfTableRow myRow = myTable.createRow();

            foreach (DataRow row in table.Rows)
            {
                totalos.Adicionar(row["cmpDcOrigemOS"].ToString());
                cl = 0;
                row["cmpDcObservacoes"] = TiraCaractEspecial(row["cmpDcObservacoes"].ToString());

                Tamanho = row["cmpDcObservacoes"].ToString().Length;

                if (Tamanho > 0)
                {
                    QtdLin    = (Tamanho % QtdCaracterLinha == 0 ? Tamanho / QtdCaracterLinha : (Tamanho / QtdCaracterLinha) + 1);
                    StrInicio = 0;

                    for (int Linha = 1; Linha <= QtdLin; Linha++)
                    {
                        StrFim = Linha == QtdLin ? Tamanho - StrInicio : QtdCaracterLinha;
                        if (Linha == 1)
                        {
                            myRow          = myTable.createRow();
                            myRow.rowStyle = myTable.rowStyle;
                            myRow[cl++].addText(row["cmpDcObservacoes"].ToString().Substring(StrInicio, StrFim).Trim());
                            myRow[cl++].addText(row["cmpDtAbertura"].ToString());
                        }
                        else
                        {
                            cl             = 0;
                            myRow          = myTable.createRow();
                            myRow.rowStyle = myTable.rowStyle;
                            myRow[cl++].addText(row["cmpDcObservacoes"].ToString().Substring(StrInicio, StrFim).Trim());
                            myRow[cl++].addText("");
                        }
                        myTable.addRow(myRow);
                        StrInicio += QtdCaracterLinha;
                        top       += nTamLinPixel;
                    }
                }
                else
                {
                    myRow          = myTable.createRow();
                    myRow.rowStyle = myTable.rowStyle;
                    myRow[cl++].addText(row["cmpDcDescricaoSolicitacao"].ToString().TrimEnd());
                    myRow[cl++].addText(row["cmpDtAbertura"].ToString());
                    myTable.addRow(myRow);
                    top += nTamLinPixel;
                }
                if (top > 980)
                {
                    myPage.addText("Pág. " + pg++, leftMargin, 10, myDoc.getFontReference(strFont), 10, pdfColor.Black);
                    myPage.addTable(myTable);

                    // Adiciona uma página
                    myPage  = myDoc.addPage(predefinedPageSize.csSharpPDFFormat);
                    top     = 40;
                    myTable = CabRelatorio(myDoc, myPage, top, DadosObra, DataInicial, DataFinal);
                    top     = +15;
                }
            }

            if (top < 980)
            {
                myPage.addText("Pág. " + pg++, leftMargin, 10, myDoc.getFontReference(strFont), 10, pdfColor.Black);
                myPage.addTable(myTable);

                // Adiciona uma página
                myPage  = myDoc.addPage(predefinedPageSize.csSharpPDFFormat);
                top     = 40;
                myTable = CabRelatorio(myDoc, myPage, top, DadosObra, DataInicial, DataFinal);
                top     = +120;
            }

            // Imprimir Resumo dos atendimentos
            myTable = new pdfTable(myDoc, 1, new pdfColor("000000"), 2,
                                   new pdfTableStyle(myDoc.getFontReference(strFont), 12, pdfColor.Black, new pdfColor("FFFFFF")),
                                   new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, pdfColor.White));

            myTable.coordX = leftMargin;
            myTable.coordY = getTop(myPage, top);

            cl = 0;
            myTable.tableHeader.rowHeight = 30;
            myTable.tableHeader.addColumn(300, predefinedAlignment.csCenter);
            myTable.tableHeader[cl++].addText("RESUMO DAS ATIVIDADES REALIZADAS");
            myPage.addTable(myTable);

            top += 30;

            myTable = new pdfTable(myDoc, 1, new pdfColor("000000"), 2,
                                   new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, new pdfColor("FFFFFF")),
                                   new pdfTableStyle(myDoc.getFontReference(strFont), 8, pdfColor.Black, pdfColor.White));

            myTable.coordX = leftMargin;
            myTable.coordY = getTop(myPage, top);

            cl = 0;
            myTable.tableHeader.rowHeight = 12;
            myTable.tableHeader.addColumn(200, predefinedAlignment.csLeft);
            myTable.tableHeader[cl++].addText("Tipo de Atendimento");

            myTable.tableHeader.addColumn(100, predefinedAlignment.csRight);
            myTable.tableHeader[cl++].addText("Quantidade");

            cl             = 0;
            myRow          = myTable.createRow();
            myRow.rowStyle = myTable.rowStyle;
            myRow[cl++].addText("Eventuais");
            myRow[cl++].addText(totalos.Eventual.ToString());
            myTable.addRow(myRow);

            cl             = 0;
            myRow          = myTable.createRow();
            myRow.rowStyle = myTable.rowStyle;
            myRow[cl++].addText("Interno");
            myRow[cl++].addText(totalos.Interno.ToString());
            myTable.addRow(myRow);

            cl             = 0;
            myRow          = myTable.createRow();
            myRow.rowStyle = myTable.rowStyle;
            myRow[cl++].addText("Preventiva");
            myRow[cl++].addText(totalos.Preventiva.ToString());
            myTable.addRow(myRow);

            cl             = 0;
            myRow          = myTable.createRow();
            myRow.rowStyle = myTable.rowStyle;
            myRow[cl++].addText("Externo");
            myRow[cl++].addText(totalos.Externa.ToString());
            myTable.addRow(myRow);

            cl             = 0;
            myRow          = myTable.createRow();
            myRow.rowStyle = myTable.rowStyle;
            myRow[cl++].addText("Fora de Escopo");
            myRow[cl++].addText(totalos.ForaEscopo.ToString());
            myTable.addRow(myRow);

            myPage.addText("Pág. " + pg++, leftMargin, 10, myDoc.getFontReference(strFont), 10, pdfColor.Black);
            myPage.addTable(myTable);

            return(myDoc);
        }
        //writes maintenance cost estimates summary to the pdf report
        protected void WriteMaintCostSummaryTable(pdfPage myPage, string tableTitle, int tblStartLine, dynamic costModuleResults)
        {
            int line = tblStartLine;

            myPage.addText(tableTitle, GetCenteredOffset(myPage, tableTitle, 20),
                           GetLineTop(myPage, line), myDoc.getFontReference(strFont), 16, pdfColor.Black);
            line = line + 1;
            //myPage.addText(tableTitle, leftMargin, bottomMargin + lineHeight, myDoc.getFontReference(strFont), 10);
            pdfTable myTable = new pdfTable(myDoc, 1, pdfColor.Black, 5,
                                            new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, new pdfColor("d9d1b3")),
                                            new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, pdfColor.White),
                                            new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, pdfColor.White));

            myTable.coordX = leftMargin;
            myTable.coordY = GetLineTop(myPage, line);
            myTable.tableHeader.rowHeight = 25;
            myTable.tableHeader.addColumn(120, predefinedAlignment.csLeft);
            myTable.tableHeader[0].addText("LID Control");
            myTable.tableHeader.addColumn(130, predefinedAlignment.csLeft);
            myTable.tableHeader[1].addText("Current Scenario");
            myTable.tableHeader.addColumn(130, predefinedAlignment.csLeft);
            myTable.tableHeader[2].addText("Baseline Scenario");
            myTable.tableHeader.addColumn(130, predefinedAlignment.csLeft);
            myTable.tableHeader[3].addText("Cost Difference");


            int         tableRowHt = 15;
            string      tempCostLow;
            string      tempCostHigh;
            string      tempCostDiffLow;
            string      tempCostDiffHigh;
            pdfTableRow myRow;

            //foreach (dynamic o in costModuleResults)
            for (int i = 0; i < costModuleResults.Count - 1; i++)
            {
                dynamic o = costModuleResults[i];
                myRow           = myTable.createRow();
                myRow.rowHeight = tableRowHt;


                myRow[0].addText(Convert.ToString(o.name));//lid control name

                if (o.currentScenarioMaintCostLow != null)
                {
                    tempCostLow  = String.Format("{0:#,###,###.##}", Math.Round((Double)o.currentScenarioMaintCostLow / 100.0, 0) * 100);
                    tempCostHigh = String.Format("{0:#,###,###.##}", Math.Round((Double)o.currentScenarioMaintCostHigh / 100.0, 0) * 100);
                    myRow[1].addText("$ " + tempCostLow + " - " + "$ " + tempCostHigh);//current maint cost low
                }

                if (o.baseScenarioMaintCostLow != null)
                {
                    tempCostLow  = String.Format("{0:#,###,###.##}", Math.Round((Double)o.baseScenarioMaintCostLow / 100.0, 0) * 100);
                    tempCostHigh = String.Format("{0:#,###,###.##}", Math.Round((Double)o.baseScenarioMaintCostHigh / 100.0, 0) * 100);
                    myRow[2].addText("$ " + tempCostLow + " - " + "$ " + tempCostHigh);//base maint cost high

                    //populate cost difference column
                    tempCostDiffLow  = String.Format("{0:#,###,###.##}", Math.Round(((Double)o.currentScenarioMaintCostLow - (Double)o.baseScenarioMaintCostLow) / 100.0, 0) * 100);
                    tempCostDiffHigh = String.Format("{0:#,###,###.##}", Math.Round(((Double)o.currentScenarioMaintCostHigh - (Double)o.baseScenarioMaintCostHigh) / 100.0, 0) * 100);
                    myRow[3].addText("$ " + tempCostDiffLow + " - " + "$ " + tempCostDiffHigh);//cost difference
                }
                myTable.addRow(myRow);
            }

            //last row is totals
            myRow           = myTable.createRow();
            myRow.rowHeight = tableRowHt;
            dynamic oTotal = costModuleResults[costModuleResults.Count - 1];

            myRow[0].addText("Total");

            //current maintenance cost low and high total
            tempCostLow  = String.Format("{0:#,###,###.##}", Math.Round((Double)oTotal.currentScenarioMaintCostLowSum / 100.0, 0) * 100);
            tempCostHigh = String.Format("{0:#,###,###.##}", Math.Round((Double)oTotal.currentScenarioMaintCostHighSum / 100.0, 0) * 100);
            myRow[1].addText("$ " + tempCostLow + " - " + "$ " + tempCostHigh);//current maintenance cost low

            //base maintenance cost difference total
            if (costModuleResults[costModuleResults.Count - 2].baseScenarioCapCostLow != null)
            {
                tempCostLow  = String.Format("{0:#,###,###.##}", Math.Round((Double)oTotal.baseScenarioMaintCostLowSum / 100.0, 0) * 100);
                tempCostHigh = String.Format("{0:#,###,###.##}", Math.Round((Double)oTotal.baseScenarioMaintCostHighSum / 100.0, 0) * 100);
                myRow[2].addText("$ " + tempCostLow + " - " + "$ " + tempCostHigh);//base maintenance cost high

                //populate cost difference column
                tempCostDiffLow  = String.Format("{0:#,###,###.##}", Math.Round(((Double)oTotal.currentScenarioMaintCostLowSum - (Double)oTotal.baseScenarioMaintCostLowSum) / 100.0, 0) * 100);
                tempCostDiffHigh = String.Format("{0:#,###,###.##}", Math.Round(((Double)oTotal.currentScenarioMaintCostHighSum - (Double)oTotal.baseScenarioMaintCostHighSum) / 100.0, 0) * 100);
                myRow[3].addText("$ " + tempCostDiffLow + " - " + "$ " + tempCostDiffHigh);//cost difference
            }
            myTable.addRow(myRow);

            myPage.addTable(myTable);
        }
Example #15
0
        private void ImprimeOsComValorMaterial(DataTable tblMat)
        {
            pdfTable    myTable = CabMaterial();
            pdfTableRow myRow;

            top += 15;
            QtdCaracterLinha = 73;

            float total = 0f;

            foreach (DataRow row in tblMat.Rows)
            {
                // Create Table Row
                cl                    = 0;
                myRow                 = myTable.createRow();
                myRow.rowStyle        = myTable.rowStyle;
                myRow[cl].columnAlign = predefinedAlignment.csLeft;
                myRow[cl++].addText(row["cmpDcItem"].ToString().Trim());

                row["cmpDcMaterialObraGrupo"] = TiraCaractEspecial(row["cmpDcMaterialObraGrupo"].ToString());

                Tamanho   = row["cmpDcMaterialObraGrupo"].ToString().Length;
                QtdLin    = (Tamanho % QtdCaracterLinha == 0 ? Tamanho / QtdCaracterLinha : (Tamanho / QtdCaracterLinha) + 1);
                StrInicio = 0;

                for (int Linha = 1; Linha <= QtdLin; Linha++)
                {
                    StrFim = Linha == QtdLin ? Tamanho - StrInicio : QtdCaracterLinha;
                    if (Linha == 1)
                    {
                        myRow[cl++].addText(row["cmpDcMaterialObraGrupo"].ToString().Substring(StrInicio, StrFim).Trim());
                        myRow[cl++].addText(row["cmpDcUnidade"].ToString().Trim());
                        myRow[cl++].addText(decimal.Parse(row["cmpQtMaterial"].ToString()).ToString("0,0.00"));
                        myRow[cl++].addText(decimal.Parse(row["cmpVlMaterial"].ToString()).ToString("0,0.00"));
                        myRow[cl++].addText(decimal.Parse(row["cmpVlSubTotal"].ToString()).ToString("0,0.00"));
                        total += float.Parse(row["cmpVlSubTotal"].ToString());
                        myTable.addRow(myRow);
                        StrInicio += QtdCaracterLinha;
                        top       += 11;
                    }
                    else
                    {
                        cl                    = 0;
                        myRow                 = myTable.createRow();
                        myRow.rowStyle        = myTable.rowStyle;
                        myRow[cl].columnAlign = predefinedAlignment.csLeft;
                        myRow[cl++].addText("");
                        myRow[cl++].addText(row["cmpDcMaterialObraGrupo"].ToString().Substring(StrInicio, StrFim).Trim());
                        myRow[cl++].addText("");
                        myRow[cl++].addText("");
                        myRow[cl++].addText("");
                        myRow[cl++].addText("");
                        myTable.addRow(myRow);
                        StrInicio += QtdCaracterLinha;
                        top       += 11;
                    }

                    if (top > 730)
                    {
                        myPage.addTable(myTable);

                        myTable = new pdfTable(myDoc, 1, new pdfColor("000000"), 2,
                                               new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, new pdfColor("FFFFFF")),
                                               new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, pdfColor.White));
                        myTable.coordX = leftMargin;
                        myTable.coordY = getTop(myPage, top);

                        //// Create table's header
                        cl = 0;
                        myTable.tableHeader.rowHeight = 10;
                        myTable.tableHeader.addColumn(570, predefinedAlignment.csRight);
                        myTable.tableHeader[cl++].addText("Subtotal: " + total.ToString("0,0.00"));
                        myPage.addTable(myTable);

                        //top += 152;
                        //myTable.coordX = leftMargin;
                        //myTable.coordY = getTop(myPage, top);

                        myPage.addText("Pág. " + pg++, leftMargin, 10, myDoc.getFontReference(strFont), 10, pdfColor.Black);

                        // Add a page
                        myPage = myDoc.addPage(predefinedPageSize.csSharpPDFFormat);
                        // Cabeçalho
                        top = 40;
                        CabRelatorio(myDoc, myPage, top, nNuOs, nNuDemanda);
                        top    += 70;
                        myTable = CabMaterial();
                    }
                }
            }

            myPage.addTable(myTable);

            top += 13;

            myTable = new pdfTable(myDoc, 1, new pdfColor("000000"), 2,
                                   new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, new pdfColor("FFFFFF")),
                                   new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, pdfColor.White));

            myTable.coordX = leftMargin;
            myTable.coordY = getTop(myPage, top);

            cl = 0;
            myTable.tableHeader.rowHeight = 10;
            myTable.tableHeader.addColumn(480, predefinedAlignment.csRight);
            myTable.tableHeader[cl++].addText("Total do Material R$ ");

            myTable.tableHeader.addColumn(90, predefinedAlignment.csRight);
            myTable.tableHeader[cl++].addText(total.ToString("0,0.00"));
            top += 20;

            float ValorBdiLucro   = (total * PercentualBdiLucro) / 100;
            float ValorBdiTributo = (total * PercentualBdiTributo) / 100;

            float TotalMaterialLucroTributo = total + ValorBdiLucro + ValorBdiTributo;

            // Create Table Row
            myRow = myTable.createRow();
            cl    = 0;
            myRow = myTable.createRow();
            myRow[cl].columnAlign = predefinedAlignment.csRight;
            myRow[cl++].addText("Lucro + Despesas Administrativas (" + PercentualBdiLucro.ToString() + "%)");
            myRow[cl++].addText(ValorBdiLucro.ToString("0,0.00"));
            myTable.addRow(myRow);

            top  += 20;
            cl    = 0;
            myRow = myTable.createRow();
            myRow[cl].columnAlign = predefinedAlignment.csRight;
            myRow[cl++].addText("Tributos (" + PercentualBdiTributo.ToString() + "%)");
            myRow[cl++].addText(ValorBdiTributo.ToString("0,0.00"));
            myTable.addRow(myRow);

            top  += 20;
            cl    = 0;
            myRow = myTable.createRow();
            myRow[cl].columnAlign = predefinedAlignment.csRight;
            myRow[cl++].addText("Total (Material + Lucro + Tributos)");
            myRow[cl++].addText(TotalMaterialLucroTributo.ToString("0,0.00"));
            myTable.addRow(myRow);
            myPage.addTable(myTable);

            if (top > 680)
            {
                myPage.addText("Pág. " + pg++, leftMargin, 10, myDoc.getFontReference(strFont), 10, pdfColor.Black);
                // Add a page
                myPage = myDoc.addPage(predefinedPageSize.csSharpPDFFormat);
                // Cabeçalho
                top = 40;
                CabRelatorio(myDoc, myPage, top, nNuOs, nNuDemanda);
                top += 70;
            }
        }
Example #16
0
        public void ImprimeOrdemServico()
        {
            top = 40;
            pg  = 1;

            using (DataTable table = Global.GetConnection().loadDataTable("select * from HzManutencao..vwATE_OS where cmpCoObraGrupoLista = " + cmpCoObra + " And cmpIdOs = " + cmpIdOS))
            {
                if (table != null && table.Rows.Count > 0)
                {
                    DataRow r = table.Rows[0];
                    nNuOs      = r["cmpNuOS"].ToString();
                    nNuDemanda = r["cmpNuDemandaCliente"].ToString();

                    DadosObra = r["cmpNoObra"].ToString().Trim();  // +(r["cmpNuContrato"] != null ? " -> Contrato nº " + r["cmpNuContrato"].ToString() : "");

                    CabRelatorio(myDoc, myPage, top, nNuOs, nNuDemanda);
                    top += 70;

                    if (bool.Parse(r["cmpInValorMaterial"].ToString()))
                    {
                        PercentualBdiLucro   = float.Parse(r["cmpPeBDILucro"].ToString());
                        PercentualBdiTributo = float.Parse(r["cmpPeBDITributos"].ToString());
                    }

                    #region Antes de Iniciar o Serviço
                    pdfTable myTable = new pdfTable(myDoc, 1, new pdfColor("000000"), 2,
                                                    new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, new pdfColor("FFFFFF")),
                                                    new pdfTableStyle(myDoc.getFontReference(strFont), 9, pdfColor.Black, pdfColor.White));
                    myTable.coordX = leftMargin;
                    myTable.coordY = getTop(myPage, top);
                    int cl = 0;
                    myTable.tableHeader.rowHeight = 20;
                    myTable.tableHeader.addColumn(570, predefinedAlignment.csCenter);
                    myTable.tableHeader[cl].addText("Antes de Iniciar o Serviço");
                    myPage.addTable(myTable);

                    top += 20;

                    myTable = new pdfTable(myDoc, 1, new pdfColor("000000"), 2,
                                           new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, new pdfColor("FFFFFF")),
                                           new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, pdfColor.White));

                    myTable.coordX = leftMargin;
                    myTable.coordY = getTop(myPage, top);

                    //// Create table's header
                    cl = 0;
                    myTable.tableHeader.rowHeight = 10;
                    myTable.tableHeader.addColumn(110, predefinedAlignment.csLeft);
                    myTable.tableHeader[cl++].addText("Solicitado em");
                    myTable.tableHeader.addColumn(180, predefinedAlignment.csLeft);
                    myTable.tableHeader[cl].columnAlign = predefinedAlignment.csLeft;
                    myTable.tableHeader[cl++].addText(r["cmpDtAbertura"].ToString());
                    myTable.tableHeader.addColumn(100, predefinedAlignment.csLeft);
                    myTable.tableHeader[cl].columnAlign = predefinedAlignment.csLeft;
                    myTable.tableHeader[cl++].addText("Tipo da O.S");
                    myTable.tableHeader.addColumn(180, predefinedAlignment.csLeft);
                    myTable.tableHeader[cl].columnAlign = predefinedAlignment.csLeft;
                    myTable.tableHeader[cl++].addText(r["cmpDcOrigemOS"].ToString());

                    top += nTamLinPixel;

                    // Create Table Row
                    pdfTableRow myRow = myTable.createRow();
                    cl    = 0;
                    myRow = myTable.createRow();
                    myRow[cl].columnAlign = predefinedAlignment.csLeft;
                    myRow[cl++].addText("Forma Solicitação");
                    myRow[cl++].addText(r["cmpDcFormaSolicitacao"].ToString().Trim());
                    myRow[cl++].addText("Setor");
                    myRow[cl++].addText(r["cmpNoSetor"].ToString().Trim());
                    myTable.addRow(myRow);

                    top += nTamLinPixel - 5;

                    myPage.addTable(myTable);

                    //Local e pavimento de atendimento
                    myTable = new pdfTable(myDoc, 1, new pdfColor("000000"), 2,
                                           new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, new pdfColor("FFFFFF")),
                                           new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, pdfColor.White));

                    myTable.coordX = leftMargin;
                    myTable.coordY = getTop(myPage, top);

                    //// Create table's header
                    cl = 0;
                    myTable.tableHeader.rowHeight = 10;
                    myTable.tableHeader.addColumn(110, predefinedAlignment.csLeft);
                    myTable.tableHeader[cl++].addText("Local");

                    myTable.tableHeader.addColumn(460, predefinedAlignment.csLeft);
                    myTable.tableHeader[cl].columnAlign = predefinedAlignment.csLeft;
                    myTable.tableHeader[cl++].addText(r["cmpDcLocal"].ToString().TrimEnd());

                    top += nTamLinPixel;

                    // Create Table Row
                    cl    = 0;
                    myRow = myTable.createRow();
                    myRow[cl].columnAlign = predefinedAlignment.csLeft;
                    myRow[cl++].addText("Pavimento");
                    myRow[cl++].addText(r["cmpDcPavimento"].ToString().Trim());
                    myTable.addRow(myRow);

                    top += nTamLinPixel;

                    //Nome do solicitante
                    cl    = 0;
                    myRow = myTable.createRow();
                    myRow[cl++].addText("Solicitante");
                    myRow[cl++].addText(r["cmpNoSolicitante"].ToString().Trim());
                    myTable.addRow(myRow);

                    top += nTamLinPixel;

                    //Telefone do solicitante
                    cl    = 0;
                    myRow = myTable.createRow();
                    myRow[cl++].addText("Telefone/Ramal");
                    myRow[cl++].addText(r["cmpNuTelefone"].ToString().Trim());
                    myTable.addRow(myRow);

                    top += nTamLinPixel;

                    //Email para contato
                    cl    = 0;
                    myRow = myTable.createRow();
                    myRow[cl++].addText("Email para Contato");
                    myRow[cl++].addText(r["cmpEeEmail"].ToString().Trim());
                    myTable.addRow(myRow);

                    top += nTamLinPixel;

                    //Tipo de serviço
                    cl    = 0;
                    myRow = myTable.createRow();
                    myRow[cl++].addText("Tipo do Serviço");
                    myRow[cl++].addText(r["cmpDcTipoAtividade"].ToString().Trim());
                    myTable.addRow(myRow);

                    top += nTamLinPixel;

                    //Solicitação do serviço
                    cl    = 0;
                    myRow = myTable.createRow();
                    myRow[cl++].addText("Solicitação");
                    myRow[cl++].addText(r["cmpDcDescricaoSolicitacao"].ToString().Trim());
                    myTable.addRow(myRow);

                    myPage.addTable(myTable);

                    top += nTamLinPixel - 27;

                    //Detalhamento da Solicitação
                    myTable = new pdfTable(myDoc, 1, new pdfColor("000000"), 2,
                                           new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, new pdfColor("FFFFFF")),
                                           new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, pdfColor.White));

                    myTable.coordX = leftMargin;
                    myTable.coordY = getTop(myPage, top);

                    //// Create table's header
                    cl = 0;
                    myTable.tableHeader.rowHeight = 10;
                    myTable.tableHeader.addColumn(570, predefinedAlignment.csLeft);
                    myTable.tableHeader[cl++].addText("Detalhamento da Solicitação");

                    top += nTamLinPixel;

                    r["cmpDcObservacoes"] = TiraCaractEspecial(r["cmpDcObservacoes"].ToString().TrimEnd());
                    Tamanho   = r["cmpDcObservacoes"].ToString().Length;
                    QtdLin    = (Tamanho % 115 == 0 ? Tamanho / 115 : (Tamanho / 115) + 1);
                    StrInicio = 0;

                    for (int Linha = 1; Linha <= QtdLin; Linha++)
                    {
                        cl    = 0;
                        myRow = myTable.createRow();
                        myRow[cl].columnAlign = predefinedAlignment.csLeft;

                        StrFim = Linha == QtdLin ? Tamanho - StrInicio : 115;
                        myRow[cl++].addText(r["cmpDcObservacoes"].ToString().Substring(StrInicio, StrFim).Trim());
                        myTable.addRow(myRow);
                        StrInicio += 115;
                    }
                    top += nTamLinPixel * QtdLin - 15;
                    myPage.addTable(myTable);
                    #endregion

                    #region Execução do Serviço
                    myTable = new pdfTable(myDoc, 1, new pdfColor("000000"), 2,
                                           new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, new pdfColor("FFFFFF")),
                                           new pdfTableStyle(myDoc.getFontReference(strFont), 9, pdfColor.Black, pdfColor.White));
                    top           += 5;
                    myTable.coordX = leftMargin;
                    myTable.coordY = getTop(myPage, top);
                    cl             = 0;
                    myTable.tableHeader.rowHeight = 20;
                    myTable.tableHeader.addColumn(570, predefinedAlignment.csCenter);
                    myTable.tableHeader[cl].addText("Execução do Serviço ");
                    myPage.addTable(myTable);

                    top += nTamLinPixel;

                    myTable = new pdfTable(myDoc, 1, new pdfColor("000000"), 2,
                                           new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, new pdfColor("FFFFFF")),
                                           new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, pdfColor.White));

                    myTable.coordX = leftMargin;
                    myTable.coordY = getTop(myPage, top);

                    cl = 0;
                    myTable.tableHeader.rowHeight = 10;
                    myTable.tableHeader.addColumn(70, predefinedAlignment.csLeft);
                    myTable.tableHeader[cl++].addText("Início em");
                    myTable.tableHeader.addColumn(100, predefinedAlignment.csLeft);
                    myTable.tableHeader[cl++].addText(r["cmpDtInicioAtendimento"].ToString() != "" ? DateTime.Parse(r["cmpDtInicioAtendimento"].ToString()).ToString("dd/MM/yyyy HH:mm") : "");
                    myTable.tableHeader.addColumn(70, predefinedAlignment.csLeft);
                    myTable.tableHeader[cl++].addText("Término em");
                    myTable.tableHeader.addColumn(100, predefinedAlignment.csLeft);
                    myTable.tableHeader[cl++].addText(r["cmpDtConclusaoAtendimento"].ToString() != "" ? DateTime.Parse(r["cmpDtConclusaoAtendimento"].ToString()).ToString("dd/MM/yyyy HH:mm") : "");
                    myTable.tableHeader.addColumn(70, predefinedAlignment.csLeft);
                    myTable.tableHeader[cl++].addText("Gestor");
                    myTable.tableHeader.addColumn(160, predefinedAlignment.csLeft);
                    myTable.tableHeader[cl++].addText(r["cmpNoAtestador"].ToString().Trim());
                    myPage.addTable(myTable);

                    top += nTamLinPixel - 5;

                    //Executantes do serviço
                    myTable = new pdfTable(myDoc, 1, new pdfColor("000000"), 2,
                                           new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, new pdfColor("FFFFFF")),
                                           new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, pdfColor.White));

                    myTable.coordX = leftMargin;
                    myTable.coordY = getTop(myPage, top);

                    //// Create table's header
                    cl = 0;
                    myTable.tableHeader.rowHeight = 10;
                    myTable.tableHeader.addColumn(70, predefinedAlignment.csLeft);
                    myTable.tableHeader[cl++].addText("Executante(s)");
                    myTable.tableHeader.addColumn(500, predefinedAlignment.csLeft);
                    myTable.tableHeader[cl++].addText(r["cmpNoExecutor"].ToString().TrimEnd());
                    myPage.addTable(myTable);

                    top += nTamLinPixel;

                    //Detalhamento da Serviço Executado
                    myTable = new pdfTable(myDoc, 1, new pdfColor("000000"), 2,
                                           new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, new pdfColor("FFFFFF")),
                                           new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, pdfColor.White));

                    myTable.coordX = leftMargin;
                    myTable.coordY = getTop(myPage, top);

                    //// Create table's header
                    cl = 0;
                    myTable.tableHeader.rowHeight = 10;
                    myTable.tableHeader.addColumn(570, predefinedAlignment.csLeft);
                    myTable.tableHeader[cl++].addText("Detalhamento do Serviço Executado");

                    top += nTamLinPixel;

                    r["cmpDcObservacaoConclusao"] = TiraCaractEspecial(r["cmpDcObservacaoConclusao"].ToString());
                    Tamanho   = r["cmpDcObservacaoConclusao"].ToString().Length;
                    QtdLin    = (Tamanho % 120 == 0 ? Tamanho / 120 : (Tamanho / 120) + 1);
                    StrInicio = 0;
                    for (int Linha = 1; Linha <= QtdLin; Linha++)
                    {
                        cl     = 0;
                        myRow  = myTable.createRow();
                        StrFim = Linha == QtdLin ? Tamanho - StrInicio : 120;
                        //if (QtdLin > 1)
                        //{
                        //    myRow[cl++].addText(r["cmpDcObservacaoConclusao"].ToString().Substring(StrInicio, StrFim).Trim());
                        //}
                        //else
                        //{
                        string observacao = r["cmpDcObservacaoConclusao"].ToString().Substring(StrInicio, StrFim).Trim();
                        //observacao=observacao.Replace(@"\"," ");
                        observacao = observacao.Replace("\t", string.Empty);

                        myRow[cl++].addText(observacao);
                        //}
                        myTable.addRow(myRow);
                        StrInicio += 120;
                    }
                    top += nTamLinPixel * QtdLin - 1;
                    myPage.addTable(myTable);
                    #endregion

                    #region Lista de Material/Serviço Utilizado
                    myTable = new pdfTable(myDoc, 1, new pdfColor("000000"), 2,
                                           new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, new pdfColor("FFFFFF")),
                                           new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, pdfColor.White));
                    myTable.coordX = leftMargin;
                    myTable.coordY = getTop(myPage, top);

                    //// Create table's header
                    cl = 0;
                    myTable.tableHeader.rowHeight = 10;
                    myTable.tableHeader.addColumn(570, predefinedAlignment.csCenter);
                    myTable.tableHeader[cl++].addText("Material / Serviço Utilizado");

                    myPage.addTable(myTable);

                    top += nTamLinPixel;

                    string sql = "select * from HzManutencao..vwATE_OSMaterial where cmpCoObraGrupoLista = " + cmpCoObra + " And cmpIdOS = " + cmpIdOS;
                    using (DataTable tblMat = Global.GetConnection().loadDataTable(sql))
                        if (tblMat != null && tblMat.Rows.Count > 0)
                        {
                            if (bool.Parse(r["cmpInValorMaterial"].ToString()))
                            {
                                ImprimeOsComValorMaterial(tblMat);
                            }
                            else
                            {
                                ImprimeOsSemValorMaterial(tblMat);
                            }
                        }

                    #endregion

                    top += 10;

                    //Aceite do Cliente
                    myTable = new pdfTable(myDoc, 1, new pdfColor("000000"), 2,
                                           new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, new pdfColor("FFFFFF")),
                                           new pdfTableStyle(myDoc.getFontReference(strFont), 9, pdfColor.Black, pdfColor.White));

                    myTable.coordX = leftMargin;
                    myTable.coordY = getTop(myPage, top);
                    cl             = 0;
                    myTable.tableHeader.rowHeight = 20;
                    myTable.tableHeader.addColumn(570, predefinedAlignment.csCenter);
                    myTable.tableHeader[cl].addText("Aceite do Cliente");
                    myPage.addTable(myTable);

                    top += 20;

                    myTable = new pdfTable(myDoc, 1, new pdfColor("000000"), 2,
                                           new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, new pdfColor("FFFFFF")),
                                           new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, pdfColor.White));
                    myTable.coordX = leftMargin;
                    myTable.coordY = getTop(myPage, top);
                    cl             = 0;
                    myRow          = myTable.createRow();
                    myTable.tableHeader.rowHeight = 10;
                    myTable.tableHeader.addColumn(570, predefinedAlignment.csLeft);
                    myTable.tableHeader[cl++].addText("Satisfeito com o serviço: " + "__Sim         __Não");
                    myPage.addTable(myTable);

                    top += 20;

                    myTable = new pdfTable(myDoc, 1, new pdfColor("000000"), 2,
                                           new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, new pdfColor("FFFFFF")),
                                           new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, pdfColor.White));

                    myTable.coordX = leftMargin;
                    myTable.coordY = getTop(myPage, top);

                    cl = 0;
                    myTable.tableHeader.rowHeight        = 40;
                    myTable.tableHeader.rowVerticalAlign = predefinedVerticalAlignment.csBottom;
                    myTable.tableHeader.addColumn(285, predefinedAlignment.csCenter);
                    myTable.tableHeader[cl].columnVerticalAlign = predefinedVerticalAlignment.csBottom;
                    myTable.tableHeader[cl++].addText("Assinatura: GrupoOrion");

                    myTable.tableHeader.addColumn(285, predefinedAlignment.csCenter);
                    myTable.tableHeader[cl].columnVerticalAlign = predefinedVerticalAlignment.csBottom;
                    myTable.tableHeader[cl].addText("Assinatura: Cliente");

                    myPage.addTable(myTable);

                    myPage.addText("Pág. " + pg++, leftMargin, 10, myDoc.getFontReference(strFont), 10, pdfColor.Black);
                }
            }
        }
Example #17
0
    // Update is called once per frame
    public IEnumerator CreatePDF()
    {
        pdfDocument myDoc       = new pdfDocument("Sample Application", "Me", false);
        pdfPage     myFirstPage = myDoc.addPage();



//		Debug.Log ( "Continue to create PDF");
        myFirstPage.addText("Daily Report", 10, 730, predefinedFont.csHelveticaOblique, 30, new pdfColor(predefinedColor.csOrange));



        /*Table's creation*/
        pdfTable myTable = new pdfTable();

        //Set table's border
        myTable.borderSize  = 1;
        myTable.borderColor = new pdfColor(predefinedColor.csDarkBlue);

        /*Add Columns to a grid*/
        myTable.tableHeader.addColumn(new pdfTableColumn("Building1", predefinedAlignment.csRight, 120));
        myTable.tableHeader.addColumn(new pdfTableColumn("Building2", predefinedAlignment.csCenter, 120));
        myTable.tableHeader.addColumn(new pdfTableColumn("Building3", predefinedAlignment.csLeft, 150));
        myTable.tableHeader.addColumn(new pdfTableColumn("Building4", predefinedAlignment.csLeft, 150));


        pdfTableRow myRow = myTable.createRow();

        myRow[0].columnValue = "A";
        myRow[1].columnValue = "100 km/h";
        myRow[2].columnValue = "180Kg";
        myRow[3].columnValue = "Orange";

        myTable.addRow(myRow);

        pdfTableRow myRow1 = myTable.createRow();

        myRow1[0].columnValue = "B";
        myRow1[1].columnValue = "130 km/h";
        myRow1[2].columnValue = "150Kg";
        myRow1[3].columnValue = "Yellow";

        myTable.addRow(myRow1);



        /*Set Header's Style*/
        myTable.tableHeaderStyle = new pdfTableRowStyle(predefinedFont.csCourierBoldOblique, 12, new pdfColor(predefinedColor.csBlack), new pdfColor(predefinedColor.csLightOrange));
        /*Set Row's Style*/
        myTable.rowStyle = new pdfTableRowStyle(predefinedFont.csCourier, 8, new pdfColor(predefinedColor.csBlack), new pdfColor(predefinedColor.csWhite));
        /*Set Alternate Row's Style*/
        myTable.alternateRowStyle = new pdfTableRowStyle(predefinedFont.csCourier, 8, new pdfColor(predefinedColor.csBlack), new pdfColor(predefinedColor.csLightYellow));
        /*Set Cellpadding*/
        myTable.cellpadding = 10;
        /*Put the table on the page object*/
        myFirstPage.addTable(myTable, 5, 700);



        yield return(StartCoroutine(myFirstPage.newAddImage(Application.dataPath + "/picture2.jpg", 2, 100)));

        myDoc.createPDF(attacName);
        myTable = null;
        Application.OpenURL(attacName);
    }
Example #18
0
        public virtual pdfDocument ImprimeAtividades(DataTable table)
        {
            String strFont    = "Helvetica";
            int    leftMargin = 30;
            int    pg         = 1;
            int    top        = 20;
            int    RegItemAtv;
            //Tamanho da lin em pixel
            int nTamLinPixel = 19;

            // Variaveis de controle para quebra de linha de campos
            //int QtdCaracterLinha = 50;
            //int Tamanho;
            //int QtdLin;
            //int StrInicio;
            //int StrFim;
            int cl;

            // Adiciona Página
            pdfDocument myDoc  = new pdfDocument("Horizon", "Orion");
            pdfPage     myPage = myDoc.addPage(predefinedPageSize.csSharpPDFFormat);

            ImprimeFormPrevEquipamento Cab = new ImprimeFormPrevEquipamento();

            Cab.cmpNoObra          = table.Rows[0]["cmpNoObra"].ToString().TrimEnd();
            Cab.cmpDcTipoAtividade = table.Rows[0]["cmpDcTipoAtividade"].ToString().TrimEnd();
            Cab.cmpDcPeriodicidade = table.Rows[0]["cmpDcPeriodicidade"].ToString().TrimEnd();

            top = Cab.CabRelatorio(myDoc, myPage, top);
            top = Cab.SubCabRelatorio(myDoc, myPage, top, table.Rows[0]);
            pdfTable myTable = ItemAtividade(myDoc, myPage, top, table.Rows[0]);

            top       += 40;
            RegItemAtv = 0;

            int IdEquipamento = int.Parse(table.Rows[0]["cmpIdEquipamentoObra"].ToString());

            // Imprimir linhas de detalhes
            pdfTableRow myRow = myTable.createRow();

            foreach (DataRow row in table.Rows)
            {
                if (IdEquipamento != int.Parse(row["cmpIdEquipamentoObra"].ToString()))
                {
                    IdEquipamento = int.Parse(row["cmpIdEquipamentoObra"].ToString());

                    myPage.addTable(myTable);

                    myTable = ConclusaoRelatorio(myDoc, myPage, top);

                    myPage.addText("Pág. " + pg++, leftMargin, 10, myDoc.getFontReference(strFont), 10, pdfColor.Black);
                    myPage.addTable(myTable);

                    // Adiciona uma página
                    myPage  = myDoc.addPage(predefinedPageSize.csSharpPDFFormat);
                    pg      = 1;
                    top     = 30;
                    top     = Cab.CabRelatorio(myDoc, myPage, top);
                    top     = Cab.SubCabRelatorio(myDoc, myPage, top, row);
                    myTable = ItemAtividade(myDoc, myPage, top, row);
                    top    += 40;
                }
                else
                {
                    if (RegItemAtv == 0)
                    {
                        RegItemAtv = 1;
                    }
                    else
                    {
                        cl             = 0;
                        myRow          = myTable.createRow();
                        myRow.rowStyle = myTable.rowStyle;
                        myRow[cl++].addText("");
                        myRow[cl++].addText(row["cmpDcItemAtividadePreventiva"].ToString().TrimEnd());
                        myTable.addRow(myRow);
                        top += nTamLinPixel;
                    }
                }
                if (top > 1000)
                {
                    myPage.addText("Pág. " + pg++, leftMargin, 10, myDoc.getFontReference(strFont), 10, pdfColor.Black);
                    myPage.addTable(myTable);

                    // Adiciona uma página
                    myPage = myDoc.addPage(predefinedPageSize.csSharpPDFFormat);

                    top     = 30;
                    top     = Cab.CabRelatorio(myDoc, myPage, top);
                    top     = Cab.SubCabRelatorio(myDoc, myPage, top, row);
                    myTable = ItemAtividade(myDoc, myPage, top, row);
                    top    += 40;
                }
            }

            if (top < 1000)
            {
                myPage.addTable(myTable);

                myTable = ConclusaoRelatorio(myDoc, myPage, top);
                myPage.addText("Pág. " + pg++, leftMargin, 10, myDoc.getFontReference(strFont), 10, pdfColor.Black);
                myPage.addTable(myTable);
            }
            return(myDoc);
        }
Example #19
0
        public static pdfDocument ImprimeCapaRostoOS(DataTable table, string DataInicial, string DataFinal)
        {
            String strFont    = "Helvetica";
            int    leftMargin = 30;
            int    pg         = 1;
            int    top        = 40;
            //Tamanho da lin em pixel
            int nTamLinPixel = 19;

            // Variaveis de controle para quebra de linha de campos
            int QtdCaracterLinha = 50;
            int Tamanho;
            int QtdLin;
            int StrInicio;
            int StrFim;
            int cl;

            DataTable DtTotMatOs;
            decimal   TotMatOs = 0;

            TotMaterial totalMat = new TotMaterial();

            totalMat.Adicionar(table);

            decimal ValorBdiLucro   = totalMat.Valor * decimal.Parse(table.Rows[0]["cmpPeBDILucro"].ToString()) / 100;
            decimal ValorBdiTributo = totalMat.Valor * decimal.Parse(table.Rows[0]["cmpPeBDITributos"].ToString()) / 100;

            decimal TotalMaterialLucroTributo = totalMat.Valor + ValorBdiLucro + ValorBdiTributo;

            // Adiciona Página
            pdfDocument myDoc  = new pdfDocument("Horizon", "Orion");
            pdfPage     myPage = myDoc.addPage(predefinedPageSize.csSharpPDFFormat);

            string DadosObra = (table.Rows[0]["cmpNoObra"].ToString().Trim() + (table.Rows[0]["cmpNuContrato"] != null ? " -> Contrato nº " + table.Rows[0]["cmpNuContrato"].ToString() : ""));

            CabRelatorio(myDoc, myPage, top, DadosObra, DataInicial, DataFinal);
            top += 30;

            #region Resultado Financeiro
            //Imprime Total Geral de Material
            pdfTable myTable = new pdfTable(myDoc, 1, new pdfColor("000000"), 2,
                                            new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, new pdfColor("FFFFFF")),
                                            new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, pdfColor.White));
            myTable.coordX = leftMargin;
            myTable.coordY = getTop(myPage, top);

            cl = 0;
            myTable.tableHeader.rowHeight = 10;
            myTable.tableHeader.addColumn(400, predefinedAlignment.csRight);
            myTable.tableHeader[cl++].addText("Total do Material R$ ");

            myTable.tableHeader.addColumn(150, predefinedAlignment.csRight);
            myTable.tableHeader[cl++].addText(totalMat.Valor.ToString("0,0.00"));
            top += 20;

            // Create Table Row
            pdfTableRow myRow = myTable.createRow();
            cl    = 0;
            myRow = myTable.createRow();
            myRow[cl].columnAlign = predefinedAlignment.csRight;
            myRow[cl++].addText("Lucro + Despesas Administrativas (" + table.Rows[0]["cmpPeBDILucro"].ToString() + "%)");
            myRow[cl++].addText(ValorBdiLucro.ToString("0,0.00"));
            myTable.addRow(myRow);

            top  += 20;
            cl    = 0;
            myRow = myTable.createRow();
            myRow[cl].columnAlign = predefinedAlignment.csRight;
            myRow[cl++].addText("Tributos (" + table.Rows[0]["cmpPeBDITributos"].ToString() + "%)");
            myRow[cl++].addText(ValorBdiTributo.ToString("0,0.00"));
            myTable.addRow(myRow);

            top  += 20;
            cl    = 0;
            myRow = myTable.createRow();
            myRow[cl].columnAlign = predefinedAlignment.csRight;
            myRow[cl++].addText("Total (Material + Lucro + Tributos)");
            myRow[cl++].addText(TotalMaterialLucroTributo.ToString("0,0.00"));
            myTable.addRow(myRow);

            myPage.addTable(myTable);
            #endregion

            top    += 10;
            myTable = SubCabRelatorio(myDoc, myPage, top);
            top    += 10;

            // Imprimir linhas de detalhes
            myRow = myTable.createRow();

            foreach (DataRow row in table.Rows)
            {
                DtTotMatOs = tblOSMaterial.RetornarTotalMatOS(Global.GetConnection(), row["cmpIdOs"].ToString());
                TotMatOs   = DtTotMatOs.Rows[0]["TotalMaterial"].ToString() != "" ? decimal.Parse(DtTotMatOs.Rows[0]["TotalMaterial"].ToString()) : 0;

                cl             = 0;
                myRow          = myTable.createRow();
                myRow.rowStyle = myTable.rowStyle;

                myRow[cl++].addText(row["cmpNuOs"].ToString());
                myRow[cl++].addText(row["cmpNoSolicitante"].ToString().TrimEnd());

                row["cmpDcObservacoes"] = TiraCaractEspecial(row["cmpDcObservacoes"].ToString().ToUpper());

                Tamanho = row["cmpDcObservacoes"].ToString().Length;

                if (Tamanho > 0)
                {
                    QtdLin    = (Tamanho % QtdCaracterLinha == 0 ? Tamanho / QtdCaracterLinha : (Tamanho / QtdCaracterLinha) + 1);
                    StrInicio = 0;

                    for (int Linha = 1; Linha <= QtdLin; Linha++)
                    {
                        StrFim = Linha == QtdLin ? Tamanho - StrInicio : QtdCaracterLinha;
                        if (Linha == 1)
                        {
                            myRow[cl++].addText(row["cmpDcObservacoes"].ToString().Substring(StrInicio, StrFim).Trim());
                            myRow[cl++].addText(row["cmpDcLocal"].ToString());
                            myRow[cl++].addText(row["cmpDtAbertura"].ToString().Substring(0, 10));
                            myRow[cl++].addText(row["cmpDtConclusaoAtendimento"].ToString() == "" ? "" : row["cmpDtConclusaoAtendimento"].ToString().Substring(0, 10));
                            myRow[cl++].addText(TotMatOs.ToString("0,0.00"));
                        }
                        else
                        {
                            cl             = 0;
                            myRow          = myTable.createRow();
                            myRow.rowStyle = myTable.rowStyle;
                            myRow[cl++].addText("");
                            myRow[cl++].addText("");
                            myRow[cl++].addText(row["cmpDcObservacoes"].ToString().Substring(StrInicio, StrFim).Trim());
                            myRow[cl++].addText("");
                            myRow[cl++].addText("");
                            myRow[cl++].addText("");
                            myRow[cl++].addText("");
                        }
                        myTable.addRow(myRow);
                        StrInicio += QtdCaracterLinha;
                        top       += nTamLinPixel;
                    }
                }
                else
                {
                    myRow[cl++].addText(row["cmpDcDescricaoSolicitacao"].ToString().TrimEnd());
                    myRow[cl++].addText(row["cmpDcLocal"].ToString());
                    myRow[cl++].addText(row["cmpDtAbertura"].ToString().Substring(0, 10));
                    myRow[cl++].addText(row["cmpDtConclusaoAtendimento"].ToString() == "" ? "" : row["cmpDtConclusaoAtendimento"].ToString().Substring(0, 10));
                    myRow[cl++].addText(TotMatOs.ToString("0,0.00"));
                    myTable.addRow(myRow);
                    top += nTamLinPixel;
                }

                if (top > 1230)
                {
                    myPage.addText("Pág. " + pg++, leftMargin, 10, myDoc.getFontReference(strFont), 10, pdfColor.Black);
                    myPage.addTable(myTable);

                    // Adiciona uma página
                    myPage = myDoc.addPage(predefinedPageSize.csSharpPDFFormat);
                    top    = 30;
                    CabRelatorio(myDoc, myPage, top, DadosObra, DataInicial, DataFinal);
                    top    += 30;
                    myTable = SubCabRelatorio(myDoc, myPage, top);
                    top     = +10;
                }
            }

            if (top < 1230)
            {
                //Imprime Total Geral de Material
                myRow          = myTable.createRow();
                myRow.rowStyle = myTable.rowStyle;
                cl             = 0;
                myRow[cl++].addText("");
                myRow[cl++].addText("");
                myRow[cl++].addText("");
                myRow[cl++].addText("");
                myRow[cl++].addText("");
                myRow[cl++].addText("Total ==>");
                myRow[cl++].addText(totalMat.Valor.ToString("0,0.00"));
                myTable.addRow(myRow);

                myPage.addText("Pág. " + pg++, leftMargin, 10, myDoc.getFontReference(strFont), 10, pdfColor.Black);
                myPage.addTable(myTable);
            }

            return(myDoc);
        }
Example #20
0
    // Update is called once per frame
    public IEnumerator CreatePDF()
    {
        pdfDocument myDoc        = new pdfDocument("Sample Application", "Me", false);
        pdfPage     myFirstPage  = myDoc.addPage();
        pdfPage     mySecondPage = myDoc.addPage();


        Debug.Log("Continue to create PDF");
        myFirstPage.addText("ADMIN Summary Sheet", 10, 730, predefinedFont.csHelveticaOblique, 30, new pdfColor(predefinedColor.csOrange));



        /*Table's creation*/
        pdfTable myTable = new pdfTable();

        //Set table's border
        myTable.borderSize  = 1;
        myTable.borderColor = new pdfColor(predefinedColor.csDarkBlue);

        /*Add Columns to a grid*/
        myTable.tableHeader.addColumn(new pdfTableColumn("faculty name", predefinedAlignment.csLeft, 90));
        myTable.tableHeader.addColumn(new pdfTableColumn("year", predefinedAlignment.csLeft, 90));
        myTable.tableHeader.addColumn(new pdfTableColumn("subject", predefinedAlignment.csLeft, 90));
        myTable.tableHeader.addColumn(new pdfTableColumn("section", predefinedAlignment.csLeft, 90));
        myTable.tableHeader.addColumn(new pdfTableColumn("category name", predefinedAlignment.csLeft, 90));
        myTable.tableHeader.addColumn(new pdfTableColumn("filename", predefinedAlignment.csLeft, 90));
        myTable.tableHeader.addColumn(new pdfTableColumn("extension", predefinedAlignment.csLeft, 50));



        pdfTableRow myRow = myTable.createRow();

        myRow[0].columnValue = "preeti";
        myRow[1].columnValue = "2017-18";
        myRow[2].columnValue = "4-Linux System Programming";
        myRow[3].columnValue = "A";
        myRow[4].columnValue = "Ethics";
        myRow[5].columnValue = "facnames(1).pdf";
        myRow[6].columnValue = "pdf";


        myTable.addRow(myRow);

        //pdfTableRow myRow1 = myTable.createRow();
        //myRow1[0].columnValue = "B";
        //myRow1[1].columnValue = "130 km/h";
        //myRow1[2].columnValue = "150Kg";
        //myRow1[3].columnValue = "Yellow";

        //myTable.addRow(myRow1);



        /*Set Header's Style*/
        myTable.tableHeaderStyle = new pdfTableRowStyle(predefinedFont.csCourierBoldOblique, 12, new pdfColor(predefinedColor.csBlack), new pdfColor(predefinedColor.csLightOrange));
        /*Set Row's Style*/
        myTable.rowStyle = new pdfTableRowStyle(predefinedFont.csCourier, 8, new pdfColor(predefinedColor.csBlack), new pdfColor(predefinedColor.csWhite));
        /*Set Alternate Row's Style*/
        myTable.alternateRowStyle = new pdfTableRowStyle(predefinedFont.csCourier, 8, new pdfColor(predefinedColor.csBlack), new pdfColor(predefinedColor.csLightYellow));
        /*Set Cellpadding*/
        myTable.cellpadding = 10;
        /*Put the table on the page object*/
        myFirstPage.addTable(myTable, 5, 700);

        //yield return StartCoroutine(myFirstPage.newAddImage("D:/TEMPORARY/UnitySharpPDF/picture2.jpg", 2, 100));
        //yield return StartCoroutine(mySecondPage.newAddImage("D:/TEMPORARY/UnitySharpPDF/picture1.jpg", 2, 100));
        yield return(myFirstPage);

        yield return(mySecondPage);

        myDoc.createPDF(attacName);
        Debug.Log(" pdf created ");
        myTable = null;

        //yield return null;
    }
Example #21
0
        public void ImprimeOS()
        {
            String strFont    = "Helvetica";
            int    leftMargin = 30;
            string nNuOs;
            int    pg           = 1;
            int    top          = 40;
            int    nTamLinPixel = 19; //Tamanho da lin em pixel
            // Variaveis de controle para quebra de linha de campos
            int QtdCaracterLinha;
            int Tamanho;
            int QtdLin;
            int StrInicio;
            int StrFim;

            //pdfDocument myDoc = new pdfDocument("Horizon", "Orion");
            // Add a page
            pdfPage myPage = myDoc.addPage(predefinedPageSize.csSharpPDFFormat);

            // Header Text
            myPage.addText("Ordem de Serviço", leftMargin, getTop(myPage, 30),
                           myDoc.getFontReference(strFont), 15, pdfColor.Black);

            using (DataTable table = Global.GetConnection().loadDataTable("select * from HzManutencao..vwATE_OS where cmpCoObraGrupoLista = " + cmpCoObra + " And cmpIdOs = " + cmpIdOS))
            {
                if (table != null && table.Rows.Count > 0)
                {
                    DataRow r = table.Rows[0];

                    pdfTable myTable = new pdfTable(myDoc, 1, new pdfColor("000000"), 2,
                                                    new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, new pdfColor("FFFFFF")),
                                                    new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, pdfColor.White));

                    myTable.coordX = leftMargin;
                    myTable.coordY = getTop(myPage, top);

                    //// Create table's header
                    int cl = 0;
                    myTable.tableHeader.rowHeight = 10;
                    myTable.tableHeader.addColumn(150, predefinedAlignment.csLeft);
                    myTable.tableHeader[cl++].addText("Nº O.S.");

                    myTable.tableHeader.addColumn(420, predefinedAlignment.csLeft);
                    myTable.tableHeader[cl].columnAlign = predefinedAlignment.csLeft;
                    myTable.tableHeader[cl++].addText(r["cmpNuOS"].ToString());
                    nNuOs = r["cmpNuOS"].ToString();

                    top += nTamLinPixel;

                    // Create Table Row
                    pdfTableRow myRow = myTable.createRow();
                    cl    = 0;
                    myRow = myTable.createRow();
                    myRow[cl].columnAlign = predefinedAlignment.csLeft;
                    myRow[cl++].addText("Data Solicitação:");
                    myRow[cl++].addText(r["cmpDtAbertura"].ToString().Trim());
                    myTable.addRow(myRow);

                    top += nTamLinPixel;

                    cl    = 0;
                    myRow = myTable.createRow();
                    myRow[cl].columnAlign = predefinedAlignment.csLeft;
                    myRow[cl++].addText("Obra:");
                    myRow[cl++].addText(r["cmpNoObra"].ToString().Trim() + (r["cmpNuContrato"] != null ? " -> Contrato nº " + r["cmpNuContrato"].ToString() : ""));
                    myTable.addRow(myRow);

                    top += nTamLinPixel;

                    cl    = 0;
                    myRow = myTable.createRow();
                    myRow[cl].columnAlign = predefinedAlignment.csLeft;
                    myRow[cl++].addText("Solicitante:");
                    myRow[cl++].addText(r["cmpNoSolicitante"].ToString().Trim());
                    myTable.addRow(myRow);

                    top += nTamLinPixel;

                    cl    = 0;
                    myRow = myTable.createRow();
                    myRow[cl].columnAlign = predefinedAlignment.csLeft;
                    myRow[cl++].addText("Pavimento:");
                    myRow[cl++].addText(r["cmpDcPavimento"].ToString().Trim());
                    myTable.addRow(myRow);

                    top += nTamLinPixel;

                    cl    = 0;
                    myRow = myTable.createRow();
                    myRow[cl].columnAlign = predefinedAlignment.csLeft;
                    myRow[cl++].addText("Local / Sala:");
                    myRow[cl++].addText(r["cmpDcLocal"].ToString().Trim());
                    myTable.addRow(myRow);

                    top += nTamLinPixel;

                    cl    = 0;
                    myRow = myTable.createRow();
                    myRow[cl].columnAlign = predefinedAlignment.csLeft;
                    myRow[cl++].addText("Setor:");
                    myRow[cl++].addText(r["cmpNoSetor"].ToString().Trim());
                    myTable.addRow(myRow);

                    top += nTamLinPixel;

                    cl    = 0;
                    myRow = myTable.createRow();
                    myRow[cl].columnAlign = predefinedAlignment.csLeft;
                    myRow[cl++].addText("Descrição do Serviço:");
                    myRow[cl++].addText(r["cmpDcDescricaoSolicitacao"].ToString().Trim());
                    myTable.addRow(myRow);

                    top += nTamLinPixel;

                    cl    = 0;
                    myRow = myTable.createRow();
                    myRow[cl].columnAlign = predefinedAlignment.csLeft;
                    myRow[cl++].addText("Detalhamento do Serviço:");

                    r["cmpDcObservacoes"] = TiraCaractEspecial(r["cmpDcObservacoes"].ToString());

                    Tamanho   = r["cmpDcObservacoes"].ToString().Length;
                    QtdLin    = (Tamanho % 69 == 0 ? Tamanho / 69 : (Tamanho / 69) + 1);
                    StrInicio = 0;

                    for (int Linha = 1; Linha <= QtdLin; Linha++)
                    {
                        if (Linha > 1)
                        {
                            cl    = 0;
                            myRow = myTable.createRow();
                            myRow[cl].columnAlign = predefinedAlignment.csLeft;
                            myRow[cl++].addText("");
                        }
                        StrFim = Linha == QtdLin ? Tamanho - StrInicio : 69;
                        myRow[cl++].addText(r["cmpDcObservacoes"].ToString().Substring(StrInicio, StrFim).Trim());
                        myTable.addRow(myRow);
                        StrInicio += 69;
                    }

                    top += nTamLinPixel * QtdLin - 1;

                    cl                    = 0;
                    myRow                 = myTable.createRow();
                    myRow.rowHeight       = 50;
                    myRow[cl].columnAlign = predefinedAlignment.csLeft;
                    myRow[cl++].addText("Conclusão/Aceite do Solicitante:");
                    myRow[cl++].addText("");
                    myTable.addRow(myRow);

                    top += nTamLinPixel;

                    myPage.addTable(myTable);

                    myTable = new pdfTable(myDoc, 1, new pdfColor("000000"), 2,
                                           new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, new pdfColor("FFFFFF")),
                                           new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, pdfColor.White));

                    myTable.coordX = leftMargin;
                    myTable.coordY = getTop(myPage, top);

                    //// Create table's header
                    cl = 0;
                    myTable.tableHeader.rowHeight = 10;
                    myTable.tableHeader.addColumn(150, predefinedAlignment.csLeft);
                    myTable.tableHeader[cl++].addText("Data Início");

                    top += nTamLinPixel;

                    myTable.tableHeader.addColumn(420, predefinedAlignment.csLeft);
                    myTable.tableHeader[cl].columnAlign = predefinedAlignment.csLeft;
                    myTable.tableHeader[cl++].addText(r["cmpDtInicioAtendimento"].ToString() != "" ? DateTime.Parse(r["cmpDtInicioAtendimento"].ToString()).ToString("dd/MM/yyyy HH:mm") : "");

                    top += nTamLinPixel;

                    cl    = 0;
                    myRow = myTable.createRow();
                    myRow[cl].columnAlign = predefinedAlignment.csLeft;
                    myRow[cl++].addText("Data Conclusão:");
                    myRow[cl++].addText(r["cmpDtConclusaoAtendimento"].ToString() != "" ? DateTime.Parse(r["cmpDtConclusaoAtendimento"].ToString()).ToString("dd/MM/yyyy HH:mm") : "");
                    myTable.addRow(myRow);

                    top += nTamLinPixel;

                    cl                    = 0;
                    myRow                 = myTable.createRow();
                    myRow.rowHeight       = 50;
                    myRow[cl].columnAlign = predefinedAlignment.csLeft;
                    myRow[cl++].addText("Verificação do Serviço:");
                    myRow[cl++].addText(TiraCaractEspecial(r["cmpDcObservacaoConclusao"].ToString().Trim()));
                    myTable.addRow(myRow);

                    myPage.addTable(myTable);

                    top += nTamLinPixel;

                    myTable = new pdfTable(myDoc, 1, new pdfColor("000000"), 2,
                                           new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, new pdfColor("FFFFFF")),
                                           new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, pdfColor.White));
                    myTable.coordX = leftMargin;
                    myTable.coordY = getTop(myPage, top);

                    //// Create table's header
                    cl = 0;
                    myTable.tableHeader.rowHeight = 10;
                    myTable.tableHeader.addColumn(570, predefinedAlignment.csLeft);
                    myTable.tableHeader[cl++].addText("Material / Serviço Utilizado");

                    myPage.addTable(myTable);

                    top += nTamLinPixel;

                    string sql = "select * from HzManutencao..vwATE_OSMaterial where cmpCoObraGrupoLista = " + cmpCoObra + " And cmpIdOS = " + r["cmpIdOS"].ToString();
                    using (DataTable tblMat = Global.GetConnection().loadDataTable(sql))
                    {
                        if (tblMat != null && tblMat.Rows.Count > 0)
                        {
                            //myTable = CabMaterial(myDoc, myPage, top);
                            myTable = CabMaterial(myPage, top);
                            top    += 15;

                            QtdCaracterLinha = 120;

                            foreach (DataRow row in tblMat.Rows)
                            {
                                // Create Table Row
                                cl                    = 0;
                                myRow                 = myTable.createRow();
                                myRow.rowStyle        = myTable.rowStyle;
                                myRow[cl].columnAlign = predefinedAlignment.csLeft;
                                myRow[cl++].addText(row["cmpDcItem"].ToString().Trim());

                                row["cmpDcMaterialObraGrupo"] = TiraCaractEspecial(row["cmpDcMaterialObraGrupo"].ToString());

                                Tamanho   = row["cmpDcMaterialObraGrupo"].ToString().Length;
                                QtdLin    = (Tamanho % QtdCaracterLinha == 0 ? Tamanho / QtdCaracterLinha : (Tamanho / QtdCaracterLinha) + 1);
                                StrInicio = 0;

                                for (int Linha = 1; Linha <= QtdLin; Linha++)
                                {
                                    StrFim = Linha == QtdLin ? Tamanho - StrInicio : QtdCaracterLinha;
                                    if (Linha == 1)
                                    {
                                        myRow[cl++].addText(row["cmpDcMaterialObraGrupo"].ToString().Substring(StrInicio, StrFim).Trim());
                                        myRow[cl++].addText(row["cmpDcUnidade"].ToString().Trim());
                                        myRow[cl++].addText(decimal.Parse(row["cmpQtMaterial"].ToString()).ToString("0,0.00"));
                                        myTable.addRow(myRow);
                                        StrInicio += QtdCaracterLinha;
                                        top       += 11;
                                    }
                                    else
                                    {
                                        cl                    = 0;
                                        myRow                 = myTable.createRow();
                                        myRow.rowStyle        = myTable.rowStyle;
                                        myRow[cl].columnAlign = predefinedAlignment.csLeft;
                                        myRow[cl++].addText("");
                                        myRow[cl++].addText(row["cmpDcMaterialObraGrupo"].ToString().Substring(StrInicio, StrFim).Trim());
                                        myRow[cl++].addText("");
                                        myRow[cl++].addText("");
                                        myTable.addRow(myRow);
                                        StrInicio += QtdCaracterLinha;
                                        top       += 11;
                                    }

                                    if (top > 730)
                                    {
                                        myPage.addTable(myTable);

                                        myTable = new pdfTable(myDoc, 1, new pdfColor("000000"), 2,
                                                               new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, new pdfColor("FFFFFF")),
                                                               new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, pdfColor.White));
                                        myTable.coordX = leftMargin;
                                        myTable.coordY = getTop(myPage, top);

                                        top           += 152;
                                        myTable.coordX = leftMargin;
                                        myTable.coordY = getTop(myPage, top);

                                        myPage.addText("Pág. " + pg++, leftMargin, 10, myDoc.getFontReference(strFont), 10, pdfColor.Black);

                                        // Add a page
                                        myPage = myDoc.addPage(predefinedPageSize.csSharpPDFFormat);

                                        // Header Text
                                        myPage.addText("Ordem de Serviço", leftMargin, getTop(myPage, 30),
                                                       myDoc.getFontReference(strFont), 15, pdfColor.Black);
                                        top     = 40;
                                        myTable = new pdfTable(myDoc, 1, new pdfColor("000000"), 2,
                                                               new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, new pdfColor("FFFFFF")),
                                                               new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, pdfColor.White));

                                        myTable.coordX = leftMargin;
                                        myTable.coordY = getTop(myPage, top);

                                        //// Create table's header
                                        cl = 0;
                                        myTable.tableHeader.rowHeight = 10;
                                        myTable.tableHeader.addColumn(150, predefinedAlignment.csLeft);
                                        myTable.tableHeader[cl++].addText("Nº O.S.");

                                        myTable.tableHeader.addColumn(420, predefinedAlignment.csLeft);
                                        myTable.tableHeader[cl].columnAlign = predefinedAlignment.csLeft;
                                        myTable.tableHeader[cl++].addText(nNuOs.ToString());
                                        myPage.addTable(myTable);

                                        top += nTamLinPixel;

                                        myTable = CabMaterial(myPage, top);
                                    }
                                }
                            }

                            myPage.addTable(myTable);
                        }
                    }

                    myTable = new pdfTable(myDoc, 1, new pdfColor("000000"), 2,
                                           new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, new pdfColor("FFFFFF")),
                                           new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, pdfColor.White));

                    myTable.coordX = leftMargin;
                    myTable.coordY = getTop(myPage, top);

                    cl    = 0;
                    myRow = myTable.createRow();
                    myTable.tableHeader.rowHeight = 10;
                    myTable.tableHeader.addColumn(570, predefinedAlignment.csLeft);
                    myTable.tableHeader[cl++].addText("Satisfeito com o serviço: " + "__Sim         __Não");

                    top += 15;

                    myPage.addTable(myTable);

                    myTable = new pdfTable(myDoc, 1, new pdfColor("000000"), 2,
                                           new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, new pdfColor("FFFFFF")),
                                           new pdfTableStyle(myDoc.getFontReference(strFont), 10, pdfColor.Black, pdfColor.White));

                    myTable.coordX = leftMargin;
                    myTable.coordY = getTop(myPage, top);

                    cl = 0;
                    myTable.tableHeader.rowHeight        = 80;
                    myTable.tableHeader.rowVerticalAlign = predefinedVerticalAlignment.csBottom;
                    myTable.tableHeader.addColumn(285, predefinedAlignment.csCenter);
                    myTable.tableHeader[cl].columnVerticalAlign = predefinedVerticalAlignment.csBottom;
                    myTable.tableHeader[cl++].addText("De acordo Empresa");

                    myTable.tableHeader.addColumn(285, predefinedAlignment.csCenter);
                    myTable.tableHeader[cl].columnVerticalAlign = predefinedVerticalAlignment.csBottom;
                    myTable.tableHeader[cl].addText("De acordo Gestor");

                    myPage.addTable(myTable);

                    myPage.addText("Pág. " + pg++, leftMargin, 10, myDoc.getFontReference(strFont), 10, pdfColor.Black);
                }
            }
        }
Example #22
0
        //Onglet Recapitulatif
        private void btnCreeReca_Click(object sender, EventArgs e)
        {
            try
            {
                //Initialisation des variables
                connec.Open();
                string         mois             = dtpReca.Value.Month.ToString();
                string         annee            = dtpReca.Value.Year.ToString();
                string         text             = "____________________________________________________";
                string         typeNull         = "Type NULL";
                float          montant          = 0;
                int            recette          = 0;
                int            percu            = 0;
                int            indentation      = 20;
                int            hauteurDesLignes = 720;
                List <string>  un            = new List <string>();
                List <string>  de            = new List <string>();
                List <string>  tr            = new List <string>();
                List <string>  qu            = new List <string>();
                List <string>  ci            = new List <string>();
                List <string>  si            = new List <string>();
                List <Boolean> nbTransaction = new List <Boolean>();
                pdfDocument    myDoc         = new pdfDocument("Recapitulatif_" + mois + "_" + annee, "Pique_Sous");
                pdfPage        myPage        = myDoc.addPage();

                //SQL
                OleDbCommand    cd1 = new OleDbCommand("SELECT [Transaction].* FROM [Transaction] WHERE MONTH([dateTransaction]) = " + dtpReca.Value.Month.ToString(), connec);
                OleDbDataReader dr1 = cd1.ExecuteReader();

                //Lecture de la base
                while (dr1.Read())
                {
                    nbTransaction.Add(dr1.GetBoolean(4));
                    if (dr1.GetBoolean(4) == true)
                    {
                        recette++;
                    }
                    if (dr1.GetBoolean(5) == true)
                    {
                        percu++;
                    }
                    montant = montant + dr1.GetFloat(3);

                    un.Add(dr1[1].ToString().Substring(0, 11));
                    de.Add(dr1[2].ToString());
                    tr.Add(dr1[3].ToString());
                    qu.Add(dr1[4].ToString());
                    ci.Add(dr1[5].ToString());

                    if (dr1[6].ToString() != "")
                    {
                        si.Add(dr1[6].ToString());
                    }
                    else
                    {
                        si.Add(typeNull);
                    }
                }
                for (int i = 0; i < si.Count; i++)
                {
                    if (si[i] != typeNull)
                    {
                        //Pour eviter de faire une requette avec une jointure
                        OleDbCommand    cd2 = new OleDbCommand("SELECT [TypeTransaction].* FROM [TypeTransaction] where [codeType] = " + si[i], connec);
                        OleDbDataReader dr2 = cd2.ExecuteReader();
                        while (dr2.Read())
                        {
                            si[i] = dr2[1].ToString();
                        }
                    }
                }

                //Creation du text dans le PDF
                myPage.addText("Recapitulatif du : " + mois + "_" + annee, indentation, hauteurDesLignes, myDoc.getFontReference(predefinedFont.csHelvetica), 20);
                hauteurDesLignes = hauteurDesLignes - 30;
                myPage.addText(text, indentation, hauteurDesLignes, myDoc.getFontReference(predefinedFont.csHelvetica), 20);
                hauteurDesLignes = hauteurDesLignes - 30;
                myPage.addText("Dépenses", indentation, hauteurDesLignes, myDoc.getFontReference(predefinedFont.csHelvetica), 20);
                hauteurDesLignes = hauteurDesLignes - (30 + 25 * un.Count);
                myPage.addText(text, indentation, hauteurDesLignes, myDoc.getFontReference(predefinedFont.csHelvetica), 20);
                hauteurDesLignes = hauteurDesLignes - 30;
                myPage.addText("Recette : " + recette.ToString(), indentation, hauteurDesLignes, myDoc.getFontReference(predefinedFont.csHelvetica), 20);
                hauteurDesLignes = hauteurDesLignes - 30;
                myPage.addText(text, indentation, hauteurDesLignes, myDoc.getFontReference(predefinedFont.csHelvetica), 20);
                hauteurDesLignes = hauteurDesLignes - 30;
                myPage.addText(" Depenses : " + montant.ToString(), indentation, hauteurDesLignes, myDoc.getFontReference(predefinedFont.csHelvetica), 20);
                hauteurDesLignes = hauteurDesLignes - 30;
                myPage.addText(text, indentation, hauteurDesLignes, myDoc.getFontReference(predefinedFont.csHelvetica), 20);
                hauteurDesLignes = hauteurDesLignes - 30;
                myPage.addText("Reste a persevoir : " + percu.ToString(), indentation, hauteurDesLignes, myDoc.getFontReference(predefinedFont.csHelvetica), 20);
                hauteurDesLignes = hauteurDesLignes - 30;
                myPage.addText(text, indentation, hauteurDesLignes, myDoc.getFontReference(predefinedFont.csHelvetica), 20);
                hauteurDesLignes = hauteurDesLignes - 30;
                myPage.addText("Somme total dépensée : -" + montant.ToString(), indentation, hauteurDesLignes, myDoc.getFontReference(predefinedFont.csHelvetica), 20);
                hauteurDesLignes = hauteurDesLignes - 30;
                myPage.addText(text, indentation, hauteurDesLignes, myDoc.getFontReference(predefinedFont.csHelvetica), 20);
                hauteurDesLignes = hauteurDesLignes - 30;
                myPage.addText("nombres de transactions : " + nbTransaction.Count.ToString(), indentation, hauteurDesLignes, myDoc.getFontReference(predefinedFont.csHelvetica), 20);
                hauteurDesLignes = hauteurDesLignes - 30;
                myPage.addText(text, indentation, hauteurDesLignes, myDoc.getFontReference(predefinedFont.csHelvetica), 20);

                //Initiallisation tableau PDF
                pdfTable myTable = new pdfTable(myDoc);
                myTable.borderSize  = 1;
                myTable.borderColor = sharpPDF.pdfColor.Black;
                myTable.tableHeader.addColumn(90);
                myTable.tableHeader.addColumn(120);
                myTable.tableHeader.addColumn(70);
                myTable.tableHeader.addColumn(70);
                myTable.tableHeader.addColumn(70);
                myTable.tableHeader.addColumn(110);
                pdfTableRow myRow = myTable.createRow();

                //Remplissage de la première ligne du tableau
                myRow[0].addText("Date Transaction");
                myRow[1].addText("Description");
                myRow[2].addText("Montant");
                myRow[3].addText("Recette ?");
                myRow[4].addText("Perçu ?");
                myRow[5].addText("Type de dépence ?");
                myTable.addRow(myRow);

                //Remplissage des ligne du tableau
                for (int i = 0; i < un.Count; i++)
                {
                    myRow = myTable.createRow();
                    myRow[0].addText(un[i]);
                    myRow[1].addText(de[i]);
                    myRow[2].addText(tr[i]);
                    myRow[3].addText(qu[i]);
                    myRow[4].addText(ci[i]);
                    myRow[5].addText(si[i]);
                    myTable.addRow(myRow);
                }

                //Place le tableau
                myTable.coordY = 650;
                myTable.coordX = 20;
                myPage.addTable(myTable);

                //creer le PDF
                FolderBrowserDialog fbd = new FolderBrowserDialog();
                if (fbd.ShowDialog() == DialogResult.OK)
                {
                    myDoc.createPDF(fbd.SelectedPath + @"\Recapitulatif_" + mois + "_" + annee + ".pdf");
                }
                myPage = null;
                myDoc  = null;
                connec.Close();
                MessageBox.Show("PDF créé");
            }
            catch (InvalidOperationException erreur)
            {
                MessageBox.Show("Erreur de chaine de connexion ! pdf");
                MessageBox.Show(erreur.Message);
            }
            catch (OleDbException erreur)
            {
                MessageBox.Show("Erreur de requete SQL ! pdf");
                MessageBox.Show(erreur.Message);
            }
        }
Example #23
0
    /// <summary>
    /// create page and add result to page for each result
    /// </summary>
    /// <param name="results"> the results to be added to the document</param>
    /// <param name="doc"> the document to be edited </param>
    private void addResults(List <Results> results, pdfDocument doc)
    {
        int      fontsize = 12;
        pdfColor black    = new pdfColor(predefinedColor.csBlack);
        pdfColor white    = new pdfColor(predefinedColor.csWhite);
        pdfColor grey     = new pdfColor(predefinedColor.csLightGray);

        foreach (Results result in results)
        {
            //create and add page to document
            pdfPage page = doc.addPage();

            //height variable to keep track of where to place next element
            int height = page.height;

            //calc new height
            height -= fontsize + 20;

            //add result name with x:20 y: height
            page.addText(result.Name, 20, height, predefinedFont.csHelveticaBold, fontsize);

            height -= fontsize + 20;

            string s;

            if (result.StepsRequired.Count != 0)
            {
                s = result.AllRequiredSteps ? "ja" : "nee";
            }
            else
            {
                s = "is geen bewijsstuk";
            }
            //add if all requred stepps are taken
            page.addText("alle benodigede stappen uitgevoerd: " + s, 20, height, predefinedFont.csHelvetica, fontsize);

            //creating table of required and taken steps
            pdfTable table = new pdfTable();

            //defineing table style
            table.borderSize        = 1;
            table.borderColor       = new pdfColor(predefinedColor.csBlack);
            table.tableHeaderStyle  = new pdfTableRowStyle(predefinedFont.csHelveticaBold, fontsize, black, white);
            table.rowStyle          = new pdfTableRowStyle(predefinedFont.csHelvetica, fontsize, black, white);
            table.alternateRowStyle = new pdfTableRowStyle(predefinedFont.csHelvetica, fontsize, black, grey);

            // tableColomns use whole page widht
            int tableColomnSize = (page.width - 40) / 2;

            //add colomns to table
            table.tableHeader.addColumn(new pdfTableColumn("required steps", predefinedAlignment.csCenter, tableColomnSize));
            table.tableHeader.addColumn(new pdfTableColumn("steps taken", predefinedAlignment.csCenter, tableColomnSize));

            //check which table is larger steps taken or steps required
            if (result.StepsRequired.Count >= result.StepsTaken.Count)
            {
                for (int i = 0; i < result.StepsRequired.Count; i++)
                {
                    //create new row
                    pdfTableRow row = table.createRow();
                    //add value to first cell of row
                    row[0].columnValue = result.StepsRequired[i];
                    try
                    {
                        // try to add value to second cell
                        row[1].columnValue = result.StepsTaken[i];
                    }
                    catch (System.Exception)
                    {
                        // on a indexOutOfBounds add empty
                        row[1].columnValue = "";
                    }
                    //add row to table
                    table.addRow(row);
                }
            }
            else
            {
                for (int i = 0; i < result.StepsTaken.Count; i++)
                {
                    //create table row
                    pdfTableRow row = table.createRow();
                    try
                    {
                        // try to add value to second cell
                        row[0].columnValue = result.StepsRequired[i];
                    }
                    catch (System.Exception)
                    {
                        // on a indexOutOfBounds add empty
                        row[0].columnValue = "";
                    }

                    row[1].columnValue = result.StepsTaken[i];
                    //add table row
                    table.addRow(row);
                }
            }
            //calc new height
            height -= 20;
            //add table to page
            page.addTable(table, 20, height);
        }
    }