예제 #1
0
파일: FallasManager.cs 프로젝트: Bakiet/DAP
        public List <equipos> FindEquiposPorObra(int?id)
        {
            obras  ob = new obras();
            fallas fa = new fallas();

            //fa = _db.fallas.Where(f => f.Id == id).FirstOrDefault();

            //ob = _db.obras.Where(o => o.Nombre == fa.Obra).FirstOrDefault();

            //if (ob != null) {
            return(_db.equipos.Where(o => o.obra_id == id).ToList());
            //}
            // else
            //{
            // return null;
            //}
        }
예제 #2
0
        public ActionResult Crear(FallaViewModel model, FormCollection collection)
        {
            var obra_id = _fallasManager.FindIdObra(model.Obra);
            var Url     = "";

            var obranombre = _obrasManager.Find(Convert.ToInt32(TempData["OBRA_ID"]));

            TempData.Keep();
            ViewBag.Obras =
                new SelectList(_fallasManager.FindObras(), "nombre", "nombre");


            ViewBag.Equipos =
                new SelectList(_fallasManager.FindEquiposPorObra(Convert.ToInt32(TempData["OBRA_ID"])), "nombre", "nombre");
            TempData.Keep();
            ViewBag.TipoFallas =
                new SelectList(_fallasManager.FindTipoFallas(), "descripcion", "descripcion");

            if (model.Tipo == "Electrónica")
            {
                ViewBag.Componentes =
                    new SelectList(_fallasManager.FindComponentesElectronicos(), "descripcion", "descripcion");
            }
            if (model.Tipo == "Mecánica")
            {
                ViewBag.Componentes =
                    new SelectList(_fallasManager.FindComponentesMecanicos(), "descripcion", "descripcion");
            }
            else
            {
                ViewBag.Componentes =
                    new SelectList(_fallasManager.FindComponentes(), "descripcion", "descripcion");
            }

            ViewBag.Status =
                new SelectList(_fallasManager.FindStatus(), "descripcion", "descripcion");

            ViewBag.Condicion =
                new SelectList(new[] { new { ID = "OBRA", Name = "OBRA" }, new { ID = "EQUIPO", Name = "EQUIPO" }, }, "ID", "Name", model.Condicion);

            /*  var db = new EntitiesDap();
             * model.ObraList = new SelectList(db.obras, "id", "nombre", "nombre");
             * model.EquipoList = new SelectList(db.equipos, "id", "nombre");
             * model.FallaList = new SelectList(db.fallas_tipo, "id", "descripcion");
             * model.ComponenteElectronicoList = new SelectList(db.componenteselectronicos_tipos, "id", "descripcion");
             * model.StatusList = new SelectList(db.fallas_status, "id", "descripcion");*/

            //  if (!ModelState.IsValid) return View(model);
            fallas falla = new fallas();


            try
            {
                DateTime?fallasolucion = null;
                DateTime?duracion      = null;

                if (model.FechaSolucion == null)
                {
                    falla = _fallasManager.Crear(Convert.ToInt32(TempData["OBRA_ID"]),
                                                 DateTime.Parse(model.FechaFalla),
                                                 fallasolucion,
                                                 obranombre.Nombre,
                                                 model.Equipo,
                                                 model.Tipo,
                                                 model.Componente,
                                                 model.Personal,
                                                 model.StatusFalla,
                                                 model.NumeroReporte,
                                                 model.Descripcion,
                                                 model.Condicion,
                                                 model.AccionesTomadas,
                                                 model.AccionesRecomendadas,
                                                 duracion,
                                                 model.PersonaReporte,
                                                 model.GerenciaResponsable);
                    TempData.Keep();
                }
                else
                {
                    falla = _fallasManager.Crear(Convert.ToInt32(TempData["OBRA_ID"]),
                                                 DateTime.Parse(model.FechaFalla),
                                                 DateTime.Parse(model.FechaSolucion),
                                                 obranombre.Nombre,
                                                 model.Equipo,
                                                 model.Tipo,
                                                 model.Componente,
                                                 model.Personal,
                                                 model.StatusFalla,
                                                 model.NumeroReporte,
                                                 model.Descripcion,
                                                 model.Condicion,
                                                 model.AccionesTomadas,
                                                 model.AccionesRecomendadas,
                                                 duracion,
                                                 model.PersonaReporte,
                                                 model.GerenciaResponsable);
                    TempData.Keep();
                }

                HttpPostedFileBase file;
                //  TempData["obraidactual"] = null;
                for (int i = 0; i < Request.Files.Count; i++)
                {
                    file = Request.Files[i];
                    var d = Request.Files.AllKeys[i].ToString();

                    if (d == "Correo" && file.FileName != "")
                    {
                        Url = CargarPdf(file);
                        _obrasManager.AgregarArchivos(falla.Id, Url, "fallas", "correo");
                    }
                }

                TempData["FlashSuccess"] = MensajesResource.INFO_Fallas_CreadoCorrectamente;
                if (TempData["OBRA_ID"] != null)
                {
                    return(RedirectToAction("Fallas", "AdministrarFallas", new { @id = Convert.ToInt32(TempData["OBRA_ID"]) }));
                }
                else
                {
                    return(RedirectToAction("Index", "AdministrarFallas"));
                }
            }
            catch (BusinessException businessEx)
            {
                ModelState.AddModelError(string.Empty, businessEx.Message);

                return(View(model));
            }
            catch (Exception e)
            {
                var log = CommonManager.BuildMessageLog(
                    TipoMensaje.Error,
                    ControllerContext.Controller.ValueProvider.GetValue("controller").RawValue.ToString(),
                    ControllerContext.Controller.ValueProvider.GetValue("action").RawValue.ToString(),
                    e.ToString(), Request);

                // CommonManager.WriteAppLog(log, TipoMensaje.Error);

                //  ModelState.AddModelError(string.Empty, e.Message);
                return(View(model));
            }
        }
