private PdfPTable Parte14()
        {
            Tabela table = new Tabela(1);
            Celula cell;
            Chunk  chunk;

            chunk = new Chunk(NOM_PARCEIRO, FontFactory.GetFont(BaseFont.HELVETICA_BOLD, 10));
            cell  = new Celula(new Phrase(chunk));
            cell.HorizontalAlignment = Element.ALIGN_RIGHT;
            table.AddCell(cell);

            chunk = new Chunk(DES_LOGRADOURO + "," + NRO_ENDERECO + " - " + NOM_CIDADE + " - " + COD_ESTADO, FontFactory.GetFont(BaseFont.HELVETICA, 10));
            cell  = new Celula(new Phrase(chunk));
            cell.HorizontalAlignment = Element.ALIGN_RIGHT;
            table.AddCell(cell);

            chunk = new Chunk("Fone: " + FONE.PoeEdicao(NRO_FONE1) + " - Fax: " + FONE.PoeEdicao(NRO_FAX), FontFactory.GetFont(BaseFont.HELVETICA, 10));
            cell  = new Celula(new Phrase(chunk));
            cell.HorizontalAlignment = Element.ALIGN_RIGHT;
            table.AddCell(cell);

            chunk = new Chunk("CEP: " + CEP.PoeEdicao(NRO_CEP) + " - " + DES_EMAIL, FontFactory.GetFont(BaseFont.HELVETICA, 10));
            cell  = new Celula(new Phrase(chunk));
            cell.HorizontalAlignment = Element.ALIGN_RIGHT;
            table.AddCell(cell);
            return(table);
        }
        private void Parte1()
        {
            Tabela   table = new Tabela(31);
            PdfPCell cell;

            cell = new PdfPCell();
            cell.AddElement(Parte11());
            cell.Colspan = 4;
            table.AddCell(cell);

            cell = new PdfPCell();
            cell.AddElement(Parte12());
            cell.Colspan = 11;
            table.AddCell(cell);

            cell = new PdfPCell();
            cell.AddElement(Parte13());
            cell.Colspan = 7;
            table.AddCell(cell);

            cell = new PdfPCell();
            cell.AddElement(Parte14());
            cell.Colspan = 9;
            table.AddCell(cell);
            doc.Add(table);
        }
        private PdfPTable Parte11()
        {
            Tabela   table = new Tabela(1);
            PdfPCell cell;
            Chunk    chunk;
            string   logo = "imagens\\" + COD_FORNECEDOR + ".jpg";
            Image    img;
            float    largura = 80F;
            float    altura  = 100F;

            try
            {
                img = Image.GetInstance(logo);
                float w = img.Width;
                float h = img.Height;
                while ((w > largura) || (h > altura))
                {
                    w *= 0.9F;
                    h *= 0.9F;
                }
                img.ScaleAbsolute(w, h);
                chunk = new Chunk(img, 0, 0);
            }
            catch
            {
                chunk = new Chunk("");
            }
            cell             = new PdfPCell(new Phrase(chunk));
            cell.BorderWidth = 0;
            table.AddCell(cell);
            return(table);
        }
Exemple #4
0
        private void RodapeFornecedor(string observacao)
        {
            Tabela table = new Tabela(6);

            table.AddCell(Celula2("Observações", 1, true));
            table.AddCell(Celula2(observacao, 5, false));
            doc.Add(table);
        }
Exemple #5
0
        public static void AdicionaCelula(Tabela tabela, string texto, string BaseFont_, int tamanho, iTextSharp.text.Color cor, int colunas)
        {
            Chunk    chunk = new Chunk(texto, FontFactory.GetFont(BaseFont_, tamanho));
            PdfPCell cell  = new PdfPCell(new Paragraph(chunk));

            cell.BackgroundColor = cor;
            cell.Colspan         = colunas;
            tabela.AddCell(cell);
        }
Exemple #6
0
        public static void AdicionaCelula(Tabela tabela, string texto, string BaseFont_, int tamanho, int alinhamento, int colunas)
        {
            Chunk    chunk = new Chunk(texto, FontFactory.GetFont(BaseFont_, tamanho));
            PdfPCell cell  = new PdfPCell(new Paragraph(chunk));

            cell.HorizontalAlignment = alinhamento;
            cell.Colspan             = colunas;
            tabela.AddCell(cell);
        }
Exemple #7
0
        private PdfPTable Parte13()
        {
            Tabela table = new Tabela(1);
            Celula cell;

            cell = new Celula(Frase("DATA: ", DateTime.Now.ToString("dd/MM/yyyyy"), 10));
            table.AddCell(cell);
            return(table);
        }
Exemple #8
0
 private void Totais(Tabela table, float total, float desconto, bool por_fabrica)
 {
     if (!por_fabrica)
     {
         table.AddCell(CelulaGrid("Desconto", 22, true, false));
         table.AddCell(CelulaGrid(desconto.ToString("###,###,##0.00"), 2, true, true));
     }
     table.AddCell(CelulaGrid("Valor Final", 22, true, false));
     table.AddCell(CelulaGrid((total - desconto).ToString("###,###,##0.00"), 2, true, true));
 }
Exemple #9
0
        private void CabecalhoFornecedor(string COD_FORNECEDOR)
        {
            Tabela   table = new Tabela(1);
            PdfPCell cell;

            doc.Add(new Paragraph(""));
            doc.Add(new Paragraph(""));
            cell             = new PdfPCell(new Phrase(new Chunk("Fornecedor " + COD_FORNECEDOR.Trim())));
            cell.BorderWidth = 0;
            table.AddCell(cell);
            doc.Add(table);
        }
        private PdfPTable Parte12()
        {
            Tabela table = new Tabela(11);
            Celula cell;
            Chunk  chunk;

            chunk        = new Chunk("PEDIDO DE FÁBRICA", FontFactory.GetFont(BaseFont.HELVETICA_BOLD, 16));
            cell         = new Celula(new Phrase(chunk));
            cell.Padding = 1;
            cell.Colspan = 11;
            table.AddCell(cell);

            cell         = new Celula(new Phrase(""));
            cell.Padding = 1;
            cell.Colspan = 11;
            table.AddCell(cell);

            chunk            = new Chunk("X", FontFactory.GetFont(BaseFont.HELVETICA_BOLD, 16));
            cell             = new Celula(new Phrase(chunk));
            cell.Colspan     = 1;
            cell.BorderWidth = 1;
            table.AddCell(cell);

            chunk        = new Chunk("PEDIDO DE VENDA", FontFactory.GetFont(BaseFont.HELVETICA, 8));
            cell         = new Celula(new Phrase(chunk));
            cell.Colspan = 4;
            table.AddCell(cell);

            cell             = new Celula(new Phrase(""));
            cell.Colspan     = 1;
            cell.BorderWidth = 1;
            table.AddCell(cell);

            chunk        = new Chunk("ASSISTÊNCIA TÉCNICA", FontFactory.GetFont(BaseFont.HELVETICA, 8));
            cell         = new Celula(new Phrase(chunk));
            cell.Colspan = 5;
            table.AddCell(cell);

            cell         = new Celula(new Phrase(""));
            cell.Colspan = 11;
            table.AddCell(cell);

            cell             = new Celula(new Phrase(""));
            cell.Colspan     = 1;
            cell.BorderWidth = 1;
            table.AddCell(cell);

            chunk        = new Chunk("ALTERÇÃO PEDIDO DE VENDA", FontFactory.GetFont(BaseFont.HELVETICA, 8));
            cell         = new Celula(new Phrase(chunk));
            cell.Colspan = 10;
            table.AddCell(cell);
            return(table);
        }
Exemple #11
0
        private PdfPTable Parte12(string titulo)
        {
            Tabela table = new Tabela(1);
            Chunk  chunk = new Chunk(titulo, FontFactory.GetFont(BaseFont.HELVETICA_BOLD, 16));
            Celula cell  = new Celula(new Phrase(chunk));

            cell.Padding = 1;
            //cell.Colspan = 11;
            //cell = new Celula(Frase(titulo, 10));
            table.AddCell(cell);
            return(table);
        }
        private PdfPTable Parte13()
        {
            Tabela table = new Tabela(1);
            Celula cell;

            cell = new Celula(Frase("No PEDIDO FÁBRICA: ", NRO_PEDIDO_FORNEC.ToString(), 10));
            table.AddCell(cell);
            cell = new Celula(Frase("DATA: ", DateTime.Now.ToString("dd/MM/yyyyy"), 10));
            table.AddCell(cell);
            cell = new Celula(Frase("REPRESENTANTE: ", Globais.sFilial, 10));
            table.AddCell(cell);
            return(table);
        }
