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 <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);
        }
Ejemplo n.º 3
0
 public static IPersistenciaTerminal GetPersistenciaTerminal()
 {
     return(PersistenciaTerminal.GetInstancia());
 }