예제 #3
0
파일: FallasManager.cs 프로젝트: Bakiet/DAP
        public fallas Crear(int obraid, DateTime fechafalla, DateTime?fechaSolucion, string obra = null, string equipo = null,
                            string tipo             = null, string componente = null, string personal = null, string statusFalla = null, string numeroReporte = null, string descripcion = null, string condicion = null, string accionesTomadas = null, string accionesRecomendadas = null, DateTime?duracion = null
                            , string personaReporte = null, string gerenciaResponsable = null)
        {
            //if(fechafalla == null)
            //{
            //    fechafalla = DateTime.Now;
            //}
            //   if(obra == null)
            //   {
            //       obra = "null";
            //   }
            //   if(equipo == null)
            //   {
            //       equipo = "null";
            //   }
            //   if(tipo == null)
            //   {
            //       tipo = "null";
            //   }
            //   if(componente == null)
            //   {
            //       componente = "null";
            //   }
            //   if(personal == null)
            //   {
            //       personal = "null";
            //   }
            //   if(statusFalla == null)
            //   {

            //       statusFalla = "null";
            //   }
            //   //if(fechaSolucion == null)
            //   //{
            //   //    fechaSolucion = DateTime.Now.ToString();
            //   //}
            //if(numeroReporte == null)
            //   {
            //       numeroReporte = "null";
            //   }
            //   if(descripcion == null)
            //   {
            //       descripcion = "null";
            //   }
            //   if(condicion == null)
            //   {
            //       condicion = "null";
            //   }
            //   if(accionesTomadas == null)
            //   {
            //       accionesTomadas = "null";
            //   }
            //   if(accionesRecomendadas == null)
            //   {
            //       accionesRecomendadas = "null";
            //   }
            //   if(duracion == null)
            //   {
            //       duracion = "null";
            //   }
            //   if(personaReporte == null)
            //   {
            //       personaReporte = "null";
            //   }
            //   if(gerenciaResponsable == null)
            //   {
            //       gerenciaResponsable = "null";
            //   }

            try
            {
                var falla = new fallas()
                {
                    FechaFalla           = fechafalla,
                    Obra                 = obra,
                    Equipo               = equipo,
                    Tipo                 = tipo,
                    Componente           = componente,
                    Personal             = personal,
                    StatusFalla          = statusFalla,
                    FechaSolucion        = fechaSolucion,
                    NumeroReporte        = numeroReporte,
                    Descripcion          = descripcion,
                    Condicion            = condicion,
                    AccionesTomadas      = accionesTomadas,
                    AccionesRecomendadas = accionesRecomendadas,
                    Duracion             = duracion,
                    PersonaReporte       = personaReporte,
                    GerenciaResponsable  = gerenciaResponsable,
                    obra_id              = obraid
                };

                _db.fallas.Add(falla);
                _db.SaveChanges();

                return(falla);
            }
            catch (Exception e)
            {
                throw e;
            }
        }