Example #1
0
 // GET: Admin/Mantenimiento
 public ActionResult Index()
 {
     try
     {
         ServiciosMantenimientoModels Model = new ServiciosMantenimientoModels();
         _ServicioMantenimiento_Datos Datos = new _ServicioMantenimiento_Datos();
         Model = Datos.ObtenerDatosIndex(Conexion, string.Empty);
         return(View(Model));
     }
     catch (Exception)
     {
         return(View(new ServiciosMantenimientoModels()));
     }
 }
Example #2
0
 // GET: Admin/Mantenimiento/Details/5
 public ActionResult Details(string id)
 {
     try
     {
         ViewBag.IDServicio = id;
         _ServicioMantenimiento_Datos Datos     = new _ServicioMantenimiento_Datos();
         ServiciosMantenimientoModels Resultado = Datos.ObtenerDetalleServicioXID(Conexion, id);
         ViewBag.IDVehiculo = Resultado.Vehiculo.IDVehiculo;
         return(View(Resultado.ListaDetalle));
     }
     catch (Exception)
     {
         TempData["typemessage"] = "2";
         TempData["message"]     = "No se puede cargar la vista";
         return(RedirectToAction("Index"));
     }
 }
Example #3
0
 public ActionResult Process(string id)
 {
     try
     {
         ServiciosMantenimientoModels Model = new ServiciosMantenimientoModels();
         _ServicioMantenimiento_Datos Datos = new _ServicioMantenimiento_Datos();
         Model.Conexion   = Conexion;
         Model.Usuario    = User.Identity.Name;
         Model.IDServicio = id;
         Datos.ProcesarServicio(Model);
         if (Model.Completado)
         {
             return(Json("true"));
         }
         else
         {
             return(Json(""));
         }
     }
     catch
     {
         return(Json(""));
     }
 }
Example #4
0
 public ActionResult Delete(string id)
 {
     try
     {
         ServiciosMantenimientoModels Model = new ServiciosMantenimientoModels();
         _ServicioMantenimiento_Datos Datos = new _ServicioMantenimiento_Datos();
         Model.Conexion   = Conexion;
         Model.Usuario    = User.Identity.Name;
         Model.IDServicio = id;
         Datos.EliminarServicio(Model);
         if (Model.Completado)
         {
             return(Json("true"));
         }
         else
         {
             throw new Exception("Error");
         }
     }
     catch
     {
         return(Json("false"));
     }
 }
Example #5
0
        public ActionResult Create(ServiciosMantenimientoViewModels Model)
        {
            _ServicioMantenimiento_Datos Datos = new _ServicioMantenimiento_Datos();
            _Combos_Datos CDatos = new _Combos_Datos();

            try
            {
                if (Token.IsTokenValid())
                {
                    if (ModelState.IsValid)
                    {
                        ServiciosMantenimientoModels ModelP = new ServiciosMantenimientoModels
                        {
                            NuevoRegistro = true,
                            IDServicio    = string.Empty,
                            Sucursal      = new CatSucursalesModels {
                                IDSucursal = Model.IDSucursal
                            },
                            Proveedor = new CatProveedorModels {
                                IDProveedor = Model.IDProveedor
                            },
                            Fecha        = Model.Fecha,
                            FechaProxima = Model.FechaProxima,
                            Vehiculo     = new CatVehiculoModels {
                                IDVehiculo = Model.ID
                            },
                            Conexion = Conexion,
                            Usuario  = User.Identity.Name
                        };
                        Datos.ACServicio(ModelP);
                        if (ModelP.Completado == true)
                        {
                            TempData["typemessage"] = "1";
                            TempData["message"]     = "Los datos se guardaron correctamente.";
                            Token.ResetToken();
                            return(RedirectToAction("CreateDetail", new { id = ModelP.IDServicio }));
                        }
                        else
                        {
                            Model.ListaSucursales   = CDatos.ObtenerComboSucursales(Conexion);
                            TempData["typemessage"] = "2";
                            TempData["message"]     = "Ocurrio un error al intentar guardar los datos. Intente más tarde.";
                            return(View(Model));
                        }
                    }
                    else
                    {
                        Model.ListaSucursales = CDatos.ObtenerComboSucursales(Conexion);
                        return(View(Model));
                    }
                }
                else
                {
                    return(RedirectToAction("Index"));
                }
            }
            catch
            {
                Model.ListaSucursales   = CDatos.ObtenerComboSucursales(Conexion);
                TempData["typemessage"] = "2";
                TempData["message"]     = "Ocurrio un error al intentar guardar los datos. Contacte a soporte técnico.";
                return(View(Model));
            }
        }