public void Guardar()
        {
            if (ceditor.ID < 0)
            {
                Camione cm = new Camione
                            {
                                NOMBRE = ceditor.Nombre,
                                DESCRIPCION = ceditor.Descripcion
                            };
                data.Camiones.InsertOnSubmit(cm);

            }
            else
            {
                var query = from c in data.Camiones
                            where c.CODIGO == ceditor.ID
                            select c;
                Camione m = query.First<Camione>();
                m.NOMBRE = ceditor.Nombre;
                m.DESCRIPCION = ceditor.Descripcion;

            }
            data.SubmitChanges();
            toDGV();
        }
Esempio n. 2
0
        public ActionResult DeleteConfirmed(string id)
        {
            Camione camione = db.Camiones.Find(id);

            db.Camiones.Remove(camione);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 3
0
 public ActionResult Edit([Bind(Include = "SerialNumber,Placa,Modelo,Year,IsActive")] Camione camione)
 {
     if (ModelState.IsValid)
     {
         db.Entry(camione).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(camione));
 }
Esempio n. 4
0
        public ActionResult Create([Bind(Include = "SerialNumber,Placa,Modelo,Year,IsActive")] Camione camione)
        {
            if (ModelState.IsValid)
            {
                db.Camiones.Add(camione);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(camione));
        }
Esempio n. 5
0
        // GET: Camiones/Delete/5
        public ActionResult Delete(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Camione camione = db.Camiones.Find(id);

            if (camione == null)
            {
                return(HttpNotFound());
            }
            return(View(camione));
        }
Esempio n. 6
0
 public override int add()
 {
     try
     {
         Camione dataCamion = new Camione
         {
             CODIGO = truck.Codigo,
             NOMBRE = truck.Nombre,
             DESCRIPCION = truck.Descripcion
         };
         Data.Camiones.InsertOnSubmit(dataCamion);
         Data.SubmitChanges();
         return 1;
     }
     catch (Exception exc)
     {
         Utils.logExceptionError(exc);
         return 0;
     }
 }