private DTOUsuarioPagamento PreencherDTOUsuarioPagamento(UsuarioPagamento usuarioPagamentoPendente) { var dtoUsuarioPagamento = new DTOUsuarioPagamento { IdConfiguracaoPagamento = usuarioPagamentoPendente.ConfiguracaoPagamento.ID, IdUsuario = usuarioPagamentoPendente.Usuario.ID, DataAceiteTermoAdesao = usuarioPagamentoPendente.DataAceiteTermoAdesao, DataInicioVigencia = usuarioPagamentoPendente.DataInicioVigencia, DataFimVigencia = usuarioPagamentoPendente.DataFimVigencia, DataPagamento = usuarioPagamentoPendente.DataPagamento, ValorPagamento = usuarioPagamentoPendente.ValorPagamento, DataInicioRenovacao = usuarioPagamentoPendente.DataInicioRenovacao, DataMaxInadimplencia = usuarioPagamentoPendente.DataMaxInadimplencia, CodigoPagamento = usuarioPagamentoPendente.NossoNumero, PagamentoEfetuado = usuarioPagamentoPendente.PagamentoEfetuado, IdConvenio = "3072072", QtdPontos = "0", MensagemBoleto = "Não Aceitar após o vencimento", DataVencimento = usuarioPagamentoPendente.DataVencimento, CPF = usuarioPagamentoPendente.Usuario.CPF }; if (usuarioPagamentoPendente.PagamentoEnviadoBanco && usuarioPagamentoPendente.FormaPagamento == enumFormaPagamento.Boleto) { //21 -> Segunda via do Boleto dtoUsuarioPagamento.FormaPagamento = "21"; } else { dtoUsuarioPagamento.FormaPagamento = ((int)usuarioPagamentoPendente.FormaPagamento).ToString(); } return(dtoUsuarioPagamento); }
private UsuarioPagamento ObterObjetoUsuarioPagamento(int idConfiguracaoPagamento, int idFormaPagamento, Usuario usuario) { var configuracaoPagamento = new ManterConfiguracaoPagamento().ObterConfiguracaoPagamentoPorId(idConfiguracaoPagamento); var dataFimVigencia = DateTime.Today.AddDays(configuracaoPagamento.QuantidadeDiasValidade); var usuarioPagamento = new UsuarioPagamento { Usuario = usuario, ConfiguracaoPagamento = configuracaoPagamento, DataInicioVigencia = DateTime.Today, DataFimVigencia = dataFimVigencia, DataPagamento = null, ValorPagamento = configuracaoPagamento.ValorAPagar, DataInicioRenovacao = dataFimVigencia.AddDays(-configuracaoPagamento.QuantidadeDiasRenovacao), DataMaxInadimplencia = dataFimVigencia.AddDays(configuracaoPagamento.QuantidadeDiasInadimplencia), DataVencimento = DateTime.Today.AddDays(configuracaoPagamento.QuantidadeDiasPagamento), //CodigoPagamento = Gerado no Salvar PagamentoEfetuado = false, DataAceiteTermoAdesao = DateTime.Now, FormaPagamento = (enumFormaPagamento)idFormaPagamento, PagamentoEnviadoBanco = false }; PreencherInformacoesDeAuditoria(usuarioPagamento); return(usuarioPagamento); }
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); }
private void EnviarDadosDePagamentoParaoBancoDoBrasil(UsuarioPagamento usuarioPagamento) { { //this.valor.Value = usuarioPagamento.ValorPagamento.ToString(); //this.dtVenc.Value = usuarioPagamento.DataVencimento.Value.ToString("ddMMyyyy"); string formaPagamento = string.Empty; if (usuarioPagamento.FormaPagamento.Equals(enumFormaPagamento.Boleto)) { if (usuarioPagamento.PagamentoEnviadoBanco) { //21 -> Significa 2ª via de Boleto formaPagamento = "21"; } else { formaPagamento = ((int)enumFormaPagamento.Boleto).ToString(); } } else if (usuarioPagamento.FormaPagamento.Equals(enumFormaPagamento.DebitoEmConta)) { formaPagamento = ((int)enumFormaPagamento.DebitoEmConta).ToString(); } //// tpPagamento; //this.urlRetorno.Value = ""; //this.nome.Value = usuarioPagamento.Usuario.Nome; //this.endereco.Value = usuarioPagamento.Usuario.Endereco; //this.cidade.Value = usuarioPagamento.Usuario.Cidade; ////Pega a UF a partir do código da UF //ufAlfaNumerica = new ManterUf().ObterUfPorID(usuarioPagamento.Usuario.UF.ID); //this.uf.Value = ufAlfaNumerica.Sigla; //this.cep.Value = usuarioPagamento.Usuario.Cep; //this.msgLoja.Value = string.Empty; string post = @"$().redirect('https://www16.bancodobrasil.com.br/site/mpag/', { 'idConv': '311620', 'refTran': '" + usuarioPagamento.NossoNumero + @"', 'valor': '1500', 'qtdPontos': '0', 'dtVenc': '" + usuarioPagamento.DataVencimento.Value.ToString("ddMMyyyy") + @"', 'tpPagamento': '" + formaPagamento + @"', 'urlRetorno': 'http://www5.fgv.br/fgvonline/teste1.html', 'urlInforma': 'http://www5.fgv.br/fgvonline/teste2.html', 'nome': '" + usuarioPagamento.Usuario.Nome + @"', 'endereco': 'value2', 'cidade': 'Rio de Janeiro', 'uf': 'RJ', 'cep': '24240170', 'msgLoja': 'Mensagem da UC' });"; Page page = HttpContext.Current.CurrentHandler as Page; if (page != null && !page.ClientScript.IsClientScriptBlockRegistered("mensagem")) { ScriptManager.RegisterStartupScript(page, typeof(WebFormHelper), "mensagem", post, true); } } }
public UsuarioPagamento ObterInformacoesCalculadasDeConfiguracaoPagamento(ConfiguracaoPagamento configuracaoPagamento) { UsuarioPagamento usuarioPagamento = new UsuarioPagamento(); this.CalcularInformacoes(configuracaoPagamento, usuarioPagamento); return(usuarioPagamento); }
public void PrepararTelaParaEdicaoDeInformarPagamento(UsuarioPagamento pUsuarioPagamento) { this.PreencherComboConfiguracoesPagamento(); this.PreencheComboOpcoesSimNao(); this.PreencherInformacoesInformarPagamento(pUsuarioPagamento); this.SetarAcaoDaTela(enumAcaoTelaCadastroDeInformarPagamento.EdicaoDePagamento); }
protected void btnInformarPagamento_Click(object sender, EventArgs e) { if (this.InformouPagamento != null) { UsuarioPagamento usuarioPagamento = null; try { usuarioPagamento = this.ObterObjetoUsuarioPagamento(); ManterUsuarioPagamento manterUsuarioPagamento = new ManterUsuarioPagamento();; manterUsuarioPagamento.SalvarInformacoesDePagamento(usuarioPagamento); } catch (AcademicoException ex) { WebFormHelper.ExibirMensagem(enumTipoMensagem.Erro, ex.Message); return; } this.IdUsuario = usuarioPagamento.Usuario.ID; InformouPagamento(this, new InformarPagamentoEventArgs(this.IdUsuario)); //(IList<ItemQuestionario>)this.QuestionarioDaSessao.ListaItemQuestionario)); //this.IdLogicoDoItemQuestionario = 0; ////ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "myscript", " $('#EdicaoNivel, #modal-background').removeClass('active');", true); //ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "myscript", " $('#ModalQuestionario').modal('hide');", true); //return; } }
public UsuarioPagamento ObterInformacoesDePagamentoDoUsuarioPorNossoNumero(string refTranNossoNumero) { var query = repositorio.session.Query <UsuarioPagamento>(); UsuarioPagamento usuarioPagamento = query.FirstOrDefault(x => x.NossoNumero == refTranNossoNumero.Trim()); return(usuarioPagamento); }
public UsuarioPagamento ObterInformacoesCalculadasDeConfiguracaoPagamento(int idConfiguracaoPagamento) { ConfiguracaoPagamento configuracaoPagamento = new BMConfiguracaoPagamento().ObterPorID(idConfiguracaoPagamento); UsuarioPagamento usuarioPagamento = bmUsuarioPagamento.ObterInformacoesCalculadasDeConfiguracaoPagamento(configuracaoPagamento); return(usuarioPagamento); }
public void Salvar(UsuarioPagamento usuarioPagamento) { this.ValidarUsuarioPagamentoInformado(usuarioPagamento); //Insert if (usuarioPagamento.ID == 0) { using (TransactionScope transaction = new TransactionScope(TransactionScopeOption.Required)) { //Insere um novo pagamento repositorio.SalvarSemCommit(usuarioPagamento); //Monta o Nosso número - Início string nossoNumero = this.GerarNossoNumero(usuarioPagamento); usuarioPagamento.NossoNumero = nossoNumero; //Monta o Nosso número - Fim //Atualiza o pagamento com o nosso número gerado repositorio.SalvarSemCommit(usuarioPagamento); repositorio.Commit(); transaction.Complete(); } } //Update else { repositorio.Salvar(usuarioPagamento); } }
public UsuarioPagamento ObterInformacoesDePagamentoDoUsuarioPorIdUsuario(int idUsuario) { var query = repositorio.session.Query <UsuarioPagamento>(); UsuarioPagamento usuarioPagamento = query.FirstOrDefault(x => x.Usuario.ID == idUsuario); return(usuarioPagamento); }
private void ValidarUsuarioPagamentoInformado(UsuarioPagamento usuarioPagamento) { this.ValidarInstancia(usuarioPagamento); if (!usuarioPagamento.DataVencimento.HasValue) { throw new AcademicoException("Data de Vencimento. Campo Obrigatório"); } }
public void IncluirUsuarioPagamento(UsuarioPagamento usuarioPagamento) { try { bmUsuarioPagamento.Salvar(usuarioPagamento); } catch (AcademicoException ex) { throw ex; } }
public void SalvarInformacoesDePagamento(UsuarioPagamento usuarioPagamento) { try { bmUsuarioPagamento.Salvar(usuarioPagamento); } catch (AcademicoException ex) { throw ex; } }
private void CalcularDatas() { ManterUsuarioPagamento manterUsuarioPagamento = new ManterUsuarioPagamento(); UsuarioPagamento usuarioPagamento = manterUsuarioPagamento.ObterInformacoesCalculadasDeConfiguracaoPagamento(int.Parse(ddlConfigPagto.SelectedItem.Value)); this.txtFimVigencia.Text = usuarioPagamento.DataFimVigenciaCalculada.ToShortDateString(); this.TxtDtInicioRenovacao.Text = usuarioPagamento.DataInicioRenovacaoCalculada.ToShortDateString(); this.txtDataMaxInadimplencia.Text = usuarioPagamento.DataMaxInadimplenciaCalculada.ToShortDateString(); this.TxtDtVencimento.Text = usuarioPagamento.DataVencimentoCalculada.ToShortDateString(); //this.txtFimVigencia.Text = configuracaoPagamento.DataInicioCompetencia.AddDays(configuracaoPagamento.QuantidadeDiasValidade).ToShortDateString(); }
/// <summary> /// Função Dinâmica para gerar o nosso número. /// </summary> /// <param name="usuarioPagamento">Informações sobre o pagamento inserido.</param> /// <returns>Nosso número gerado dinamicamente</returns> public string GerarNossoNumero(UsuarioPagamento usuarioPagamento) { const int limiteDeDigitos = 17; const string digitosIniciais = "3072072"; // 0000000568"; var qtdDigitosCodigoPagamento = usuarioPagamento.ID.ToString().Length; //Ex: 3001 var qtdDigitos = digitosIniciais.Length + qtdDigitosCodigoPagamento; //Ex: 7 + 4 = 11 var qtdDeZeroaGerar = limiteDeDigitos - qtdDigitos; //Ex: 17 - 11 = 4 -> Terá que gerar 4 zeros //Ex: 25750110000003001 var nossoNumero = string.Concat(digitosIniciais, "0".PadRight(qtdDeZeroaGerar, '0'), usuarioPagamento.ID.ToString()); return(nossoNumero); }
public void PreencheCampos() { if (Session["UsuarioPagamentoEdit"] != null) { string cdInformacao = Session["UsuarioPagamentoEdit"].ToString(); InformarPagamento = ManterUsuarioPagamento.ObterInformacoesDePagamentoPorIDUsuario(int.Parse(cdInformacao)); PreencherInformacoesInformarPagamento(InformarPagamento); } else { //this.ucCascataSolucaoEducacional1.PreencherCombos(); } }
public void BaixarPagamento(UsuarioPagamento usuarioPagamento) { try { UsuarioPagamento usuarioPagamentoEncontrado = bmUsuarioPagamento.ObterInformacoesDePagamentoDoUsuarioPorNossoNumero(usuarioPagamento.NossoNumero); //Verifica se o pagamento já foi realizado //if(usuarioPagamento.PagamentoEfetuado) } catch (Exception ex) { throw ex; } }
//protected void btnVoltar_Click(object sender, EventArgs e) //{ // try // { // this.dgvInformacoesDePagamento.Visible = true; // this.dgvHistoricoDePagamento.Visible = false; // this.pnlHistoricoPagamento.Visible = false; // this.btnVoltar.Visible = false; // this.btnEnviaBB.Visible = false; // this.pnlUcInformarPagamento.Visible = false; // this.pnlHistoricoPagamento.Visible = false; // } // catch (AcademicoException ex) // { // WebFormHelper.ExibirMensagem(enumTipoMensagem.Erro, ex.Message); // return; // } //} protected void dgvHistoricoDePagamento_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType.Equals(DataControlRowType.DataRow)) { UsuarioPagamento usuarioPagamento = (UsuarioPagamento)e.Row.DataItem; if (usuarioPagamento != null && usuarioPagamento.ID > 0) { Label lblFormaPagamento = (Label)e.Row.FindControl("lblFormaPagamento"); if (lblFormaPagamento != null) { lblFormaPagamento.Text = WebFormHelper.ObterFormaDePagamentoFormatado(usuarioPagamento.FormaPagamento); } Label lblPago = (Label)e.Row.FindControl("lblPago"); if (lblPago != null) { lblPago.Text = WebFormHelper.ObterDescricaoDeOpcaoSimOuNao(usuarioPagamento.PagamentoEfetuado); } Button btnEnviaBB = (Button)e.Row.FindControl("btnEnviaBB"); //Quando INPago = false, ou seja, se o pagamento ainda não foi feito, então exibe o link para o site do Banco do Brasil. if (!usuarioPagamento.PagamentoEfetuado) { if (btnEnviaBB != null) { btnEnviaBB.CommandArgument = usuarioPagamento.ID.ToString(); btnEnviaBB.Visible = true; } else { btnEnviaBB.Visible = false; } } else { btnEnviaBB.Visible = false; } } } }
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 RegistrarPagamentoInformado(UsuarioPagamento usuarioPagamento, DateTime dataPagamentoInformado, string textoAutenticacaoBancaria, decimal valorPago) { this.ValidarInstancia(usuarioPagamento); this.ValidarInformacoesSobrePagamento(dataPagamentoInformado, textoAutenticacaoBancaria); //Update if (usuarioPagamento.ID > 0) { //Atualiza informações sobre o pagamento usuarioPagamento.PagamentoInformado = true; usuarioPagamento.PagamentoConfirmado = false; usuarioPagamento.ValorPagamento = valorPago; usuarioPagamento.DataPagamentoInformado = dataPagamentoInformado; usuarioPagamento.TextoDaAutenticacaoBancaria = textoAutenticacaoBancaria; //Atualiza o pagamento repositorio.Salvar(usuarioPagamento); } }
public void PreencherInformacoesInformarPagamento(UsuarioPagamento pUsuarioPagamento) { if (pUsuarioPagamento != null) { string PagamentoEfetuado = string.Empty; this.txtDataInicioVigencia.Text = pUsuarioPagamento.DataInicioVigencia.ToShortDateString(); this.txtFimVigencia.Text = pUsuarioPagamento.DataFimVigencia.ToShortDateString(); this.txtValor.Text = pUsuarioPagamento.ValorPagamento.ToString(); this.TxtDtInicioRenovacao.Text = pUsuarioPagamento.DataInicioRenovacao.ToShortDateString(); this.txtDataMaxInadimplencia.Text = pUsuarioPagamento.DataMaxInadimplencia.ToShortDateString(); //Data de Vencimento if (pUsuarioPagamento.DataVencimento.HasValue) { this.TxtDtVencimento.Text = pUsuarioPagamento.DataVencimento.Value.ToShortDateString(); } this.TxtCodInformacao.Enabled = false; this.TxtCodInformacao.Text = pUsuarioPagamento.NossoNumero; WebFormHelper.SetarValorNaCombo(pUsuarioPagamento.ConfiguracaoPagamento.ID.ToString(), this.ddlConfigPagto); this.DdlFormaPagamento.ClearSelection(); WebFormHelper.SetarValorNaCombo(((int)pUsuarioPagamento.FormaPagamento).ToString(), this.DdlFormaPagamento); if (pUsuarioPagamento.PagamentoEfetuado == true) { PagamentoEfetuado = Constantes.SiglaSim; } else { PagamentoEfetuado = Constantes.SiglaNao; } this.DdlInPago.ClearSelection(); WebFormHelper.SetarValorNaCombo(PagamentoEfetuado, this.DdlInPago); } }
protected void dgvInformacoesDeHistoricoDePagamento_RowDataBound(object sender, System.Web.UI.WebControls.GridViewRowEventArgs e) { if (e.Row.RowType.Equals(DataControlRowType.DataRow)) { UsuarioPagamento usuarioPagamento = (UsuarioPagamento)e.Row.DataItem; if (usuarioPagamento != null && usuarioPagamento.ID > 0) { LinkButton lkblinkSiteBB = (LinkButton)e.Row.FindControl("lkblinkSiteBB"); //Quando INPago = false, ou seja, se o pagamento ainda não foi feito, então exibe o link para o site do Banco do Brasil. if (!usuarioPagamento.PagamentoEfetuado) { if (lkblinkSiteBB != null) { lkblinkSiteBB.CommandArgument = usuarioPagamento.ID.ToString(); lkblinkSiteBB.Visible = true; } else { lkblinkSiteBB.Visible = false; } } else { lkblinkSiteBB.Visible = false; } CheckBox chkInPago = (CheckBox)e.Row.FindControl("chkInPago"); chkInPago.Checked = false; if (usuarioPagamento.PagamentoConfirmado.HasValue && usuarioPagamento.PagamentoConfirmado.Value) { chkInPago.Checked = true; } } } }
public void IncluirPagamentoDoUsuario(Usuario usuario, UsuarioPagamento usuarioPagamento) { BMUsuario bmUsuario = null; using (var scope = new TransactionScope(TransactionScopeOption.Required)) { bmUsuario = new BMUsuario(); //using (var transaction = bmUsuario.repositorio.ObterTransacao()) //{ //Atualiza os dados do usuario bmUsuario.Salvar(usuario); //Insere um novo pagamento para o usuário bmUsuarioPagamento.Salvar(usuarioPagamento); // transaction.Commit(); //} scope.Complete(); } }
public UsuarioPagamento ObterObjetoUsuarioPagamento() { UsuarioPagamento usuarioPagamento = null; //Cadastro de um novo pagamento if (AcaoDaTela.Equals((int)enumAcaoTelaCadastroDeInformarPagamento.NovoPagamento)) { usuarioPagamento = new Dominio.Classes.UsuarioPagamento(); usuarioPagamento.Usuario = new ManterUsuario().ObterUsuarioPorID(this.IdUsuario); } else if (AcaoDaTela.Equals((int)enumAcaoTelaCadastroDeInformarPagamento.EdicaoDePagamento)) { usuarioPagamento = new ManterUsuarioPagamento().ObterInformacoesDePagamentoPorID(this.IdUsuarioPagamento); } if (!string.IsNullOrWhiteSpace(this.DdlInPago.SelectedItem.Value)) { string foiPago = this.DdlInPago.SelectedItem.Value; if (foiPago.ToUpper().Equals("S")) { usuarioPagamento.PagamentoEfetuado = true; } else if (foiPago.ToUpper().Equals("N")) { usuarioPagamento.PagamentoEfetuado = false; } } if (!string.IsNullOrWhiteSpace(this.DdlFormaPagamento.SelectedItem.Value)) { int formaPagamento = int.Parse(this.DdlFormaPagamento.SelectedItem.Value.ToString()); usuarioPagamento.FormaPagamento = (enumFormaPagamento)formaPagamento; } //Configuracao de Pagamento usuarioPagamento.ConfiguracaoPagamento = new ManterConfiguracaoPagamento().ObterConfiguracaoPagamentoPorId(int.Parse(ddlConfigPagto.SelectedItem.Value)); //Data Inicio Vigencia if (!string.IsNullOrWhiteSpace(this.txtDataInicioVigencia.Text)) { DateTime dataInicioVigenciaAux = DateTime.Now; if (!DateTime.TryParse(this.txtDataInicioVigencia.Text, out dataInicioVigenciaAux)) { throw new AcademicoException("Valor inválido para o Campo data Início Vigência"); } else { usuarioPagamento.DataInicioVigencia = dataInicioVigenciaAux; } } //Data Fim Vigencia if (!string.IsNullOrWhiteSpace(this.txtFimVigencia.Text)) { DateTime dataFimVigenciaAux = DateTime.Now; if (!DateTime.TryParse(this.txtFimVigencia.Text, out dataFimVigenciaAux)) { throw new AcademicoException("Valor inválido para o Campo data Fim Vigência"); } else { usuarioPagamento.DataFimVigencia = dataFimVigenciaAux; } } //Valor if (!string.IsNullOrWhiteSpace(this.txtValor.Text)) { Decimal valorPagamento = 0; if (!Decimal.TryParse(this.txtValor.Text, out valorPagamento)) { throw new AcademicoException("Valor inválido para o Campo Valor Pagamento"); } else { usuarioPagamento.ValorPagamento = valorPagamento; } } //Data Inicio Renovação if (!string.IsNullOrWhiteSpace(this.TxtDtInicioRenovacao.Text)) { DateTime dataInicioRenovacaoAux = DateTime.Now; if (!DateTime.TryParse(this.TxtDtInicioRenovacao.Text.Trim(), out dataInicioRenovacaoAux)) { throw new AcademicoException("Valor inválido para o Campo Data de Início de Renovação"); } else { usuarioPagamento.DataInicioRenovacao = dataInicioRenovacaoAux; } } //Data Max Inadimplencia if (!string.IsNullOrWhiteSpace(this.txtDataMaxInadimplencia.Text)) { DateTime dataMaxInadimplenciaAux = DateTime.Now; if (!DateTime.TryParse(this.txtDataMaxInadimplencia.Text, out dataMaxInadimplenciaAux)) { throw new AcademicoException("Valor inválido para o Campo Data Máxima de Inadimplência"); } else { usuarioPagamento.DataMaxInadimplencia = dataMaxInadimplenciaAux; } } if (!string.IsNullOrWhiteSpace(this.TxtDtVencimento.Text)) { DateTime dataVencimentoAux = DateTime.Now; if (!DateTime.TryParse(this.TxtDtVencimento.Text, out dataVencimentoAux)) { throw new AcademicoException("Valor inválido para o Campo Data de Vencimento"); } else { usuarioPagamento.DataVencimento = dataVencimentoAux; } } //Codigo Informacao if (!string.IsNullOrWhiteSpace(this.TxtCodInformacao.Text)) { usuarioPagamento.NossoNumero = this.TxtCodInformacao.Text.Trim(); } //Data Inicio Vigencia if (!string.IsNullOrWhiteSpace(this.DtInicioVigencia)) { DateTime dtInicioVigenciaAux = DateTime.Now; if (!DateTime.TryParse(this.DtInicioVigencia, out dtInicioVigenciaAux)) { throw new AcademicoException("Valor inválido para o Campo Data de Início de Vigência"); } else { usuarioPagamento.DataInicioVigencia = dtInicioVigenciaAux; } } //Data Fim Vigencia if (!string.IsNullOrWhiteSpace(this.DtFimVigencia)) { DateTime dtFimVigenciaAux = DateTime.Now; if (!DateTime.TryParse(this.DtFimVigencia, out dtFimVigenciaAux)) { throw new AcademicoException("Valor inválido para o Campo Data Fim de Vigência"); } else { usuarioPagamento.DataFimVigencia = dtFimVigenciaAux; } } //Data Inicio Renovação if (!string.IsNullOrWhiteSpace(this.DtInicioRenovacao)) { DateTime dtInicioRenovacaoAux = DateTime.Now; if (!DateTime.TryParse(this.TxtDtInicioRenovacao.Text, out dtInicioRenovacaoAux)) { throw new AcademicoException("Valor inválido para o Campo Data de início Renovação"); } else { usuarioPagamento.DataInicioRenovacao = dtInicioRenovacaoAux; } } return(usuarioPagamento); }
/// <summary> /// Grava na tabela a informação que o usuário realizou o pagamento. /// </summary> /// <param name="cpf"></param> /// <param name="nossoNumero">É o campo nosso número no boleto</param> /// <param name="autenticacaoBancaria"></param> /// <param name="dataPagamentoInformado"></param> /// <param name="valorPagamentoInformado"></param> /// <returns></returns> public void RegistrarPagamentoInformado(string cpf, string nossoNumero, string autenticacaoBancaria, string dataPagamentoInformado, string valorPagamentoInformado) { UsuarioPagamento usuarioPagamento = this.ObterInformacoesDePagamentoDoUsuarioPorNossoNumero(nossoNumero); decimal valorPago = 0; //Se não encontrou o pagamento pelo nosso número, exibe mensagem de erro if ((usuarioPagamento == null || (usuarioPagamento != null && usuarioPagamento.ID == 0))) { throw new AcademicoException("Pagamento não encontrado"); } else { //Se ainda não pagou, verifica se o valor a pagar confere com o valor que o usuário esta informando que pagou if (!usuarioPagamento.PagamentoEfetuado) { valorPago = 0; if (!decimal.TryParse(valorPagamentoInformado, out valorPago)) { throw new AcademicoException(string.Format("O valor {0} é inválido para o pagamento", valorPagamentoInformado)); } else { //usuarioPagamento.ValorPagamento -> Valor a pagar //valor pago -> valor informado que foi pago if (!usuarioPagamento.ValorPagamento.Equals(valorPago)) { throw new AcademicoException(string.Format("O valor informado {0} é diferente do valor a ser pago. Valor a ser pago: {1}", valorPago, usuarioPagamento.ValorPagamento)); } else { /* O Valor a pagar é igual ao valor informado que foi pago, então registra (grava) * as informações de pagamento */ if (string.IsNullOrWhiteSpace(cpf)) { throw new AcademicoException("O CPF informado é inválido"); } if (!usuarioPagamento.Usuario.CPF.Equals(Regex.Replace(cpf.Trim(), @"\D", "").ToString())) { throw new AcademicoException("O CPF informado não corresponde ao do boleto"); } DateTime dataPagamentoInformadoAux = DateTime.Now; if (!DateTime.TryParse(dataPagamentoInformado, out dataPagamentoInformadoAux)) { throw new AcademicoException(string.Format("O valor {0} é inválido para a data informada para pagamento", dataPagamentoInformado)); } else { //Se conseguiu fazer o parse na data de pagamento, verifica se o usuário informou a data igual a 01/01/1900 if (dataPagamentoInformadoAux.Equals(DateTime.MinValue)) { throw new AcademicoException(String.Format("O valor {0} é inválido para a data informada para pagamento", dataPagamentoInformadoAux)); } } this.usuarioPagamentoBM.RegistrarPagamentoInformado(usuarioPagamento, dataPagamentoInformadoAux, autenticacaoBancaria, valorPago); } } } else { throw new AcademicoException("Pagamento não encontrado"); } } }
private void InformarPagamento(int idUsuario, String Nome, String Endereco, String Cidade, String Cep, Uf UF) { //throw new NotImplementedException(); //Forma de passagem de parametros por "POST" { string idconv = "311620"; string qtdPontos = "0"; string tpPagamento = "0"; DateTime?DataVigencia; DateTime?DataMaxVigencia; DateTime?DataInicioRenovacao; DateTime?DataInicioVigencia; DateTime?DataFimVigencia; DateTime?DataMaxInadimplencia; string Dia, Mes, Ano; int dia, mes, ano; Uf ufAlfaNumerica; string xscript = "document.forms[0].enctype='application/x-www-form-urlencoded'; document.forms[0].action='https://www16.bancodobrasil.com.br/site/mpag/';" + "document.forms[0].target='_blank';" + "document.forms[0].submit();" + "document.forms[0].action='GerenciadorPagamentoCnab643.aspx';" + "document.forms[0].target='_self';"; ClientScript.RegisterHiddenField("idConv", idconv); ClientScript.RegisterHiddenField("refTran", this.ucInformarPagamento1.codInformacao.ToString()); ClientScript.RegisterHiddenField("valor", this.ucInformarPagamento1.valor.ToString()); ClientScript.RegisterHiddenField("qtdPontos", qtdPontos); DataMaxVigencia = CommonHelper.TratarData(this.ucInformarPagamento1.DtMaxInadimplencia.ToString(), "Data Máxima de Inadimplência"); DataInicioRenovacao = CommonHelper.TratarData(this.ucInformarPagamento1.DtInicioRenovacao.ToString(), "Data Inicio Renovação"); DataInicioVigencia = CommonHelper.TratarData(this.ucInformarPagamento1.DtInicioVigencia.ToString(), "Data Início Vigência"); DataFimVigencia = CommonHelper.TratarData(this.ucInformarPagamento1.DtFimVigencia.ToString(), "Data Fim Vigência"); DataMaxInadimplencia = CommonHelper.TratarData(this.ucInformarPagamento1.DtMaxInadimplencia.ToString(), "Data Max Inadimplência"); DataVigencia = CommonHelper.TratarData(this.ucInformarPagamento1.DtInicioVigencia.ToString(), "Data de Início"); dia = Convert.ToDateTime(DataVigencia).Day; if (dia <= 9) { Dia = "0" + dia; } else { Dia = dia.ToString(); } mes = Convert.ToDateTime(DataVigencia).Month; if (mes <= 9) { Mes = "0" + mes; } else { Mes = mes.ToString(); } ano = Convert.ToDateTime(DataVigencia).Year; Ano = ano.ToString(); ClientScript.RegisterHiddenField("dtVenc", Dia + Mes + Ano); ClientScript.RegisterHiddenField("tpPagamento", tpPagamento); ClientScript.RegisterHiddenField("urlRetorno", "http://www5.fgv.br/fgvonline/universidadecorporativasebrae/inicial.aspx"); ClientScript.RegisterHiddenField("nome", Nome); ClientScript.RegisterHiddenField("endereco", Endereco); ClientScript.RegisterHiddenField("cidade", Cidade); //Pega a UF a partir do código da UF ManterUf manterUf = new ManterUf(); ufAlfaNumerica = manterUf.ObterUfPorID(UF.ID); ClientScript.RegisterHiddenField("uf", ufAlfaNumerica.Sigla); ClientScript.RegisterHiddenField("cep", Cep); ClientScript.RegisterHiddenField("msgLoja", ""); ClientScript.RegisterStartupScript(this.GetType(), "jsenviar", xscript, true); //Inserir aqui a gravação de um registro na tabela TB_UsuarioPagamento campos IN_Pago com 1 e DT_Pagamento ManterUsuarioPagamento manterUsuarioPagamento = new ManterUsuarioPagamento(); classes.UsuarioPagamento usuarioPagamento = new UsuarioPagamento(); //Cadastra dados dos pagamentos usuarioPagamento.Usuario = new ManterUsuario().ObterUsuarioPorID(idUsuario); usuarioPagamento.ConfiguracaoPagamento = new ManterConfiguracaoPagamento().ObterConfiguracaoPagamentoPorId(int.Parse(this.ddlConfigPagto.SelectedValue)); usuarioPagamento.DataInicioVigencia = DateTime.Parse(this.ucInformarPagamento1.DtInicioVigencia); usuarioPagamento.DataFimVigencia = DateTime.Parse(this.ucInformarPagamento1.DtFimVigencia); usuarioPagamento.ValorPagamento = decimal.Parse(this.ucInformarPagamento1.valor.ToString()); usuarioPagamento.DataInicioRenovacao = DateTime.Parse(this.ucInformarPagamento1.DtInicioRenovacao); usuarioPagamento.DataMaxInadimplencia = DateTime.Now.AddDays(368); usuarioPagamento.NossoNumero = this.ucInformarPagamento1.codInformacao.ToString(); usuarioPagamento.PagamentoEfetuado = false; usuarioPagamento.FormaPagamento = this.ucInformarPagamento1.codFormaPagamento; manterUsuarioPagamento.IncluirUsuarioPagamento(usuarioPagamento); } }
private void CalcularInformacoes(ConfiguracaoPagamento configuracaoPagamento, UsuarioPagamento usuarioPagamento) { //Calcular data Fim de vigência usuarioPagamento.DataFimVigenciaCalculada = configuracaoPagamento.DataInicioCompetencia.AddDays(configuracaoPagamento.QuantidadeDiasValidade); //Data de Inicio da Renovacao usuarioPagamento.DataInicioRenovacaoCalculada = configuracaoPagamento.DataFimCompetencia.AddDays(-configuracaoPagamento.QuantidadeDiasRenovacao); //Data Máxima de Inadimplência usuarioPagamento.DataMaxInadimplenciaCalculada = configuracaoPagamento.DataFimCompetencia.AddDays(configuracaoPagamento.QuantidadeDiasInadimplencia); //Data Vencimento usuarioPagamento.DataVencimentoCalculada = configuracaoPagamento.DataInicioCompetencia.AddDays(configuracaoPagamento.QuantidadeDiasPagamento); }
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 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; } }