Ejemplo n.º 1
0
        public ViajesNacionales BuscarViaje(int pNumero)
        {
            ViajesNacionales resp = null;
            SqlConnection    cnn  = new SqlConnection(Conexion.CONEXION);

            SqlCommand cmd = new SqlCommand("BuscarViajeNacional", cnn);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@numero", pNumero);
            try
            {
                cnn.Open();
                SqlDataReader lector = cmd.ExecuteReader();

                while (lector.Read())
                {
                    Compania compania = FabricaPersistencia.GetPersistenciaCompania().BuscarParaViaje((string)lector["nomCompania"]);
                    Terminal terminal = FabricaPersistencia.GetPersistenciaTerminal().BuscarParaViaje((string)lector["codTerminal"]);
                    Empleado empleado = FabricaPersistencia.GetPersistenciaEmpleado().BuscarParaViaje((string)lector["cedulaEmpleado"]);

                    resp = new ViajesNacionales((int)lector["numViaje"],
                                                compania,
                                                terminal,
                                                (DateTime)lector["fechaHoraPartida"],
                                                (DateTime)lector["fechaHoraArribo"],
                                                (int)lector["cantidadAsientos"],
                                                empleado,
                                                (int)lector["paradasIntermedias"]);
                }
                lector.Close();
            }
            catch (Exception ex)
            { throw ex; }
            finally { cnn.Close(); }
            return(resp);
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
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);
        }
        public List <ComentarioFeedbackLugar> ListarComentariosFeedbackLugarxUsuario(string CiUsuario)
        {
            MySqlConnection                conexion = new MySqlConnection(Conexion.Cnn);
            ComentarioFeedbackLugar        ComentarioFeedbackLugar       = null;
            List <ComentarioFeedbackLugar> listaComentariosFeedbackLugar = new List <ComentarioFeedbackLugar>();

            MySqlCommand comando = new MySqlCommand("ListarComentariosFeedbackLugarxUsuario", conexion);

            comando.CommandType = System.Data.CommandType.StoredProcedure;
            comando.Parameters.AddWithValue("pCiUsuario", CiUsuario);

            try
            {
                conexion.Open();
                MySqlDataReader lector = comando.ExecuteReader();
                if (lector.HasRows)
                {
                    while (lector.Read())
                    {
                        Usuario unUsuario = null;

                        unUsuario = Persistencia.Clases_Trabajo.PersistenciaAdmin.GetInstancia().Buscar(CiUsuario);

                        if (unUsuario == null)
                        {
                            unUsuario = Persistencia.Clases_Trabajo.PersistenciaCliente.GetInstancia().Buscar(CiUsuario);
                        }
                        else if (unUsuario == null)
                        {
                            unUsuario = Persistencia.Clases_Trabajo.PersistenciaOrganizador.GetInstancia().Buscar(CiUsuario);
                        }
                        else if (unUsuario == null)
                        {
                            unUsuario = Persistencia.Clases_Trabajo.PersistenciaDueño.GetInstancia().Buscar(CiUsuario);
                        }

                        ComentarioFeedbackLugar = new ComentarioFeedbackLugar(Convert.ToInt32(lector["IdComentario"]), Convert.ToString(lector["AsuntoComentario"]), Convert.ToString(lector["MensajeComentario"]), unUsuario, Convert.ToDateTime(lector["FechaRealizado"]), FabricaPersistencia.getPersistenciaFeedbackLugar().BuscarMensajeFeedbackLugar((int)lector["IdFeedback"]));
                        listaComentariosFeedbackLugar.Add(ComentarioFeedbackLugar);
                    }
                }
                lector.Close();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
                conexion.Close();
            }
            return(listaComentariosFeedbackLugar);
        }