public Boolean guardar(clsTipoCombustible ctm, ref string Mensaje) { try { using (INVENTARIOEntities te = new INVENTARIOEntities()) { TipoCombustible tm = new TipoCombustible(); tm.IdEmpresa = Convert.ToInt32(ctm.empresa); tm.IdTipoCombustible = Convert.ToInt32(ctm.codigo); tm.Descripcion = Convert.ToString(ctm.descripcion); tm.IdEstado = Convert.ToInt32(ctm.codigo); te.AddToTipoCombustible(tm); te.SaveChanges(); } return(true); } catch (Exception e) { Mensaje = "ERROR" + e.InnerException + e.Message; //System.Windows.Forms.MessageBox.Show("error al guardar" + e); return(false); } }
public async Task <IActionResult> Edit(int id, [Bind("IdTipoCombustible,Descripcion,Estado")] TipoCombustible tipoCombustible) { if (id != tipoCombustible.IdTipoCombustible) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(tipoCombustible); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TipoCombustibleExists(tipoCombustible.IdTipoCombustible)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(tipoCombustible)); }
private void listaTiposCombustible_SelectedIndexChanged(object sender, EventArgs e) { if (listaTiposCombustible.SelectedItem != null) { tipoSeleccionado = (TipoCombustible)listaTiposCombustible.SelectedItem; textDescripcion.Text = tipoSeleccionado.nombre; } }
public ActionResult DeleteConfirmed(int id) { TipoCombustible tipoCombustible = db.TipoCombustible.Find(id); db.TipoCombustible.Remove(tipoCombustible); db.SaveChanges(); return(RedirectToAction("Index")); }
private void Save() { System.IO.StreamWriter writer = new System.IO.StreamWriter("Files/Carro.txt", true); writer.WriteLine(VIN + "," + Modelo + "," + Color + "," + Marca + "," + TipoCombustible.ToString() + "," + TipoTransmision.ToString() + "," + IdCarro.ToString()); writer.Close(); }
//CONSTRUCTORES public Moto(string nombre, int nRuedas, ConsoleColor color, int potencia, TipoCombustible combustible) { this._nombre = nombre; this._nruedas = nRuedas; this._color = color; this._traccion = TipoTraccion.RWD; //Todas las motos tienen por defecto tipo de tracción trasera (RWD) this._potencia = potencia; this._conbustible = combustible; }
//Constructor vacío para crear una moto por defecto public Moto() { this._nombre = "Honda"; this._nruedas = 2; this._color = ConsoleColor.Red; this._traccion = TipoTraccion.RWD; this._potencia = 125; this._conbustible = TipoCombustible.Normal; }
public ActionResult Edit([Bind(Include = "Id,Descripcion,Estado")] TipoCombustible tipoCombustible) { if (ModelState.IsValid) { db.Entry(tipoCombustible).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tipoCombustible)); }
public async Task <IActionResult> Create([Bind("IdTipoCombustible,Descripcion,Estado")] TipoCombustible tipoCombustible) { if (ModelState.IsValid) { _context.Add(tipoCombustible); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(tipoCombustible)); }
public Moto() { Random rnd = new Random(); Nombre = _modelos[rnd.Next(_modelos.Length)]; NRuedas = 2; Color = Colores[rnd.Next(Colores.Length)]; _potencia = (uint)rnd.Next(125, 1000); _tipoCombustible = rnd.Next(0, 2) == 1 ? TipoCombustible.mezcla : TipoCombustible.normal; AsignaTipoTraccion = (TipoTraccion)rnd.Next(0, 5); }
public ActionResult Create([Bind(Include = "Id,Descripcion,Estado")] TipoCombustible tipoCombustible) { if (ModelState.IsValid) { db.TipoCombustible.Add(tipoCombustible); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tipoCombustible)); }
/// <summary> /// Filtra el tipo de Combustible /// </summary> /// <param name="tc"></param> /// <returns></returns> public List <TipoCombustibleModel> Filter(TipoCombustible tc) => _db.TipoCombustibles .Where(x => (x.Id_Estado == 1) && ((tc.Descripcion == null || tc.Descripcion == string.Empty)? true: x.Descripcion.ToLower().Trim().Contains(tc.Descripcion.Trim().ToLower())) ) .Select(x => new TipoCombustibleModel() { Id = x.Id, Estado = x.Estado.Estado1, TipoCombustible = x.Descripcion }).ToList();
// GET: TipoCombustibles/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TipoCombustible tipoCombustible = db.TipoCombustible.Find(id); if (tipoCombustible == null) { return(HttpNotFound()); } return(View(tipoCombustible)); }
public FormTipoCombustible() { InitializeComponent(); fachada = FachadaUISistema.getFachada(); tipoSeleccionado = null; listaTiposCombustible.Items.Clear(); foreach (TipoCombustible t2 in fachada.getListaTiposCombustible()) { listaTiposCombustible.Items.Add(t2); } listaTiposCombustible.Show(); }
public void InsertTipoCombustible(TipoCombustible tc) { if (tc.Id == 0) { _db.TipoCombustibles.Add(tc); } else { var tcb = _db.TipoCombustibles.FirstOrDefault(x => x.Id == tc.Id); tcb.Id_Estado = tc.Id_Estado; tcb.Id_User = tc.Id_User; tcb.Descripcion = tcb.Descripcion; } _db.SaveChanges(); }
public Boolean modificar(clsTipoCombustible ctm) { using (INVENTARIOEntities te = new INVENTARIOEntities()) { EntityKey ekey = new EntityKey("INVENTARIOEntities.TipoCombustible", "IdTipoCombustible", ctm.codigo); object OBJ = null; if (te.TryGetObjectByKey(ekey, out OBJ)) { TipoCombustible TipoCombustible = (TipoCombustible)OBJ; TipoCombustible.Descripcion = ctm.descripcion; TipoCombustible.IdEstado = Convert.ToInt32(ctm.estado); } te.SaveChanges(System.Data.Objects.SaveOptions.DetectChangesBeforeSave); } return(true); }
private void Button1_Click(object sender, EventArgs e) { if (!Validar()) { return; } var TipoCombustible = new TipoCombustible() { Descripcion = txtDescripcion.Text, EstadoID = (int)ENUM_ESTADO_TIPO_COMBUSTIBLE.ACTIVO }; dbContext.TiposCombustible.Add(TipoCombustible); dbContext.SaveChanges(); OnNuevoTipoCombustibleAdded(this, new NuevoTipoCombustibleEventArgs { TipoCombustible = TipoCombustible }); this.Close(); }
private void btnRegistrar_Click(object sender, EventArgs e) { try { String descripcion = textDescripcion.Text.Trim(); if (descripcion.Length > 0) { if (tipoSeleccionado == null) { fachada.crearTipoCombustible(descripcion); MessageBox.Show("El tipo de combustible ha sido creado"); } else { fachada.editarTipoCombustible((TipoCombustible)listaTiposCombustible.SelectedItem, textDescripcion.Text); MessageBox.Show("Se ha editado el elemento seleccionado de forma correcta!"); } listaTiposCombustible.Items.Clear(); foreach (TipoCombustible t in fachada.getListaTiposCombustible()) { listaTiposCombustible.Items.Add(t); } listaTiposCombustible.Show(); } else { MessageBox.Show("Valores incorrectos.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (MiExcepcion es) { MessageBox.Show(es.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error en los datos", MessageBoxButtons.OK, MessageBoxIcon.Error); } tipoSeleccionado = null; listaTiposCombustible.SelectedItem = null; }
public IHttpActionResult Post([FromBody] TipoCombustible tp) { RespuestaApi <TipoCombustible> respuesta = new RespuestaApi <TipoCombustible>(); respuesta.datos = tp.denominacion; int filaAfectadas; try { Db.Conectar(); if (Db.EstaLaConexionAbierta()) { filaAfectadas = Db.InsertarTipocombustible(tp); } } catch (Exception e) { respuesta.error = "Error al conectar con la base de datos " + e.ToString(); } Db.Desconectar(); return(Ok(respuesta)); }
private void buttonGuardar_Click(object sender, EventArgs e) { try { TipoCombustible tipoC = (TipoCombustible)comboBoxTipoComb.SelectedItem; TanqueCombustible tanque = (TanqueCombustible)comboBoxTanque.SelectedItem; if ((textBoxCantidad.Text.Trim().Length > 0) && (tipoC != null) && (tanque != null)) { int cantidad = Convert.ToInt32(textBoxCantidad.Text.Trim()); if (tareaSeleccionada == null) { fachada.crearTareaReposicionCombustible((TanqueCombustible)comboBoxTanque.SelectedItem, cantidad); MessageBox.Show("La tarea ha sido creada"); } listBoxListaTareas.Items.Clear(); foreach (TareaReposicionCombustible t in fachada.getListaTareasReposicionCombustible()) { listBoxListaTareas.Items.Add(t); } listBoxListaTareas.Show(); borrarDatos(); } else { MessageBox.Show("Faltan datos.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (MiExcepcion es) { MessageBox.Show(es.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error en los datos", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnEditar_Click(object sender, EventArgs e) { if (tipoSeleccionado != null) { fachada.eliminarTipoCombustible(tipoSeleccionado.nombre); MessageBox.Show("Se ha eliminado el elemento seleccionado de forma correcta!"); listaTiposCombustible.Items.Clear(); foreach (TipoCombustible t2 in fachada.getListaTiposCombustible()) { listaTiposCombustible.Items.Add(t2); } listaTiposCombustible.Show(); tipoSeleccionado = null; borrarDatos(); } else { MessageBox.Show("Debe seleccionar un tipo de combustible"); } }
//public string List() //{ // string todos = ""; // foreach (Carro Carro in ListaCarros) // { // todos += Carro.ToString(); // } // return todos; //} /// <summary> /// Muestra los datos de un Carro /// </summary> public void Show() { Console.WriteLine(VIN.PadRight(5) + Modelo.PadLeft(2).PadRight(4) + Color.PadRight(10) + Marca.PadRight(10) + TipoCombustible.ToString().PadRight(10) + TipoTransmision.ToString().PadRight(10).PadLeft(12) + IdCarro.ToString().PadRight(2).PadLeft(4)); }
public override string ToString() { return(VIN.ToString() + "\t" + Modelo + "\t" + Color + "\t" + Marca + "\t" + TipoCombustible.ToString() + "\t" + TipoTransmision.ToString() + "\t" + IdCarro.ToString()); }
public Moto(string nom, int nRueda, ConsoleColor c, TipoTraccion t, int pt, TipoCombustible comb) : base(nom, nRueda, c, t) { _potencia = pt; _combustible = comb; }