public static PersistenciaTerminal GetInstancia()
 {
     if (_instancia == null)
     {
         _instancia = new PersistenciaTerminal();
     }
     return(_instancia);
 }
        public Internacional BuscarInternacional(int pNumeroViaje)
        {
            SqlDataReader dr;

            Internacional unInternacional = null;

            Empleado unEmpelado  = null;
            Terminal unaTerminal = null;
            Compania unaCompania = null;

            SqlConnection oConexion = new SqlConnection(Conexion.Con);
            SqlCommand    comando   = new SqlCommand("Sp_BuscarInternacionales", oConexion);

            comando.CommandType = CommandType.StoredProcedure;
            comando.Parameters.AddWithValue("@numeroViaje", pNumeroViaje);

            try
            {
                dr = comando.ExecuteReader();

                if (dr.HasRows)
                {
                    while (dr.Read())
                    {
                        unEmpelado = PersistenciaEmpleado.getInstancia().BuscarEmpleado(int.Parse(dr["CiEmpleado"].ToString()));

                        unaTerminal = PersistenciaTerminal.getInstancia().BuscarTerminal(dr["CodigoTerminal"].ToString());

                        unaCompania = PersistenciaCompania.getInstancia().BuscarCompania(dr["NombreCompania"].ToString());

                        unInternacional = new Internacional(int.Parse(dr["NumeroViaje"].ToString()), DateTime.Parse(dr["FHSalida"].ToString()),
                                                            DateTime.Parse(dr["FHLlegada"].ToString()), int.Parse(dr["Asientos"].ToString()),
                                                            unEmpelado, unaTerminal, unaCompania, bool.Parse(dr["ServicioABordo"].ToString()),
                                                            dr["Documentacion"].ToString());
                    }
                }
                dr.Close();
            }
            catch (Exception ex)
            {
                throw new ApplicationException("Problemas con la base de datos:" + ex.Message);
            }
            finally
            {
                oConexion.Close();
            }
            return(unInternacional);
        }
        public List <Viajes> ListarNacionalesTodos()
        {
            List <Viajes> lista = new List <Viajes>();

            SqlConnection DBCS    = Conexion.CrearCnn();
            Nacionales    N       = null;
            SqlCommand    comando = new SqlCommand("ListarNacionalesTodos", DBCS);

            comando.CommandType = CommandType.StoredProcedure;
            SqlDataReader r;

            try
            {
                DBCS.Open();
                r = comando.ExecuteReader();
                if (r.HasRows)
                {
                    while (r.Read())
                    {
                        N = new Nacionales(Convert.ToInt32(r.GetValue(0)),
                                           Convert.ToInt32(r.GetValue(1)),
                                           Convert.ToDateTime(r.GetValue(2)),
                                           Convert.ToDateTime(r.GetValue(3)),
                                           PersistenciaEmpleado.GetInstancia().BuscarEmpleadosTodos(Convert.ToInt32(r.GetValue(4))),
                                           PersistenciaTerminal.GetInstancia().BuscarTerminalTodos(r.GetValue(5).ToString()),
                                           PersistenciaCompania.GetInstancia().BuscarCompaniaTodas(r.GetValue(6).ToString()),
                                           Convert.ToInt32(r.GetValue(7))
                                           );
                        lista.Add(N);
                    }
                }
                r.Close();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                DBCS.Close();
            }
            return(lista);
        }
        public Nacionales BuscarViajeNacional(int numero)
        {
            SqlConnection DBCS    = Conexion.CrearCnn();
            Nacionales    n       = null;
            SqlCommand    comando = new SqlCommand("BuscarViajeNacional", DBCS);

            comando.CommandType = CommandType.StoredProcedure;

            comando.Parameters.Add(new SqlParameter("@Numero", numero));

            try
            {
                DBCS.Open();
                SqlDataReader r;

                r = comando.ExecuteReader();
                if (r.HasRows)
                {
                    r.Read();
                    n = new Nacionales(Convert.ToInt32(r.GetValue(0)),
                                       Convert.ToInt32(r.GetValue(1)),
                                       Convert.ToDateTime(r.GetValue(2)),
                                       Convert.ToDateTime(r.GetValue(3)),
                                       PersistenciaEmpleado.GetInstancia().BuscarEmpleadosTodos(Convert.ToInt32(r.GetValue(4))),
                                       PersistenciaTerminal.GetInstancia().BuscarTerminalTodos(r.GetValue(5).ToString()),
                                       PersistenciaCompania.GetInstancia().BuscarCompaniaTodas(r.GetValue(6).ToString()),
                                       Convert.ToInt32(r.GetValue(7))
                                       );
                }

                r.Close();

                return(n);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                DBCS.Close();
            }
        }
        public List <Internacional> ListadoInternacionales()
        {
            Internacional        unInternacional      = null;
            List <Internacional> listaInternacionales = new List <Internacional>();

            SqlConnection oConexion = new SqlConnection(Conexion.Con);
            SqlCommand    comando   = new SqlCommand("Sp_ListarInternacionales", oConexion);

            comando.CommandType = CommandType.StoredProcedure;

            try
            {
                oConexion.Open();
                SqlDataReader dr = comando.ExecuteReader();

                if (dr.HasRows)
                {
                    while (dr.Read())
                    {
                        unInternacional = new Internacional((int)dr["NumeroViaje"], (DateTime)dr["FHSalida"], (DateTime)dr["FHLlegada"],
                                                            (int)dr["Asientos"], PersistenciaEmpleado.getInstancia().BuscarEmpleado((int)dr["CiEmpleado"]),
                                                            PersistenciaTerminal.getInstancia().BuscarTerminal((string)dr["CodigoTerminal"]),
                                                            PersistenciaCompania.getInstancia().BuscarCompania((string)dr["NombreCompania"]), (bool)dr["ServicioABordo"],
                                                            (string)dr["Documentacion"]);

                        listaInternacionales.Add(unInternacional);
                    }
                }
                dr.Close();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                oConexion.Close();
            }
            return(listaInternacionales);
        }
