Пример #1
0
        private void gerarBoletoBB()
        {
            BoletoBrasil bolBB = new BoletoBrasil();

            bolBB.Aceite         = false;
            bolBB.CedenteAgencia = "001";
            bolBB.CedenteConta   = "0012345-0";
            bolBB.CedenteContaDV = "99";
            bolBB.CedenteNome    = "Swap Informática";
            bolBB.Carteira       = 32;
            bolBB.Instrucao1     = "Pagar ainda hoje de preferência";

            bolBB.Sequencial      = 1;
            bolBB.Documento       = "112345";
            bolBB.DtDocumento     = Convert.ToDateTime(DateTime.Now);
            bolBB.DtEmissao       = Convert.ToDateTime(DateTime.Now);
            bolBB.DtProcessamento = Convert.ToDateTime(DateTime.Now);
            bolBB.DtVencimento    = Convert.ToDateTime(DateTime.Now);
            float fValor = 0f;

            float.TryParse(Request.QueryString["valor"].ToString(), out fValor);
            bolBB.Valor = fValor;



            bolBB.SacadoNome     = Request.QueryString["sacado"].ToString();
            bolBB.SacadoEndereco = Request.QueryString["endereco"].ToString();
            bolBB.SacadoCPF_CNPJ = Request.QueryString["cpf"].ToString();
            bolBB.SacadoCidade   = Request.QueryString["cidade"].ToString();
            bolBB.SacadoUF       = Request.QueryString["uf"].ToString();
            bolBB.SacadoBairro   = Request.QueryString["bairro"].ToString();
            bolBB.SacadoCEP      = Request.QueryString["cep"].ToString();
            ImprimeBoleto(bolBB);
        }
Пример #2
0
        private void DadosBoleto()
        {
            CodBarraBoleto = " ";
            LinhaDigBoleto = " ";
            NossoNumero    = " ";
            Filiais Filial = new Filiais();

            Filial.Controle = Controle;
            Filial.LerDados(IdFilial);
            if (Filial.IdFilial > 0)
            {
                Bancos Banco = new Bancos();
                Banco.Controle = Controle;
                Banco.LerDados(Filial.IdBanco);
                if (Banco.IdBanco > 0)
                {
                    Boleto bolBB = new BoletoBrasil();
                    bolBB.Aceite         = false;
                    bolBB.CedenteAgencia = Banco.NumAgencia;
                    bolBB.CedenteConta   = Banco.Conta;
                    bolBB.CedenteContaDV = Banco.DigConta.ToString();
                    bolBB.CedenteNome    = Filial.Filial;
                    bolBB.Contrato       = int.Parse(Filial.Convenio);
                    bolBB.Carteira       = 18;
                    bolBB.Sequencial     = IdLanc;
                    bolBB.DtVencimento   = Vencimento;
                    bolBB.Valor          = float.Parse(VlrOriginal.ToString());
                    string lNossoNumero, lLinhaDigitavel, lCodigoBarras;
                    bolBB.MontaCodigos(out lNossoNumero, out lLinhaDigitavel, out lCodigoBarras);
                    LinhaDigBoleto = lLinhaDigitavel;
                    CodBarraBoleto = lCodigoBarras;
                    NossoNumero    = lNossoNumero;
                    IdBanco        = Banco.IdBanco;
                }
            }
        }
