Ejemplo n.º 1
0
        public ActionResult ModificaPM(int idInterno, int idOrden, string unidad)
        {
            clsQuickCheck        objQC     = new clsQuickCheck();
            List <clsEvaluacion> lstEvalua = new List <clsEvaluacion>();

            try
            {
                if (Session["Usuario"] != null)
                {
                    var consultQC = (from qc in entity.manttoquickchecks
                                     join cqc in entity.camsolquickchecks on qc.IDInternoI equals cqc.IDInterno into cs
                                     from cqc in cs.DefaultIfEmpty()
                                     where qc.IDInternoI == idInterno &&
                                     qc.ID == idOrden
                                     select new { qc, cqc.ItemARevisar }).FirstOrDefault();

                    objQC.IDUnidad     = unidad;
                    objQC.IDOrden      = idOrden;
                    objQC.IDInterno    = idInterno;
                    objQC.Eval         = consultQC.qc.Evaluar == null? false : true;
                    objQC.Comentarios  = consultQC.qc.Comentario;
                    objQC.Refacciones  = consultQC.qc.RefacRequeridas;
                    objQC.Verde        = (bool)consultQC.qc.Verde;
                    objQC.VerdeRojo    = null;
                    objQC.Rojo         = (bool)consultQC.qc.Rojo;
                    objQC.ItemARevisar = consultQC.ItemARevisar;


                    if (objQC.Eval == true)
                    {
                        var consultEval = (from qce in entity.quickcheckevalactividads
                                           join cce in entity.calidadconceptoevaluacions on qce.ConceptoEvaluacion equals cce.ConceptoEvaluacion into ce
                                           from cce in ce.DefaultIfEmpty()
                                           where qce.Evaluacion == cce.Evaluacion &&
                                           qce.IDInterno == objQC.IDInterno &&
                                           qce.ID == idOrden
                                           select new { qce, cce.Orden }).ToList();

                        foreach (var item2 in consultEval)
                        {
                            var eval = new clsEvaluacion();
                            eval.ConceptoEvaluacion = item2.qce.ConceptoEvaluacion;
                            eval.Evaluacion         = item2.qce.Evaluacion;
                            eval.Id        = item2.Orden;
                            eval.IdInterno = item2.qce.IDInterno;
                            eval.Unidad    = item2.qce.Unidad;
                            eval.Valor     = item2.qce.Valor == null ? 0 : (decimal)item2.qce.Valor;
                            lstEvalua.Add(eval);
                        }
                        objQC.Evaluacion = lstEvalua;
                    }
                }
            }catch (Exception e)
            {
                Danger("error" + e.Message);
                return(RedirectToAction("BuscaQC", "SDM", new { idOrden = objQC.IDOrden, serieU = objQC.IDUnidad }));
            }

            return(View(objQC));
        }
Ejemplo n.º 2
0
        public ActionResult BuscaQC(int?idOrden, string serieU)
        {
            List <clsQuickCheck> lstQC = new List <clsQuickCheck>();

            try
            {
                if (Session["Usuario"] != null)
                {
                    var objCheckLst = (from qc in entity.manttoquickchecks
                                       join cqc in entity.camsolquickchecks on qc.IDInternoI equals cqc.IDInterno into cs
                                       from cqc in cs.DefaultIfEmpty()
                                       where qc.ID == idOrden
                                       select new { qc, cqc.ItemARevisar, cqc.Sistemas, cqc.Prioritario }).ToList();

                    if (objCheckLst != null && objCheckLst.Count > 0)
                    {
                        foreach (var item in objCheckLst)
                        {
                            clsQuickCheck objQC = new clsQuickCheck();
                            objQC.IDInterno    = item.qc.IDInternoI;
                            objQC.IDUnidad     = serieU;
                            objQC.ItemARevisar = item.ItemARevisar;
                            objQC.Rojo         = item.qc.Rojo == null ? false : (bool)item.qc.Rojo;
                            objQC.Verde        = item.qc.Verde == null ? false : (bool)item.qc.Verde;
                            objQC.Comentarios  = item.qc.Comentario;
                            objQC.Refacciones  = item.qc.RefacRequeridas;
                            objQC.IDOrden      = item.qc.ID;
                            objQC.KM           = int.Parse(Session["KM"].ToString());
                            objQC.Eval         = item.qc.Evaluar == null ? false : (bool)item.qc.Evaluar;
                            if (item.qc.Evaluar == true)
                            {
                                var lstEvaluacion = new List <clsEvaluacion>();

                                var consultEval = (from qce in entity.quickcheckevalactividads
                                                   join cce in entity.calidadconceptoevaluacions on qce.ConceptoEvaluacion equals cce.ConceptoEvaluacion into ce
                                                   from cce in ce.DefaultIfEmpty()
                                                   where qce.Evaluacion == cce.Evaluacion &&
                                                   qce.IDInterno == objQC.IDInterno &&
                                                   qce.ID == idOrden
                                                   select new { qce, cce.Orden }).ToList();

                                foreach (var item2 in consultEval)
                                {
                                    var eval = new clsEvaluacion();
                                    eval.ConceptoEvaluacion = item2.qce.ConceptoEvaluacion;
                                    eval.Evaluacion         = item2.qce.Evaluacion;
                                    eval.Id     = item2.Orden;
                                    eval.Unidad = item2.qce.Unidad;
                                    eval.Valor  = item2.qce.Valor == null ? 0 : (decimal)item2.qce.Valor;
                                    lstEvaluacion.Add(eval);
                                }
                                objQC.Evaluacion = lstEvaluacion;
                            }
                            lstQC.Add(objQC);
                        }
                    }
                    else
                    {
                        Warning("No se encontro lista de quick checks para la orden dada. Favor de contactar al administrador");
                        RedirectToAction("OpcionesUnidad", "SDM", new { idUnidad = idOrden });
                    }
                }
                else
                {
                    return(RedirectToAction("Index", "Seguridad"));
                }
            }catch (Exception e)
            {
                Warning("Error" + e.Message);
                RedirectToAction("OpcionesUnidad", "SDM", new { idUnidad = idOrden });
            }
            return(View(lstQC));
        }