Exemple #13
0
        private void CabecalhoRelatorio()
        {
            Tabela   table = new Tabela(4);
            PdfPCell cell;
            Chunk    chunk;
            string   logo = "imagens\\logo_rel.jpg";
            Image    img;
            float    largura = 80F;
            float    altura  = 100F;

            try
            {
                img = Image.GetInstance(logo);
                float w = img.Width;
                float h = img.Height;
                while ((w > largura) || (h > altura))
                {
                    w *= 0.9F;
                    h *= 0.9F;
                }
                img.ScaleAbsolute(w, h);
                chunk = new Chunk(img, 0, 0);
            }
            catch
            {
                chunk = new Chunk("");
            }
            cell                   = new PdfPCell(new Phrase(chunk));
            cell.BorderWidth       = 0;
            cell.BorderWidthBottom = 1;
            cell.Colspan           = 1;
            table.AddCell(cell);

            cell                     = new PdfPCell(new Phrase(new Chunk("Relatório de Pedidos", FontFactory.GetFont(BaseFont.HELVETICA, 18))));
            cell.BorderWidth         = 0;
            cell.BorderWidthBottom   = 1;
            cell.Colspan             = 2;
            cell.VerticalAlignment   = Element.ALIGN_MIDDLE;
            cell.HorizontalAlignment = Element.ALIGN_CENTER;
            table.AddCell(cell);

            cell                     = new PdfPCell(new Phrase(new Chunk(DateTime.Now.ToString("d/M/yyyy"), FontFactory.GetFont(BaseFont.HELVETICA, 18))));
            cell.BorderWidth         = 0;
            cell.BorderWidthBottom   = 1;
            cell.Colspan             = 1;
            cell.VerticalAlignment   = Element.ALIGN_MIDDLE;
            cell.HorizontalAlignment = Element.ALIGN_CENTER;
            table.AddCell(cell);

            doc.Add(table);
        }
Exemple #14
0
        private void CabecalhoPedido(string COD_FORNECEDOR, DateTime DAT_ORCAMENTO, short COD_ORCAMENTO, int NRO_PEDIDO, string vendedor, string observacao)
        {
            Tabela   table = new Tabela(1);
            PdfPCell cell;

            doc.Add(new Paragraph(""));
            doc.Add(new Paragraph(""));
            cell             = new PdfPCell(new Phrase(new Chunk("Pedido " + COD_FORNECEDOR.Trim() + " - " + NRO_PEDIDO.ToString())));
            cell.BorderWidth = 0;
            table.AddCell(cell);
            doc.Add(table);

            table = new Tabela(6);
            table.AddCell(Celula2("Vendedor", 1, true));
            table.AddCell(Celula2(vendedor, 5, false));
            table.AddCell(Celula2("Observações", 1, true));
            table.AddCell(Celula2(observacao, 5, false));
            doc.Add(table);
        }
Exemple #15
0
        private void CabecalhoTabela(Tabela table, bool mostrar_valores)
        {
            //doc.Add(new Paragraph(""));
            //doc.Add(new Paragraph(""));
            PdfPCell cell = CelulaGrid("", mostrar_valores ? 24 : 12, true, false);

            cell.BorderWidth = 0;
            table.AddCell(cell);

            table.AddCell(CelulaGrid("Item", mostrar_valores ? 4 : 2, true, false));
            table.AddCell(CelulaGrid("Descrição", mostrar_valores ? 6 : 5, true, false));
            table.AddCell(CelulaGrid("Códigos Específicos", mostrar_valores ? 4 : 3, true, false));
            table.AddCell(CelulaGrid("Qtde", 2, true, false));
            if (mostrar_valores)
            {
                table.AddCell(CelulaGrid("Unitário", 2, true, true));
                table.AddCell(CelulaGrid("Total", 2, true, true));
                table.AddCell(CelulaGrid("IPI", 2, true, true));
                table.AddCell(CelulaGrid("Total c/ IPI", 2, true, true));
            }
        }
Exemple #16
0
        public static void Cabecalho(Document doc, string titulo, string sub_titulo)
        {
            Tabela   table = new Tabela(22);
            PdfPCell cell;

            cell = new PdfPCell();
            cell.AddElement(Parte11());
            cell.Colspan = 4;
            table.AddCell(cell);

            cell = new PdfPCell();
            cell.AddElement(Parte12(titulo, sub_titulo));
            cell.Colspan = 11;
            table.AddCell(cell);

            cell = new PdfPCell();
            cell.AddElement(Parte13());
            cell.Colspan = 7;
            table.AddCell(cell);

            doc.Add(table);
        }
Exemple #17
0
        private void Parte1(PDF pdf, string titulo)
        {
            Tabela   table = new Tabela(22);
            PdfPCell cell;

            cell = new PdfPCell();
            cell.AddElement(Parte11());
            cell.Colspan = 4;
            table.AddCell(cell);

            cell = new PdfPCell();
            cell.AddElement(Parte12(titulo));
            cell.Colspan = 11;
            table.AddCell(cell);

            cell = new PdfPCell();
            cell.AddElement(Parte13());
            cell.Colspan = 7;
            table.AddCell(cell);

            pdf.doc.Add(table);
        }
Exemple #18
0
        public static void GeraDespesasNatureza(Document doc, DateTime inicio, DateTime fim)
        {
            Tabela table = new Tabela(5);

            AdicionaCelula(table, "Natureza", BaseFont.HELVETICA_BOLD, 8, iTextSharp.text.Color.WHITE, 1);
            AdicionaCelula(table, "Descrição", BaseFont.HELVETICA_BOLD, 8, iTextSharp.text.Color.WHITE, 3);
            AdicionaCelula(table, "Valor", BaseFont.HELVETICA_BOLD, 8, iTextSharp.text.Color.WHITE, Element.ALIGN_RIGHT, 1);

            string datai = inicio.ToString("M/d/yyyy");
            string dataf = fim.ToString("M/d/yyyy");
            string sql   =
                "select b.COD_NATUREZA,b.DES_NATUREZA,sum(a.VLR_PREVISTO) " +
                "from TITULOS_PAGAR a, NATUREZAS_PAGAMENTO b " +
                "where a.COD_NATUREZA = b.COD_NATUREZA and " +
                "      a.DAT_VENCIMENTO between '" + datai + "' and '" + dataf + "' " +
                "group by b.COD_NATUREZA,b.DES_NATUREZA " +
                "order by 3 desc";
            FbCommand    cmd    = new FbCommand(sql, Globais.bd);
            FbDataReader reader = cmd.ExecuteReader(CommandBehavior.Default);
            float        total  = 0;

            while (reader.Read())
            {
                string codigo    = reader.GetString(0);
                string descricao = reader.GetString(1);
                float  valor     = reader.GetFloat(2);
                total += valor;
                AdicionaCelula(table, codigo, BaseFont.HELVETICA, 8, Element.ALIGN_LEFT, 1);
                AdicionaCelula(table, descricao, BaseFont.HELVETICA, 8, Element.ALIGN_LEFT, 3);
                AdicionaCelula(table, valor.ToString("#,###,##0.00"), BaseFont.HELVETICA, 8, Element.ALIGN_RIGHT, 1);
            }
            reader.Close();

            AdicionaCelula(table, "Total", BaseFont.HELVETICA_BOLD, 8, Color.WHITE, 4);
            AdicionaCelula(table, total.ToString("#,###,##0.00"), BaseFont.HELVETICA_BOLD, 8, Color.LIGHT_GRAY, Element.ALIGN_RIGHT, 1);
            doc.Add(table);
        }