Пример #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            FBloqueto connBloqueto = new FBloqueto();

            string strCB = connBloqueto.CodigoBarras();
            string strLD = connBloqueto.LinhaDigitavel(strCB);

            //string DataAtual = System.DateTime.Now.ToString("dd/MM/yyyy");

            string DataAtual = "22/02/2012";

            Boleto bolBB = new BoletoBrasil();

            bolBB.Aceite         = "sim";
            bolBB.CedenteAgencia = "3474";
            bolBB.CedenteConta   = "33228";
            bolBB.CedenteContaDV = "3";
            bolBB.CedenteNome    = "Integra Softwares Soluções e Serviços Ltda";
            bolBB.Carteira       = 17;
            bolBB.Instrucao1     = "Não aceitar após vencimento";

            bolBB.Sequencial      = 000002; //variavel
            bolBB.Documento       = "00000001";
            bolBB.Contrato        = 2338947;
            bolBB.DtDocumento     = Convert.ToDateTime(DataAtual);
            bolBB.DtEmissao       = Convert.ToDateTime(DataAtual);
            bolBB.DtProcessamento = Convert.ToDateTime(DataAtual);
            bolBB.DtVencimento    = Convert.ToDateTime(DataAtual).AddDays(1);
            bolBB.Valor           = 5;                           //float.Parse(dtInscrito.Rows[0][61].ToString());

            bolBB.SacadoNome     = "Daniel Teófilo Vasconcelos"; //variavel
            bolBB.SacadoEndereco = "Rua Recanto do Passaré 107"; //variavel
            bolBB.SacadoCPF_CNPJ = "76976076387";                //varicael
            bolBB.SacadoCidade   = "Fortaleza";                  //variavel
            bolBB.SacadoUF       = "CE";                         //variavel
            bolBB.SacadoBairro   = "Passaré";                    //variavel
            bolBB.SacadoCEP      = "60744-050";                  //variavel

            //Adaptação
            DateTime dtData = Convert.ToDateTime(DataAtual).AddDays(1);

            DataAtual = dtData.ToString("dd/MM/yyyy");
            string Ref = "2338947000000020000";

            Ref = Ref + 18;

            //Boletos connBoletos = new Boletos();
            // string strLinha = connBoletos.Calculo_LinhaEditavel(Ref, "5", DataAtual);
            //string strCodBarras = connBoletos.Monta_CodBarras(Ref, "5", DataAtual);

            // Boletos connBoletos = new Boletos();
            // string strLinha = connBoletos.Calculo_LinhaEditavel(Ref, "5", DataAtual);
            //string strCodBarras = connBoletos.Monta_CodBarras(Ref, "5", DataAtual);


            HTMLBoleto geraBoleto = new HTMLBoleto();

            geraBoleto.ImagesFolder = "imagesBoleto";

            //geraBoleto.AddBoleto(bolBB, strLinha, strCodBarras);
            //geraBoleto.AddBoleto(bolBB, strLD, strCB);

            //geraBoleto.AddBoleto(bolBB, strLinha, strCodBarras);
            geraBoleto.AddBoleto(bolBB, strLD, strCB);

            Response.Write(geraBoleto.ToString());
        }
