Esempio n. 1
0
        public static Personajes TraerPersonajes(int Id)
        {
            Personajes    unacategoria = new Personajes();
            SqlConnection Conexion     = Conectar();
            SqlCommand    consulta     = Conexion.CreateCommand();

            consulta.CommandType = System.Data.CommandType.StoredProcedure;
            consulta.CommandText = "sp_TraerPersonaje";
            consulta.Parameters.AddWithValue("@idPersonaje", Id);
            SqlDataReader lector = consulta.ExecuteReader();

            if (lector.Read())
            {
                string Nombre;
                Nombre = lector["Nombre"].ToString();
                unacategoria.Nombre = lector["Nombre"].ToString();
            }
            return(unacategoria);
        }
Esempio n. 2
0
        public static bool InsertarPersonajes(Personajes P)
        {
            bool          a        = false;
            SqlConnection Conexion = Conectar();
            SqlCommand    consulta = Conexion.CreateCommand();

            consulta.CommandType = System.Data.CommandType.StoredProcedure;
            consulta.CommandText = "CrearPersonaje";
            consulta.Parameters.AddWithValue("@Nombre", P.Nombre);
            consulta.Parameters.AddWithValue("@Categoria", P.Categoria);
            consulta.Parameters.AddWithValue("@Imagen", P.Imagen);
            int regsAfectados = consulta.ExecuteNonQuery();

            if (regsAfectados == 1)
            {
                a = true;
            }
            Desconectar(Conexion);
            return(a);
        }
Esempio n. 3
0
        public static List <Personajes> TraerPersonaje(Personajes x)
        {
            List <Personajes> C = new List <Personajes>();
            Personajes        cat;
            SqlConnection     Conexion = Conectar();
            SqlCommand        consulta = Conexion.CreateCommand();

            consulta.CommandType = System.Data.CommandType.StoredProcedure;
            consulta.CommandText = "VerPersonajes";
            SqlDataReader lector = consulta.ExecuteReader();

            while (lector.Read())
            {
                cat             = new Personajes();
                cat.Nombre      = lector["Nombre"].ToString();
                cat.Categoria   = Convert.ToInt32(lector["idCategoría"]);
                cat.IdPersonaje = Convert.ToInt32(lector["IdPersonaje"]);
                cat.Imagen      = lector["Imagen"].ToString();
                C.Add(cat);
            }
            Desconectar(Conexion);
            return(C);
        }