示例#1
0
        public void TestMethod1()
        {
            Taxa taxa = null;

            taxa = new TaxaDAO().PesquisarPorTaxa(1);
            Assert.IsNotNull(taxa);
        }
        protected void btnSimular_Click(object sender, EventArgs e)
        {
            lblAviso.Text = "";

            double valorDesejado, valorParcela, valorTotal;
            int    parcelas;

            Taxa taxa = new TaxaDAO().PesquisarPorTaxa(EmprestimoOPS.VerificarPerfil(cc)); //obtem taxa atraves do perfil da pessoa

            if (Double.TryParse(txtValor.Text, out valorDesejado) && Int32.TryParse(txtParcelas.Text, out parcelas))
            {
                divSimulacao.Visible = true;

                valorParcela = EmprestimoOPS.CalcularParcelas(parcelas, taxa, valorDesejado); //calcula valor das parcelas
                valorTotal   = valorParcela * parcelas;

                lblParcelas.Text   = parcelas.ToString();
                lblValor.Text      = "R$ " + valorParcela.ToString("0.00");
                lblValorTotal.Text = "R$" + valorTotal.ToString("0.00");
                lblTaxa.Text       = taxa.Valor + "%";
            }
            else
            {
                lblAviso.Text = "Dados incorretos!";
            }
        }
        protected void btnRealizar_Click(object sender, EventArgs e)
        {
            float valorDesejado;
            int   parcelas;

            Taxa taxa = new TaxaDAO().PesquisarPorTaxa(1);

            string tipoPagamento = rblPagamento.SelectedValue;

            if (float.TryParse(txtValor.Text, out valorDesejado) && Int32.TryParse(txtParcelas.Text, out parcelas))
            {
                Emprestimo emprestimo = new Emprestimo()
                {
                    Valor         = valorDesejado,
                    Parcelas      = parcelas,
                    ContaCorrente = cc,
                    Taxa          = taxa,
                    DataInicio    = DateTime.Parse(txtDataPrimeiroVencimento.Text),
                };

                EmprestimoDAO empDAO = new EmprestimoDAO();
                //if(empDAO.InserirEmprestimo(emprestimo, tipoPagamento){

                lblAviso.Text = "Emprestimo Realizado";
                //atualizar saldo da conta corrente

                lblResultado.Text = "Empréstimo Realizado com Sucesso!";
                //}
            }
            else
            {
                lblAviso.Text = "Dados incorretos!";
            }
        }
示例#4
0
        private void PopularMenuDD()
        {
            TaxaDAO     taxaDao = new TaxaDAO();
            List <Taxa> lTaxas  = taxaDao.BuscarTodasTaxas();

            ddlInvTax.DataSource     = lTaxas;
            ddlInvTax.DataTextField  = "Nome";
            ddlInvTax.DataValueField = "Id";
            ddlInvTax.DataBind();
        }
示例#5
0
        protected void btnRealizar_Click(object sender, EventArgs e)
        {
            float valorDesejado;
            int   parcelas;


            string tipoPagamento = rblPagamento.SelectedValue;

            if (!DateTime.TryParse(txtDataPrimeiroVencimento.Text, out data))
            {   //verifica data
                lblAviso.Text        = "Escolha uma data válida!";
                divSimulacao.Visible = false;
            }
            else if (float.TryParse(txtValor.Text, NumberStyles.Any, CultureInfo.InvariantCulture.NumberFormat, out valorDesejado) && Int32.TryParse(txtParcelas.Text, out parcelas) && dataMinima <= data && dataMaxima >= data && parcelas > 0)
            {
                if (valorDesejado > cc.Limite)
                {
                    lblAviso.Text = "Valor é superior ao limite disponível em sua conta!";
                }
                else if (valorDesejado > 0)
                {
                    Taxa taxa = new TaxaDAO().PesquisarPorTaxa(EmprestimoOPS.VerificarPerfil(cc)); //obtem taxa atraves do perfil da pessoa

                    Emprestimo emprestimo = new Emprestimo()
                    {
                        Valor         = valorDesejado,
                        Parcelas      = parcelas,
                        ContaCorrente = cc,
                        Taxa          = taxa,
                        DataInicio    = data,
                    };

                    EmprestimoDAO empDAO = new EmprestimoDAO();
                    if (empDAO.InserirEmprestimo(emprestimo, tipoPagamento))
                    {
                        lblResultado.Text      = "Empréstimo Realizado com Sucesso!";
                        divResultado.Visible   = true;
                        divRealizarBtn.Visible = false;
                    }
                }
                else
                {
                    divSimulacao.Visible = false;
                    lblAviso.Text        = "Valor precisa ser maior que zero!";
                }
            }
            else
            {
                divSimulacao.Visible = false;
                lblAviso.Text        = "Dados incorretos!";
            }
        }
