Ejemplo n.º 1
0
        public ActionResult EditIfUpdatePartial(ProcesoValoresModel dataImpacto)
        {
            if (ModelState.IsValid)
            {
                using (Entities db = new Entities())
                {
                    if (dataImpacto.IdTipoEscala > 0)
                    {
                        tblBIAProceso _proceso = db.tblBIAProceso.FirstOrDefault(x => x.IdEmpresa == dataImpacto.IdEmpresa &&
                                                                                 x.IdProceso == dataImpacto.IdProceso);

                        if (_proceso != null)
                        {
                            var regs = db.tblBIAImpactoFinanciero.FirstOrDefault(x => x.IdEmpresa == dataImpacto.IdEmpresa &&
                                                                                 x.IdDocumentoBIA == _proceso.IdDocumentoBia &&
                                                                                 x.IdProceso == dataImpacto.IdProceso);
                            regs.IdEscala = dataImpacto.IdTipoEscala;
                            db.SaveChanges();
                        }
                    }
                }
            }
            else
            {
                ViewData["EditError"] = "Please, correct all errors.";
            }

            return(PartialView("AjustarIFPartialView"));
        }
Ejemplo n.º 2
0
        public ActionResult UpdateCriticos(CriticoModel model)
        {
            long   IdEmpresa       = long.Parse(Session["IdEmpresa"].ToString());
            long   modId           = long.Parse(Session["modId"].ToString());
            string _modId          = Session["modId"].ToString();
            int    IdTipoDocumento = int.Parse(_modId.Substring(0, (_modId.Length == 7 ? 1 : 2)));

            IList <string> ValoresIF  = (Session["ValoresIF"] != null ? Session["ValoresIF"].ToString().Split(',').ToList() : new List <string>());
            IList <string> ValoresIO  = (Session["ValoresIO"] != null ? Session["ValoresIO"].ToString().Split(',').ToList() : new List <string>());
            IList <string> ValoresMTD = (Session["ValoresMTD"] != null ? Session["ValoresMTD"].ToString().Split(',').ToList() : new List <string>());
            IList <string> ValoresRTO = (Session["ValoresRTO"] != null ? Session["ValoresRTO"].ToString().Split(',').ToList() : new List <string>());
            IList <string> ValoresRPO = (Session["ValoresRPO"] != null ? Session["ValoresRPO"].ToString().Split(',').ToList() : new List <string>());
            IList <string> ValoresWRT = (Session["ValoresWRT"] != null ? Session["ValoresWRT"].ToString().Split(',').ToList() : new List <string>());

            IQueryable <DocumentoProcesoModel> _Procesos = Metodos.GetProcesosByImpacto().AsQueryable();

            using (Entities db = new Entities())
            {
                foreach (DocumentoProcesoModel _proceso in _Procesos)
                {
                    tblBIAProceso proceso = db.tblBIAProceso.FirstOrDefault(x => x.IdEmpresa == IdEmpresa && x.IdProceso == _proceso.IdProceso);
                    if (proceso != null)
                    {
                        proceso.Critico = _proceso.Selected;
                    }
                }

                if (ValoresIF.Count() > 0)
                {
                    foreach (string valor in ValoresIF)
                    {
                        long          _valor       = long.Parse(valor);
                        tblEscala     _escala      = db.tblEscala.FirstOrDefault(x => x.IdEmpresa == IdEmpresa && x.IdTipoEscala == 1 && x.IdEscala == _valor);
                        string        _Descripcion = _escala.Descripcion;
                        tblCriticidad _criticidad  = new tblCriticidad
                        {
                            DescripcionEscala = _Descripcion,
                            IdEmpresa         = IdEmpresa,
                            IdTipoEscala      = _escala.IdEscala,
                            FechaAplicacion   = DateTime.UtcNow,
                        };
                        db.tblCriticidad.Add(_criticidad);
                    }
                }
                if (ValoresIO.Count() > 0)
                {
                    foreach (string valor in ValoresIO)
                    {
                        long          _valor       = long.Parse(valor);
                        tblEscala     _escala      = db.tblEscala.FirstOrDefault(x => x.IdEmpresa == IdEmpresa && x.IdTipoEscala == 2 && x.IdEscala == _valor);
                        string        _Descripcion = _escala.Descripcion;
                        tblCriticidad _criticidad  = new tblCriticidad
                        {
                            DescripcionEscala = _Descripcion,
                            IdEmpresa         = IdEmpresa,
                            IdTipoEscala      = _escala.IdEscala,
                            FechaAplicacion   = DateTime.UtcNow,
                        };
                        db.tblCriticidad.Add(_criticidad);
                    }
                }
                if (ValoresMTD.Count() > 0)
                {
                    foreach (string valor in ValoresMTD)
                    {
                        long          _valor       = long.Parse(valor);
                        tblEscala     _escala      = db.tblEscala.FirstOrDefault(x => x.IdEmpresa == IdEmpresa && x.IdTipoEscala == 3 && x.IdEscala == _valor);
                        string        _Descripcion = _escala.Descripcion;
                        tblCriticidad _criticidad  = new tblCriticidad
                        {
                            DescripcionEscala = _Descripcion,
                            IdEmpresa         = IdEmpresa,
                            IdTipoEscala      = _escala.IdEscala,
                            FechaAplicacion   = DateTime.UtcNow,
                        };
                        db.tblCriticidad.Add(_criticidad);
                    }
                }
                if (ValoresRTO.Count() > 0)
                {
                    foreach (string valor in ValoresRTO)
                    {
                        long          _valor       = long.Parse(valor);
                        tblEscala     _escala      = db.tblEscala.FirstOrDefault(x => x.IdEmpresa == IdEmpresa && x.IdTipoEscala == 4 && x.IdEscala == _valor);
                        string        _Descripcion = _escala.Descripcion;
                        tblCriticidad _criticidad  = new tblCriticidad
                        {
                            DescripcionEscala = _Descripcion,
                            IdEmpresa         = IdEmpresa,
                            IdTipoEscala      = _escala.IdEscala,
                            FechaAplicacion   = DateTime.UtcNow,
                        };
                        db.tblCriticidad.Add(_criticidad);
                    }
                }
                if (ValoresRPO.Count() > 0)
                {
                    foreach (string valor in ValoresRPO)
                    {
                        long          _valor       = long.Parse(valor);
                        tblEscala     _escala      = db.tblEscala.FirstOrDefault(x => x.IdEmpresa == IdEmpresa && x.IdTipoEscala == 5 && x.IdEscala == _valor);
                        string        _Descripcion = _escala.Descripcion;
                        tblCriticidad _criticidad  = new tblCriticidad
                        {
                            DescripcionEscala = _Descripcion,
                            IdEmpresa         = IdEmpresa,
                            IdTipoEscala      = _escala.IdEscala,
                            FechaAplicacion   = DateTime.UtcNow,
                        };
                        db.tblCriticidad.Add(_criticidad);
                    }
                }
                if (ValoresWRT.Count() > 0)
                {
                    foreach (string valor in ValoresWRT)
                    {
                        long          _valor       = long.Parse(valor);
                        tblEscala     _escala      = db.tblEscala.FirstOrDefault(x => x.IdEmpresa == IdEmpresa && x.IdTipoEscala == 6 && x.IdEscala == _valor);
                        string        _Descripcion = _escala.Descripcion;
                        tblCriticidad _criticidad  = new tblCriticidad
                        {
                            DescripcionEscala = _Descripcion,
                            IdEmpresa         = IdEmpresa,
                            IdTipoEscala      = _escala.IdEscala,
                            FechaAplicacion   = DateTime.UtcNow,
                        };
                        db.tblCriticidad.Add(_criticidad);
                    }
                }

                db.SaveChanges();
            }

            return(RedirectToAction("Criticos", new
            {
                modId
            }));
        }