internal List <ApuestaExamen> RetrieveExamen()
        {
            MySqlConnection con     = Connect();
            MySqlCommand    command = con.CreateCommand();

            command.CommandText = "select email_fk , id_mercado_fk, cuota, dinero_apostado from apuesta";

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

                ApuestaExamen        a       = null;
                List <ApuestaExamen> apuesta = new List <ApuestaExamen>();
                while (res.Read())
                {
                    Debug.WriteLine("Recuperado: " + res.GetString(0) + " " + res.GetInt32(1) + " " + res.GetDouble(2) + " " + res.GetDouble(3));

                    a = new ApuestaExamen(res.GetString(0), res.GetInt32(1), res.GetDouble(2), res.GetDouble(3));
                }



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

            catch (MySqlException e)
            {
                Debug.WriteLine("Se ha producido un error de conexion");
                return(null);
            }
        }
Exemplo n.º 2
0
        internal List <ApuestaExamen> ApuestasExamen()
        {
            CultureInfo culInfo = new System.Globalization.CultureInfo("es-ES");

            culInfo.NumberFormat.NumberDecimalSeparator          = ".";
            culInfo.NumberFormat.CurrencyDecimalSeparator        = ".";
            culInfo.NumberFormat.PercentDecimalSeparator         = ".";
            culInfo.NumberFormat.CurrencyDecimalSeparator        = ".";
            System.Threading.Thread.CurrentThread.CurrentCulture = culInfo;

            MySqlConnection con     = Connect();
            MySqlCommand    command = con.CreateCommand();

            command.CommandText = "select a.dinero_apostado, a.cuota, u.nombre from apuestas a, usuarios u where u.id_usuario=a.usuarios_id_usuarios";
            Debug.WriteLine("COMMAND " + command.CommandText);


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

                ApuestaExamen        m     = null;
                List <ApuestaExamen> datos = new List <ApuestaExamen>();

                while (res.Read())
                {
                    Debug.WriteLine("Cantidad:  " + res.GetDouble(0) + " Nombre_usuario " + res.GetString(2) + " Cuota_apuesta : " + res.GetDouble(1));

                    m = new ApuestaExamen(res.GetDouble(0), res.GetString(2), res.GetDouble(1));
                    datos.Add(m);
                }
                con.Close();
                return(datos);
            }
            catch (MySqlException e)
            {
                Debug.WriteLine("Error de conexión");
                return(null);
            }
        }