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!"; } }
private void Atualizar(object sender, RoutedEventArgs e) { if (!dataDevolucao.SelectedDate.HasValue) { MessageBox.Show("Necessário preencher uma data de devolução"); return; } Emprestimo emp = EmprestimoDAO.BuscarEmprestimo(Convert.ToInt32(id.Text)); emp.DataDevolucao = dataDevolucao.SelectedDate; emp.StatusDoEmprestimo = true; var retorno = EmprestimoDAO.Atualizar(emp); if (retorno) { MessageBox.Show("Empréstimo atualizado"); LimparFormulario(); btnCadastrar.Visibility = Visibility.Visible; btnAtualizar.Visibility = Visibility.Hidden; dataDevolucao.Visibility = Visibility.Hidden; lbDtDevolucao.Visibility = Visibility.Hidden; CarregarEmprestimos(); } else { MessageBox.Show("Empréstimo não atualizado"); } }
public Menu() { InitializeComponent(); List <Emprestimo> emprestimos = EmprestimoDAO.ListarNumeroDeEmprestimos(); tabelaEmprestimos.ItemsSource = emprestimos; }
public void ConsultarEmprestimoIdTeste() { Emprestimo emprestimo = new EmprestimoDAO().PesquisarEmprestimoPorId(1); Console.Write(emprestimo); Assert.IsNotNull(emprestimo); }
public void PopularGrid() { EmprestimoDAO empDao = new EmprestimoDAO(); DataTable dTable = empDao.PesquisarEmprestimosContaCorrenteComTaxa(cc); dTable.Columns.Add("Pagamento_tipo", typeof(String)); dTable.Columns.Add("Emprestimo_Inicio_Formatado", typeof(String)); dTable.Columns.Add("Emprestimo_Valor_Formatado", typeof(String)); PagamentoDAO pagDAO = new PagamentoDAO(); foreach (DataRow row in dTable.Rows) { row["Pagamento_tipo"] = pagDAO.TipoPagamentoEmprestimo(new Emprestimo() { Id = Convert.ToInt32(row["Emprestimo_id"].ToString()) }); DateTime data = Convert.ToDateTime(row["Emprestimo_Inicio"]); row["Emprestimo_Inicio_Formatado"] = data.ToString("dd/MM/yyyy"); row["Emprestimo_Valor_Formatado"] = Convert.ToDouble(row["Emprestimo_Valor"]).ToString("c2"); } gdvEmprestimos.DataSource = dTable; gdvEmprestimos.DataBind(); }
private void Cadastrar(object sender, RoutedEventArgs e) { Emprestimo emp = new Emprestimo(); emp.DataEmprestimo = dataEmprestimo.SelectedDate; emp.DataPrevistaDevolucao = dataPrevDevol.SelectedDate; Pessoa p = PessoaDAO.ObterPessoa(Convert.ToInt32(cboOperador.SelectedValue)); emp.Operador = p; Pessoa pe = PessoaDAO.ObterPessoa(Convert.ToInt32(cboUsuario.SelectedValue)); emp.Usuario = pe; emp.Equipamentos = list; if (EmprestimoDAO.CadastrarEmprestimo(emp)) { MessageBox.Show("Empréstimo realizado com sucesso!"); CarregarEmprestimos(); LimparFormulario(); } else { MessageBox.Show("Empréstimo não realizado"); } }
public static void Executar() { Emprestimo empres = new Emprestimo(); Console.WriteLine("Qual o nome do livro que deseja emprestar?"); empres.NomeLivroEmprestado.NomeLivro = Console.ReadLine(); if (LivroDAO.BuscarNomeLivro(empres.NomeLivroEmprestado) != null) { Console.WriteLine("Livro Emprestado com sucesso!"); Console.WriteLine("Aperte algum botão para continuar a operação!"); Console.ReadKey(); Console.Clear(); Console.WriteLine("Qual o nome do cliente?"); empres.NomeClienteEmprestado.Nome = Console.ReadLine(); if (ClienteDAO.BuscarClientePorNome(empres.NomeClienteEmprestado) != null) { Console.WriteLine("Cliente encontrado na base com sucesso!"); empres.DataEmprestimo = DateTime.Now; EmprestimoDAO.Cadastrar(empres); } else { Console.WriteLine("Por favor, cadastrar o cliente"); } } else { Console.WriteLine("Erro ao realizar o emprestimo, esse livro não está emprestado!"); } Console.WriteLine("Pressione algum botão para voltar ao Menu anterior!"); Console.ReadKey(); }
public void TestMethodEmprestimoDAOBoleto() { EmprestimoDAO empDAO = new EmprestimoDAO(); PessoaDAO dao = new PessoaDAO(); Pessoa p = dao.PesquisaPessoaPorId(2); ContaCorrente cli1 = new ContaCorrente { Numero = 4, Saldo = 0.0, Limite = 0.0f, Pessoa = p, Emprestimos = null, Investimentos = null }; Taxa taxa = new Taxa() { Id = 1, Valor = 10 }; Emprestimo emprestimo = new Emprestimo() { Valor = 2000, Parcelas = 10, ContaCorrente = cli1, Taxa = taxa, DataInicio = DateTime.Now }; Assert.AreEqual(true, empDAO.InserirEmprestimo(emprestimo, "boleto")); }
public void ConsultarTipoEmprestimo() { Emprestimo emprestimo = new EmprestimoDAO().PesquisarEmprestimoPorId(5); Console.WriteLine(new PagamentoDAO().BuscarPagamentosPorEmprestimo(emprestimo)[0]); String tipo = new PagamentoDAO().TipoPagamentoEmprestimo(emprestimo); Console.Write(tipo); }
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!"; } }
// GET: Emprestimos/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Emprestimo emprestimo = EmprestimoDAO.BuscarEmprestimoPorId(id); if (emprestimo == null) { return(HttpNotFound()); } return(View("Darbaixa", emprestimo)); }
public ActionResult Edit([Bind(Include = "id,valor")] Emprestimo emprestimo, int status, DateTime dataDevolucao) { double novoValor = emprestimo.valor; emprestimo = EmprestimoDAO.BuscarEmprestimoPorId(emprestimo.id); emprestimo.valor = novoValor; emprestimo.status = status; emprestimo.dataDevolucao = Convert.ToString(dataDevolucao); if (ModelState.IsValid) { EmprestimoDAO.EditarEmprestimo(emprestimo); return(RedirectToAction("Index")); } return(View(emprestimo)); }
private void Pesquisar(object sender, RoutedEventArgs e) { int?idUsuario = Convert.ToInt32(cboUsuario.SelectedValue); if (idUsuario == 0) { idUsuario = null; } int?idOperador = Convert.ToInt32(cboOperador.SelectedValue); if (idOperador == 0) { idOperador = null; } int?idEquipamento = Convert.ToInt32(cboEquipamento.SelectedValue); if (idEquipamento == 0) { idEquipamento = null; } DateTime?dataInicio = dtInicio.SelectedDate; DateTime?dataFim = dtFim.SelectedDate; DateTime?dataInicioDevolucao = dtIniDev.SelectedDate; DateTime?dataFimDevolucao = dtFimDev.SelectedDate; bool apenasAtrasados = false; if (checkApenasAtrasados.IsChecked == true) { apenasAtrasados = true; } bool excluirDevolvidos = false; if (checkExcluirDevolvidos.IsChecked == true) { excluirDevolvidos = true; } List <Emprestimo> emprestimos = EmprestimoDAO.ListarComParametros(idUsuario, idOperador, dataInicio, dataFim, dataInicioDevolucao, dataFimDevolucao, idEquipamento, apenasAtrasados, excluirDevolvidos); tabelaEmprestimos.ItemsSource = emprestimos; }
protected void gdvEmprestimos_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName.Equals("Ver")) { EmprestimoDAO empDao = new EmprestimoDAO(); Session["emprestimo"] = empDao.PesquisarEmprestimoPorId(Convert.ToInt32(e.CommandArgument.ToString())); GridViewRow clickedRow = ((LinkButton)e.CommandSource).NamingContainer as GridViewRow; Label lblPagamento = (Label)clickedRow.FindControl("lblPagamento"); if (lblPagamento.Text.Equals("Débito em Conta")) { Session["tipoPagamento"] = "Débito em Conta"; Response.Redirect("~/Views/vwsVisualizarPagamentoEmprestimo.aspx"); } else if (lblPagamento.Text.Equals("Boleto")) { Session["tipoPagamento"] = "Boleto"; Response.Redirect("~/Views/vwsVisualizarPagamentoEmprestimo.aspx"); } } }
public ActionResult Create([Bind(Include = "id,livro,valor,cep,endereco")] Emprestimo emprestimo, long matricula, string nome, DateTime dataPrazo) { string url = "https://viacep.com.br/ws/" + emprestimo.cep + "/json/"; WebClient client = new WebClient(); try { Emprestimo aux = new Emprestimo(); string resultado = client.DownloadString(@url); //Converter para UTF8 byte[] bytes = Encoding.Default.GetBytes(resultado); resultado = Encoding.UTF8.GetString(bytes); //Converter os dados da string em objeto aux = JsonConvert.DeserializeObject <Emprestimo>(resultado); emprestimo.endereco = aux.Logradouro + emprestimo.endereco; emprestimo.Bairro = aux.Bairro; emprestimo.Localidade = aux.Localidade; emprestimo.Uf = aux.Uf; emprestimo.Logradouro = aux.Logradouro; } catch { emprestimo.cep = "Cep Inválido"; } emprestimo.status = 0; emprestimo.nome = nome; emprestimo.bibliotecario = BibliotecarioDAO.BuscarBibliotecarioPorMatricula(matricula); if (ModelState.IsValid) { emprestimo.livro.ano = DateTime.Now; emprestimo.dataDevolucao = "26/04/2000 00:00:00"; emprestimo.dataPrazo = Convert.ToString(dataPrazo); EmprestimoDAO.CadastrarEmprestimo(emprestimo); return(RedirectToAction("Index")); } return(View(emprestimo)); }
public EmprestimoRepository(IConfiguration configuration) : base(configuration) { emprestimoDAO = new DAO.EmprestimoDAO(configuration); }
public void alterar() { EmprestimoDAO altera = new EmprestimoDAO(); altera.Update(this); }
public void Salva() { EmprestimoDAO salva = new EmprestimoDAO(); salva.Insert(this); }
// GET: Emprestimos public ActionResult Index() { return(View(EmprestimoDAO.RetonarEmprestimos(User.Identity.Name))); }
public ActionResult Delete(int id) { EmprestimoDAO.RemoverEmprestimo(id); return(RedirectToAction("Index")); }
public void Excluir() { EmprestimoDAO Excluir = new EmprestimoDAO(); Excluir.Delete(this); }
public void ConsultaEmprestimoTaxaTeste() { var table = new EmprestimoDAO().PesquisarEmprestimosContaCorrenteComTaxa(new ContaDAO().PesquisarContaPorNumero(3) as ContaCorrente); Assert.AreEqual(6, table.Rows.Count); }
public void novo() { EmprestimoDAO novo = new EmprestimoDAO(); novo.Insert(this); }
private void CarregarEmprestimos() { List <Emprestimo> emprestimos = EmprestimoDAO.ListarEmprestimosComEquipamentoUsuarioOperador(); tabelaEmprestimos.ItemsSource = emprestimos; }