public FlightViewBox(Flight flight, DbFace dbface)
        {
            InitializeComponent();

            this.flight = flight;

            // Fill out all the data files
            lblOrigin.Text = Airport.GetAirport(flight.Origin, dbface).ToString();
            lblDestination.Text = Airport.GetAirport(flight.Destination, dbface).ToString();
            lblLeave.Text = flight.DateLeave.ToString("M/d/yyyy");
            lblReturn.Text = flight.DateReturn.ToString("M/d/yyyy");
            lblPrice.Text = "$" + flight.Price.ToString();
            lblDistance.Text = flight.Km.ToString() + " km";
            TimeSpan span = DateTime.Now.Subtract(flight.LastChecked);
            if (span.Days > 0)
                lblLastChecked.Text = span.Days + " days and " + span.Hours + " hours ago";
            else
                lblLastChecked.Text = span.Hours + " hours ago";

            lblLink.Text = "http://www.orbitz.com/";
        }
Exemple #2
0
        // Record a new flight option
        public void RecordOption(string origin, string destination, DateTime start, DateTime end, int price, int distance, DbFace dbface)
        {
            lock (dbface)
            {
                dbface.Execute(string.Format("insert into flights (origin, destination, date_leave, date_return, price, km, source, user) values ('{0}', '{1}', '{2}', '{3}', {4}, {5}, '{6}', '{7}') on duplicate key update price = {4}, source = '{6}', user = '******'", origin, destination, MyDate(start), MyDate(end), price, distance, source, user), false);
            }

            lock (results)
            {
                Flight flight = new Flight(origin, destination, Airport.GetAirport(destination, dbface).Country, start, end, price, distance, DateTime.Now);
                results.Add(flight.Score, flight);
            }
        }
Exemple #3
0
        // Find all flights that fit the search criteria
        // if nextstart = 0, don't try again
        public List<Flight> FindStoredFlights(DbFace dbface, string order, int start, int limit, int maxgive, out int nextstart)
        {
            List<Flight> flights = new List<Flight>();

            string[] origins = Airport.ParseAirportCodes(txtOrigins.Text);
            List<Dictionary<string, object>> rows = dbface.AssocEnumerate(string.Format("select flights.*, airports.country as destcountry from flights left join airports on flights.destination = airports.code where (origin = '{0}') and date_leave >= '{1}' and date_leave <= '{2}' and datediff(date_return, date_leave) >= {3} and datediff(date_return, date_leave) <= {4} order by {5} limit {6}, {7}", string.Join("' or origin = '", origins), MyDate(earliest.Value), MyDate(latest.Value), GetNum(shortest.Text, false).Value, GetNum(longest.Text, false).Value, order, start, limit));

            nextstart = start;
            foreach (Dictionary<string, object> row in rows)
            {
                nextstart++;

                Flight flight = new Flight(row);
                // Is this airport enabled?
                if (Airport.IsAirportEnabled(flight.Destination))
                {
                    flights.Add(flight);
                    if (flights.Count == maxgive)
                        return flights;
                }
            }

            if (rows.Count < limit)
                nextstart = 0;
            return flights;
        }