コード例 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            bool flagCarne = false;
            int quantidade = 1;

            string boletoCodigoDoBanco = "104";
            float boletoValor = 666;
            string boletoCarteira = "SR";
            string boletoNossoNumero = "24000000000000002";
            string boletoNumeroDoDocumento = "0000002";

            string dataDeVencimento = "30/10/2015";
            string dataDoDocumento = "05/10/2015";
            string dataDeProcessamento = "05/10/2015";

            string cedenteCpfCNPJ = "17.405.814/0001-09";
            string cedenteNome = "Daniel";
            string cedenteConta = "1234";
            string cedenteAgencia = "12345";
            string cedenteCodigo = "377306";

            string sacadoCpfCnpj = "123.123.123-00";
            string sacadoNome = "Nome do sacado";
            string sacadoEndereco = "rua do sacado";
            string sacadoBairro = "Catolé";
            string sacadoCidade = "Campina Grande";
            string sacadoCEP = "58100-000";
            string sacadoUF = "PB";

            string instrucao = "";

            BoletoDados boletoDados = new BoletoDados(flagCarne, quantidade, boletoCodigoDoBanco, boletoValor,
                boletoCarteira, boletoNossoNumero, boletoNumeroDoDocumento, dataDeVencimento, dataDoDocumento,
                dataDeProcessamento, cedenteCpfCNPJ, cedenteNome, cedenteConta, cedenteAgencia, cedenteCodigo,
                sacadoCpfCnpj, sacadoNome, sacadoEndereco, sacadoBairro, sacadoCidade, sacadoCEP, sacadoUF,
                instrucao);

            Panel1.Controls.Add(boletoDados.montaBoleto(boletoDados));
        }
コード例 #2
0
        public BoletoBancario montaBoleto(BoletoDados boletoDados)
        {
            BoletoBancario boletoBancario = new BoletoBancario();
            boletoBancario.CodigoBanco = short.Parse(boletoDados.boletoCodigoDoBanco);

            Cedente cedente = new Cedente(boletoDados.cedenteCpfCNPJ, boletoDados.cedenteNome,
                boletoDados.cedenteAgencia, boletoDados.cedenteConta);

            Boleto boleto = new Boleto(DateTime.Parse(boletoDados.dataDeVencimento),
                Convert.ToDecimal(boletoDados.boletoValor), boletoDados.boletoCarteira,
                boletoDados.boletoNossoNumero, cedente);

            boleto.NumeroDocumento = boletoDados.boletoNumeroDoDocumento;
            boleto.DataDocumento = DateTime.Parse(boletoDados.dataDoDocumento);
            boleto.DataProcessamento = DateTime.Parse(boletoDados.dataDeProcessamento);

            boleto.Sacado = new Sacado(boletoDados.sacadoCpfCnpj, boletoDados.sacadoNome);
            boleto.Sacado.Endereco.End = boletoDados.sacadoEndereco;
            boleto.Sacado.Endereco.Bairro = boletoDados.sacadoBairro;
            boleto.Sacado.Endereco.Cidade = boletoDados.sacadoCidade;
            boleto.Sacado.Endereco.CEP = boletoDados.sacadoCEP;
            boleto.Sacado.Endereco.UF = boletoDados.sacadoUF;

            boletoBancario.Boleto = boleto;
            boletoBancario.FormatoCarne = boletoDados.flagCarne;

            if (boletoBancario.CodigoBanco == (short)237) //Banco Bradesco
            {
                boletoBancario.MostrarContraApresentacaoNaDataVencimento = false;
                boletoBancario.MostrarCodigoCarteira = false;
                boletoBancario.MostrarComprovanteEntrega = true;
            }
            else
            {
                if(boletoBancario.CodigoBanco == (short)104) //Banco CAIXA
                {
                    EspecieDocumento_Caixa espDocCaixa = new EspecieDocumento_Caixa();
                    boleto.EspecieDocumento = new EspecieDocumento_Caixa(espDocCaixa.getCodigoEspecieByEnum(EnumEspecieDocumento_Caixa.DuplicataMercantil));
                    boletoBancario.MostrarComprovanteEntrega = true;
                }
                else
                {
                    if (boletoBancario.CodigoBanco == (short)033) //Banco SANTANDER
                    {
                        //Espécie Documento - [R] Recibo
                        boleto.EspecieDocumento = new EspecieDocumento_Santander("17");

                        boletoBancario.MostrarCodigoCarteira = true;
                        boletoBancario.MostrarComprovanteEntrega = true;
                    }
                    else
                    {
                        //Banco SICOOB
                        boletoBancario.MostrarCodigoCarteira = false;
                        boletoBancario.MostrarComprovanteEntrega = true;
                    }
                }
            }

            boletoBancario.Boleto.Valida();

            return boletoBancario;
        }