Exemple #19
0
        private PdfPTable Parte13()
        {
            Tabela table = new Tabela(1);
            Celula cell;

            cell = new Celula(Frase("DATA: ", DateTime.Now.ToString("dd/MM/yyyyy"), 10));
            table.AddCell(cell);
            if (por_vendedor)
            {
                cell = new Celula(Frase("VENDEDOR: ", vendedor, 10));
            }
            else
            if (por_consultor)
            {
                cell = new Celula(Frase("CONSULTOR: ", consultor, 10));
            }
            else
            if (por_filial)
            {
                cell = new Celula(Frase("FILIAL: ", Globais.sFilial, 10));
            }
            table.AddCell(cell);
            return(table);
        }
        private void Parte4(Cabecalho2_Pedido cab2, bool mostrar_valores)
        {
            Chunk  chunk;
            Celula cell;
            Tabela table = new Tabela(31);

            // linha1
            cell         = new Celula(Frase("", 10));
            cell.Colspan = mostrar_valores ? 22 : 31;
            table.AddCell(cell);

            if (mostrar_valores)
            {
                chunk        = new Chunk("TOTAL GERAL COM IPI", FontFactory.GetFont(BaseFont.HELVETICA, 10));
                cell         = new Celula(new Phrase(chunk));
                cell.Colspan = 6;
                table.AddCell(cell);

                chunk = new Chunk(total.ToString("###,###,##0.00"), FontFactory.GetFont(BaseFont.HELVETICA_BOLD, 10));
                cell  = new Celula(new Phrase(chunk));
                cell.HorizontalAlignment = Element.ALIGN_RIGHT;
                cell.BorderWidth         = 1;
                cell.Colspan             = 3;
                table.AddCell(cell);
            }

            // linha2
            chunk        = new Chunk("No PEDIDO REPRESENTANTE", FontFactory.GetFont(BaseFont.HELVETICA, 10));
            cell         = new Celula(new Phrase(chunk));
            cell.Colspan = 4;
            table.AddCell(cell);

            chunk                    = new Chunk(NRO_PEDIDO.ToString(), FontFactory.GetFont(BaseFont.HELVETICA_BOLD, 10));
            cell                     = new Celula(new Phrase(chunk));
            cell.Colspan             = 4;
            cell.BorderWidth         = 1;
            cell.HorizontalAlignment = Element.ALIGN_CENTER;
            table.AddCell(cell);

            cell         = new Celula(new Phrase(""));
            cell.Colspan = 1;
            table.AddCell(cell);

            chunk        = new Chunk("No O.C. CLIENTE", FontFactory.GetFont(BaseFont.HELVETICA, 10));
            cell         = new Celula(new Phrase(chunk));
            cell.Colspan = 4;
            table.AddCell(cell);

            cell             = new Celula(new Phrase(""));
            cell.Colspan     = 4;
            cell.BorderWidth = 1;
            table.AddCell(cell);

            cell         = new Celula(new Phrase(""));
            cell.Colspan = 1;
            table.AddCell(cell);

            chunk        = new Chunk("No PED ESPECIAL", FontFactory.GetFont(BaseFont.HELVETICA, 10));
            cell         = new Celula(new Phrase(chunk));
            cell.Colspan = 5;
            table.AddCell(cell);

            cell             = new Celula(new Phrase(""));
            cell.Colspan     = 4;
            cell.BorderWidth = 1;
            table.AddCell(cell);

            cell         = new Celula(new Phrase(""));
            cell.Colspan = 4;
            table.AddCell(cell);

            // linha3
            string observacao = cab2.observacao;

            string[] linhas = observacao.Split('\n');
            int      lin    = 0;

            foreach (string linha in linhas)
            {
                if (++lin == 1)
                {
                    chunk = new Chunk("OBS: ", FontFactory.GetFont(BaseFont.HELVETICA, 10));
                }
                else
                {
                    chunk = new Chunk("", FontFactory.GetFont(BaseFont.HELVETICA, 10));
                }
                cell                   = new Celula(new Phrase(chunk));
                cell.Colspan           = 2;
                cell.VerticalAlignment = Element.ALIGN_BOTTOM;
                table.AddCell(cell);

                chunk                  = new Chunk(linha, FontFactory.GetFont(BaseFont.HELVETICA, 10));
                cell                   = new Celula(new Phrase(chunk));
                cell.Colspan           = 29;
                cell.VerticalAlignment = Element.ALIGN_BOTTOM;
                cell.BorderWidthBottom = 1;
                table.AddCell(cell);
            }

/*
 *                      chunk = new Chunk("OBS:", FontFactory.GetFont(BaseFont.HELVETICA, 10));
 *                      cell = new Celula(new Phrase(chunk));
 *                      cell.Colspan = 2;
 *                      cell.VerticalAlignment = Element.ALIGN_BOTTOM;
 *                      table.AddCell(cell);
 *
 *                      chunk = new Chunk(cab2.observacao, FontFactory.GetFont(BaseFont.HELVETICA, 10));
 *                      cell = new Celula(new Phrase(chunk));
 *                      cell.Colspan = 29;
 *                      cell.BorderWidthBottom = 1;
 *                      table.AddCell(cell);
 *
 *                      // linha4
 *                      cell = new Celula(new Phrase(""));
 *                      cell.Colspan = 31;
 *                      cell.BorderWidthBottom = 1;
 *                      table.AddCell(cell);
 */
            // linha5
            cell         = new Celula(new Phrase(""));
            cell.Colspan = 31;
            table.AddCell(cell);

            chunk        = new Chunk("PEDIDO APROVADO", FontFactory.GetFont(BaseFont.HELVETICA, 10));
            cell         = new Celula(new Phrase(chunk));
            cell.Colspan = 5;
            table.AddCell(cell);

            cell             = new Celula(new Phrase(""));
            cell.Colspan     = 1;
            cell.BorderWidth = 1;
            table.AddCell(cell);

            chunk        = new Chunk("SIM", FontFactory.GetFont(BaseFont.HELVETICA, 10));
            cell         = new Celula(new Phrase(chunk));
            cell.Colspan = 2;
            table.AddCell(cell);

            cell             = new Celula(new Phrase(""));
            cell.Colspan     = 1;
            cell.BorderWidth = 1;
            table.AddCell(cell);

            chunk        = new Chunk("NÃO", FontFactory.GetFont(BaseFont.HELVETICA, 10));
            cell         = new Celula(new Phrase(chunk));
            cell.Colspan = 2;
            table.AddCell(cell);

            chunk                  = new Chunk("ASS. CLIENTE:", FontFactory.GetFont(BaseFont.HELVETICA, 10));
            cell                   = new Celula(new Phrase(chunk));
            cell.Colspan           = 4;
            cell.VerticalAlignment = Element.ALIGN_BOTTOM;
            table.AddCell(cell);

            cell                   = new Celula(new Phrase(""));
            cell.Colspan           = 6;
            cell.BorderWidthBottom = 1;
            table.AddCell(cell);

            chunk                  = new Chunk("ASS. REPRES:", FontFactory.GetFont(BaseFont.HELVETICA, 10));
            cell                   = new Celula(new Phrase(chunk));
            cell.Colspan           = 4;
            cell.VerticalAlignment = Element.ALIGN_BOTTOM;
            table.AddCell(cell);

            cell                   = new Celula(new Phrase(""));
            cell.Colspan           = 6;
            cell.BorderWidthBottom = 1;
            table.AddCell(cell);

            doc.Add(table);
        }
        private void Parte3(ArrayList areas, bool mostrar_valores)
        {
            CelulaCabecalho cell;
            CelulaItem      cellI;
            Tabela          table = new Tabela(mostrar_valores ? 31 : 24);

            // cabecalho
            cell         = new CelulaCabecalho(Frase("ITEM", 10));
            cell.Colspan = 1;
            table.AddCell(cell);

            cell         = new CelulaCabecalho(Frase("QTD", 10));
            cell.Colspan = 1;
            table.AddCell(cell);

            cell         = new CelulaCabecalho(Frase("COD FIXO", 10));
            cell.Colspan = 2;
            table.AddCell(cell);

            cell         = new CelulaCabecalho(Frase("COD VARIÁVEL", 10));
            cell.Colspan = 5;
            table.AddCell(cell);

            cell         = new CelulaCabecalho(Frase("DESCRIÇÃO", 10));
            cell.Colspan = 11;
            table.AddCell(cell);

            cell         = new CelulaCabecalho(Frase("MEDIDA", 10));
            cell.Colspan = 4;
            table.AddCell(cell);

            if (mostrar_valores)
            {
                cell                     = new CelulaCabecalho(Frase("R$ UNIT S/IPI", 10));
                cell.Colspan             = 3;
                cell.HorizontalAlignment = Element.ALIGN_RIGHT;
                table.AddCell(cell);

                cell         = new CelulaCabecalho(Frase("IPI%", 10));
                cell.Colspan = 1;
                table.AddCell(cell);

                cell                     = new CelulaCabecalho(Frase("R$ TOTAL C/IPI", 10));
                cell.Colspan             = 3;
                cell.HorizontalAlignment = Element.ALIGN_RIGHT;
                table.AddCell(cell);
            }

            total = 0;
            int seq = 0;

            foreach (Area area in areas)
            {
                foreach (Item item in area.itens)
                {
                    // itens
                    char   letra = (char)((int)'A' + seq++);
                    string s     = letra.ToString();
                    cellI         = new CelulaItem(Frase(s, 10));             // item
                    cellI.Colspan = 1;
                    table.AddCell(cellI);

                    cellI         = new CelulaItem(Frase(item.qtde.ToString(), 10));             // qtd
                    cellI.Colspan = 1;
                    table.AddCell(cellI);

                    cellI         = new CelulaItem(Frase(item.codigo, 10));             // fixo
                    cellI.Colspan = 2;
                    table.AddCell(cellI);

                    cellI         = new CelulaItem(Frase(item.especificos, 10));             // variavel
                    cellI.Colspan = 5;
                    table.AddCell(cellI);

                    cellI         = new CelulaItem(Frase(item.descricao, 10));             // descricao
                    cellI.Colspan = 11;
                    table.AddCell(cellI);

                    cellI         = new CelulaItem(Frase(item.medidas, 10));             // medida
                    cellI.Colspan = 4;
                    table.AddCell(cellI);

                    if (mostrar_valores)
                    {
                        cellI                     = new CelulaItem(Frase(item.vlr_semipi.ToString("###,###,##0.00"), 10));     // sem ipi
                        cellI.Colspan             = 3;
                        cellI.HorizontalAlignment = Element.ALIGN_RIGHT;
                        table.AddCell(cellI);

                        cellI         = new CelulaItem(Frase(item.ipi.ToString(), 10));                 // ipi
                        cellI.Colspan = 1;
                        table.AddCell(cellI);

                        cellI                     = new CelulaItem(Frase(item.vlr_unitario.ToString("###,###,##0.00"), 10));     // com ipi
                        cellI.Colspan             = 3;
                        cellI.HorizontalAlignment = Element.ALIGN_RIGHT;
                        table.AddCell(cellI);
                    }

                    total += item.vlr_unitario;
                }
            }
            doc.Add(table);
        }
        private void Parte2(Cabecalho2_Pedido cab2)
        {
            Tabela table = new Tabela(31);
            Celula cell;

            // linha1
            cell         = new Celula(Frase("CLIENTE: ", cab2.cliente, 10));
            cell.Colspan = 22;
            table.AddCell(cell);

            cell         = new Celula(Frase("CONTATO: ", cab2.contato, 10));
            cell.Colspan = 22;
            table.AddCell(cell);

            // linha2
            cell         = new Celula(Frase("ENDEREÇO: ", cab2.endereco + "," + cab2.numero, 10));
            cell.Colspan = 22;
            table.AddCell(cell);

            cell         = new Celula(Frase("E-mail: ", cab2.email, 10));
            cell.Colspan = 9;
            table.AddCell(cell);

            // linha3
            cell         = new Celula(Frase("BAIRRO: ", cab2.bairro, 10));
            cell.Colspan = 11;
            table.AddCell(cell);

            cell         = new Celula(Frase("CIDADE: ", cab2.cidade, 10));
            cell.Colspan = 11;
            table.AddCell(cell);

            cell         = new Celula(Frase("UF: ", cab2.estado, 10));
            cell.Colspan = 5;
            table.AddCell(cell);

            cell         = new Celula(Frase("CEP: ", CEP.PoeEdicao(cab2.cep), 10));
            cell.Colspan = 4;
            table.AddCell(cell);

            // linha4
            cell         = new Celula(Frase("CNPJ: ", cab2.cnpj, 10));
            cell.Colspan = 11;
            table.AddCell(cell);

            cell         = new Celula(Frase("INCRIÇÃO ESTADUAL: ", cab2.ie, 10));
            cell.Colspan = 16;
            table.AddCell(cell);

            cell         = new Celula(Frase("FONE: ", FONE.PoeEdicao(cab2.fone), 10));
            cell.Colspan = 4;
            table.AddCell(cell);

            // linha4
            if (cab2.entrega.Trim().Length > 0)
            {
                cell = new Celula(Frase("LOCAL DE ENTREGA: ",
                                        cab2.entrega.Trim() + "," + cab2.numero_entrega.Trim() + " - " +
                                        cab2.compl_entrega.Trim() + " - " +
                                        cab2.bairro_entrega.Trim() + " - " + cab2.cidade_entrega.Trim() +
                                        cab2.estado_entrega.Trim() + " - " +
                                        CEP.PoeEdicao(cab2.cep_entrega), 10));
            }
            else
            {
                cell = new Celula(Frase("LOCAL DE ENTREGA: ", "IDEM", 10));
            }
            cell.Colspan = 31;
            table.AddCell(cell);

            // linha5
            if (cab2.cobranca.Trim().Length > 0)
            {
                cell = new Celula(Frase("LOCAL DE COBRANÇA: ",
                                        cab2.cobranca.Trim() + "," + cab2.numero_cobranca.Trim() + " - " +
                                        cab2.compl_cobranca.Trim() + " - " +
                                        cab2.bairro_cobranca.Trim() + " - " + cab2.cidade_cobranca.Trim() +
                                        cab2.estado_cobranca.Trim() + " - " +
                                        CEP.PoeEdicao(cab2.cep_cobranca), 10));
            }
            else
            {
                cell = new Celula(Frase("LOCAL DE COBRANÇA: ", "IDEM", 10));
            }
            cell.Colspan = 31;
            table.AddCell(cell);

            // linha6
            cell         = new Celula(Frase("FRETE: % ", 10));
            cell.Colspan = 5;
            table.AddCell(cell);

            if (IDT_FRETE == 'C')
            {
                cell = new Celula(new Phrase(""));
            }
            else
            {
                Chunk chunk = new Chunk("X", FontFactory.GetFont(BaseFont.HELVETICA_BOLD, 16));
                cell = new Celula(new Phrase(chunk));
            }
            cell.Colspan     = 1;
            cell.BorderWidth = 1;
            table.AddCell(cell);

            cell         = new Celula(Frase("FORNECEDOR", 10));
            cell.Colspan = 4;
            table.AddCell(cell);

            if (IDT_FRETE == 'C')
            {
                Chunk chunk = new Chunk("X", FontFactory.GetFont(BaseFont.HELVETICA_BOLD, 16));
                cell = new Celula(new Phrase(chunk));
            }
            else
            {
                cell = new Celula(new Phrase(""));
            }
            cell.Colspan     = 1;
            cell.BorderWidth = 1;
            table.AddCell(cell);

            cell         = new Celula(Frase("CLIENTE", 10));
            cell.Colspan = 4;
            table.AddCell(cell);

            cell         = new Celula(Frase("TRANSPORTADORA: ", "", 10));
            cell.Colspan = 12;
            table.AddCell(cell);

            cell         = new Celula(Frase("FONE: ", "", 10));
            cell.Colspan = 5;
            table.AddCell(cell);

            // linha7
            cell         = new Celula(Frase("CONDIÇÕES DE PAGAMENTO: ", "", 10));
            cell.Colspan = 8;
            table.AddCell(cell);

            cell         = new Celula(Frase("SINAL-R$ ", "", 10));
            cell.Colspan = 5;
            table.AddCell(cell);

            cell         = new Celula(Frase("PARCELAS 1-R$ ", "", 10));
            cell.Colspan = 6;
            table.AddCell(cell);

            cell         = new Celula(Frase("2-R$ ", "", 10));
            cell.Colspan = 4;
            table.AddCell(cell);

            cell         = new Celula(Frase("3-R$ ", "", 10));
            cell.Colspan = 4;
            table.AddCell(cell);

            cell         = new Celula(Frase("4-R$ ", "", 10));
            cell.Colspan = 4;
            table.AddCell(cell);

            // linha8
            cell         = new Celula(Frase("SAÍDA DA FÁBRICA: ", "", 10));
            cell.Colspan = 19;
            table.AddCell(cell);

            cell         = new Celula(Frase("DESCONTO: ", "", 10));
            cell.Colspan = 5;
            table.AddCell(cell);

            cell         = new Celula(Frase("ENC FINANCEIRO: ", "", 10));
            cell.Colspan = 7;
            table.AddCell(cell);
            doc.Add(table);
        }