Esempio n. 6
0
        //BUSCAR VIAJE INTERNACIONAL
        public ViajeInternacional BuscarViajeInternacional(int NViaje)
        {
            //conexion
            SqlConnection conect = new SqlConnection(Conexion.Cnn);

            //sp
            SqlCommand sp = new SqlCommand("BuscarViajeInternacional", conect);

            sp.CommandType = CommandType.StoredProcedure;

            //parametro
            sp.Parameters.Add("@NViaje", NViaje);
            //reader
            SqlDataReader reader;

            ViajeInternacional viaje = null;

            try
            {
                conect.Open();
                reader = sp.ExecuteReader();

                if (reader.HasRows)
                {
                    reader.Read();
                    viaje = new ViajeInternacional(Convert.ToInt32(reader[0]), ((PersistenciaCompania.getInstance()).BuscarCompania(reader[1].ToString())), ((PersistenciaTerminal.getInstance()).BuscarTerminal(reader[2].ToString())), ((PersistenciaEmpleado.getInstance().BuscarEmpleado(Convert.ToInt32(reader[3])))), Convert.ToDateTime(reader[4]), Convert.ToDateTime(reader[5]), Convert.ToInt32(reader[6]), Convert.ToBoolean(reader[7]), reader[8].ToString());
                }
                return(viaje);
            }
            catch (Exception ex) { throw ex; }
        }
Esempio n. 7
0
        //----------------------------------------------------------------------BUSQUEDAS------------------------------------------------------------------------------------


        //LISTAR VIAJES INTERNACICONALES
        public List <Viaje> ListarViajesInternacionales()
        {
            //conexion
            SqlConnection conect = new SqlConnection(Conexion.Cnn);

            //sp
            SqlCommand sp = new SqlCommand("ListarViajesInternacionales", conect);

            sp.CommandType = CommandType.StoredProcedure;

            //reader
            SqlDataReader reader;
            //Lista
            List <Viaje> lista = new List <Viaje>();

            try
            {
                conect.Open();
                reader = sp.ExecuteReader();

                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        ViajeInternacional viaje = new ViajeInternacional(Convert.ToInt32(reader[0]), ((PersistenciaCompania.getInstance()).BuscarCompania(reader[1].ToString())), ((PersistenciaTerminal.getInstance()).BuscarTerminal(reader[2].ToString())), ((PersistenciaEmpleado.getInstance().BuscarEmpleado(Convert.ToInt32(reader[3])))), Convert.ToDateTime(reader[4]), Convert.ToDateTime(reader[5]), Convert.ToInt32(reader[6]), Convert.ToBoolean(reader[7]), reader[8].ToString());
                        lista.Add(viaje);
                    }
                }
                return(lista);
            }
            catch (Exception ex) { throw ex; }

            finally { conect.Close(); }
        }
Esempio n. 8
0
 //get instancia
 public static PersistenciaTerminal getInstance()
 {
     return((instancia == null) ? instancia = new PersistenciaTerminal() : instancia);
 }
Esempio n. 9
0
 //persistencia terminal
 public static iPersistenciaTerminal getPersistenciaTerminal()
 {
     return(PersistenciaTerminal.getInstance());
 }
Esempio n. 10
0
 public static IPersistenciaTerminal GetPersistenciaTerminal()
 {
     return(PersistenciaTerminal.GetInstancia());
 }