Esempio n. 1
0
        public List <Jugada> ListarJugadasPremiadasPorSorteo(Sorteo sorteo)
        {
            SqlConnection conexion  = null;
            SqlDataReader drJugadas = null;

            conexion = new SqlConnection(Conexion.Cnn);

            SqlCommand cmdJugadasPremiadasDeJugador = new SqlCommand("ListarJugadasPremiadasPorSorteo", conexion);

            cmdJugadasPremiadasDeJugador.CommandType = CommandType.StoredProcedure;
            cmdJugadasPremiadasDeJugador.Parameters.AddWithValue("@FechaHoraSorteo", sorteo.FechaHora);

            List <Jugada> jugadas = new List <Jugada>();

            try
            {
                conexion.Open();
                drJugadas = cmdJugadasPremiadasDeJugador.ExecuteReader();

                if (drJugadas.HasRows)
                {
                    while (drJugadas.Read())
                    {
                        Jugador jugador = PersistenciaJugador.GetInstancia().BuscarJugador((int)drJugadas["DocumentoJugador"]);

                        List <int> numeros = NumerosDeJugada(Convert.ToInt32(drJugadas["Id"]), jugador);

                        Jugada jugada = new Jugada(Convert.ToInt32(drJugadas["Id"]), jugador, (DateTime)drJugadas["FechaHora"], FabricaPersistencia.GetPersistenciaSorteo().BuscarSorteo((DateTime)drJugadas["FechaHoraSorteo"]), numeros);

                        jugadas.Add(jugada);
                    }
                }
            }
            catch
            {
                throw new Exception("Error al buscar las jugadas premiadas del jugador");
            }
            finally
            {
                if (drJugadas != null)
                {
                    drJugadas.Close();
                }

                if (conexion != null)
                {
                    conexion.Close();
                }
            }

            return(jugadas);
        }
Esempio n. 2
0
        public Jugada BuscarJugada(Jugador jugador, int id)
        {
            SqlConnection conexion = null;
            SqlDataReader drJugada = null;

            conexion = new SqlConnection(Conexion.Cnn);

            SqlCommand cmdBuscarJugada = new SqlCommand("BuscarJugada", conexion);

            cmdBuscarJugada.CommandType = CommandType.StoredProcedure;

            cmdBuscarJugada.Parameters.AddWithValue("@id", id);
            cmdBuscarJugada.Parameters.AddWithValue("@documento", jugador.Documento);

            Jugada jugada = null;

            try
            {
                conexion.Open();

                drJugada = cmdBuscarJugada.ExecuteReader();

                if (drJugada.HasRows)
                {
                    drJugada.Read();

                    List <int> numeros = NumerosDeJugada(id, jugador);

                    jugada = new Jugada(id, jugador, (DateTime)drJugada["FechaHora"], FabricaPersistencia.GetPersistenciaSorteo().BuscarSorteo((DateTime)drJugada["FechaHoraSorteo"]), numeros);
                }
            }
            catch
            {
                throw new Exception("Error al buscar la jugada");
            }
            finally
            {
                if (drJugada != null)
                {
                    drJugada.Close();
                }

                if (conexion != null)
                {
                    conexion.Close();
                }
            }

            return(jugada);
        }