예제 #1
0
        public ActionResult Editar(Clientes a)

        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(View());
                }
                using (var db = new AlmacenContext())
                {
                    Clientes cli = db.Clientes.Find(a.Id);
                    cli.Nombre          = a.Nombre;
                    cli.Apellido        = a.Apellido;
                    cli.Direccion       = a.Direccion;
                    cli.Direccion       = a.Correo;
                    cli.Telefono        = a.Telefono;
                    cli.Tipo_de_cliente = a.Tipo_de_cliente;
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
예제 #2
0
        public ActionResult Editar(Despacho a)

        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(View());
                }
                using (var db = new AlmacenContext())
                {
                    Despacho Des = db.Despacho.Find(a.Id);
                    Des.Fecha               = a.Fecha;
                    Des.Tipo_de_accion      = a.Tipo_de_accion;
                    Des.Cliente             = a.Cliente;
                    Des.Contacto            = a.Contacto;
                    Des.Detalle_de_producto = a.Detalle_de_producto;
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
예제 #3
0
 public ActionResult Eliminar(int Id)
 {
     using (var db = new AlmacenContext())
     {
         Clientes cli = db.Clientes.Find(Id);
         db.Clientes.Remove(cli);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
 }
예제 #4
0
 public ActionResult Eliminar(int Id)
 {
     using (var db = new AlmacenContext())
     {
         Despacho Pro = db.Despacho.Find(Id);
         db.Despacho.Remove(Pro);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
 }
예제 #5
0
        public ActionResult Agregar(Clientes a)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }

            try
            {
                using (AlmacenContext db = new AlmacenContext())
                {
                    db.Clientes.Add(a);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("error agregar", ex);
                return(View());
            }
        }