Beispiel #1
0
        private void btnGerar_Click(object sender, EventArgs e)
        {
            Configuracao o = ConfiguracaoBLL.get();

            if (o.Agencia != null)
            {
                GerarUI g = new GerarUI();
                g.Show();
            }
            else
            {
                MessageBox.Show("É preciso fazer as configurações inicias antes de prosseguir, clique em OK que abriremos a tela de configuração pra você!");
                ConfiguracaoUI c = new ConfiguracaoUI();
                c.ShowDialog();
            }
        }
Beispiel #2
0
        public ConfiguracaoUI()
        {
            InitializeComponent();
            toolStripStatusLabel1.Text = "";
            Configuracao o = ConfiguracaoBLL.get();

            if (o.Agencia != null)
            {
                txtAgencia.Text     = o.Agencia;
                txtConta.Text       = o.Conta;
                txtContaDigito.Text = o.ContaDigito;
                txtCedente.Text     = o.Cedente;
                txtCNPJ.Text        = o.CNPJ;
                txtRazao.Text       = o.RazaoSocial;
                txtDescricao.Text   = o.Descricao;
            }
        }
Beispiel #3
0
        private void btnSalvar_Click(object sender, EventArgs e)
        {
            if (validForm())
            {
                Configuracao o = new Configuracao();
                o.Agencia     = txtAgencia.Text;
                o.Conta       = txtConta.Text;
                o.ContaDigito = txtContaDigito.Text;
                o.Cedente     = txtCedente.Text;
                o.CNPJ        = txtCNPJ.Text;
                o.RazaoSocial = txtRazao.Text;
                o.Descricao   = txtDescricao.Text;

                ConfiguracaoBLL.save(o);

                toolStripStatusLabel1.Text = "Salvo com sucesso.";
            }
        }
Beispiel #4
0
        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";
            }
        }