Exemple #1
0
        //Permite crear un nuevo rol
        public void AgregarRoles(CatRoles roles)
        {
            comando.Connection  = conn.AbrirConexion();
            comando.CommandText = "AgregarRoles";
            comando.CommandType = CommandType.StoredProcedure;

            comando.Parameters.AddWithValue("@Rol", roles.Rol);

            comando.ExecuteNonQuery();
            conn.CerrarConexion();
        }
Exemple #2
0
        //Permite consultar los detalles de un rol
        public CatRoles ConsultarListaRoles(int?id)
        {
            CatRoles roles = new CatRoles();

            comando.Connection  = conn.AbrirConexion();
            comando.CommandText = "Listar_Roles_Por_Id";
            comando.CommandType = CommandType.StoredProcedure;
            comando.Parameters.AddWithValue("@Id", id);

            leer = comando.ExecuteReader();
            while (leer.Read())
            {
                roles.Id  = Convert.ToInt32(leer["id_Rol"]);
                roles.Rol = leer["rol"].ToString();
            }

            conn.CerrarConexion();
            return(roles);
        }
Exemple #3
0
        //Muestra la lista de Roles
        public IEnumerable <CatRoles> ListaRoles()
        {
            List <CatRoles> listRoles = new List <CatRoles>();

            comando.Connection  = conn.AbrirConexion();
            comando.CommandText = "Listar_Roles";
            comando.CommandType = CommandType.StoredProcedure;
            leer = comando.ExecuteReader();

            while (leer.Read())
            {
                CatRoles roles = new CatRoles();
                roles.Id  = Convert.ToInt32(leer["id_Rol"]);
                roles.Rol = leer["rol"].ToString();



                listRoles.Add(roles);
            }
            leer.Close();
            conn.CerrarConexion();

            return(listRoles);
        }