public async Task <IActionResult> Edit(int id, [Bind("AvionesID,Modelos,Eye,Capacity")] Aviones aviones) { if (id != aviones.AvionesID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(aviones); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AvionesExists(aviones.AvionesID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(aviones)); }
private int AsignarNumeroVehiculo() { int numero = 0; while (true) { numero++; if (cbxTipoVehiculo.SelectedIndex == 0) { if (!Aviones.Exists(x => x.Numero == numero)) { break; } } if (cbxTipoVehiculo.SelectedIndex == 1) { if (!Autos.Exists(x => x.Numero == numero)) { break; } } if (cbxTipoVehiculo.SelectedIndex == 2) { if (!Colectivos.Exists(x => x.Numero == numero)) { break; } } } return(numero); }
private void bmnNuevoVehiculo_Click(object sender, EventArgs e) { frmNuevoVehiculo form = new frmNuevoVehiculo(); form.Owner = this; form.Aviones = Aviones; form.Autos = Autos; form.Colectivos = Colectivos; form.ShowDialog(); if (form.estado) { if (form.tipo == 0) { Aviones.Add(form.Avion); srcAviones.ResetBindings(true); dgvAviones.Refresh(); } else if (form.tipo == 1) { Autos.Add(form.Auto); srcAutos.ResetBindings(true); dgvAutos.Refresh(); } else { Colectivos.Add(form.Colectivo); srcColectivos.ResetBindings(true); dgvColectivos.Refresh(); } } }
public ActionResult DeleteConfirmed(int id) { Aviones aviones = db.Aviones.Find(id); db.Aviones.Remove(aviones); db.SaveChanges(); return(RedirectToAction("Index")); }
public void AddAvion(Aviones A1) { using (AeropuertoEntities context = new AeropuertoEntities()) { context.Aviones.Add(A1); context.SaveChanges(); } }
/// <summary> /// Crea el objeto Avion /// </summary> private void iniciarAvion() { GameObject aux = Instantiate(prefabAvion); Aviones avion = aux.GetComponent <Aviones>(); avion.setPosY(Random.Range(setYMin, setYMax)); cuentaAtras = 0; avionesEnVuelo++; }
public async Task <IActionResult> Create([Bind("AvionesID,Modelos,Eye,Capacity")] Aviones aviones) { if (ModelState.IsValid) { _context.Add(aviones); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(aviones)); }
public ActionResult Edit([Bind(Include = "IdAvion,Codigo,IdTipoAvion,HorasVuelo,Capacidad,Estatus")] Aviones aviones) { if (ModelState.IsValid) { db.Entry(aviones).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.IdTipoAvion = new SelectList(db.TipoAvion, "IdTipoAvion", "Nombre", aviones.IdTipoAvion); return(View(aviones)); }
public void AgregarAviones() { using (AeropuertoEntities context = new AeropuertoEntities()) { var A1 = new Aviones(); A1.Asientos = "45"; A1.Cantidad = 4; A1.Modelo = "ABCFGJJ"; bl.AddAvion(A1); } }
// GET: Aviones/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Aviones aviones = db.Aviones.Find(id); if (aviones == null) { return(HttpNotFound()); } return(View(aviones)); }
public void AgregarAviones() { Aviones a = new Aviones(); a.Modelo = "789-9 Dreamliner"; a.Asientos = "217-323"; a.Cantidad = 200; using (AeropuertoEntities context = new AeropuertoEntities()) { context.Aviones.Add(a); context.SaveChanges(); } }
// GET: Aviones/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Aviones aviones = db.Aviones.Find(id); if (aviones == null) { return(HttpNotFound()); } ViewBag.IdTipoAvion = new SelectList(db.TipoAvion, "IdTipoAvion", "Nombre", aviones.IdTipoAvion); return(View(aviones)); }
private void bnvEditarAvion_Click(object sender, EventArgs e) { if (dgvAviones.Rows.Count != 0) { frmEditarVehiculo form = new frmEditarVehiculo(); form.Owner = this; int num = Convert.ToInt16(dgvAviones.CurrentRow.Cells[0].Value); form.Avion = Aviones.Find(x => x.Numero == num); form.tipoElegido = 0; form.ShowDialog(); int pos = Aviones.FindIndex(x => x.Numero == form.Avion.Numero); Aviones[pos] = form.Avion; srcAviones.ResetBindings(true); dgvAviones.Refresh(); } }
public void Insertar() { Vuelos v1 = new Vuelos(); v1.Id_vuelo = 5; v1.Escala = "xxx"; v1.Duracion = 5; Aviones A1 = new Aviones(); A1.Id = 4; A1.Modelo = "Airbus456"; A1.Asientos = "568"; A1.Cantidad = 684; Paises_Destino_Aeropuerto PDA = new Paises_Destino_Aeropuerto(); PDA.id = 6; PDA.id_vuelo = 5; PDA.Paises = "USA"; PDA.Destino = "New York"; PDA.Aeropuerto = "Juan Santa Maria "; PDA.Tarifa = 564; Pasajeros pj = new Pasajeros(); pj.id = 8; pj.Id_vuelo = 5; pj.Nombre = "Nombre 1"; pj.Apellidos = "Apellidos 1"; pj.Visa = 454221; pj.Pasaporte = 26564; using (AeropuertoEntities context = new AeropuertoEntities()) { context.Vuelos.Add(v1); context.SaveChanges(); } }
private float CalcularCostoTotal(int opcion, int id, int cantPasKm) { float costo = 0; if (opcion == 0) { Avion a = Aviones.Find(x => x.Numero == id); costo = cantPasKm * a.CostoPorPersona + ((a.LowCost) ? 1200 : 2700); } else if (opcion == 1) { Auto a = Autos.Find(x => x.Numero == id); costo = cantPasKm * a.CostoPorKm; } else { Colectivo c = Colectivos.Find(x => x.Numero == id); costo = cantPasKm * c.CostoPorPersona + ((c.AlmuerzoCena) ? 100 : 0) + ((c.CocheCama) ? 30 : 0); } return(costo); }
private bool ComprobarVehiculo(List <Viaje> list, int id) { bool vehiculoDisponible = !list.Exists(x => x.IdVehiculo == id && x.FechaViaje.Date == fecha.Date); if (vehiculoDisponible) { if (tipoElegido == 0) { return((Aviones.Find(x => x.Numero == id).CantidadButacas >= cantPasajeros) ? true : false); } else if (tipoElegido == 1) { return((Autos.Find(x => x.Numero == id).CantidadButacas >= cantPasajeros) ? true : false); } else { return((Colectivos.Find(x => x.Numero == id).CantidadButacas >= cantPasajeros) ? true : false); } } else { return(false); } }