Exemple #23
0
        private void Parte2(DataGridView dgv, bool justificativas)
        {
            CelulaCabecalho cell;
            CelulaItem      cellI;
            Tabela          table = new Tabela(11);

            // cabecalho
            cell         = new CelulaCabecalho(Frase("Fornecedor", 10));
            cell.Colspan = 2;
            table.AddCell(cell);

            cell         = new CelulaCabecalho(Frase("Data", 10));
            cell.Colspan = 1;
            table.AddCell(cell);

            cell         = new CelulaCabecalho(Frase("Orçamento", 10));
            cell.Colspan = 1;
            table.AddCell(cell);

            cell         = new CelulaCabecalho(Frase("Pedido", 10));
            cell.Colspan = 1;
            table.AddCell(cell);

            cell         = new CelulaCabecalho(Frase("Cliente", 10));
            cell.Colspan = 2;
            table.AddCell(cell);

            cell                     = new CelulaCabecalho(Frase("Vlr Pedido", 10));
            cell.Colspan             = 1;
            cell.HorizontalAlignment = Element.ALIGN_RIGHT;
            table.AddCell(cell);

            cell                     = new CelulaCabecalho(Frase("Valor", 10));
            cell.Colspan             = 1;
            cell.HorizontalAlignment = Element.ALIGN_RIGHT;
            table.AddCell(cell);

            cell                     = new CelulaCabecalho(Frase("%Pago", 10));
            cell.Colspan             = 1;
            cell.HorizontalAlignment = Element.ALIGN_RIGHT;
            table.AddCell(cell);

            cell                     = new CelulaCabecalho(Frase("Comissão", 10));
            cell.Colspan             = 1;
            cell.HorizontalAlignment = Element.ALIGN_RIGHT;
            table.AddCell(cell);

            percentual_comissao = 0;
            total_comissao      = 0;
            total_pedido        = 0;
            total_valor         = 0;
            total_pago          = 0;
            total_pagar         = 0;
            nitens = 0;

            foreach (DataGridViewRow row in dgv.Rows)
            {
                /*
                 * if (!(bool)row.Cells["S"].Value)
                 * {
                 *      continue;
                 * }
                 * bool pg=false;
                 * if (por_vendedor)
                 *      pg = row.Cells["IdtVendedor"].Value.ToString().Equals("S");
                 * if (por_consultor)
                 *      pg = row.Cells["IdtConsultor"].Value.ToString().Equals("S");
                 * if (por_filial)
                 *      pg = row.Cells["IdtFilial"].Value.ToString().Equals("S");
                 */
                bool pg = (bool)row.Cells["PG"].Value;

                if (!mostra_pagar && !pg)
                {
                    continue;
                }
                if (!mostra_pago && pg)
                {
                    continue;
                }
                cellI         = new CelulaItem(Frase(row.Cells["Fornecedor"].Value.ToString(), 10));
                cellI.Colspan = 2;
                table.AddCell(cellI);

                cellI         = new CelulaItem(Frase(row.Cells["Data"].Value.ToString(), 10));
                cellI.Colspan = 1;
                table.AddCell(cellI);

                cellI         = new CelulaItem(Frase(row.Cells["Orcamento"].Value.ToString(), 10));
                cellI.Colspan = 1;
                table.AddCell(cellI);

                cellI         = new CelulaItem(Frase(row.Cells["Pedido"].Value.ToString(), 10));
                cellI.Colspan = 1;
                table.AddCell(cellI);

                cellI         = new CelulaItem(Frase(row.Cells["Cliente"].Value.ToString(), 10));
                cellI.Colspan = 2;
                table.AddCell(cellI);

                cellI                     = new CelulaItem(Frase(Globais.StrToFloat(row.Cells["ValorPedido"].Value.ToString()).ToString("#,###,##0.00"), 10));
                cellI.Colspan             = 1;
                cellI.HorizontalAlignment = Element.ALIGN_RIGHT;
                table.AddCell(cellI);

                cellI                     = new CelulaItem(Frase(Globais.StrToFloat(row.Cells["Valor"].Value.ToString()).ToString("#,###,##0.00"), 10));
                cellI.Colspan             = 1;
                cellI.HorizontalAlignment = Element.ALIGN_RIGHT;
                table.AddCell(cellI);

                //cellI = new CelulaItem(Frase(Globais.StrToFloat(row.Cells["PerVendedor"].Value.ToString()).ToString("#0.00"), 10));
                cellI                     = new CelulaItem(Frase(Globais.StrToFloat(row.Cells["Pago"].Value.ToString()).ToString("#0.00"), 10));
                cellI.Colspan             = 1;
                cellI.HorizontalAlignment = Element.ALIGN_RIGHT;
                table.AddCell(cellI);

                float comissao = Globais.StrToFloat(row.Cells["Comissao"].Value.ToString());
                //float valor = Globais.StrToFloat(row.Cells["Valor"].Value.ToString());
                //float per_pago = Globais.StrToFloat(row.Cells["PerVendedor"].Value.ToString());
                //float comissao = per_pago * valor / 100f;
                cellI                     = new CelulaItem(Frase(comissao.ToString("#,###,##0.00"), 10));
                cellI.Colspan             = 1;
                cellI.HorizontalAlignment = Element.ALIGN_RIGHT;
                table.AddCell(cellI);
                percentual_comissao += Globais.StrToFloat(row.Cells["Pago"].Value.ToString());
                total_comissao      += comissao;
                total_pedido        += Globais.StrToFloat(row.Cells["ValorPedido"].Value.ToString());
                total_valor         += Globais.StrToFloat(row.Cells["Valor"].Value.ToString());
                if ((bool)row.Cells["PG"].Value)
                {
                    total_pago += comissao;
                }
                else
                {
                    total_pagar += comissao;
                }

                if (justificativas)
                {
                    string justificativa = row.Cells["Justificativa"].Value.ToString().Trim();
                    if (justificativa.Length > 0)
                    {
                        cellI         = new CelulaItem(Frase("Justificativa: " + justificativa, 10));
                        cellI.Colspan = 11;
                        table.AddCell(cellI);
                    }
                }
                nitens++;
            }
            doc.Add(table);
        }
