コード例 #1
0
        public MemoryStream Gerar(Int32 id)
        {
            EntregaRelatorio entrega = _da.Obter(id);

            Document     doc = new Document(PageSize.A4, 45, 45, 85, 50);
            MemoryStream str = new MemoryStream();

            PdfWriter wrt = PdfWriter.GetInstance(doc, str);

            wrt.SetEncryption(PdfWriter.STRENGTH128BITS, null, null, PdfWriter.AllowPrinting);

            wrt.PageEvent = CabecalhoRodapeFactory.Criar(entrega.ProtocoloSetorCriacao);

            doc.Open();

            PdfMetodosAuxiliares.PularLinha(doc);
            PdfMetodosAuxiliares.PularLinha(doc);

            PdfPTable tabela = PdfMetodosAuxiliares.CriarTabela();

            tabela.DefaultCell.HorizontalAlignment = Element.ALIGN_CENTER;
            tabela.DefaultCell.Border = 0;
            tabela.AddCell(new Phrase(new Chunk("Registro de Entrega de Título", PdfMetodosAuxiliares.arial16Negrito)));
            doc.Add(tabela);


            PdfMetodosAuxiliares.PularLinha(doc);
            PdfMetodosAuxiliares.PularLinha(doc);

            tabela = PdfMetodosAuxiliares.CriarTabela();
            tabela.DefaultCell.HorizontalAlignment = Element.ALIGN_LEFT;
            tabela.DefaultCell.Border = 0;

            Phrase frase = PdfMetodosAuxiliares.AddTexto("Nesta data foram retirados os seguintes títulos referentes ao ", PdfMetodosAuxiliares.arial10);

            frase.Add(new Chunk(entrega.ProtocoloTipo + " " + entrega.ProtocoloNumero + ":", PdfMetodosAuxiliares.arial10Negrito));
            tabela.AddCell(frase);

            doc.Add(tabela);

            tabela = PdfMetodosAuxiliares.CriarTabela(2, new float[] { 20, 80 });
            tabela.DefaultCell.HorizontalAlignment = Element.ALIGN_LEFT;

            PdfMetodosAuxiliares.AddCabecarioTabela(tabela, "Número");
            PdfMetodosAuxiliares.AddCabecarioTabela(tabela, "Modelo");

            foreach (var titulo in entrega.Titulos)
            {
                tabela.AddCell(PdfMetodosAuxiliares.AddTexto(titulo.Numero, PdfMetodosAuxiliares.arial10));
                tabela.AddCell(PdfMetodosAuxiliares.AddTexto(titulo.Modelo, PdfMetodosAuxiliares.arial10));
            }

            doc.Add(tabela);

            PdfMetodosAuxiliares.PularLinha(doc);
            PdfMetodosAuxiliares.PularLinha(doc);
            PdfMetodosAuxiliares.PularLinha(doc);

            tabela = PdfMetodosAuxiliares.CriarTabela();
            tabela.DefaultCell.Border = 0;

            tabela.AddCell(PdfMetodosAuxiliares.AddTexto(PdfMetodosAuxiliares.AssinaturaCampo, PdfMetodosAuxiliares.arial10));
            tabela.AddCell(PdfMetodosAuxiliares.AddTexto("Nome: " + entrega.Nome, PdfMetodosAuxiliares.arial10));
            tabela.AddCell(PdfMetodosAuxiliares.AddTexto("CPF: " + entrega.CPF, PdfMetodosAuxiliares.arial10));

            doc.Add(tabela);

            PdfMetodosAuxiliares.PularLinha(doc);
            PdfMetodosAuxiliares.PularLinha(doc);
            PdfMetodosAuxiliares.PularLinha(doc);

            tabela = PdfMetodosAuxiliares.CriarTabela();
            tabela.DefaultCell.HorizontalAlignment = Element.ALIGN_RIGHT;
            tabela.DefaultCell.Border = 0;

            tabela.AddCell(PdfMetodosAuxiliares.AdicionarLocalDataEmissao(entrega.LocalEntrega, entrega.DataEntrega));

            doc.Add(tabela);

            doc.Close();
            doc.Dispose();

            return(str);
        }
コード例 #2
0
        internal EntregaRelatorio Obter(int id, BancoDeDados banco = null)
        {
            EntregaRelatorio entrega = new EntregaRelatorio();

            using (BancoDeDados bancoDeDados = BancoDeDados.ObterInstancia(banco))
            {
                #region Entrega de Título

                Comando comando = bancoDeDados.CriarComando(@"select e.id, lp.texto protocolo_tipo, p.id protocolo_id, 
				p.setor_criacao, p.numero||'/'||p.ano protocolo_numero, nvl(pe.nome, e.nome) nome, nvl(pe.cpf,e.cpf) cpf, e.data_entrega, e.tid, (select lm.texto||' - '||le.sigla 
				from {0}tab_setor_endereco t, {0}lov_municipio lm, {0}lov_estado le where t.municipio = lm.id and lm.estado = le.id  and t.setor = p.setor_criacao) local_entrega 
				from {0}tab_titulo_entrega e, {0}tab_pessoa pe, {0}tab_protocolo p, {0}lov_protocolo lp where e.pessoa = pe.id(+) and e.protocolo = p.id and p.protocolo = lp.id 
				and e.id = :id"                , EsquemaBanco);

                comando.AdicionarParametroEntrada("id", id, DbType.Int32);

                using (IDataReader reader = bancoDeDados.ExecutarReader(comando))
                {
                    if (reader.Read())
                    {
                        entrega.Nome                  = reader["nome"].ToString();
                        entrega.CPF                   = reader["cpf"].ToString();
                        entrega.DataEntrega           = Convert.ToDateTime(reader["data_entrega"]);
                        entrega.ProtocoloTipo         = reader["protocolo_tipo"].ToString();
                        entrega.ProtocoloNumero       = reader["protocolo_numero"].ToString();
                        entrega.ProtocoloSetorCriacao = Convert.ToInt32(reader["setor_criacao"]);
                        entrega.LocalEntrega          = reader["local_entrega"].ToString();
                    }

                    reader.Close();
                }

                #endregion

                #region Títulos

                comando = bancoDeDados.CriarComando(@"select tn.numero|| '/' ||tn.ano numero, m.nome modelo_nome from {0}tab_titulo_entrega_titulos te, {0}tab_titulo t, 
				{0}tab_titulo_numero tn, {0}tab_titulo_modelo m where t.modelo = m.id and te.titulo = t.id and t.id = tn.titulo and te.entrega = :entrega"                , EsquemaBanco);

                comando.AdicionarParametroEntrada("entrega", id, DbType.Int32);

                using (IDataReader reader = bancoDeDados.ExecutarReader(comando))
                {
                    TituloRelatorio titulo;

                    while (reader.Read())
                    {
                        titulo        = new TituloRelatorio();
                        titulo.Numero = reader["numero"].ToString();
                        titulo.Modelo = reader["modelo_nome"].ToString();
                        entrega.Titulos.Add(titulo);
                    }

                    reader.Close();
                }

                #endregion
            }

            return(entrega);
        }