Example #1
0
        public static List <TravelSection> All()
        {
            List <TravelSection> list = new List <TravelSection>();

            using (SQLiteConnection conn = DatabaseUtility.GetConnection())
            {
                using (SQLiteCommand command = new SQLiteCommand(conn))
                {
                    command.CommandText = "SELECT * " +
                                          "FROM travel_section, travel " +
                                          "WHERE travel_section.travel_id = travel.travel_id AND " +
                                          "travel.state = 'En Transito'";

                    using (SQLiteDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            int      id                     = reader.GetInt32(0);
                            DateTime init_time              = reader.GetDateTime(1);
                            DateTime arrival_time           = reader.GetDateTime(2);
                            int      priority               = reader.GetInt32(3);
                            int      travel_id              = reader.GetInt32(4);
                            int      origin_station_id      = reader.GetInt32(5);
                            int      destination_station_id = reader.GetInt32(6);

                            TravelSection travelSection = new TravelSection(id, init_time, arrival_time, travel_id, priority, origin_station_id, destination_station_id);
                            list.Add(travelSection);
                        }
                    }
                }
            }
            return(list);
        }
Example #2
0
        // Static Methods

        public static TravelSection GetLastTravelSection()
        {
            TravelSection travel_section = null;

            using (SQLiteConnection conn = DatabaseUtility.GetConnection())
            {
                using (SQLiteCommand command = new SQLiteCommand(conn))
                {
                    command.CommandText = "SELECT * FROM travel_section ORDER by travel_section_id DESC limit 1";
                    using (SQLiteDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            int      id                     = reader.GetInt32(0);
                            DateTime init_time              = reader.GetDateTime(1);
                            DateTime arrival_time           = reader.GetDateTime(2);
                            int      priority               = reader.GetInt32(3);
                            int      travel_id              = reader.GetInt32(4);
                            int      origin_station_id      = reader.GetInt32(5);
                            int      destination_station_id = reader.GetInt32(6);

                            travel_section = new TravelSection(id, init_time, arrival_time, travel_id, priority, origin_station_id, destination_station_id);
                        }
                    }
                }
            }
            return(travel_section);
        }