Exemple #24
0
        private void Parte3()
        {
            Tabela   table = new Tabela(11);
            PdfPCell cell;

            cell         = new CelulaCabecalho(Frase("Total", 10));
            cell.Colspan = 7;
            table.AddCell(cell);

            cell                     = new CelulaCabecalho(Frase(total_pedido.ToString("#,###,##0.00"), 10));
            cell.Colspan             = 1;
            cell.HorizontalAlignment = Element.ALIGN_RIGHT;
            table.AddCell(cell);

            cell                     = new CelulaCabecalho(Frase(total_valor.ToString("#,###,##0.00"), 10));
            cell.Colspan             = 1;
            cell.HorizontalAlignment = Element.ALIGN_RIGHT;
            table.AddCell(cell);

            float media = (percentual_comissao / nitens);

            cell                     = new CelulaCabecalho(Frase(media.ToString("#0.00"), 10));
            cell.Colspan             = 1;
            cell.HorizontalAlignment = Element.ALIGN_RIGHT;
            table.AddCell(cell);

            cell                     = new CelulaCabecalho(Frase(total_comissao.ToString("#,###,##0.00"), 10));
            cell.Colspan             = 1;
            cell.HorizontalAlignment = Element.ALIGN_RIGHT;
            table.AddCell(cell);

            cell         = new CelulaCabecalho(Frase("", 10));
            cell.Colspan = 9;
            table.AddCell(cell);

            cell                     = new CelulaCabecalho(Frase("Pago", 10));
            cell.Colspan             = 1;
            cell.HorizontalAlignment = Element.ALIGN_RIGHT;
            table.AddCell(cell);

            cell                     = new CelulaCabecalho(Frase(total_pago.ToString("#,###,##0.00"), 10));
            cell.Colspan             = 1;
            cell.HorizontalAlignment = Element.ALIGN_RIGHT;
            table.AddCell(cell);
            //
            cell         = new CelulaCabecalho(Frase("", 10));
            cell.Colspan = 9;
            table.AddCell(cell);

            cell                     = new CelulaCabecalho(Frase("Pagar", 10));
            cell.Colspan             = 1;
            cell.HorizontalAlignment = Element.ALIGN_RIGHT;
            table.AddCell(cell);

            cell                     = new CelulaCabecalho(Frase(total_pagar.ToString("#,###,##0.00"), 10));
            cell.Colspan             = 1;
            cell.HorizontalAlignment = Element.ALIGN_RIGHT;
            table.AddCell(cell);

            doc.Add(table);
        }
