示例#1
0
        internal MercadoDinero RetrieveDinero()
        {
            MySqlConnection con     = Connect();
            MySqlCommand    command = con.CreateCommand();

            command.CommandText = "SELECT * FROM Mercado";

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

            MercadoDinero Dinero = null;

            if (res.Read())
            {
                Debug.WriteLine("dinero recuperado " + res.GetInt32(0) + res.GetDouble(4) + res.GetDouble(5));
                Dinero = new MercadoDinero(res.GetInt32(0), res.GetDouble(4), res.GetDouble(5));
            }

            return(Dinero);
        }
示例#2
0
        internal void Calculos(MercadoDinero Dinero)
        {
            MySqlConnection con              = Connect();
            MySqlCommand    command          = con.CreateCommand();
            double          probabilidadOver = Dinero.DineroOver / (Dinero.DineroOver + Dinero.DineroUnder);
            double          cuotaOver        = 0;
            double          over             = 0.95;

            if (probabilidadOver != 0)
            {
                cuotaOver = 1 / probabilidadOver * 0.95;
                over      = Math.Round((double)Convert.ToDouble(cuotaOver), 2);
            }

            double probabilidadUnder = Dinero.DineroUnder / (Dinero.DineroOver + Dinero.DineroUnder);
            double cuotaUnder        = 0;
            double under             = 0.95;

            if (probabilidadUnder != 0)
            {
                cuotaUnder = 1 / probabilidadUnder * 0.95;
                under      = Math.Round((double)Convert.ToDouble(cuotaUnder), 2);
            }



            Debug.WriteLine("under: " + cuotaUnder + "dineroOver: " + Dinero.DineroOver + "dineroUnder: " + Dinero.DineroUnder + "probabilidad: " + probabilidadUnder);
            Debug.WriteLine("under: " + under);
            con.Open();

            command.CommandText = "UPDATE Mercado SET CuotaUnder=" + under.ToString(CultureInfo.CreateSpecificCulture("us-US")) + ", CuotaOver =" + over.ToString(CultureInfo.CreateSpecificCulture("us-US")) + " WHERE ID= " + Dinero.MercadoID + ";";
            Debug.WriteLine("Comando: " + command.CommandText);



            command.ExecuteNonQuery();
        }