Пример #4
0
        private void button1_Click(object sender, EventArgs e)
        {
            lblError.Text    = string.Empty;
            lblProcesos.Text = string.Empty;
            openFileDialog1.InitialDirectory = @"C:\";
            openFileDialog1.Title            = "Seleccionar archivo";

            openFileDialog1.CheckFileExists = true;
            openFileDialog1.CheckPathExists = true;

            openFileDialog1.DefaultExt       = "xls";
            openFileDialog1.Filter           = "Excel Files(.xls)|*.xls| Excel Files(.xlsx)|*.xlsx| Excel Files(*.xlsm)|*.xlsm";
            openFileDialog1.FilterIndex      = 1;
            openFileDialog1.RestoreDirectory = true;

            openFileDialog1.ReadOnlyChecked = true;
            openFileDialog1.ShowReadOnly    = true;
            CultureInfo invC = CultureInfo.InvariantCulture;

            Stream outputFile = File.Create(@"C:\gpusuario\traceCargaCobros.txt");
            TextWriterTraceListener textListener = new TextWriterTraceListener(outputFile);
            TraceSource             trace        = new TraceSource("trSource", SourceLevels.All);

            try
            {
                trace.Listeners.Clear();
                trace.Listeners.Add(textListener);
                trace.TraceInformation("Carga cobros");

                Business.Parametros param = new Business.Parametros(companySelected(), cbTipoArchivo.SelectedIndex.ToString());
                BoletosBrasil       lst   = new BoletosBrasil();

                if (openFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    string archivo = openFileDialog1.FileName;

                    var ds = LeerExcelDataReader(archivo);

                    lst.LBoletosBrasil = new List <BoletoBrasil>();

                    lblProcesos.Text += "Opening " + archivo + Environment.NewLine;
                    lblError.Text    += "Opening " + archivo + Environment.NewLine + Environment.NewLine;
                    string tipoDato = string.Empty;
                    for (int i = param.IniciaDatosFila; i < ds.Tables[0].Rows.Count; i++)
                    {
                        if (ds.Tables[0].Rows[i].ItemArray.GetValue(0).ToString() != string.Empty)
                        {
                            BoletoBrasil d = new BoletoBrasil();
                            trace.TraceInformation("fila: " + i.ToString() + " col FechaTotalLiquidadoCol:" + param.FechaTotalLiquidadoCol.ToString());
                            tipoDato = ds.Tables[0].Rows[i].ItemArray.GetValue(param.FechaTotalLiquidadoCol).GetType().ToString();
                            d.FechaTotalLiquidado = ConvierteAFecha(tipoDato, ds.Tables[0].Rows[i].ItemArray.GetValue(param.FechaTotalLiquidadoCol).ToString(), param.FormatoFecha, invC);

                            trace.TraceInformation("fila: " + i.ToString() + " col NumeroCobroCol:" + param.NumeroCobroCol.ToString());
                            d.NumeroCobro = ds.Tables[0].Rows[i].ItemArray.GetValue(param.NumeroCobroCol).ToString().Trim();
                            //en caso de tarjeta, agregar la fecha al número de cobro y NC
                            if (cbTipoArchivo.SelectedIndex == 1)
                            {
                                d.NumeroCobro += d.FechaTotalLiquidado.ToString("yyyMMdd");
                            }

                            trace.TraceInformation("fila: " + i.ToString() + " col NumeroFacturaCol:" + param.NumeroFacturaCol.ToString());
                            d.NumeroFactura       = ds.Tables[0].Rows[i].ItemArray.GetValue(param.NumeroFacturaCol).ToString().Trim();
                            d.NumeroFacturaYCuota = d.NumeroFactura;

                            //el número de la planilla puede venir así: B-10201, B-10201., B-10201 01, B-10201. 01, B10201
                            d.NumeroFactura = d.NumeroFactura.Trim().Length > 7 ? Model.Utiles.Izquierda(d.NumeroFactura, 8) : d.NumeroFactura;
                            if (!d.NumeroFactura.Substring(1, 1).Equals("-"))   //las facturas deben tener guión luego de la serie
                            {
                                d.NumeroFactura = d.NumeroFactura.Insert(1, "-");
                            }

                            trace.TraceInformation("fila: " + i.ToString() + " col CodigoLiquidacionCol:" + param.CodigoLiquidacionCol.ToString());
                            d.CodigoLiquidacion = ds.Tables[0].Rows[i].ItemArray.GetValue(param.CodigoLiquidacionCol).ToString().Trim();

                            trace.TraceInformation("fila: " + i.ToString() + " col FechaVencimientoPago:" + param.FechaVencimientoPagoCol.ToString());
                            tipoDato = ds.Tables[0].Rows[i].ItemArray.GetValue(param.FechaVencimientoPagoCol).GetType().ToString();
                            d.FechaVencimientoPago = ConvierteAFecha(tipoDato, ds.Tables[0].Rows[i].ItemArray.GetValue(param.FechaVencimientoPagoCol).ToString(), param.FormatoFecha, invC);

                            trace.TraceInformation("fila: " + i.ToString() + " col ValorBoletoCol:" + param.ValorBoletoCol.ToString());
                            d.ValorBoleto = decimal.Parse(ds.Tables[0].Rows[i].ItemArray.GetValue(param.ValorBoletoCol).ToString().Trim());

                            trace.TraceInformation("fila: " + i.ToString() + " col JurosCol:" + param.JurosCol.ToString() + " " + ds.Tables[0].Rows[i].ItemArray.GetValue(param.JurosCol).ToString());
                            d.Juros = ds.Tables[0].Rows[i].ItemArray.GetValue(param.JurosCol) == null || ds.Tables[0].Rows[i].ItemArray.GetValue(param.JurosCol).ToString().Trim().Equals(String.Empty) ? 0 : decimal.Parse(ds.Tables[0].Rows[i].ItemArray.GetValue(param.JurosCol).ToString().Trim());
                            trace.TraceInformation("fila: " + i.ToString() + " col AbatimentoCol:" + param.AbatimentoCol.ToString());
                            d.Abatimento = ds.Tables[0].Rows[i].ItemArray.GetValue(param.AbatimentoCol) == null || ds.Tables[0].Rows[i].ItemArray.GetValue(param.AbatimentoCol).ToString().Trim().Equals(String.Empty) ? 0 : decimal.Parse(ds.Tables[0].Rows[i].ItemArray.GetValue(param.AbatimentoCol).ToString().Trim());
                            trace.TraceInformation("fila: " + i.ToString() + " col ValorPagoCol:" + param.ValorPagoCol.ToString());
                            d.ValorPago = decimal.Parse(ds.Tables[0].Rows[i].ItemArray.GetValue(param.ValorPagoCol).ToString().Trim());
                            trace.TraceInformation("fila: " + i.ToString() + " col NombrePagadorCol:" + param.NombrePagadorCol.ToString());
                            d.NombrePagador = ds.Tables[0].Rows[i].ItemArray.GetValue(param.NombrePagadorCol).ToString();

                            lst.LBoletosBrasil.Add(d);

                            using (var context = new GBRAEntities())
                            {
                                int sp = context.dibb_spCollectionOfBankSlips_insUpd(Utiles.getLast(d.NumeroCobro.ToString(), 21), Utiles.getLast(d.NumeroFacturaYCuota, 21), Utiles.getLast(openFileDialog1.FileName, 150), Utiles.getLast(Environment.UserName, 50));
                                trace.TraceInformation("fila: " + i.ToString() + " resultado dibb_spCollectionOfBankSlips_insUpd: " + sp.ToString());
                            }
                        }
                        else
                        {
                            lblError.Text += "Row: " + (i + 1).ToString() + " is blank." + Environment.NewLine;
                        }
                    }


                    Business.AdminBandejasGP bandeja = new Business.AdminBandejasGP(param);
                    bandeja.IntegraCobrosXL.EventoErrorIntegracion  += new EventHandler <Business.ErrorIntegracionEventArgs>(ErroresAlImportar);
                    bandeja.IntegraCobrosXL.EventoAlertaIntegracion += new EventHandler <Business.AlertaIntegracionEventArgs>(Alertas);

                    bandeja.ProcesaBandejaXL(lst, Business.Bandeja.TargetGP.RMCobro);

                    if (cbTipoArchivo.SelectedIndex == 1)
                    {
                        //procesa el monto de los juros
                        bandeja.ProcesaBandejaXL(lst, Business.Bandeja.TargetGP.RMNotaCredito);
                    }
                }
            }
            catch (Exception of)
            {
                lblError.Text += "Please check the file. It doesn't look like a file for uploading " + cbTipoArchivo.SelectedItem.ToString() + Environment.NewLine + Environment.NewLine + of.Message + " (Form1.button1_Click) " + of.StackTrace + Environment.NewLine;
            }
            finally
            {
                trace.Flush();
                trace.Close();
            }
        }