Exemple #25
0
        public PedidoConsolidado2(string arquivo, string filtro_pedidos, bool por_item, bool por_pedido, bool por_cliente, bool por_fabrica, bool mostrar_valores, bool mostrar_subcodigo, string observacao_fabrica, List <string> pedidosDestacarIpi)
        {
            #region seleciona pedidos
            ArrayList pedidos = new ArrayList();
            string    sql     =
                "select " +
                "p.COD_FORNECEDOR,p.DAT_ORCAMENTO,p.COD_ORCAMENTO,p.COD_PEDIDO,p.NRO_PEDIDO,p.OBSERVACAO,p.VLR_PEDIDO," +
                "o.COD_CLIENTE,o.COD_CARACTERISTICA,o.COD_VENDEDOR,o.VLR_DESCONTO,c.NOM_PARCEIRO, " +
                "f.DES_FORMULA,f.DES_FORMULA_PEDIDO, " +
                "(select 1 from PEDIDOS p2 where p2.COD_FORNECEDOR=p.COD_FORNECEDOR and p2.DAT_ORCAMENTO=p.DAT_ORCAMENTO and p2.COD_ORCAMENTO=p.COD_ORCAMENTO and p2.COD_PEDIDO=2), " +
                "p.VLR_INICIAL " +
                "from PEDIDOS p " +
                "inner join ORCAMENTOS o on o.COD_FORNECEDOR=p.COD_FORNECEDOR and o.DAT_ORCAMENTO=p.DAT_ORCAMENTO and o.COD_ORCAMENTO=p.COD_ORCAMENTO " +
                "inner join PARCEIROS c on c.COD_PARCEIRO=o.COD_CLIENTE " +
                "inner join CARACTERISTICAS f on f.COD_FORNECEDOR=o.COD_FORNECEDOR and f.COD_CARACTERISTICA=o.COD_CARACTERISTICA " +
                "where " + filtro_pedidos + " " +
                "order by p.COD_FORNECEDOR,p.DAT_ORCAMENTO,p.COD_ORCAMENTO,p.COD_PEDIDO";
            //StreamWriter sw = new StreamWriter(new FileStream("c:\\softplace\\softplace.log", FileMode.Create));
            //sw.WriteLine(sql);
            //sw.Close();

            FbCommand    cmd    = new FbCommand(sql, Globais.bd);
            FbDataReader reader = cmd.ExecuteReader(CommandBehavior.Default);
            if (!por_fabrica)
            {
                por_cliente = true;
            }
            string ultimo_cliente = "";
            while (reader.Read())
            {
                DadosPedido dados = new DadosPedido();
                dados.COD_FORNECEDOR = reader.GetString(0).Trim();
                dados.DAT_ORCAMENTO  = reader.GetDateTime(1);
                dados.COD_ORCAMENTO  = reader.GetInt16(2);
                dados.COD_PEDIDO     = reader.GetInt16(3);
                dados.NRO_PEDIDO     = !reader.IsDBNull(4) ? reader.GetInt16(4) : (short)0;
                //MessageBox.Show("Pedido:" + dados.NRO_PEDIDO.ToString());
                dados.OBSERVACAO         = !reader.IsDBNull(5) ? reader.GetString(5).Trim() : "";
                dados.VLR_PEDIDO         = !reader.IsDBNull(6) ? reader.GetFloat(6) : 0f;
                dados.VLR_INICIAL        = !reader.IsDBNull(15) ? reader.GetFloat(15) : 0f;
                dados.COD_CLIENTE        = !reader.IsDBNull(7) ? reader.GetString(7).Trim() : "";
                dados.COD_CARACTERISTICA = !reader.IsDBNull(8) ? reader.GetString(8).Trim() : "";
                dados.COD_VENDEDOR       = !reader.IsDBNull(9) ? reader.GetString(9).Trim() : "";
                dados.VLR_DESCONTO       = !reader.IsDBNull(10) ? reader.GetFloat(10) : 0f;
                dados.NOM_PARCEIRO       = !reader.IsDBNull(11) ? reader.GetString(11).Trim() : "";
                dados.DES_FORMULA        = !reader.IsDBNull(12) ? reader.GetString(12).Trim() : "";
                dados.DES_FORMULA_PEDIDO = !reader.IsDBNull(13) ? reader.GetString(13).Trim() : "";
                if (dados.DES_FORMULA_PEDIDO.Length == 0)
                {
                    dados.DES_FORMULA_PEDIDO = dados.DES_FORMULA;
                }
                if (!dados.COD_CLIENTE.Equals(ultimo_cliente))
                {
                    if (!ultimo_cliente.Equals(""))
                    {
                        por_cliente = false;
                    }
                    ultimo_cliente = dados.COD_CLIENTE;
                }
                if (dados.COD_PEDIDO == 1)
                {
                    if (!reader.IsDBNull(14))
                    {
                        dados.VLR_DESCONTO = 0;
                    }
                    dados.CarregaItens();
                }
                else
                {
                    DadosItem item = new DadosItem();
                    item.QTD_ITEM    = 1;
                    item.VLR_PRECO   = dados.VLR_PEDIDO;
                    item.COD_PRODUTO = "Serviço";
                    item.SUB_CODIGO  = "-";
                    item.DES_PRODUTO = dados.OBSERVACAO;
                    dados.itens      = new ArrayList();
                    dados.itens.Add(item);
                }
                pedidos.Add(dados);
            }
            reader.Close();
            if (pedidos.Count == 0)
            {
                return;
            }
            #endregion

            #region ordena os itens
            SortedList pedidos_ord = new SortedList();
            string     chave       = "";
            // #   fabrica  pedido   item
            // 0   0        0        0
            // 1   0        0        1
            // 2   0        1        0
            // 3   0        1        1
            // 4   1        0        0
            // 5   1        0        1
            // 6   1        1        0
            // 7   1        1        1
            string   zera_desconto_fornecedor = "";
            DateTime zera_desconto_data       = DateTime.Now;
            short    zera_desconto_orcamento  = 0;
            foreach (DadosPedido pedido in pedidos)
            {
                int i = 0;
                if (pedido.itens != null)
                {
                    foreach (DadosItem item in pedido.itens)
                    {
                        i++;
                        #region seta chave
                        if (por_fabrica)                 // 4 5 6 7
                        {
                            if (por_pedido)              // 6 7
                            {
                                if (por_item)            // 7
                                {
                                    // fabrica + pedido + item
                                    chave = pedido.COD_FORNECEDOR + pedido.DAT_ORCAMENTO.ToString("yyyy/MM/dd") + pedido.COD_ORCAMENTO.ToString("00000") + pedido.COD_PEDIDO.ToString("0") +
                                            item.COD_PRODUTO + item.SUB_CODIGO + item.COD_ESPECIFICOS +
                                            item.SEQ_ITEM;
                                }
                                else                         // 6
                                {
                                    // fabrica + pedido
                                    chave = pedido.COD_FORNECEDOR + pedido.DAT_ORCAMENTO.ToString("yyyy/MM/dd") + pedido.COD_ORCAMENTO.ToString("00000") + pedido.COD_PEDIDO.ToString("0") +
                                            item.SEQ_ITEM;
                                }
                            }
                            else                     // 4 5
                            {
                                if (por_item)        // 5
                                {
                                    // fabrica + item
                                    chave = pedido.COD_FORNECEDOR +
                                            item.COD_PRODUTO + item.SUB_CODIGO + item.COD_ESPECIFICOS +
                                            pedido.COD_FORNECEDOR + pedido.DAT_ORCAMENTO.ToString("yyyy/MM/dd") + pedido.COD_ORCAMENTO.ToString("00000") + pedido.COD_PEDIDO.ToString("0") + item.SEQ_ITEM;
                                }
                                else                         // 4
                                {
                                    // fabrica = fabrica + pedido
                                    chave = pedido.COD_FORNECEDOR + pedido.DAT_ORCAMENTO.ToString("yyyy/MM/dd") + pedido.COD_ORCAMENTO.ToString("00000") + pedido.COD_PEDIDO.ToString("0") +
                                            item.SEQ_ITEM;
                                }
                            }
                        }
                        else                  // 0 1 2 3
                        {
                            if (por_pedido)   // 2 3
                            {
                                if (por_item) // 3
                                {
                                    // pedido + item = fabrica + pedido + item
                                    chave = pedido.COD_FORNECEDOR + pedido.DAT_ORCAMENTO.ToString("yyyy/MM/dd") + pedido.COD_ORCAMENTO.ToString("00000") + pedido.COD_PEDIDO.ToString("0") +
                                            item.COD_PRODUTO + item.SUB_CODIGO + item.COD_ESPECIFICOS +
                                            item.SEQ_ITEM;
                                }
                                else                         // 2
                                {
                                    // pedido = fabrica + pedido
                                    chave = pedido.COD_FORNECEDOR + pedido.DAT_ORCAMENTO.ToString("yyyy/MM/dd") + pedido.COD_ORCAMENTO.ToString("00000") + pedido.COD_PEDIDO.ToString("0") +
                                            item.SEQ_ITEM;
                                }
                            }
                            else                     // 0 1
                            {
                                if (por_item)        // 1
                                {
                                    // por item
                                    chave = item.COD_PRODUTO + item.SUB_CODIGO + item.COD_ESPECIFICOS +
                                            pedido.COD_FORNECEDOR + pedido.DAT_ORCAMENTO.ToString("yyyy/MM/dd") + pedido.COD_ORCAMENTO.ToString("00000") + pedido.COD_PEDIDO.ToString("0") + item.SEQ_ITEM;
                                }
                                else                         // 0
                                {
                                    // nada = pedido
                                    chave = pedido.COD_FORNECEDOR + pedido.DAT_ORCAMENTO.ToString("yyyy/MM/dd") + pedido.COD_ORCAMENTO.ToString("00000") + pedido.COD_PEDIDO.ToString("0") +
                                            item.SEQ_ITEM;
                                }
                            }
                        }
                        #endregion

                        item.COD_FORNECEDOR     = pedido.COD_FORNECEDOR;
                        item.DAT_ORCAMENTO      = pedido.DAT_ORCAMENTO;
                        item.COD_ORCAMENTO      = pedido.COD_ORCAMENTO;
                        item.COD_PEDIDO         = pedido.COD_PEDIDO;
                        item.NRO_PEDIDO         = pedido.NRO_PEDIDO;
                        item.OBSERVACAO         = pedido.OBSERVACAO;
                        item.VLR_PEDIDO         = pedido.VLR_PEDIDO;
                        item.COD_CLIENTE        = pedido.COD_CLIENTE;
                        item.COD_CARACTERISTICA = pedido.COD_CARACTERISTICA;
                        item.COD_VENDEDOR       = pedido.COD_VENDEDOR;

                        // o desconto será feito no primeiro item do pedido
                        // alterado em 19/06/11
                        // o consolidado estava ficando errado quando o valor do pedido era alterado
                        if (pedido.COD_FORNECEDOR.Equals(zera_desconto_fornecedor) &&
                            (pedido.DAT_ORCAMENTO == zera_desconto_data) &&
                            (pedido.COD_ORCAMENTO == zera_desconto_orcamento))
                        {
                            // o desconto já foi feito no outro pedido desse orçamento
                            pedido.VLR_DESCONTO = 0;
                            pedido.VLR_INICIAL  = pedido.VLR_PEDIDO;                    // evita duplicação do desconto nos próximos itens
                        }
                        bool deuDesconto = false;
                        if (pedido.VLR_PEDIDO < pedido.VLR_INICIAL)
                        {
                            item.VLR_DESCONTO = pedido.VLR_INICIAL - pedido.VLR_PEDIDO;
                        }
                        else
                        if (pedido.VLR_PEDIDO > pedido.VLR_INICIAL)
                        {
                            item.VLR_DESCONTO = pedido.VLR_PEDIDO - pedido.VLR_INICIAL;
                        }
                        else
                        {
                            item.VLR_DESCONTO = pedido.VLR_DESCONTO;
                            deuDesconto       = true;
                        }
                        if ((item.VLR_DESCONTO > -0.2) && (item.VLR_DESCONTO < 0.2))
                        {
                            item.VLR_DESCONTO = 0;
                            deuDesconto       = false;
                        }
                        pedido.VLR_DESCONTO = 0;
                        pedido.VLR_INICIAL  = pedido.VLR_PEDIDO;                // evita duplicação do desconto nos próximos itens
                        if (deuDesconto)
                        {
                            zera_desconto_fornecedor = pedido.COD_FORNECEDOR;
                            zera_desconto_data       = pedido.DAT_ORCAMENTO;
                            zera_desconto_orcamento  = pedido.COD_ORCAMENTO;
                        }

                        item.NOM_PARCEIRO       = pedido.NOM_PARCEIRO;
                        item.DES_FORMULA        = pedido.DES_FORMULA;
                        item.DES_FORMULA_PEDIDO = pedido.DES_FORMULA_PEDIDO;
                        pedidos_ord.Add(chave, item);
                        //MessageBox.Show(chave);
                    }
                }
            }
            #endregion

            FileStream fs;
            try
            {
                fs     = new FileStream(arquivo, FileMode.Create);
                doc    = new Document(PageSize.LETTER.Rotate());
                writer = PdfWriter.GetInstance(doc, fs);
                doc.Open();
                CabecalhoRelatorio();

                Tabela    table;              //= new Tabela(mostrar_valores ? 24 : 12);
                string    ultimo_fornecedor = "";
                string    ultimo_pedido     = "";
                DadosItem item0             = (DadosItem)pedidos_ord.GetByIndex(0);
                CabecalhoCliente(item0.COD_FORNECEDOR, item0.DAT_ORCAMENTO, item0.COD_ORCAMENTO, !por_cliente);
                if (por_fabrica)
                {
                    CabecalhoFornecedor(item0.COD_FORNECEDOR);
                }
                if (por_pedido)
                {
                    CabecalhoPedido(item0.COD_FORNECEDOR, item0.DAT_ORCAMENTO, item0.COD_ORCAMENTO, item0.NRO_PEDIDO, item0.COD_VENDEDOR, item0.OBSERVACAO);
                }
                int itens_tabela = 0;
                //doc.Add(table);

                table = new Tabela(mostrar_valores ? 24 : 12);
                CabecalhoTabela(table, mostrar_valores);
                float total    = 0;
                float desconto = 0;
                for (int i = 0; i < pedidos_ord.Count; i++)
                {
                    DadosItem item = (DadosItem)pedidos_ord.GetByIndex(i);
                    if (item.QTD_ITEM == 0)                     // item agrupado
                    {
                        continue;
                    }

                    string chave_fornecedor = item.COD_FORNECEDOR;
                    string chave_pedido     = item.DAT_ORCAMENTO.ToString("yyyy/MM/dd") + item.COD_ORCAMENTO.ToString("00000");

                    string chaveDestacar = item.COD_FORNECEDOR.Trim() + ":" + item.DAT_ORCAMENTO.ToString("M/d/yyyy") + ":" + item.COD_ORCAMENTO.ToString() + ":" + item.COD_PEDIDO.ToString();
                    bool   destacar      = false;
                    foreach (string aux in pedidosDestacarIpi)
                    {
                        if (aux.Equals(chaveDestacar))
                        {
                            destacar = true;
                            break;
                        }
                    }
                    if (!destacar)
                    {
                        if (item.PER_IPI > 0)
                        {
                            item.VLR_PRECO += (item.PER_IPI * item.VLR_PRECO / 100);
                        }
                        item.PER_IPI = 0;
                    }

                    #region agrupa por item
                    if (por_item)
                    {
                        string chave_item = item.COD_PRODUTO + item.SUB_CODIGO + item.COD_ESPECIFICOS + item.VLR_PRECO.ToString();
                        for (int j = i + 1; j < pedidos_ord.Count; j++)
                        {
                            DadosItem proximo       = (DadosItem)pedidos_ord.GetByIndex(j);
                            string    chave_proximo = proximo.COD_PRODUTO + proximo.SUB_CODIGO + proximo.COD_ESPECIFICOS + proximo.VLR_PRECO.ToString();
                            if (chave_item.Equals(chave_proximo))
                            {
                                item.QTD_ITEM   += proximo.QTD_ITEM;
                                proximo.QTD_ITEM = 0;
                            }
                        }
                    }
                    #endregion

                    bool quebrou_pedido = false;
                    if (ultimo_fornecedor != chave_fornecedor)
                    {
                        if (por_fabrica)
                        {
                            if (itens_tabela > 0)
                            {
                                if (mostrar_valores)
                                {
                                    Totais(table, total, desconto, por_fabrica);
                                }
                                total    = 0;
                                desconto = 0;
                                doc.Add(table);
                                RodapeFornecedor(observacao_fabrica);
                                doc.NewPage();
                                table = new Tabela(mostrar_valores ? 24 : 12);
                                CabecalhoRelatorio();
                                CabecalhoFornecedor(item.COD_FORNECEDOR);
                                if (por_pedido)
                                {
                                    if (ultimo_pedido != chave_pedido)
                                    {
                                        quebrou_pedido = true;
                                        CabecalhoPedido(item.COD_FORNECEDOR, item.DAT_ORCAMENTO, item.COD_ORCAMENTO, item.NRO_PEDIDO, item.COD_VENDEDOR, item.OBSERVACAO);
                                        ultimo_pedido = chave_pedido;
                                    }
                                }
                                itens_tabela = 0;
                                CabecalhoTabela(table, mostrar_valores);
                            }
                        }

                        ultimo_fornecedor = chave_fornecedor;
                    }
                    if (!quebrou_pedido && por_pedido && (ultimo_pedido != chave_pedido))
                    {
                        if (itens_tabela > 0)
                        {
                            if (mostrar_valores)
                            {
                                Totais(table, total, desconto, por_fabrica);
                            }
                            total    = 0;
                            desconto = 0;
                            doc.Add(table);
                            table = new Tabela(mostrar_valores ? 24 : 12);
                            CabecalhoPedido(item.COD_FORNECEDOR, item.DAT_ORCAMENTO, item.COD_ORCAMENTO, item.NRO_PEDIDO, item.COD_VENDEDOR, item.OBSERVACAO);
                            itens_tabela = 0;
                            CabecalhoTabela(table, mostrar_valores);
                        }

                        ultimo_pedido = chave_pedido;
                    }

                    desconto += item.VLR_DESCONTO;

                    if (mostrar_subcodigo)
                    {
                        table.AddCell(CelulaGrid(item.COD_PRODUTO + "-" + item.SUB_CODIGO, mostrar_valores ? 4 : 2, false, false));
                    }
                    else
                    {
                        table.AddCell(CelulaGrid(item.COD_PRODUTO, mostrar_valores ? 4 : 2, false, false));
                    }
                    table.AddCell(CelulaGrid(item.DES_PRODUTO, mostrar_valores ? 6 : 5, false, false));
                    table.AddCell(CelulaGrid(item.COD_ESPECIFICOS, mostrar_valores ? 4 : 3, false, false));
                    table.AddCell(CelulaGrid(item.QTD_ITEM.ToString(), 2, false, false));

                    float per_frete = cCaracteristicas.Frete(item.COD_FORNECEDOR, item.COD_CARACTERISTICA);
                    if (mostrar_valores)
                    {
                        float ipi    = item.PER_IPI;
                        float preco  = item.VLR_PRECO;
                        float semipi = item.VLR_PRECO;
                        if (item.COD_PEDIDO == 1)
                        {
                            if (!item.IDT_ESPECIAL.Equals("S"))
                            {
                                Globais.CalculaFormula(ref preco, item.DES_FORMULA_PEDIDO, ipi, per_frete, 0);
                                Globais.CalculaFormula(ref semipi, item.DES_FORMULA_PEDIDO, 0, per_frete, 0);
                            }
                            else
                            {
                                // desfaz formula
                                Globais.DesfazFormula(ref preco, item.DES_FORMULA, ipi, per_frete, 0);
                                Globais.DesfazFormula(ref semipi, item.DES_FORMULA, ipi, per_frete, 0);
                                // refaz parte do pedido
                                Globais.CalculaFormula(ref preco, item.DES_FORMULA_PEDIDO, ipi, per_frete, 0);
                                Globais.CalculaFormula(ref semipi, item.DES_FORMULA_PEDIDO, 0, per_frete, 0);
                            }
                        }
                        else
                        {
                            ipi = 0;
                        }
                        total += preco * item.QTD_ITEM;

                        table.AddCell(CelulaGrid(semipi.ToString("###,###,##0.00"), 2, false, true));
                        table.AddCell(CelulaGrid((semipi * item.QTD_ITEM).ToString("###,###,##0.00"), 2, false, true));
                        table.AddCell(CelulaGrid(ipi.ToString("#0.00") + "%", 2, false, true));
                        table.AddCell(CelulaGrid((preco * item.QTD_ITEM).ToString("###,###,##0.00"), 2, false, true));
                    }

                    itens_tabela++;
                }
                if (itens_tabela > 0)
                {
                    if (mostrar_valores)
                    {
                        Totais(table, total, desconto, por_fabrica);
                    }
                    total    = 0;
                    desconto = 0;
                    doc.Add(table);
                    if (por_fabrica)
                    {
                        RodapeFornecedor(observacao_fabrica);
                    }
                }
                doc.Close();
                fs.Close();
            }
            catch (Exception e)
            {
                Log.Grava(Globais.sUsuario, "erro:" + e.Message);
                MessageBox.Show("Erro na geração do relatório\r\n" + e.Message);
                return;
            }
        }
