Example #1
0
        private System.Boolean preparaBoleto()
        {
            string nomeFuncao = "geraBoletos.Boletos.preparaBoleto";

            System.Boolean isPassou = false;

            try
            {
                if (!isBoletoCarregado)
                {
                    throw new Exception("Boletos não carregados!");
                }

                debitos.getDadosDebito(txtPedido.Text, CarSystem.Tipos.statusDebito.todos);

                foreach (System.Windows.Forms.DataGridViewRow dgLinha in dgParcelas.Rows)
                {
                    if (dgLinha.Cells[10].Value != null && dgLinha.Cells[10].Value.ToString() == "Imprimir")
                    {
                        if (cliente.contrato.ToString() != dgLinha.Cells[1].Value.ToString())
                        {
                            cliente.getCliente(dgLinha.Cells[1].Value.ToString());
                            debitos.getDadosDebito(cliente.contrato, CarSystem.Tipos.statusDebito.todos);
                        }

                        DataGridViewComboBoxCell cbCelula;
                        DateTime vencimento;


                        foreach (CarSystem.Interface.IInformacoesDebito infoDebito in debitos.getDebitos())
                        {
                            if (infoDebito.identificadorDebito == Convert.ToInt64(dgLinha.Cells[7].Value))
                            {
                                if (dgLinha.Cells["statusDebito"].Value.ToString() == "1")
                                {
                                    if (dgParcelas.Columns["valorAtualizado"] != null)
                                    {
                                        boletos.banco.funcoesBoleto.imprimeBoleto(cliente, infoDebito.nossoNumero, infoDebito.numeroDocumento, Convert.ToDateTime(dgLinha.Cells["vencimento"].Value), Convert.ToDouble(dgLinha.Cells["valorAtualizado"].Value));
                                    }
                                    else
                                    {
                                        cbCelula   = (DataGridViewComboBoxCell)dgLinha.Cells["vencimento"];
                                        vencimento = Convert.ToDateTime(((DataRowView)cbCelula.Items[0]).Row.ItemArray[0].ToString());
                                        boletos.banco.funcoesBoleto.imprimeBoleto(cliente, infoDebito.nossoNumero, infoDebito.numeroDocumento, vencimento, Convert.ToDouble(dgLinha.Cells["valorDebito"].Value));
                                    }
                                }
                                else
                                {
                                    boletos.banco.funcoesBoleto.imprimeBoleto(infoDebito, cliente);
                                }
                                break;
                            }

                            if (infoDebito.codigoBanco != boletos.banco.nomeBanco)
                            {
                                boletos.banco.setBanco(infoDebito.codigoBanco, dados);
                            }
                        }

                        //boletos.banco.imprimeBoleto(cliente,CarSystem.Tipos.tipoEmissao.Producao,CarSystem.Tipos.statusDebito.aVencer);

                        isPassou = true;
                    }
                }
            }
            //catch (CarSystem.Utilidades.Campos.CampoException)
            //{
            //    boletos.getBoletos();
            //}
            catch (Exception ex)
            {
                throw new Exception("(" + nomeFuncao + ")" + ex.Message);
            }

            return(isPassou);
        }