示例#1
0
        // GET: Ppag/Edit/5
        public ActionResult Edit(int id, int np)
        {
            int pagina = 763; //ID EN BASE DE DATOS

            using (TruequeEntities db = new TruequeEntities())
            {
                string u = User.Identity.Name;
                //string u = "admin";
                var user = db.USUARIOs.Where(a => a.ID.Equals(u)).FirstOrDefault();
                ViewBag.permisos = db.PAGINAVs.Where(a => a.ID.Equals(user.ID)).ToList();
                ViewBag.carpetas = db.CARPETAVs.Where(a => a.USUARIO_ID.Equals(user.ID)).ToList();
                ViewBag.usuario  = user; ViewBag.returnUrl = Request.Url.PathAndQuery;;
                ViewBag.rol      = user.PUESTO.PUESTOTs.Where(a => a.SPRAS_ID.Equals(user.SPRAS_ID)).FirstOrDefault().TXT50;
                ViewBag.Title    = db.PAGINAs.Where(a => a.ID.Equals(pagina)).FirstOrDefault().PAGINATs.Where(b => b.SPRAS_ID.Equals(user.SPRAS_ID)).FirstOrDefault().TXT50;
                ViewBag.warnings = db.WARNINGVs.Where(a => (a.PAGINA_ID.Equals(pagina) || a.PAGINA_ID.Equals(0)) && a.SPRAS_ID.Equals(user.SPRAS_ID)).ToList();
                ViewBag.textos   = db.TEXTOes.Where(a => (a.PAGINA_ID.Equals(761) || a.PAGINA_ID.Equals(0)) && a.SPRAS_ID.Equals(user.SPRAS_ID)).ToList();

                try
                {
                    string p = Session["pais"].ToString();
                    ViewBag.pais = p + ".svg";
                }
                catch
                {
                    //ViewBag.pais = "mx.svg";
                    //return RedirectToAction("Pais", "Home");
                }
                Session["spras"] = user.SPRAS_ID;
                ViewBag.lan      = user.SPRAS_ID;
            }
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            if (id >= 10)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            PERMISO_PAGINA pERMISO_PAGINA = db.PERMISO_PAGINA.Where(x => x.ROL_ID == id && x.PAGINA_ID == np).FirstOrDefault();

            ViewBag.ac = pERMISO_PAGINA.PERMISO;
            if (pERMISO_PAGINA == null)
            {
                return(HttpNotFound());
            }
            //ViewBag.ID = new SelectList(db.PAGINAs, "ID", "URL", pERMISO_PAGINA.PAGINA_ID);
            //ViewBag.ROL_ID = new SelectList(db.PUESTOes, "ID", "ID", pERMISO_PAGINA.ROL_ID);
            return(View(pERMISO_PAGINA));
        }
示例#2
0
        public ActionResult Edit([Bind(Include = "PAGINA_ID,ROL_ID,PERMISO")] PERMISO_PAGINA pERMISO_PAGINA, string ac)
        {
            if (ModelState.IsValid)
            {
                PERMISO_PAGINA pp = pERMISO_PAGINA;
                if (ac == "Activo")
                {
                    pp.PERMISO = false;
                }
                else if (ac == "Inactivo")
                {
                    pp.PERMISO = true;
                }
                db.Entry(pERMISO_PAGINA).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index", new { id = pp.ROL_ID }));
            }
            int pagina = 763; //ID EN BASE DE DATOS

            using (TAT001Entities db = new TAT001Entities())
            {
                string u = User.Identity.Name;
                //string u = "admin";
                var user = db.USUARIOs.Where(a => a.ID.Equals(u)).FirstOrDefault();
                ViewBag.permisos = db.PAGINAVs.Where(a => a.ID.Equals(user.ID)).ToList();
                ViewBag.carpetas = db.CARPETAVs.Where(a => a.USUARIO_ID.Equals(user.ID)).ToList();
                ViewBag.usuario  = user; ViewBag.returnUrl = Request.Url.PathAndQuery;;
                ViewBag.rol      = user.PUESTO.PUESTOTs.Where(a => a.SPRAS_ID.Equals(user.SPRAS_ID)).FirstOrDefault().TXT50;
                ViewBag.Title    = db.PAGINAs.Where(a => a.ID.Equals(pagina)).FirstOrDefault().PAGINATs.Where(b => b.SPRAS_ID.Equals(user.SPRAS_ID)).FirstOrDefault().TXT50;
                ViewBag.warnings = db.WARNINGVs.Where(a => (a.PAGINA_ID.Equals(pagina) || a.PAGINA_ID.Equals(0)) && a.SPRAS_ID.Equals(user.SPRAS_ID)).ToList();
                ViewBag.textos   = db.TEXTOes.Where(a => (a.PAGINA_ID.Equals(761) || a.PAGINA_ID.Equals(0)) && a.SPRAS_ID.Equals(user.SPRAS_ID)).ToList();

                try
                {
                    string p = Session["pais"].ToString();
                    ViewBag.pais = p + ".svg";
                }
                catch
                {
                    //ViewBag.pais = "mx.svg";
                    //return RedirectToAction("Pais", "Home");
                }
                Session["spras"] = user.SPRAS_ID;
                ViewBag.lan      = user.SPRAS_ID;
            }
            ViewBag.PAGINA_ID = new SelectList(db.PAGINAs, "ID", "URL", pERMISO_PAGINA.PAGINA_ID);
            ViewBag.ROL_ID    = new SelectList(db.PUESTOes, "ID", "ID", pERMISO_PAGINA.ROL_ID);
            return(View(pERMISO_PAGINA));
        }
