Exemplo n.º 1
0
        public bool UpdateLiga(Liga l)
        {
            MySqlConnection Conexion = new MySqlConnection();
            MySqlCommand    Query    = new MySqlCommand();
            MySqlDataReader consulta;

            AbrirConexionSql(Conexion);
            //
            Query.CommandText = "UPDATE LIGAS SET CAMPEON_ACTUAL=" + l.getUltimoCampeon() + " WHERE ID=" + l.getId() + ";";
            Query.Connection  = Conexion;
            consulta          = Query.ExecuteReader();

            Conexion.Close();
            return(true);
        }
Exemplo n.º 2
0
        public bool NuevaLiga(Liga liga)
        {
            MySqlConnection Conexion = new MySqlConnection();
            MySqlCommand    Query    = new MySqlCommand();
            MySqlDataReader consulta;

            AbrirConexionSql(Conexion);
            //Insertar aqui...
            if (liga.getUltimoCampeon() == 0)
            {
                Query.CommandText = "INSERT INTO LIGAS(NOMBRE) VALUES ('" + liga.getNombre() + "');";
            }
            else
            {
                Query.CommandText = "INSERT INTO LIGAS(NOMBRE,CAMPEON_ACTUAL) VALUES ('" + liga.getNombre() + "','" + liga.getUltimoCampeon() + "');";
            }

            Query.Connection = Conexion;
            consulta         = Query.ExecuteReader();

            Conexion.Close();
            return(true);
        }
Exemplo n.º 3
0
        public List <Liga> TraerLigas()
        {
            List <Liga>     ligas    = new List <Liga>();
            MySqlConnection Conexion = new MySqlConnection();
            MySqlCommand    Query    = new MySqlCommand();
            MySqlDataReader consulta;

            try
            {
                AbrirConexionSql(Conexion);

                Query.CommandText = "SELECT * FROM ligas";
                Query.Connection  = Conexion;

                //Consultar
                consulta = Query.ExecuteReader();

                while (consulta.Read())
                {
                    Liga l = new Liga();

                    l.setId(consulta.GetInt32("ID"));
                    l.setNombre(consulta.GetString("NOMBRE"));
                    //l.setUltimoCampeon(consulta.GetInt32("CAMPEON_ACTUAL"));
                    ligas.Add(l);
                }
                Conexion.Close();
                return(ligas);
            }
            catch
            {
                Console.WriteLine("Se produjo un error al buscar los partidos");
                Conexion.Close();
                return(ligas);
            }
        }