Example #1
0
        internal List <EventoDTO> RetrieveDTO() //internal es como un public pero un poco mas restrictivo
        {
            MySqlConnection con     = Connect();
            MySqlCommand    command = con.CreateCommand();

            command.CommandText = "select * from Eventos";

            try
            {
                con.Open();
                MySqlDataReader  res     = command.ExecuteReader();
                EventoDTO        e       = null;
                List <EventoDTO> eventos = new List <EventoDTO>();
                while (res.Read())

                {
                    Debug.WriteLine("Recuperado:" + res.GetInt32(0) + " " + res.GetString(1) + " " + res.GetString(2) + " " + res.GetDateTime(3));
                    e = new EventoDTO(res.GetString(1), res.GetString(2), res.GetDateTime(3));
                    eventos.Add(e);
                }
                con.Close();
                return(eventos);
            }
            catch (MySqlException e)
            {
                Debug.WriteLine("Se ha producido un error de conexion");
                return(null);
            }
        }
Example #2
0
        internal List <EventoDTO> RetrieveDTO()
        {
            MySqlConnection con     = Connect();
            MySqlCommand    command = con.CreateCommand();

            command.CommandText = "select * from evento";

            try
            {
                con.Open();
                MySqlDataReader res = command.ExecuteReader();

                EventoDTO        a     = null;
                List <EventoDTO> lista = new List <EventoDTO>();
                while (res.Read())
                {
                    Debug.WriteLine("Recuperado: " + res.GetString(1) + " " + res.GetString(2) + " " + res.GetString(3));
                    a = new EventoDTO(res.GetString(1), res.GetString(2), res.GetString(3));
                    lista.Add(a);
                }

                return(lista);
            }
            catch (MySqlException e)
            {
                Debug.WriteLine("Se ha producido un error de conexion");
                return(null);
            }
        }
Example #3
0
        internal List <EventoDTO> RetrieveDTO()
        {
            MySqlConnection con     = Connect();
            MySqlCommand    command = con.CreateCommand();

            command.CommandText = "select nombreEquipo,visitante,fechaEvento from eventos";
            try
            {
                con.Open();
                MySqlDataReader resultado = command.ExecuteReader();

                EventoDTO        evento  = null;
                List <EventoDTO> eventos = new List <EventoDTO>();
                while (resultado.Read())
                {
                    Debug.WriteLine("Recuperado: "
                                    + resultado.GetString(0) + " " + resultado.GetString(1) + " " + resultado.GetDateTime(2));
                    evento = new EventoDTO(
                        resultado.GetString(0), resultado.GetString(1), resultado.GetDateTime(2));
                    eventos.Add(evento);
                }
                con.Close();
                return(eventos);
            }
            catch (Exception)
            {
                Debug.WriteLine("Ha ocurrido un error.");
                return(null);
            }
        }
Example #4
0
        internal EventoDTO Retrieve()
        {
            MySqlConnection con     = Connect();
            MySqlCommand    command = con.CreateCommand();

            command.CommandText = "SELECT * FROM Evento";

            con.Open();
            MySqlDataReader res = command.ExecuteReader();

            EventoDTO e = null;

            if (res.Read())
            {
                Debug.WriteLine("Recuperado: " + res.GetString(1) + res.GetString(2) + res.GetString(3));
                e = new EventoDTO(res.GetString(1), res.GetString(2), res.GetString(3));
            }


            return(e);
        }