Exemple #1
0
        /// <summary>
        /// realiza el jugego por un jugador
        /// </summary>
        /// <param name="dropJugador">lista del jugador</param>
        /// <param name="dropColor">lista del color</param>
        /// <param name="txtCantidadJugadorApuesta">cantidad</param>
        /// <param name="ColorRuleta">Color ramdom</param>
        /// <param name="stGanancia">donde quedara guardada la salida</param>
        /// <param name="stlblDineroActual">donde quedaará guardado el dinero acual</param>
        private void Jugar(DropDownList dropJugador, DropDownList dropColor, TextBox txtCantidadJugadorApuesta,
                           Color ColorRuleta, out string stGanancia, out string stlblDineroActual)
        {
            casinoEntities casino    = new casinoEntities();
            var            idJugador = int.Parse(dropJugador.SelectedValue);
            var            Jugador   = casino.jugadores.SingleOrDefault(j => j.id == idJugador);

            decimal recuperado = CantidadRecuperadXColor(ColorRuleta);

            var cantidadApuesta = int.Parse(txtCantidadJugadorApuesta.Text);
            var ganancia        = recuperado * cantidadApuesta;
            var mensajeGanancia = "";

            if (dropColor.SelectedItem.Text == ColorRuleta.ToString())
            {
                Jugador.cantidad = Jugador.cantidad + ganancia;
                mensajeGanancia  = $"{recuperado} veces lo apostado: ${Math.Round(ganancia, 1)}";
            }
            else
            {
                Jugador.cantidad = Jugador.cantidad - cantidadApuesta;
                mensajeGanancia  = "$0";
            }

            casino.SaveChanges();
            stGanancia        = mensajeGanancia;
            stlblDineroActual = $"${Math.Round(Jugador.cantidad, 1)}";
        }
Exemple #2
0
 /// <summary>
 /// /verifica si la transaccion fu exitoisa
 /// </summary>
 /// <param name="casino">entidad a guardar</param>
 public void VerificaTran(casinoEntities casino)
 {
     if (casino.SaveChanges() > 0)
     {
         ShowMensajes("Cambios guardados exitosamente");
     }
     else
     {
         ShowMensajes("No se pudo intente de nuevo");
     }
     Limpiar();
 }