Example #1
0
        internal void Save(Apuesta d)
        {
            MySqlConnection con     = Connect();
            MySqlCommand    command = con.CreateCommand();
            string          sql     = "insert into apuestas (dinero,cuota,tipo_O_U,usuarios_id_usuarios1,mercado_idmercado1) values('" + d.Dinero.ToString() + "','" + d.Cuota.ToString("0.0", CultureInfo.InvariantCulture) + "','" + d.Tipo.ToString() + "','" + d.FK_UsuarioId.ToString() + "','" + d.FK_MercadoId + "');";

            command.CommandText = sql;

            Debug.WriteLine("comando " + command.CommandText);
            try
            {
                con.Open();
                command.ExecuteNonQuery();
                con.Close();
            }
            catch (MySqlException e)
            {
                Debug.WriteLine(e.Message);
            }
        }
Example #2
0
        internal Apuesta Retrieve()
        {
            MySqlConnection con     = Connect();
            MySqlCommand    command = con.CreateCommand();

            command.CommandText = "select * from apuestas";

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

            Apuesta a = null;

            if (res.Read())
            {
                Debug.WriteLine("Recuperado: " + res.GetInt16(0) + " " + res.GetFloat(1) + " " + res.GetFloat(2) + " " + res.GetChar(3) + res.GetInt16(4) + " " + res.GetFloat(5));
                a = new Apuesta(res.GetInt16(0), res.GetFloat(1), res.GetFloat(2), res.GetChar(3), res.GetInt16(4), res.GetInt32(5), res.GetString(6));
            }

            con.Close();

            return(a);
        }