Ejemplo n.º 1
0
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         TextBox textBox  = (TextBox)Miasto;
         TextBox textBox2 = (TextBox)Wspl;
         if (String.IsNullOrEmpty(textBox.Text) || String.IsNullOrEmpty(textBox2.Text))
         {
             MessageBox.Show("Pola są puste, nie można dodać lotniska.", "Bląd", MessageBoxButton.OK, MessageBoxImage.Warning);
         }
         else
         {
             string   miasto = textBox.Text;
             double   wspl   = Double.Parse(textBox2.Text);
             Lotnisko l      = new Lotnisko
             {
                 Miasto = miasto,
                 Wspl   = wspl
             };
             BOOKEDFLY.dodajLotnisko(l);
             MessageBox.Show("Dodano lotnisko.", "Sukces", MessageBoxButton.OK, MessageBoxImage.Information);
         }
     }
     catch (Exception)
     {
         MessageBox.Show("Nieprawidłowe współrzędne ", "Bląd", MessageBoxButton.OK, MessageBoxImage.Warning);
     }
 }
Ejemplo n.º 2
0
        public static void wczytLotniska() //metoda wczytująca lotniska z pliku "Lotniska.txt"
        {
            String           line;
            NumberFormatInfo nfi = new NumberFormatInfo();

            nfi.NumberGroupSeparator = " ";
            StreamReader sr = new StreamReader("txt/Lotniska.txt");

            while ((line = sr.ReadLine()) != null)
            {
                String[] wczytanie = line.Split(" ");
                String   miasto    = wczytanie[0];
                // Konwertuje String na double
                String   punk  = wczytanie[1];
                double   punkt = Convert.ToDouble(punk);
                Lotnisko l     = new Lotnisko
                {
                    Miasto = miasto,
                    Wspl   = punkt
                };
                BOOKEDFLY.dodajLotnisko(l);
            }
            sr.Close();
        }