Exemple #26
0
        private void CabecalhoCliente(string COD_FORNECEDOR, DateTime DAT_ORCAMENTO, short COD_ORCAMENTO, bool servico)
        {
            cPedidos   pedido     = new cPedidos();
            cPedidoPDF pedido_pdf = new cPedidoPDF();

            pedido_pdf.cab2 = pedido.DadosCabecalho2(COD_FORNECEDOR, DAT_ORCAMENTO, COD_ORCAMENTO, servico);

            Tabela table = new Tabela(6);

            table.AddCell(Celula2("Cliente", 1, true));
            table.AddCell(Celula2(pedido_pdf.cab2.cliente, 3, false));
            table.AddCell(Celula2("CPF/CNPJ", 1, true));
            table.AddCell(Celula2(pedido_pdf.cab2.cnpj, 1, false));

            table.AddCell(Celula2("Endereço", 1, true));
            table.AddCell(Celula2(pedido_pdf.cab2.endereco.Trim() + " " +
                                  pedido_pdf.cab2.numero.Trim() + " - " +
                                  pedido_pdf.cab2.compl.Trim() + "\r\n" +
                                  pedido_pdf.cab2.bairro.Trim() + " - " +
                                  pedido_pdf.cab2.cidade.Trim() + " - " +
                                  pedido_pdf.cab2.estado.Trim() + " - " +
                                  "CEP " + CEP.PoeEdicao(pedido_pdf.cab2.cep), 3, false));
            table.AddCell(Celula2("IE", 1, true));
            table.AddCell(Celula2(pedido_pdf.cab2.ie, 1, false));

            table.AddCell(Celula2("Local Entrega", 1, true));
            if (pedido_pdf.cab2.entrega.Trim().Length > 0)
            {
                table.AddCell(Celula2(pedido_pdf.cab2.entrega.Trim() + " " +
                                      pedido_pdf.cab2.numero_entrega.Trim() + " - " +
                                      pedido_pdf.cab2.compl_entrega.Trim() + "\r\n" +
                                      pedido_pdf.cab2.bairro_entrega.Trim() + " - " +
                                      pedido_pdf.cab2.cidade_entrega.Trim() + " - " +
                                      pedido_pdf.cab2.estado_entrega.Trim() + " - " +
                                      "CEP " + CEP.PoeEdicao(pedido_pdf.cab2.cep), 3, false));
            }
            else
            {
                table.AddCell(Celula2(pedido_pdf.cab2.endereco.Trim() + " " +
                                      pedido_pdf.cab2.numero.Trim() + " - " +
                                      pedido_pdf.cab2.compl.Trim() + "\r\n" +
                                      pedido_pdf.cab2.bairro.Trim() + " - " +
                                      pedido_pdf.cab2.cidade.Trim() + " - " +
                                      pedido_pdf.cab2.estado.Trim() + " - " +
                                      "CEP " + CEP.PoeEdicao(pedido_pdf.cab2.cep), 3, false));
            }
            table.AddCell(Celula2("IM", 1, true));
            table.AddCell(Celula2(pedido_pdf.cab2.im, 1, false));

            table.AddCell(Celula2("Contato", 1, true));
            table.AddCell(Celula2(pedido_pdf.cab2.contato, 1, false));

            table.AddCell(Celula2("Fone", 1, true));
            string fones = FONES.Concatena(pedido_pdf.cab2.fone, pedido_pdf.cab2.fone2, pedido_pdf.cab2.celular, pedido_pdf.cab2.fone1_parceiro, pedido_pdf.cab2.fone2_parceiro, pedido_pdf.cab2.celular_parceiro);

            table.AddCell(Celula2(fones, 1, false));

            table.AddCell(Celula2("email", 1, true));
            table.AddCell(Celula2(pedido_pdf.cab2.email, 1, false));
            doc.Add(table);
        }