Пример #1
0
        public ActionResult Nuevo(string nombre, string orden, string padre)
        {
            if (nombre == null)
            {
                return(Json(new { estado = 0 }));
            }

            Ent_Funcion _funcion = new Ent_Funcion();

            Int32 ord = 0;

            Int32.TryParse(orden, out ord);

            _funcion.fun_id     = "0";
            _funcion.fun_nombre = nombre;
            _funcion.fun_orden  = ord.ToString();
            _funcion.fun_padre  = padre;

            Dat_Funcion funcion = new Dat_Funcion();

            funcion.fun = _funcion;

            Boolean _valida_nuevo = funcion.InsertarFuncion();

            return(Json(new { estado = (_valida_nuevo) ? "1" : "-1", desmsg = (_valida_nuevo) ? "Se actualizo satisfactoriamente." : "Hubo un error al actualizar." }));
        }
Пример #2
0
        public List <Ent_Funcion> get_lista(Boolean listar = false)
        {
            string             sqlquery = "[USP_Leer_Funcion_Sistema]";
            List <Ent_Funcion> list     = null;

            try
            {
                using (SqlConnection cn = new SqlConnection(Ent_Conexion.conexion))
                {
                    if (cn.State == 0)
                    {
                        cn.Open();
                    }
                    using (SqlCommand cmd = new SqlCommand(sqlquery, cn))
                    {
                        cmd.CommandTimeout = 0;
                        cmd.CommandType    = CommandType.StoredProcedure;
                        SqlDataReader dr = cmd.ExecuteReader();

                        if (dr.HasRows)
                        {
                            list = new List <Ent_Funcion>();
                            Ent_Funcion fun = new Ent_Funcion();
                            if (!listar)
                            {
                                fun.fun_id     = "0";
                                fun.fun_nombre = "(Vacio)";
                                list.Add(fun);
                            }

                            while (dr.Read())
                            {
                                fun            = new Ent_Funcion();
                                fun.fun_id     = dr["Fun_Id"].ToString();
                                fun.fun_nombre = dr["Fun_Nombre"].ToString();
                                fun.fun_orden  = dr["Fun_Orden"].ToString();
                                fun.fun_padre  = dr["Fun_Padre"].ToString();
                                list.Add(fun);
                            }
                        }
                    }
                }
            }
            catch (Exception exc)
            {
                list = null;
            }
            return(list);
        }
Пример #3
0
        public ActionResult Edit(int?id)
        {
            List <Ent_Funcion> listfuncion = (List <Ent_Funcion>)Session[_session_listfuncion_private];

            if (id == null || listfuncion == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Ent_Funcion filafuncion = listfuncion.Find(x => x.fun_id == id.ToString());

            Dat_Funcion funcion = new Dat_Funcion();

            ViewBag.funcion = funcion.get_lista();
            return(View(filafuncion));
        }
Пример #4
0
        /*agreanfo controler*/
        public ActionResult Aplicacion(Decimal id)
        {
            List <Ent_Funcion> listfuncion = (List <Ent_Funcion>)Session[_session_listfuncion_private];

            if (listfuncion == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Ent_Funcion filafuncion = listfuncion.Find(x => x.fun_id == id.ToString());

            ViewBag.funid     = id.ToString();
            ViewBag.funnombre = filafuncion.fun_nombre.ToString();

            Dat_Aplicacion aplicacion = new Dat_Aplicacion();

            ViewBag.aplicacion = aplicacion.get_lista();

            return(View(lista_fun_apl(id)));
        }
Пример #5
0
        public List <Ent_Funcion> get_lista(decimal rol_id)
        {
            string             sqlquery = "USP_Leer_Funcion_Roles";
            List <Ent_Funcion> list     = null;

            try
            {
                using (SqlConnection cn = new SqlConnection(Ent_Conexion.conexion))
                {
                    if (cn.State == 0)
                    {
                        cn.Open();
                    }
                    using (SqlCommand cmd = new SqlCommand(sqlquery, cn))
                    {
                        cmd.CommandTimeout = 0;
                        cmd.CommandType    = CommandType.StoredProcedure;
                        cmd.Parameters.AddWithValue("@rol_id", rol_id);
                        SqlDataReader dr = cmd.ExecuteReader();
                        list = new List <Ent_Funcion>();
                        if (dr.HasRows)
                        {
                            while (dr.Read())
                            {
                                Ent_Funcion fila = new Ent_Funcion();
                                fila.fun_id     = dr["fun_id"].ToString();
                                fila.fun_nombre = dr["fun_nombre"].ToString();
                                list.Add(fila);
                            }
                        }
                    }
                }
            }
            catch (Exception)
            {
                list = null;
            }
            return(list);
        }