예제 #1
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex > -1)
            {
                if (dataGridView1.Columns[e.ColumnIndex] is DataGridViewButtonColumn)
                {
                    Int32  id = Int32.Parse(dataGridView1.Rows[e.RowIndex].Cells[5].Value.ToString());
                    Boleto o  = BoletoBLL.get(id);
                    if (o.Recebido)
                    {
                        MessageBox.Show("Essa boleta já está quitada.");
                    }
                    else
                    {
                        o.Recebido     = true;
                        o.DataRecebido = DateTime.Now.Date;
                        BoletoBLL.save(ref o);

                        atuGrid();
                    }
                }
            }
        }
예제 #2
0
파일: Retorno.cs 프로젝트: oraculum/CEF
        private void btnLocalizar_Click(object sender, EventArgs e)
        {
            toolStripStatusLabel1.Text = "";
            intQtde = 0;

            OpenFileDialog openFile = new OpenFileDialog();

            if (openFile.ShowDialog() == DialogResult.OK)
            {
                txtFileRetorno.Text = openFile.FileName;
                int          nLoopCtr     = 1;
                int          intNossoNum  = 0;
                Boolean      blnBolNaoLoc = false;
                StreamReader sr           = new StreamReader(txtFileRetorno.Text);

                String[] fields = new String[3];

                while (true)
                {
                    string line = sr.ReadLine();
                    if (line == null)
                    {
                        break;
                    }

                    toolStripStatusLabel1.Text = "Processando linhas " + nLoopCtr.ToString();
                    Application.DoEvents();
                    nLoopCtr++;

                    fields = processLine(line);
                    if (fields[0] != null)
                    {
                        BolProcessada bp = new BolProcessada();
                        bp.NossoNum = fields[0];

                        intNossoNum += 1;
                        Boleto b = BoletoBLL.get(Int32.Parse(fields[0]));
                        if (b.ID > 0)
                        {
                            b.DataRecebido  = DateTime.Parse(fields[1]);
                            b.ValorRecebido = Decimal.Parse(fields[2]);
                            b.Recebido      = true;

                            BoletoBLL.save(ref b);

                            bp.Cliente   = b.Cliente.Nome;
                            bp.Valor     = b.Valor;
                            bp.ValorPago = b.ValorRecebido;
                        }
                        else
                        {
                            bp.Cliente   = "*** NOSSO NUMERO NÃO LOCALIZADO NO BANCO DE DADOS ***";
                            blnBolNaoLoc = true;
                        }

                        listBol.Add(bp);
                        toolStripStatusLabel1.Text = "Processando Nosso Num.: " + fields[0];
                    }
                }

                if (intQtde != intNossoNum)
                {
                    MessageBox.Show("Atenção: arq. retorno " + intQtde.ToString() +
                                    "/nNosso Num encontrados " + intNossoNum.ToString());
                }

                if (blnBolNaoLoc)
                {
                    MessageBox.Show("Existem boletas que não foram localizadas no banco de dados");
                }

                dataGridView1.DataSource = listBol;

                toolStripStatusLabel1.Text = "Processo finalizado. Total boletas " + intQtde;
            }
        }
예제 #3
0
파일: GerarUI.cs 프로젝트: oraculum/CEF
        private void btnGerar_Click(object sender, EventArgs e)
        {
            if (validForm())
            {
                List <Entity.Boleto> lb = new List <Entity.Boleto>();

                Int16    qtde = Int16.Parse(txtQtde.Text);
                DateTime venc = DateTime.Parse(txtVencimento.Text);
                lblVencimentos.Text = "";

                for (int i = 0; i < qtde; i++)
                {
                    Entity.Boleto o = new Entity.Boleto();
                    o.Cliente    = ClienteBLL.get(Int32.Parse(txtCliente.Text));
                    o.Valor      = Decimal.Parse(txtValor_Contrato.Text);
                    o.Obs1       = txtObs1.Text;
                    o.Obs2       = txtObs2.Text;
                    o.Obs3       = txtObs3.Text;
                    o.Vencimento = venc;

                    BoletoBLL.save(ref o);
                    lb.Add(o);

                    lblVencimentos.Text += venc.ToShortDateString() + Environment.NewLine;
                    venc = venc.AddMonths(1);
                }

                lbb = new List <BoletoNet.BoletoBancario>();

                foreach (Entity.Boleto boleto in lb)
                {
                    Configuracao   config = ConfiguracaoBLL.get();
                    Entity.Boleto  b      = boleto;
                    BoletoBancario bb     = new BoletoBancario();
                    bb.CodigoBanco       = 104;
                    bb.OcultarInstrucoes = true;

                    Cedente c = new Cedente(config.CNPJ, config.RazaoSocial, config.Agencia, config.Conta_Format, config.ContaDigito);
                    c.Codigo = config.Cedente;
                    String           base_nossnum = (24000000000000000 + b.ID).ToString();
                    BoletoNet.Boleto bol          = new BoletoNet.Boleto(b.Vencimento, b.Valor, "SR", base_nossnum, c);
                    bol.NumeroDocumento        = b.ID.ToString();
                    bol.Sacado                 = new Sacado(b.Cliente.CNPJ, b.Cliente.Nome + " (" + b.Cliente.Fantasia + ") ");
                    bol.Sacado.Endereco.End    = b.Cliente.Endereco;
                    bol.Sacado.Endereco.Numero = b.Cliente.Numero;
                    bol.Sacado.Endereco.Bairro = b.Cliente.Bairro;
                    bol.Sacado.Endereco.Cidade = b.Cliente.Cidade;
                    bol.Sacado.Endereco.UF     = b.Cliente.UF;
                    bol.Sacado.Endereco.CEP    = b.Cliente.CEP;

                    bol.DataDocumento = DateTime.Today.Date;
                    bol.ValorBoleto   = b.Valor;
                    Instrucao lot = new Instrucao(104);
                    lot.Descricao = config.Descricao;
                    bol.Instrucoes.Add(lot);

                    if (!String.IsNullOrEmpty(txtValor_Bruto.Text))
                    {
                        Instrucao obs = new Instrucao(104);
                        obs.Descricao = "Cobrar valor normal contrato após o vencimento R$ " + Decimal.Parse(txtValor_Bruto.Text).ToString("n");
                        bol.Instrucoes.Add(obs);
                    }

                    if (b.Obs1.Length > 0)
                    {
                        Instrucao obs1 = new Instrucao(104);
                        obs1.Descricao = b.Obs1;
                        bol.Instrucoes.Add(obs1);
                    }
                    if (b.Obs2.Length > 0)
                    {
                        Instrucao obs2 = new Instrucao(104);
                        obs2.Descricao = b.Obs2;
                        bol.Instrucoes.Add(obs2);
                    }
                    if (b.Obs3.Length > 0)
                    {
                        Instrucao obs3 = new Instrucao(104);
                        obs3.Descricao = b.Obs3;
                        bol.Instrucoes.Add(obs3);
                    }

                    bb.Boleto = bol;
                    bb.Boleto.Valida();

                    //salvando o nosso numero depois de gerado
                    b.NossoNum = bb.Boleto.NossoNumero;
                    BoletoBLL.save(ref b);

                    lbb.Add(bb);
                }

                GeraLayout();
                _impressaoBoleto.webBrowser1.Navigate(_arquivo);
                _impressaoBoleto.ShowDialog();


                toolStripStatusLabel1.Text = "Boletos gerados";
            }
        }