// GET: ClienteController/Edit/5 public ActionResult EditCliente(int id) { RepoCliente repoCliente = new RepoCliente(); ClienteViewModel Nuevo = _mapper.Map <ClienteViewModel>(repoCliente.GetCliente(id)); return(View(Nuevo)); }
private void btn_altaCredito_Click(object sender, EventArgs e) { if (txt_monto.Text != "" && cmb_TipoPago.Text != "") { long monto; long tarjetaNum; String tarjeta = txt_tarjeta.Text; bool montoEsNumerico; montoEsNumerico = long.TryParse(txt_monto.Text, out monto); bool tarjetaEsNumerica; tarjetaEsNumerica = long.TryParse(txt_tarjeta.Text, out tarjetaNum); string tipoPago = ""; if (montoEsNumerico) { switch (cmb_TipoPago.Text) { case "Efectivo": tipoPago = "E"; tarjeta = "0"; break; case "Credito": if (tarjetaEsNumerica) { tipoPago = "C"; } else { MessageBox.Show("Tarjeta no numerica"); return; } break; case "Debito": if (tarjetaEsNumerica) { tipoPago = "D"; } else { MessageBox.Show("Tarjeta no numerica"); return; } break; } RepoCliente.instance().cargarCredito(tipoPago, long.Parse(tarjeta), monto, currentUserID); } else { MessageBox.Show("Los campos monto y/o tarjeta no son validos"); } } else { MessageBox.Show("Todos los campos deben tener informacion"); } }
// GET: ClienteController public ActionResult Index() { RepoCliente repoCliente = new RepoCliente(); var listaClientes = repoCliente.GetAll(); List <ClienteViewModel> ListClienteVM = _mapper.Map <List <ClienteViewModel> >(listaClientes); return(View(ListClienteVM)); }
//// GET: Locacoes/Details/5 //public ActionResult Details(int? id) //{ // if (id == null) // { // return new HttpStatusCodeResult(HttpStatusCode.BadRequest); // } // Locacao locacao = db.Locacoes.Find(id); // if (locacao == null) // { // return HttpNotFound(); // } // return View(locacao); //} // GET: Locacoes/Create public ActionResult Create() { IRepoCliente repo_cliente = new RepoCliente(); IRepoVeiculo repo_veic = new RepoVeiculo(); Locacao_vm loc_vm = new Locacao_vm(); loc_vm.Cliente = new SelectList(repo_cliente.LerTodosCliente(), "ClienteId", "Nome"); loc_vm.Veiculo = new SelectList(repo_veic.LerTodosVeiculo(), "VeiculoId", "Placa"); return(View(loc_vm)); }
public void deshabilitarCliente(String clie_id) { try { RepoCliente.instance().deshabilitarCliente(clie_id); MessageBox.Show("Cliente Deshabilitado Correctamente"); } catch (Exception ex) { MessageBox.Show("Error al deshabilitar Cliente \n" + ex.Message); } }
public virtual void Execute(RepoCliente repoCliente, Cliente cliente) { try { repoCliente.InsertCliente(cliente); MessageBox.Show(Messages.OPERACION_EXITOSA); } catch (Exception) { MessageBox.Show(Messages.ERROR_INESPERADO); } }
public void habilitarProveedor(string p) { try { RepoCliente.instance().habilitarProveedor(p); MessageBox.Show("Proveedor Habilitado Correctamente"); } catch (Exception ex) { MessageBox.Show("Error al habilitar Proveedor \n" + ex.Message); } }
// GET: PedidoController/Create public IActionResult AltaPedido() { var repoCliente = new RepoCliente(); var repoCadete = new RepoCadetes(); var PedidoViewModel = new PedidoViewModel { listadoDeCadetes = _mapper.Map <List <CadeteViewModel> >(repoCadete.GetAll()), listadoDeClientes = _mapper.Map <List <ClienteViewModel> >(repoCliente.GetAll()) }; return(View(PedidoViewModel)); }
public void modificarCliente(String clie_id, String nombre, String apellido, String dni, String mail, String telefono, String saldo, String direccion, String ciudad, String codPostal, String fechaNac) { try { Cliente nuevoCliente = new Cliente(-1, nombre, apellido, Convert.ToInt64(dni), -1, mail, telefono, direccion, Convert.ToDouble(saldo), Convert.ToInt32(codPostal), ciudad, Convert.ToDateTime(fechaNac)); RepoCliente.instance().modificarCliente(clie_id, nuevoCliente); MessageBox.Show("Cliente Modificado Correctamente"); } catch (Exception ex) { MessageBox.Show("Error al modificar Cliente \n" + ex.Message); } }
public override void Execute(RepoCliente repoCliente, Cliente cliente) { try { repoCliente.InsertCliente(cliente); MessageBox.Show(Messages.OPERACION_EXITOSA); MessageBox.Show("Los datos autogenerados para el login son:\nUsername: "******"\nPassword: "******"Info"); } catch (Exception) { MessageBox.Show(Messages.ERROR_INESPERADO); } }
public ActionResult Borrar(int id) { try { RepoCliente repoCliente = new RepoCliente(); repoCliente.EliminarCliente(id); } catch { throw; } // listaClientes.RemoveAll(t => t.Id == id); return(RedirectToAction("Index")); }
private void Comprar_Load(object sender, EventArgs e) { this.dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect; this.dataGridView1.MultiSelect = false; var bindingList = new BindingList <Oferta>(RepoOferta.instance().traerOfertasDisponibles()); var source = new BindingSource(bindingList, null); dataGridView1.DataSource = source; saldo = RepoCliente.instance().traerSaldo(currentUserID); /* listBox1.DisplayMember = "ofer_descripcion"; * listBox1.ValueMember = "ofer_id"; */ }
private void btn_comprar_Click(object sender, EventArgs e) { int selectedrowindex = dataGridView1.SelectedCells[0].RowIndex; DataGridViewRow selectedRow = dataGridView1.Rows[selectedrowindex]; int stock = Convert.ToInt32(selectedRow.Cells["ofer_disponible"].Value); int maximoPorCliente = Convert.ToInt32(selectedRow.Cells["ofer_maxDisponible"].Value); if (txt_cantidad.Value > 0) { if (txt_cantidad.Value <= maximoPorCliente && stock - txt_cantidad.Value >= 0) { /* * int selectedrowindex = dataGridView1.SelectedCells[0].RowIndex; * DataGridViewRow selectedRow = dataGridView1.Rows[selectedrowindex]; */ string a = Convert.ToString(selectedRow.Cells["ofer_id"].Value); if (saldo - (Convert.ToInt32(selectedRow.Cells["ofer_precioOferta"].Value) * Convert.ToInt32(txt_cantidad.Value)) >= 0) { RepoCliente.instance().generarCompra(currentUserID, a, Convert.ToInt32(txt_cantidad.Value)); this.dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect; this.dataGridView1.MultiSelect = false; var bindingList = new BindingList <Oferta>(RepoOferta.instance().traerOfertasDisponibles()); var source = new BindingSource(bindingList, null); dataGridView1.DataSource = source; saldo = RepoCliente.instance().traerSaldo(currentUserID); btn_comprar.Enabled = false; txt_cantidad.Enabled = false; } else { MessageBox.Show("No hay saldo suficiente, su saldo actual es de " + saldo.ToString() + " pesos."); } } else { MessageBox.Show("El stock no es suficiente o la cantidad supera al maximo por cliente"); } } else { MessageBox.Show("La cantidad debe ser mayor a 0"); } }
private void Cupones_Load(object sender, EventArgs e) { this.dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect; this.dataGridView1.MultiSelect = false; var bindingList = new BindingList <Cupon>(RepoCliente.instance().traerCuponesPropios(currentUserID)); var source = new BindingSource(bindingList, null); dataGridView1.DataSource = source; var listaBind = new BindingList <Cliente>(RepoCliente.instance().traerClientes()); var sourceClientes = new BindingSource(listaBind, null); cmb_Clientes.DataSource = sourceClientes; cmb_Clientes.DisplayMember = "nombreYApellido"; cmb_Clientes.ValueMember = "clie_id"; }
public void TestMethod1() { var mockContext = new Mock <IContext>(); mockContext.Setup(m => m.Clientes).Returns(new FakeSET <Cliente>()); var service = new RepoCliente(mockContext.Object); service.CadastrarCliente(new Cliente() { Nome = "Codorna", Cpf = "089.358.804-00", DadosCartao = "1", Endereco = "rua dez", ClienteId = 50 }); mockContext.Verify(m => m.SaveChanges(), Times.Once()); }
// POST: ClienteController/Edit/5 public ActionResult Modificar(ClienteViewModel nuevo) { Cliente ClienteDTO = _mapper.Map <Cliente>(nuevo); if (ModelState.IsValid) { RepoCliente repoCliente = new RepoCliente(); repoCliente.ModificarCliente(ClienteDTO); //listaClientes.Add(nuevo); } else { Console.WriteLine("hubo una falla"); } return(RedirectToAction("Index")); }
public ActionResult PrevisionGanancia() { if (Session["rol"] != null) { if (Session["rol"].ToString() == "admin") { RepoCliente repoCli = new RepoCliente(); List <Cliente> listaCli = repoCli.TraerTodo(); return(View(listaCli)); } else { return(Redirect("/usuario/Index")); } } else { return(Redirect("/usuario/Index")); } }
public ActionResult CrearCliente(ClienteViewModel nuevo) { Cliente ClienteDTO = _mapper.Map <Cliente>(nuevo); var mensaje = " "; if (ModelState.IsValid) { RepoCliente repoCliente = new RepoCliente(); repoCliente.AltaCliente(ClienteDTO); //listaClientes.Add(nuevo); mensaje = "todo ok"; } else { mensaje = "hubo una falla"; } return(Content(mensaje)); }
private void btn_Regalar_Click(object sender, EventArgs e) { if (cmb_Clientes.Text != "") { int selectedrowindex = dataGridView1.SelectedCells[0].RowIndex; DataGridViewRow selectedRow = dataGridView1.Rows[selectedrowindex]; int idCupon = Convert.ToInt32(selectedRow.Cells["cupo_id"].Value); RepoCliente.instance().regalarCupon(idCupon, Convert.ToInt32(cmb_Clientes.SelectedValue)); var bindingList = new BindingList <Cupon>(RepoCliente.instance().traerCuponesPropios(currentUserID)); var source = new BindingSource(bindingList, null); dataGridView1.DataSource = source; btn_Regalar.Enabled = false; cmb_Clientes.Enabled = false; } else { MessageBox.Show("Debe ingresar un cliente"); } }
public ActionResult CalcularGanancia(string id) { if (Session["rol"] != null) { if (Session["rol"].ToString() == "admin") { //aca conseguimos todos los decuentos de la base de dato y los guardamos en un objeto RepoDescuento repoDes = new RepoDescuento(); List <Descuento> descuentos = repoDes.TraerTodo(); Descuento descuentoObj = descuentos[0]; int antiguedadAplicableEnDias = descuentoObj.AntiguedadAplicable; decimal comisionDiaria = descuentoObj.ComisionDiaria; decimal descuentoAplicable = descuentoObj.DescuentoAplicable; //aca creamos el objeto cliente RepoCliente repoCli = new RepoCliente(); Cliente cliente = repoCli.BuscarPorRut(id); //aca conseguimos la lista de todas las importaciones de la base de datos decimal costoTotal = 0; RepoImportacion repoImp = new RepoImportacion(); List <Importacion> listaImp = repoImp.TraerTodo(); //aca filtramos todas las importaciones por las pertinentes a un cliente en particular List <Importacion> importacionesPorCliente = new List <Importacion>(); foreach (Importacion impo1 in listaImp) { if (impo1.Producto.Cliente.Rut == id.ToString()) { importacionesPorCliente.Add(impo1); } } //aca filtramos las importaciones por aquellas q estan en el rango de fechas que aplica para el calculo // la fecha de ingreso tiene que ser anterior a la fecha de hoy. Y fecha de salida mayor a la de hoy. List <Importacion> importacionesCalculables = new List <Importacion>(); foreach (Importacion impo2 in importacionesPorCliente) { if (impo2.EsCalculable()) { importacionesCalculables.Add(impo2); } } //aca calculamos el costo de todas las importaciones foreach (Importacion impo3 in importacionesCalculables) { costoTotal += impo3.CalcularCosto(); } costoTotal = costoTotal * ((comisionDiaria) / 100); //aca vemos si aplica descuento por antiguedad, en cuyo caso, lo aplicamos if (cliente.CantidadDias() >= antiguedadAplicableEnDias) { costoTotal = costoTotal - (costoTotal * ((descuentoAplicable) / 100)); } ViewBag.Mensaje = costoTotal; return(View(cliente)); } } else { return(Redirect("/usuario/Index")); } return(Redirect("/usuario/Index")); }
public cCliente() { ObjDados = new RepoCliente(); }