示例#1
0
        internal List <MercadoDTO> RetrieveDTO()
        {
            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("recuperamos: " + res.GetInt32(0) + " " + res.GetInt32(1) + " " + res.GetFloat(2) + " " + res.GetFloat(3) + " " + res.GetFloat(4) + " " + res.GetInt32(5) + " " + res.GetInt32(6));
                    m = new MercadoDTO(res.GetFloat(2), res.GetFloat(3), res.GetFloat(4));
                    mercados.Add(m);
                }
                con.Close();
                return(mercados);
            }
            catch (MySqlException e)
            {
                Debug.WriteLine("se ha producido un error de conexión");
                return(null);
            }
        }
示例#2
0
        internal MercadoDTO RetrieveMercado(ApuestaDTO apuesta)
        {
            MySqlConnection con     = connect();
            MySqlCommand    command = con.CreateCommand();

            if (apuesta.TipoApuesta == "Over")
            {
                command.CommandText = "SELECT CuotaOver FROM Mercado WHERE id = " + apuesta.Mercado_id;
            }
            else if (apuesta.TipoApuesta == "Under")
            {
                command.CommandText = "SELECT CuotaUnder FROM MercadoWHERE id = " + apuesta.Mercado_id;;
            }

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

                if (res.Read())
                {
                    m = new MercadoDTO(res.GetDouble(1), res.GetDouble(2), res.GetDouble(3), res.GetDouble(4), res.GetDouble(5), res.GetInt32(6));
                }
                con.Close();
                return(m);
            }
            catch (MySqlException a)
            {
                Debug.WriteLine("Se ha producido un error de conexión.");
                return(null);
            }
        }
        internal MercadoDTO RetrieveMercado()
        {
            MySqlConnection con     = conect();
            MySqlCommand    command = con.CreateCommand();

            command.CommandText = "SELECT * FROM Mercado";

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

            MercadoDTO m = null;

            if (res.Read())
            {
                Debug.WriteLine("Recuparado: " + res.GetDouble(1) + res.GetDouble(2) + res.GetDouble(3));
                m = new MercadoDTO(res.GetDouble(1), res.GetDouble(2), res.GetDouble(3), res.GetDouble(4), res.GetDouble(5), res.GetInt32(6));
            }

            return(m);
        }
        internal MercadoDTO RetrieveMercado(ApuestaDTO apuesta)
        {
            MySqlConnection con     = conect();
            MySqlCommand    command = con.CreateCommand();


            con.Open();



            if (apuesta.TipoApuesta == "Over")
            {
                command.CommandText = "UPDATE Mercado Set DineroOver = DineroOver + " + apuesta.DineroApostado + " WHERE ID= " + apuesta.Mercado_id;;
            }
            else if (apuesta.TipoApuesta == "Under")
            {
                command.CommandText = "UPDATE Mercado Set DineroUnder = DineroUnder + " + apuesta.DineroApostado + " WHERE ID= " + apuesta.Mercado_id;
            }
            try
            {
                con.Open();
                MySqlDataReader res = command.ExecuteReader();
                MercadoDTO      m   = null;

                if (res.Read())
                {
                    m = new MercadoDTO(res.GetInt32(1), res.GetInt32(2), res.GetInt32(3), res.GetDouble(4), res.GetDouble(5), res.GetInt32(6));
                }
                return(m);
            }
            catch (MySqlException a)
            {
                Debug.WriteLine("Se ha producido un error de conexión");
                return(null);
            }
        }