public async Task <IActionResult> Edit(int id, [Bind("id_parc,parcelas,dt_vencimento,dt_pagamento,valor")] VendaParcela vendaParcela) { if (id != vendaParcela.id_parc) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(vendaParcela); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!VendaParcelaExists(vendaParcela.id_parc)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(vendaParcela)); }
public async Task <IActionResult> Edit(int id, [Bind("id_servHist,servicosId,oqfoialterado,dtAlteracao")] ServicoHistoricoModelView servicoHistoricoView) { if (id != servicoHistoricoView.id_servHist) { return(NotFound()); } if (ModelState.IsValid) { try{ var shmv = new ServicoHistorico(); shmv.oqfoialterado = servicoHistoricoView.oqfoialterado; shmv.id_servHist = id; shmv.dtAlteracao = DateTime.Now; int IdServ = 0; int.TryParse(servicoHistoricoView.servicosId, out IdServ); shmv.servicos = _context.Servicos.Where(w => w.id_serv == IdServ).FirstOrDefault(); _context.Update(shmv); await _context.SaveChangesAsync(); }catch (DbUpdateConcurrencyException) { if (!ServicoHistoricoExists(servicoHistoricoView.id_servHist)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } CarregarListaServicos(); return(View(servicoHistoricoView)); }
public async Task <IActionResult> Edit(int id, [Bind("id_serv,nome_serv,valor_serv")] Servico servico) { if (id != servico.id_serv) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(servico); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ServicoExists(servico.id_serv)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(servico)); }
public async Task <IActionResult> Edit(int id, [Bind("id_tpPag,nome_tpPag")] TipoPagamento tipoPagamento) { if (id != tipoPagamento.id_tpPag) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(tipoPagamento); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TipoPagamentoExists(tipoPagamento.id_tpPag)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(tipoPagamento)); }
public async Task <IActionResult> Edit(int id, [Bind("id_vend,nome_vend,ativo")] Vendedor vendedor) { if (id != vendedor.id_vend) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(vendedor); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!VendedorExists(vendedor.id_vend)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(vendedor)); }
public async Task <IActionResult> Edit(int id, [Bind("id_cli,nome_cli,contato_cli,contato_cli2,dataCad_cli")] Cliente cliente) { if (id != cliente.id_cli) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(cliente); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ClienteExists(cliente.id_cli)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(cliente)); }
public async Task <IActionResult> Edit(int id, [Bind("id_neg, ServicoId, VendedorId, min_porcent,max_porcent")] TabelaNgociacoesViewModel tabelaNegociacao) { if (id != tabelaNegociacao.id_neg) { return(NotFound()); } if (ModelState.IsValid) { try { var tn = new TabelaNegociacao(); tn.id_neg = id; int IdServ = 0; int.TryParse(tabelaNegociacao.ServicoId, out IdServ); tn.servicos = _context.Servicos.Where(w => w.id_serv == IdServ).FirstOrDefault(); int IdVendedor = 0; int.TryParse(tabelaNegociacao.VendedorId, out IdVendedor); tn.vendedores = _context.Vendederores.Where(w => w.id_vend == IdVendedor).FirstOrDefault(); tn.min_porcent = tabelaNegociacao.min_porcent; tn.max_porcent = tabelaNegociacao.max_porcent; _context.Update(tn); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TabelaNegociacaoExists(tabelaNegociacao.id_neg)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } CarregaServico(); CarregaVendedores(); return(View(tabelaNegociacao)); }
public async Task <IActionResult> Edit(int id, [Bind("id_venda,dataVenda,valor,parcelas,tipoPagamentoId,servicosId,vendedoresId,clientesId, tabelaNegociacaoId")] TipoPagamentosModel vendaModel) { if (id != vendaModel.id_venda) { return(NotFound()); } if (ModelState.IsValid) { try{ var tpg = new Venda(); var tn = new TabelaNegociacao(); tpg.dataVenda = vendaModel.dataVenda; tpg.id_venda = id; tpg.valor = vendaModel.valor; tpg.parcelas = vendaModel.parcelas; int idPag = 0; int.TryParse(vendaModel.tipoPagamentoId, out idPag); tpg.tipoPagamento = _context.TiposPagamento.Where(w => w.id_tpPag == idPag).FirstOrDefault(); int IdServ = 0; int.TryParse(vendaModel.servicosId, out IdServ); tpg.servicos = _context.Servicos.Where(w => w.id_serv == IdServ).FirstOrDefault(); int IdVendedor = 0; int.TryParse(vendaModel.vendedoresId, out IdVendedor); tpg.vendedores = _context.Vendederores.Where(w => w.id_vend == IdVendedor).FirstOrDefault(); int IdCliente = 0; int.TryParse(vendaModel.clientesId, out IdCliente); tpg.clientes = _context.Clientes.Where(w => w.id_cli == IdCliente).FirstOrDefault(); var tbPreco = _context.TabelasNegociacao.Where(w => w.servicos.id_serv == IdServ && w.vendedores.id_vend == IdVendedor).FirstOrDefault(); // condições de verificação. if (tbPreco == null || tbPreco.min_porcent > vendaModel.valor || tbPreco.max_porcent < vendaModel.valor) { //TempData[]"Message" = "Valor mais Baixo ou mais Alto que o valor minimo ou maximo permitido"; return(RedirectToAction("Index")); } _context.Update(tpg); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!VendaExists(vendaModel.id_venda)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } CarregarListaClientes(); CarregarListaVendedores(); CarregarListaServicos(); CarregarListaTpPagamentos(); return(View(vendaModel)); }