Exemplo n.º 1
0
 // GET: Admin/Mantenimiento/Create
 public ActionResult Create(string id)
 {
     try
     {
         Token.SaveToken();
         ServiciosMantenimientoViewModels Servicio = new ServiciosMantenimientoViewModels();
         _Combos_Datos Datos = new _Combos_Datos();
         Servicio.ListaSucursales  = Datos.ObtenerComboSucursales(Conexion);
         Servicio.ListaProveedores = Datos.ObtenerComboProveedoresMantenimiento(Conexion, string.Empty);
         Servicio.ID = id;
         return(View(Servicio));
     }
     catch (Exception)
     {
         TempData["typemessage"] = "2";
         TempData["message"]     = "No se puede cargar la vista";
         return(RedirectToAction("Servicios", new { id = id }));
     }
 }
 public ServiciosMantenimientoViewModels ObtenerDatosServicio(string Conexion, string IDServicio)
 {
     try
     {
         ServiciosMantenimientoViewModels Resultado = new ServiciosMantenimientoViewModels();
         SqlDataReader Dr = SqlHelper.ExecuteReader(Conexion, "spCSLDB_Mantenimiento_get_DetalleServicio", IDServicio);
         while (Dr.Read())
         {
             Resultado.IDServicio   = IDServicio;
             Resultado.ID           = !Dr.IsDBNull(Dr.GetOrdinal("ID")) ? Dr.GetString(Dr.GetOrdinal("ID")) : string.Empty;
             Resultado.IDSucursal   = !Dr.IsDBNull(Dr.GetOrdinal("IDSucursal")) ? Dr.GetString(Dr.GetOrdinal("IDSucursal")) : string.Empty;
             Resultado.IDProveedor  = !Dr.IsDBNull(Dr.GetOrdinal("IDProveedor")) ? Dr.GetString(Dr.GetOrdinal("IDProveedor")) : string.Empty;
             Resultado.Fecha        = !Dr.IsDBNull(Dr.GetOrdinal("Fecha")) ? Dr.GetDateTime(Dr.GetOrdinal("Fecha")) : DateTime.MinValue;
             Resultado.FechaProxima = !Dr.IsDBNull(Dr.GetOrdinal("FechaProxima")) ? Dr.GetDateTime(Dr.GetOrdinal("FechaProxima")) : DateTime.MinValue;
             break;
         }
         return(Resultado);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 3
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));
            }
        }