public static Base FindAirportInfo(string code)
        {
            var airportInfo = File.ReadLines(fileName).First(line => Regex.IsMatch(line, "(^"+ code +".*$)"));
            Console.WriteLine(airportInfo);

            string[] infoArray = airportInfo.Split(':');

            var lat = double.Parse(infoArray[5] + CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator + infoArray[6] + infoArray[7]);
            var log = double.Parse(infoArray[9] + CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator + infoArray[10] + infoArray[11]);

            if ("S".Equals(infoArray[8])) lat = lat*-1;

            if ("U".Equals(infoArray[12])) log = log * -1;

            Base airportBase = new Base()
            {
                ICAO = infoArray[0],
                IATA = infoArray[1],
                AirportName = infoArray[2],
                City = infoArray[3],
                Country = infoArray[4],
                Latitude = lat,
                Longitude = log,
                Altitude = int.Parse(infoArray[13])
            };
            return airportBase;
        }
示例#2
0
        private void AddButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var myBase = new Base() { ICAO = IcaoTextBox.Text };
                myBase.Insert();

                boardJobViewSource.Source = myBase.GetAll();
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message, "ERROR", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
示例#3
0
        public void DeleteBase(Base myBase)
        {
            try
            {
                using (SQLiteConnection conn = new SQLiteConnection(connString))
                {

                    var cmdSql = new SQLiteCommand("DELETE FROM [Bases] WHERE icao = (@icao)", conn);
                    conn.Open();
                    cmdSql.Parameters.AddWithValue("@icao", myBase.ICAO);
                    int result = cmdSql.ExecuteNonQuery();
                    conn.Close();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                throw ex;
            }
        }
示例#4
0
        public void InsertBase(Base myBase)
        {
            try
            {
                using (SQLiteConnection conn = new SQLiteConnection(connString))
                {

                    var cmdSql = new SQLiteCommand("INSERT INTO [Bases] (icao) VALUES (@icao)", conn);
                    conn.Open();
                    cmdSql.Parameters.AddWithValue("@icao", myBase.ICAO);
                    cmdSql.ExecuteNonQuery();
                    conn.Close();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                throw ex;
            }
        }
示例#5
0
        public List<Base> SelectAllBase()
        {
            try
            {
                using (SQLiteConnection conn = new SQLiteConnection(connString))
                {

                    var cmdSql = new SQLiteCommand("SELECT * FROM [Bases]", conn);
                    conn.Open();
                    var reader = cmdSql.ExecuteReader();

                    var listAll = new List<Base>();
                    while (reader.Read())
                    {
                        var myBase = new Base();
                        myBase.ICAO = reader["icao"].ToString().Trim();
                        listAll.Add(myBase);
                    }
                    reader.Dispose();
                    conn.Close();
                    return listAll;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                throw ex;
            }

            return null;
        }