コード例 #1
0
ファイル: DanfeHeader.cs プロジェクト: spltechnology/spldanfe
 private static decimal GetPesoLiquido(TNFeInfNFeTransp transp)
 {
     var total = (from x in transp.vol where x.pesoL != null select x.pesoL.Replace('.', ',').ToDecimal()).Sum();
     return total;
 }
コード例 #2
0
ファイル: DanfeHeader.cs プロジェクト: spltechnology/spldanfe
        private static void PrintTransportadora(PdfPTable pdfTable, TNFeInfNFeTransp transp)
        {
            pdfTable.AddCell(
                new BuilderCell("", 5).Create("TRANSPORTADOR/VOLUMES TRANSPORTADOS")
                    .Bold()
                    .HorizontalLeft()
                    .VerticalBottom()
                    .Colspan(19)
                    .NoBorder()
                    .BorderBuilder(false, false, false, true)
                    .Standard());

            pdfTable.AddCell(
                new BuilderCell("", 5).Create("NOME/RAZÃO SOCIAL")
                    .HorizontalLeft()
                    .VerticalTop()
                    .Colspan(5)
                    .BorderBuilder(true, true, false, true)
                    .Standard());
            pdfTable.AddCell(
                new BuilderCell("", 5).Create("FRETE POR CONTA")
                    .HorizontalLeft()
                    .VerticalTop()
                    .Colspan(3)
                    .BorderBuilder(true, true, false, true)
                    .Standard());
            pdfTable.AddCell(
                new BuilderCell("", 5).Create("CÓDIGO ANTT")
                    .HorizontalLeft()
                    .VerticalTop()
                    .Colspan(3)
                    .BorderBuilder(true, true, false, true)
                    .Standard());
            pdfTable.AddCell(
                new BuilderCell("", 5).Create("PLACA DO VEÍCULO")
                    .HorizontalLeft()
                    .VerticalTop()
                    .Colspan(3)
                    .BorderBuilder(true, true, false, true)
                    .Standard());
            pdfTable.AddCell(
                new BuilderCell("", 5).Create("UF")
                    .HorizontalLeft()
                    .VerticalTop()
                    .Colspan(1)
                    .BorderBuilder(true, true, false, true)
                    .Standard());
            pdfTable.AddCell(
                new BuilderCell("", 5).Create("CNPJ/CPF")
                    .HorizontalLeft()
                    .VerticalTop()
                    .Colspan(4)
                    .BorderBuilder(true, true, false, true)
                    .Standard());

            string freteDesc = "Sem frete";
            if (transp.modFrete.Equals("0"))
                freteDesc = "(0) Emitente";
            else if (transp.modFrete.Equals("1"))
                freteDesc = "(1) Destinatário";
            else if (transp.modFrete.Equals("2"))
                freteDesc = "(2) Terceiros";

            string ufEmpresa;

            var emptyTranspotadora = new TNFeInfNFeTranspTransporta
            {
                Item = string.Empty,
                xEnder = string.Empty,
            };

            if (transp.transporta == null)
            {
                transp.transporta = emptyTranspotadora;
                ufEmpresa = string.Empty;
            }
            else
            {
                ufEmpresa = transp.transporta.UF.ToString();
            }

            pdfTable.AddCell(
                new BuilderCell("", 9).Create(transp.transporta.xNome)
                    .VerticalCenter()
                    .HorizontalLeft()
                    .Bold()
                    .Colspan(5)
                    .NoBorder()
                    .BorderBuilder(true, true, false, false)
                    .Standard());
            pdfTable.AddCell(
                new BuilderCell("", 9).Create(freteDesc)
                    .VerticalCenter()
                    .HorizontalCenter()
                    .Bold()
                    .Colspan(3)
                    .NoBorder()
                    .BorderBuilder(true, true, false, false)
                    .Standard());
            pdfTable.AddCell(
                new BuilderCell("", 9).Create("")
                    .VerticalCenter()
                    .HorizontalCenter()
                    .Bold()
                    .Colspan(3)
                    .NoBorder()
                    .BorderBuilder(true, true, false, false)
                    .Standard());
            pdfTable.AddCell(
                new BuilderCell("", 9).Create("")
                    .VerticalCenter()
                    .HorizontalCenter()
                    .Bold()
                    .Colspan(3)
                    .NoBorder()
                    .BorderBuilder(true, true, false, false)
                    .Standard());
            pdfTable.AddCell(
                new BuilderCell("", 9).Create("")
                    .VerticalCenter()
                    .HorizontalCenter()
                    .Bold()
                    .Colspan(1)
                    .NoBorder()
                    .BorderBuilder(true, true, false, false)
                    .Standard());
            pdfTable.AddCell(
                new BuilderCell("", 9).Create(CustomMasks.MaskCpfCnpj(transp.transporta.Item))
                    .VerticalCenter()
                    .HorizontalCenter()
                    .Bold()
                    .Colspan(4)
                    .NoBorder()
                    .BorderBuilder(true, true, false, false)
                    .Standard());

            pdfTable.AddCell(
                new BuilderCell("", 5).Create("ENDEREÇO")
                    .HorizontalLeft()
                    .VerticalTop()
                    .Colspan(8)
                    .BorderBuilder(true, true, false, true)
                    .Standard());
            pdfTable.AddCell(
                new BuilderCell("", 5).Create("MUNICÍPIO")
                    .HorizontalLeft()
                    .VerticalTop()
                    .Colspan(6)
                    .BorderBuilder(true, true, false, true)
                    .Standard());
            pdfTable.AddCell(
                new BuilderCell("", 5).Create("UF")
                    .HorizontalLeft()
                    .VerticalTop()
                    .Colspan(1)
                    .BorderBuilder(true, true, false, true)
                    .Standard());
            pdfTable.AddCell(
                new BuilderCell("", 5).Create("INSCRIÇÃO ESTADUAL")
                    .HorizontalLeft()
                    .VerticalTop()
                    .Colspan(4)
                    .BorderBuilder(true, true, false, true)
                    .Standard());

            pdfTable.AddCell(
                new BuilderCell("", 9).Create(transp.transporta.xEnder)
                    .VerticalCenter()
                    .HorizontalLeft()
                    .Bold()
                    .Colspan(8)
                    .NoBorder()
                    .BorderBuilder(true, true, false, false)
                    .Standard());
            pdfTable.AddCell(
                new BuilderCell("", 9).Create(transp.transporta.xMun)
                    .VerticalCenter()
                    .HorizontalCenter()
                    .Bold()
                    .Colspan(6)
                    .NoBorder()
                    .BorderBuilder(true, true, false, false)
                    .Standard());
            pdfTable.AddCell(
                new BuilderCell("", 9).Create(ufEmpresa)
                    .VerticalCenter()
                    .HorizontalCenter()
                    .Bold()
                    .Colspan(1)
                    .NoBorder()
                    .BorderBuilder(true, true, false, false)
                    .Standard());
            pdfTable.AddCell(
                new BuilderCell("", 9).Create(transp.transporta.IE)
                    .VerticalCenter()
                    .HorizontalCenter()
                    .Bold()
                    .Colspan(4)
                    .NoBorder()
                    .BorderBuilder(true, true, false, false)
                    .Standard());

            pdfTable.AddCell(
                new BuilderCell("", 5).Create("QUANTIDADE")
                    .HorizontalLeft()
                    .VerticalTop()
                    .Colspan(2)
                    .BorderBuilder(true, true, false, true)
                    .Standard());
            pdfTable.AddCell(
                new BuilderCell("", 5).Create("ESPÉCIE")
                    .HorizontalLeft()
                    .VerticalTop()
                    .Colspan(3)
                    .BorderBuilder(true, true, false, true)
                    .Standard());
            pdfTable.AddCell(
                new BuilderCell("", 5).Create("MARCA")
                    .HorizontalLeft()
                    .VerticalTop()
                    .Colspan(3)
                    .BorderBuilder(true, true, false, true)
                    .Standard());
            pdfTable.AddCell(
                new BuilderCell("", 5).Create("NUMERAÇÃO")
                    .HorizontalLeft()
                    .VerticalTop()
                    .Colspan(3)
                    .BorderBuilder(true, true, false, true)
                    .Standard());
            pdfTable.AddCell(
                new BuilderCell("", 5).Create("PESO BRUTO")
                    .HorizontalLeft()
                    .VerticalTop()
                    .Colspan(4)
                    .BorderBuilder(true, true, false, true)
                    .Standard());
            pdfTable.AddCell(
                new BuilderCell("", 5).Create("PESO LÍQUIDO")
                    .HorizontalLeft()
                    .VerticalTop()
                    .Colspan(4)
                    .BorderBuilder(true, true, false, true)
                    .Standard());

            pdfTable.AddCell(
                new BuilderCell("", 9).Create(transp.vol.Count().ToString())
                    .VerticalCenter()
                    .HorizontalCenter()
                    .Bold()
                    .Colspan(2)
                    .NoBorder()
                    .BorderBuilder(true, true, false, false)
                    .Standard());
            pdfTable.AddCell(
                new BuilderCell("", 9).Create("")
                    .VerticalCenter()
                    .HorizontalCenter()
                    .Bold()
                    .Colspan(3)
                    .NoBorder()
                    .BorderBuilder(true, true, false, false)
                    .Standard());
            pdfTable.AddCell(
                new BuilderCell("", 9).Create("")
                    .VerticalCenter()
                    .HorizontalCenter()
                    .Bold()
                    .Colspan(3)
                    .NoBorder()
                    .BorderBuilder(true, true, false, false)
                    .Standard());
            pdfTable.AddCell(
                new BuilderCell("", 9).Create("")
                    .VerticalCenter()
                    .HorizontalRight()
                    .Bold()
                    .Colspan(3)
                    .NoBorder()
                    .BorderBuilder(true, true, false, false)
                    .Standard());

            var pesoBruto = GetPesoBruto(transp);
            var pesoLiquido = GetPesoLiquido(transp);
            pdfTable.AddCell(
                new BuilderCell("", 9).Create(pesoBruto)
                    .VerticalCenter()
                    .HorizontalRight()
                    .Bold()
                    .Colspan(4)
                    .NoBorder()
                    .BorderBuilder(true, true, false, false)
                    .Standard());
            pdfTable.AddCell(
                new BuilderCell("", 9).Create(pesoLiquido)
                    .VerticalCenter()
                    .HorizontalRight()
                    .Bold()
                    .Colspan(4)
                    .NoBorder()
                    .BorderBuilder(true, true, false, false)
                    .Standard());
        }