示例#3
0
        // GET: Ppag/Create
        public ActionResult Create(int id)
        {
            int pagina = 764; //ID EN BASE DE DATOS

            using (TAT001Entities db = new TAT001Entities())
            {
                string u = User.Identity.Name;
                //string u = "admin";
                var user = db.USUARIOs.Where(a => a.ID.Equals(u)).FirstOrDefault();
                ViewBag.permisos = db.PAGINAVs.Where(a => a.ID.Equals(user.ID)).ToList();
                ViewBag.carpetas = db.CARPETAVs.Where(a => a.USUARIO_ID.Equals(user.ID)).ToList();
                ViewBag.usuario  = user; ViewBag.returnUrl = Request.Url.PathAndQuery;;
                ViewBag.rol      = user.PUESTO.PUESTOTs.Where(a => a.SPRAS_ID.Equals(user.SPRAS_ID)).FirstOrDefault().TXT50;
                ViewBag.Title    = db.PAGINAs.Where(a => a.ID.Equals(pagina)).FirstOrDefault().PAGINATs.Where(b => b.SPRAS_ID.Equals(user.SPRAS_ID)).FirstOrDefault().TXT50;
                ViewBag.warnings = db.WARNINGVs.Where(a => (a.PAGINA_ID.Equals(pagina) || a.PAGINA_ID.Equals(0)) && a.SPRAS_ID.Equals(user.SPRAS_ID)).ToList();
                ViewBag.textos   = db.TEXTOes.Where(a => (a.PAGINA_ID.Equals(761) || a.PAGINA_ID.Equals(0)) && a.SPRAS_ID.Equals(user.SPRAS_ID)).ToList();

                try
                {
                    string p = Session["pais"].ToString();
                    ViewBag.pais = p + ".svg";
                }
                catch
                {
                    //ViewBag.pais = "mx.svg";
                    //return RedirectToAction("Pais", "Home");
                }
                Session["spras"] = user.SPRAS_ID;
                ViewBag.lan      = user.SPRAS_ID;
                ViewBag.IDI      = id;
            }
            List <PERMISO_PAGINA> pp  = db.PERMISO_PAGINA.Where(x => x.ROL_ID == id).ToList();
            List <PAGINA>         pi  = db.PAGINAs.ToList();
            List <PAGINA>         lst = new List <PAGINA>();

            for (int y = 0; y < pi.Count; y++)
            {
                PERMISO_PAGINA pg = pp.Where(x => x.PAGINA_ID == pi[y].ID).FirstOrDefault();
                if (pg == null)
                {
                    lst.Add(pi[y]);
                }
            }
            ViewBag.PAGINA_ID = new SelectList(lst, "ID", "ID");
            ViewBag.ROL_ID    = new SelectList(db.PUESTOes, "ID", "ID");
            return(View());
        }
示例#4
0
        public ActionResult Create([Bind(Include = "PAGINA_ID,ROL_ID,PERMISO")] PERMISO_PAGINA pERMISO_PAGINA, string idx)
        {
            if (ModelState.IsValid)
            {
                var ppx = db.PERMISO_PAGINA.Where(x => x.ROL_ID == pERMISO_PAGINA.ROL_ID && x.PAGINA_ID == pERMISO_PAGINA.PAGINA_ID).FirstOrDefault();
                //si el valor que se esta tratando de meter ya existe no entrara en la condicion
                if (ppx == null)
                {
                    //en automatico estara activa
                    pERMISO_PAGINA.PERMISO = true;
                    db.PERMISO_PAGINA.Add(pERMISO_PAGINA);
                    db.SaveChanges();
                    return(RedirectToAction("Index", new { id = int.Parse(idx) }));
                }
            }
            int pagina = 764; //ID EN BASE DE DATOS

            using (TruequeEntities db = new TruequeEntities())
            {
                string u = User.Identity.Name;
                //string u = "admin";
                var user = db.USUARIOs.Where(a => a.ID.Equals(u)).FirstOrDefault();
                ViewBag.permisos = db.PAGINAVs.Where(a => a.ID.Equals(user.ID)).ToList();
                ViewBag.carpetas = db.CARPETAVs.Where(a => a.USUARIO_ID.Equals(user.ID)).ToList();
                ViewBag.usuario  = user; ViewBag.returnUrl = Request.Url.PathAndQuery;;
                ViewBag.rol      = user.PUESTO.PUESTOTs.Where(a => a.SPRAS_ID.Equals(user.SPRAS_ID)).FirstOrDefault().TXT50;
                ViewBag.Title    = db.PAGINAs.Where(a => a.ID.Equals(pagina)).FirstOrDefault().PAGINATs.Where(b => b.SPRAS_ID.Equals(user.SPRAS_ID)).FirstOrDefault().TXT50;
                ViewBag.warnings = db.WARNINGVs.Where(a => (a.PAGINA_ID.Equals(pagina) || a.PAGINA_ID.Equals(0)) && a.SPRAS_ID.Equals(user.SPRAS_ID)).ToList();
                ViewBag.textos   = db.TEXTOes.Where(a => (a.PAGINA_ID.Equals(761) || a.PAGINA_ID.Equals(0)) && a.SPRAS_ID.Equals(user.SPRAS_ID)).ToList();
                ViewBag.error    = "Valores Existentes";
                try
                {
                    string p = Session["pais"].ToString();
                    ViewBag.pais = p + ".svg";
                }
                catch
                {
                    //ViewBag.pais = "mx.svg";
                    //return RedirectToAction("Pais", "Home");
                }
                Session["spras"] = user.SPRAS_ID;
            }
            ViewBag.PAGINA_ID = new SelectList(db.PAGINAs, "ID", "ID", pERMISO_PAGINA.PAGINA_ID);
            ViewBag.ROL_ID    = new SelectList(db.PUESTOes, "ID", "ID", pERMISO_PAGINA.ROL_ID);
            return(View(pERMISO_PAGINA));
        }