示例#6
0
        protected void btnSimular_Click(object sender, EventArgs e)
        {
            lblAviso.Text = "";

            double valorDesejado, valorParcela, valorTotal;
            int    parcelas;


            if (!DateTime.TryParse(txtDataPrimeiroVencimento.Text, out data))
            {   //verifica data
                lblAviso.Text        = "Escolha uma data válida!";
                divSimulacao.Visible = false;
            }
            else if (Double.TryParse(txtValor.Text, NumberStyles.Any, CultureInfo.InvariantCulture.NumberFormat, out valorDesejado) &&
                     Int32.TryParse(txtParcelas.Text, out parcelas) && dataMinima <= data && dataMaxima >= data)

            {
                if (valorDesejado > cc.Limite)
                {
                    lblAviso.Text = "Valor é superior ao limite disponível em sua conta!";
                }

                else if (valorDesejado > 0)
                {
                    divSimulacao.Visible   = true;
                    divRealizarBtn.Visible = true;

                    Taxa taxa = new TaxaDAO().PesquisarPorTaxa(EmprestimoOPS.VerificarPerfil(cc)); //obtem taxa atraves do perfil da pessoa

                    valorParcela = EmprestimoOPS.CalcularParcelas(parcelas, taxa, valorDesejado);  //calcula valor das parcelas
                    valorTotal   = valorParcela * parcelas;

                    lblParcelas.Text   = parcelas.ToString();
                    lblValor.Text      = valorParcela.ToString("c2");
                    lblValorTotal.Text = valorTotal.ToString("c2");
                    lblTaxa.Text       = taxa.Valor.ToString("F") + " % a.m.";
                }
                else
                {
                    divSimulacao.Visible = false;
                    lblAviso.Text        = "Valor precisa ser maior que zero!";
                }
            }
            else
            {
                divSimulacao.Visible = false;
                lblAviso.Text        = "Dados incorretos!";
            }
        }
示例#7
0
        protected void btnSal_Click(object sender, EventArgs e)
        {
            try
            {
                TaxaDAO taxaDao       = new TaxaDAO();
                string  nome          = txtInvNom.Text;
                double  rentabilidade = 0;
                Taxa    taxa          = taxaDao.PesquisarPorTaxa(int.Parse(ddlInvTax.SelectedValue));
                int     id            = idSelecionado;

                if (txtInvRen.Text.Length > 0)
                {
                    rentabilidade = Double.Parse(txtInvRen.Text);
                }
                InvestimentoDAO investimentoDao = new InvestimentoDAO();

                Investimento investimento = new Investimento()
                {
                    Id            = id,
                    Nome          = nome,
                    Taxa          = taxa,
                    Rentabilidade = rentabilidade
                };

                investimento = investimentoDao.EditarInvestimento(investimento);


                if (investimento != null)
                {
                    lblRes.Text = "Investimento alterado com sucesso!";
                    LimpaCampos();
                    PopularGrid();
                }
                else
                {
                    lblRes.Text = "Falha ao alterar investimento!";
                }
                divRes.Visible = true;
            }
            catch (Exception exp)
            {
                lblRes.Text = "Erro!";
            }
        }
示例#8
0
        protected void btnCad_Click(object sender, EventArgs e)
        {
            try
            {
                TaxaDAO taxaDao       = new TaxaDAO();
                string  nome          = txtInvNom.Text;
                double  rentabilidade = 0;
                Taxa    taxa          = new TaxaDAO().PesquisarPorTaxa(int.Parse(ddlInvTax.SelectedValue));
                if (txtInvRen.Text.Length > 0)
                {
                    rentabilidade = Double.Parse(txtInvRen.Text);
                }
                InvestimentoDAO investimentoDao = new InvestimentoDAO();

                Investimento investimento = new Investimento()
                {
                    Nome          = nome,
                    Taxa          = taxa,
                    Rentabilidade = rentabilidade
                };

                investimento = investimentoDao.CadastrarInvestimento(investimento);

                if (investimento != null)
                {
                    lblRes.Text = "Inserção realizada com sucesso";
                    LimpaCampos();
                    PopularGrid();
                }
                else
                {
                    lblRes.Text = "Erro na inserção.";
                }
                divRes.Visible = true;
            }

            catch (Exception)
            {
                lblRes.Text    = "Investimento já existente";
                divRes.Visible = true;
            }
        }