コード例 #1
0
        internal List <MercadoDTO> RetrieveTipoUnderOver(int id_mercado)
        {
            MySqlConnection con     = Connect();
            MySqlCommand    command = con.CreateCommand();

            command.CommandText = "select tipo_mercado,cuota_over,cuota_under from mercado where id_mercado = @A";
            command.Parameters.AddWithValue("@A", id_mercado);

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

                MercadoDTO        m       = null;
                List <MercadoDTO> mercado = new List <MercadoDTO>();
                while (res.Read())
                {
                    Debug.WriteLine("Recuperado: " + res.GetInt32(0) + " " + res.GetDouble(1) + " " + res.GetDouble(2));

                    m = new MercadoDTO(res.GetInt32(0), res.GetDouble(1), res.GetDouble(2));


                    mercado.Add(m);
                }

                con.Close();
                return(mercado);
            }

            catch (MySqlException e)
            {
                Debug.WriteLine("Se ha producido un error de conexion");
                return(null);
            }
        }
コード例 #2
0
        internal List <MercadoDTO> RetrieveTipoMercado()
        {
            MySqlConnection con     = Connect();
            MySqlCommand    command = con.CreateCommand();

            command.CommandText = "select * from mercados";


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

                MercadoDTO        m        = null;
                List <MercadoDTO> mercados = new List <MercadoDTO>();

                while (res.Read())
                {
                    Debug.WriteLine("Datos de mercado: Tipo: " + res.GetInt32(0) + " cuota_over: " + res.GetString(1) +
                                    " cuota_under " + res.GetDouble(2));
                    m = new MercadoDTO(res.GetDouble(1), res.GetDouble(2), res.GetDouble(3));
                    mercados.Add(m);
                }
                con.Close();
                return(mercados);
            }
            catch (MySqlException e)
            {
                Debug.WriteLine("Error de conexión");
                return(null);
            }
        }
コード例 #3
0
        internal List <MercadoDTO> RetrieveDTO()
        {
            MySqlConnection con     = Connect();
            MySqlCommand    command = con.CreateCommand();

            command.CommandText = "select * from mercado";

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

                MercadoDTO        m       = null;
                List <MercadoDTO> mercado = new List <MercadoDTO>();
                while (res.Read())
                {
                    Debug.WriteLine("Recuperado: " + res.GetInt32(0) + " " + res.GetInt32(1) + " " + res.GetDouble(2) + " " + res.GetDouble(3) + " " + res.GetDouble(4) + " " + res.GetDouble(5) + " " + res.GetInt32(6));

                    m = new MercadoDTO(res.GetInt32(1), res.GetInt32(2), res.GetDouble(3));

                    mercado.Add(m);
                }

                con.Close();
                return(mercado);
            }

            catch (MySqlException e)
            {
                Debug.WriteLine("Se ha producido un error de conexion");
                return(null);
            }
        }