protected void btnGerarDadosPagamento_Click(object sender, EventArgs e) { BMUsuarioPagamento bmUsuarioPagamento = new BMUsuarioPagamento(); UsuarioPagamento novoUsuarioPagamento = new UsuarioPagamento(); novoUsuarioPagamento.Usuario = new BMUsuario().ObterPorId(int.Parse(ddlUsuario.SelectedValue)); novoUsuarioPagamento.ConfiguracaoPagamento = new BMConfiguracaoPagamento().ObterPorID(1); novoUsuarioPagamento.DataInicioVigencia = DateTime.Now; novoUsuarioPagamento.DataFimVigencia = DateTime.Now.AddYears(2); novoUsuarioPagamento.ValorPagamento = 15; novoUsuarioPagamento.DataInicioRenovacao = DateTime.Now.AddYears(2); novoUsuarioPagamento.DataMaxInadimplencia = DateTime.Now.AddMonths(2); novoUsuarioPagamento.PagamentoConfirmado = false; novoUsuarioPagamento.PagamentoEfetuado = false; novoUsuarioPagamento.FormaPagamento = enumFormaPagamento.Boleto; novoUsuarioPagamento.DataAceiteTermoAdesao = DateTime.Now; novoUsuarioPagamento.DataVencimento = DateTime.Now.AddDays(2); novoUsuarioPagamento.PagamentoEnviadoBanco = false; //CADASTRA O NOVO REGISTRO bmUsuarioPagamento.Salvar(novoUsuarioPagamento); //RECUPERA O NOSSO NUMERO E SALVA O REGISTRO novoUsuarioPagamento.NossoNumero = new BMUsuarioPagamento().GerarNossoNumero(novoUsuarioPagamento); bmUsuarioPagamento.Salvar(novoUsuarioPagamento); PreencherGrid(novoUsuarioPagamento.Usuario.ID); }
protected void EnviaInformacoesParaSiteDoBancoDoBrasil(int idUsuarioPagamento) { try { UsuarioPagamento usuarioPagamento = new BMUsuarioPagamento().ObterInformacoesDePagamentoPorID(idUsuarioPagamento); this.EnviarDadosDePagamentoParaoBancoDoBrasil(usuarioPagamento); } catch (Exception ex) { WebFormHelper.ExibirMensagem(enumTipoMensagem.Alerta, ex.Message); } }
protected void PreencherGrid(int idUsuario) { BMUsuarioPagamento bmUsuarioPagamento = new BMUsuarioPagamento(); IList <UsuarioPagamento> listaUsuarioPagamento = bmUsuarioPagamento.ObterInformacoesDePagamentoDoUsuario(idUsuario); if (listaUsuarioPagamento != null && listaUsuarioPagamento.Count() > 0) { pnlInformacoesDePagamento.Visible = true; WebFormHelper.PreencherGrid(listaUsuarioPagamento, dgvDados); } else { dvPagamento.Visible = true; } }
protected void dgvDados_RowCommand(object sender, GridViewCommandEventArgs e) { int idPagamento = int.Parse(e.CommandArgument.ToString()); BMUsuarioPagamento bmUsuarioPagamento = new BMUsuarioPagamento(); UsuarioPagamento pagamento = bmUsuarioPagamento.ObterInformacoesDePagamentoPorID(idPagamento); if (pagamento.PagamentoConfirmado.HasValue && !pagamento.PagamentoConfirmado.Value) { pagamento.DataPagamento = DateTime.Now; pagamento.PagamentoEfetuado = true; pagamento.PagamentoConfirmado = true; pagamento.DataPagamentoInformado = DateTime.Now; bmUsuarioPagamento.Salvar(pagamento); PreencherGrid(pagamento.Usuario.ID); } }
public void ProcessarArquivoDeDebitoDoBancoDoBrasilCBR643(HttpPostedFile arquivoEnviado) { try { bmUsuarioPagamento = new BMUsuarioPagamento(); string linhacompleta, identificacao, datalote, convenio = null; decimal valorrecebido = 0; string liquidacao = null; string datadocredito, refTranNossoNumero = null; StringBuilder sbPagamentosNaoEncontrados = new StringBuilder(); sbPagamentosNaoEncontrados.Append("O(s) seguinte(s) Pagamento(s) não foi(oram) encontrado(s)"); sbPagamentosNaoEncontrados.AppendLine("<br />"); sbPagamentosNaoEncontrados.AppendLine("<br />"); bool arquivoVazio = true; bool temPagamentoNaoEncontrado = false; using (StreamReader sr = new StreamReader(arquivoEnviado.InputStream)) { while ((linhacompleta = sr.ReadLine()) != null) { //linhacompleta = linha; identificacao = linhacompleta.Substring(0, 1); if (int.Parse(identificacao) == 0) //registro header { datalote = linhacompleta.Substring(94, 6); } //else if (int.Parse(identificacao) == 9) //registro footer //{ // //TODO: -> Rever este ponto, pois podemos ter um arquivo começando com o valor 9. // throw new AcademicoException("Arquivo Inválido."); //} else { arquivoVazio = false; convenio = linhacompleta.Substring(31, 7); if (convenio == "3072072") { valorrecebido = decimal.Parse(linhacompleta.Substring(253, 13)); datadocredito = linhacompleta.Substring(175, 6); datadocredito = datadocredito.Substring(0, 2) + "/" + datadocredito.Substring(2, 2) + "/20" + datadocredito.Substring(4, 2); liquidacao = linhacompleta.Substring(108, 2); refTranNossoNumero = linhacompleta.Substring(63, 17); if (liquidacao == "03" || liquidacao == "13") { //TODO: Verificar esta regra no legado. //Houve problema com a liquidação - 03 = Comando recusado (Motivo indicado na posição 087/088), 13 = Abatimento Cancelado } else { if (!string.IsNullOrWhiteSpace(refTranNossoNumero)) { ManterUsuarioPagamento manterUsuarioPagamento = new ManterUsuarioPagamento(); UsuarioPagamento usuarioPagamento = manterUsuarioPagamento.ObterInformacoesDePagamentoDoUsuarioNossoNumero(refTranNossoNumero); //Se não encontrou o pagamento pelo nosso número, concatena if (usuarioPagamento == null) { sbPagamentosNaoEncontrados.AppendLine(string.Concat(refTranNossoNumero, "<br />")); temPagamentoNaoEncontrado = true; continue; } if (valorrecebido > 0) { usuarioPagamento.DataPagamento = DateTime.Parse(datadocredito); usuarioPagamento.ValorPagamento = valorrecebido / 10; usuarioPagamento.PagamentoConfirmado = true; usuarioPagamento.Auditoria = new Auditoria("Processo de retorno"); manterUsuarioPagamento.SalvarInformacoesDePagamento(usuarioPagamento); } } } } } } } //}Fim do ForEach if (arquivoVazio) { throw new AcademicoException("Arquivo Inválido."); } if (temPagamentoNaoEncontrado) { throw new AcademicoException(sbPagamentosNaoEncontrados.ToString()); } } catch (AcademicoException ex) { throw ex; } catch (Exception ex) { throw ex; } }
public ManterUsuarioPagamento() : base() { bmUsuarioPagamento = new BMUsuarioPagamento(); }
public void ProcessarArquivoDeDebitoDoBancoDoBrasil(HttpPostedFile arquivoEnviado) { try { bmUsuarioPagamento = new BMUsuarioPagamento(); string linhacompleta, identificacao, datalote, convenio = null; decimal valorrecebido = 0; string datadocredito, refTranNossoNumero = null; //foreach (string linha in linhas) // { StringBuilder sbPagamentosNaoEncontrados = new StringBuilder(); sbPagamentosNaoEncontrados.Append("O(s) seguinte(s) Pagamento(s) não foi(oram) encontrado(s)"); sbPagamentosNaoEncontrados.AppendLine("<br />"); sbPagamentosNaoEncontrados.AppendLine("<br />"); bool arquivoVazio = true; bool temPagamentoNaoEncontrado = false; using (StreamReader sr = new StreamReader(arquivoEnviado.InputStream)) { while ((linhacompleta = sr.ReadLine()) != null) { identificacao = linhacompleta.Substring(0, 1); if (identificacao.ToUpper().Equals("A")) //registro header { datalote = linhacompleta.Substring(65, 8); } //else if (identificacao.ToUpper().Equals("Z")) //registro footer //{ // throw new AcademicoException("Arquivo Inválido."); //} else //registro detalhe { arquivoVazio = false; convenio = linhacompleta.Substring(64, 7); if (convenio == "3072072") { valorrecebido = decimal.Parse(linhacompleta.Substring(81, 12)); datadocredito = linhacompleta.Substring(29, 8); datadocredito = datadocredito.Substring(6, 2) + "/" + datadocredito.Substring(4, 2) + "/" + datadocredito.Substring(0, 4); refTranNossoNumero = linhacompleta.Substring(64, 17); if (refTranNossoNumero.Substring(0, 7) == "3072072") { ManterUsuarioPagamento manterUsuarioPagamento = new ManterUsuarioPagamento(); UsuarioPagamento usuarioPagamento = this.ObterInformacoesDePagamentoDoUsuarioNossoNumero(refTranNossoNumero); //Se não encontrou o pagamento pelo nosso número, concatena if (usuarioPagamento == null) { sbPagamentosNaoEncontrados.AppendLine(string.Concat(refTranNossoNumero, "<br />")); temPagamentoNaoEncontrado = true; continue; } usuarioPagamento.DataPagamento = DateTime.Parse(datadocredito); usuarioPagamento.ValorPagamento = valorrecebido; usuarioPagamento.PagamentoConfirmado = true; usuarioPagamento.Auditoria = new Auditoria(); if (valorrecebido > 0) { //Inserir aqui a gravação de um registro na tabela TB_UsuarioPagamento campos IN_Pago com 1 e DT_Pagamento usuarioPagamento.DataPagamento = DateTime.Parse(datadocredito); usuarioPagamento.ValorPagamento = valorrecebido / 10; usuarioPagamento.PagamentoConfirmado = true; usuarioPagamento.Auditoria = new Auditoria("Processo de retorno"); manterUsuarioPagamento.SalvarInformacoesDePagamento(usuarioPagamento); } } } } } } //}fim foreach if (arquivoVazio) { throw new AcademicoException("Arquivo Inválido."); } if (temPagamentoNaoEncontrado) { throw new AcademicoException(sbPagamentosNaoEncontrados.ToString()); } } catch (AcademicoException ex) { throw ex; } catch (Exception ex) { throw ex; } }