Ejemplo n.º 1
0
 private void DodajOsobe(object sender, RoutedEventArgs e)
 {
     try
     {
         TextBox textBox  = (TextBox)Imie;
         TextBox textBox2 = (TextBox)Nazwisko;
         if (String.IsNullOrEmpty(textBox.Text) || String.IsNullOrEmpty(textBox2.Text))
         {
             MessageBox.Show("Pola są puste, nie można dodać osoby.", "Bląd", MessageBoxButton.OK, MessageBoxImage.Warning);
         }
         else
         {
             string Oimie     = textBox.Text;
             string Onazwisko = textBox2.Text;
             Osoba  osoba     = new Osoba
             {
                 Imie     = Oimie,
                 Nazwisko = Onazwisko
             };
             BOOKEDFLY.dodajOsobe(osoba);
             MessageBox.Show("Dodano osobę.", "Sukces", MessageBoxButton.OK, MessageBoxImage.Information);
         }
     }
     catch (Exception)
     {
         MessageBox.Show("Nieprawidłowe dane.", "Bląd", MessageBoxButton.OK, MessageBoxImage.Warning);
     }
 }
Ejemplo n.º 2
0
 private void DodajTrase(object sender, RoutedEventArgs e)
 {
     try
     {
         int      indexM1   = Miasto1.SelectedIndex;
         int      indexM2   = Miasto2.SelectedIndex;
         Lotnisko SLotnisko = BOOKEDFLY.ListaLotnisk.ElementAt(indexM1);
         Lotnisko KLotnisko = BOOKEDFLY.ListaLotnisk.ElementAt(indexM2);
         Trasa    trasas    = new Trasa(SLotnisko, KLotnisko);
         trasas.odleglosc = Math.Round(trasas.liczOdleglosc(SLotnisko.Wspl, KLotnisko.Wspl));
         trasas.czas      = trasas.liczCzas(trasas.odleglosc);
         if (SLotnisko == KLotnisko)
         {
             MessageBox.Show("Nie można utworzyć trasy. Zaznaczono dwa te same miasta.", "Bląd", MessageBoxButton.OK, MessageBoxImage.Warning);
         }
         else if (BOOKEDFLY.ListaTras.IndexOf(new Trasa(SLotnisko, KLotnisko)) > 0)
         {
             MessageBox.Show("Nie można utworzyć trasy. Trasa już istnieje.", "Bląd", MessageBoxButton.OK, MessageBoxImage.Warning);
         }
         else
         {
             Trasa trasa = new Trasa(SLotnisko, KLotnisko);
             trasa.odleglosc = Math.Round(trasa.liczOdleglosc(SLotnisko.Wspl, KLotnisko.Wspl));
             trasa.czas      = trasa.liczCzas(trasa.odleglosc);
             BOOKEDFLY.dodajTrase(trasa);
             MessageBox.Show("Dodano trasę.", "Sukces", MessageBoxButton.OK, MessageBoxImage.Information);
         }
     }
     catch (Exception)
     {
         MessageBox.Show("Błąd w utworzeniu trasy. Nie zaznaczono miast.", "Bląd", MessageBoxButton.OK, MessageBoxImage.Warning);
     }
 }
Ejemplo n.º 3
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.º 4
0
 private void usunKrotko(object sender, RoutedEventArgs e)
 {
     try
     {
         int selectedIndex = Krotko.SelectedIndex;
         BOOKEDFLY.usunSamolotK(selectedIndex);
     }
     catch (Exception)
     {
         MessageBox.Show("Błąd w skasowaniu samolotu.", "Bląd", MessageBoxButton.OK, MessageBoxImage.Warning);
     }
 }
Ejemplo n.º 5
0
 private void UsunLot(object sender, RoutedEventArgs e)
 {
     try
     {
         Lot lot = (Lot)Loty.SelectedItem;
         BOOKEDFLY.usunLot(lot);
     }
     catch (Exception)
     {
         MessageBox.Show("Błąd w skasowaniu lotu.", "Błąd", MessageBoxButton.OK, MessageBoxImage.Warning);
     }
 }
Ejemplo n.º 6
0
 private void usunDlugo(object sender, RoutedEventArgs e)
 {
     try
     {
         int selectedIndex = Dlugo.SelectedIndex;
         BOOKEDFLY.usunSamolotD(selectedIndex);
         MessageBox.Show("Usunięto samolot.", "Sukces", MessageBoxButton.OK, MessageBoxImage.Information);
     }
     catch (Exception)
     {
         MessageBox.Show("Błąd w skasowaniu samolotu.", "Bląd", MessageBoxButton.OK, MessageBoxImage.Warning);
     }
 }
Ejemplo n.º 7
0
 private void UsunFirme(object sender, RoutedEventArgs e)
 {
     try
     {
         int selectedIndex = Firmy.SelectedIndex;
         BOOKEDFLY.usunFirme(selectedIndex);
         MessageBox.Show("Usunięto firmę.", "Sukces", MessageBoxButton.OK, MessageBoxImage.Information);
     }
     catch (Exception)
     {
         MessageBox.Show("Błąd w skasowaniu firmy.", "Bląd", MessageBoxButton.OK, MessageBoxImage.Warning);
     }
 }
Ejemplo n.º 8
0
 private void UsunBilety(object sender, RoutedEventArgs e)
 {
     try
     {
         Bilet bilet = (Bilet)Bilety.SelectedItem;
         BOOKEDFLY.usunBilet(bilet);
         MessageBox.Show("Usunięto bilety.", "Sukces", MessageBoxButton.OK, MessageBoxImage.Information);
     }
     catch (Exception)
     {
         MessageBox.Show("Błąd w skasowaniu biletów.", "Błąd", MessageBoxButton.OK, MessageBoxImage.Warning);
     }
 }
Ejemplo n.º 9
0
 private void removeButton_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         int selectedIndex = Lotniska.SelectedIndex;
         BOOKEDFLY.usunLotnisko(selectedIndex);
         MessageBox.Show("Usunięto lotnisko.", "Sukces", MessageBoxButton.OK, MessageBoxImage.Information);
     }
     catch (Exception)
     {
         MessageBox.Show("Błąd w skasowaniu lotniska.", "Bląd", MessageBoxButton.OK, MessageBoxImage.Warning);
     }
 }
Ejemplo n.º 10
0
 private void GenerujBilety(object sender, RoutedEventArgs e)
 {
     try
     {
         Lot   lot   = (Lot)Loty.SelectedItem;
         Bilet bilet = new Bilet();
         bilet.lot          = lot;
         bilet.liczbaMiejsc = lot.samolot.IloscMiejsc;
         BOOKEDFLY.dodajBilet(bilet);
         MessageBox.Show("Pomyślnie wygenerowano pulę biletów.", "Sukces", MessageBoxButton.OK, MessageBoxImage.Information);
     }
     catch (Exception)
     {
         MessageBox.Show("Błąd w wygenerowaniu biletów.", "Błąd", MessageBoxButton.OK, MessageBoxImage.Warning);
     }
 }
Ejemplo n.º 11
0
        public static void wczytOsob() //metoda wczytująca osoby z pliku "Osoba.txt"
        {
            String       line;
            StreamReader sr = new StreamReader("txt/Osoba.txt");

            while ((line = sr.ReadLine()) != null)
            {
                string[] wczytanie = line.Split(" ");
                Osoba    osoba     = new Osoba();
                String   n1        = wczytanie[0];
                String   naz1      = wczytanie[1];
                osoba.Imie     = n1;
                osoba.Nazwisko = naz1;
                BOOKEDFLY.dodajOsobe(osoba);
            }
            sr.Close();
        }
Ejemplo n.º 12
0
 public static void wczytBilety()
 {
     try
     {
         using (Stream stream = File.Open("bin/Bilety.bin", FileMode.Open))
         {
             BinaryFormatter bin       = new BinaryFormatter();
             List <Bilet>    tempBilet = (List <Bilet>)bin.Deserialize(stream);
             foreach (Bilet bilet in tempBilet)
             {
                 BOOKEDFLY.dodajBilet(bilet);
             }
         }
     }
     catch (IOException)
     {
     }
 }
Ejemplo n.º 13
0
 public static void wczytTrasy()
 {
     try
     {
         using (Stream stream = File.Open("bin/Trasy.bin", FileMode.Open))
         {
             BinaryFormatter bin       = new BinaryFormatter();
             List <Trasa>    tempTrasa = (List <Trasa>)bin.Deserialize(stream);
             foreach (Trasa t in tempTrasa)
             {
                 BOOKEDFLY.dodajTrase(t);
             }
         }
     }
     catch (IOException)
     {
     }
 }
Ejemplo n.º 14
0
 public static void wczytLoty()
 {
     try
     {
         using (Stream stream = File.Open("bin/Loty.bin", FileMode.Open))
         {
             BinaryFormatter bin     = new BinaryFormatter();
             List <Lot>      tempLot = (List <Lot>)bin.Deserialize(stream);
             foreach (Lot lot in tempLot)
             {
                 BOOKEDFLY.generujLot(lot);
             }
         }
     }
     catch (IOException)
     {
     }
 }
Ejemplo n.º 15
0
 private void PowielDzien(object sender, RoutedEventArgs e)
 {
     try
     {
         Lot lot       = (Lot)Loty.SelectedItem;
         Lot powielony = new Lot();
         int godzina   = lot.dataLotu.godzina;
         int minuta    = lot.dataLotu.minuta;
         powielony.samolot   = lot.samolot;
         powielony.trasaLotu = lot.trasaLotu;
         powielony.dataLotu  = new Data(Kalendarz.SelectedDate.Value.Year, Kalendarz.SelectedDate.Value.Month, Kalendarz.SelectedDate.Value.Day, godzina, minuta);
         BOOKEDFLY.generujLot(powielony);
         MessageBox.Show("Powielono dzień.", "Sukces", MessageBoxButton.OK, MessageBoxImage.Information);
     }
     catch (Exception)
     {
         MessageBox.Show("Błąd w powieleniu dnia.", "Błąd", MessageBoxButton.OK, MessageBoxImage.Warning);
     }
 }
Ejemplo n.º 16
0
        public static void wczytFirmy() //metoda wczytująca firmy z pliku "Firma.txt"
        {
            String           line;
            NumberFormatInfo nfi = new NumberFormatInfo();

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

            while ((line = sr.ReadLine()) != null)
            {
                string[] wczytanie = line.Split(" ");
                FirmaPos f         = new FirmaPos();
                String   no        = wczytanie[0];
                double   naz1      = double.Parse(wczytanie[1], nfi);
                f.Nazwa = no;
                f.KRS   = naz1;
                BOOKEDFLY.dodajFirme(f);
            }
            sr.Close();
        }
Ejemplo n.º 17
0
        static public void wczytSamolotyDlugo() //metoda wczytująca samoloty długodystansowe z pliku "SDlugo.txt"
        {
            String           line;
            NumberFormatInfo nfi = new NumberFormatInfo();

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

            while ((line = sr.ReadLine()) != null)
            {
                string[]        wczytanie = line.Split(" ");
                String          nazwa     = wczytanie[0];
                String          firma     = wczytanie[1];
                double          zasieg    = double.Parse(wczytanie[2], nfi);
                int             miejsca   = int.Parse(wczytanie[3], nfi);
                Dlugodystansowy dl        = new Dlugodystansowy(nazwa, firma, zasieg, miejsca);
                BOOKEDFLY.dodajSamolotD(dl);
            }
            sr.Close();
        }
Ejemplo n.º 18
0
 private void DobierzTrase(object sender, RoutedEventArgs e)
 {
     try
     {
         Trasa wybrana = BOOKEDFLY.ListaTras.ElementAt(Trasy.SelectedIndex);
         if (wybrana.odleglosc < 2000)
         {
             ObservableCollection <Krotkodystansowy> Samolotykrotko = BOOKEDFLY.dobierzSamolotyKrotko(wybrana.odleglosc);
             Wybrane.ItemsSource = Samolotykrotko;
         }
         else
         {
             ObservableCollection <Dlugodystansowy> Samolotydlugo = BOOKEDFLY.dobierzSamolotyDlugo(wybrana.odleglosc);
             Wybrane.ItemsSource = Samolotydlugo;
         }
     }
     catch (Exception)
     {
         MessageBox.Show("Błąd w wyborze trasy.", "Błąd", MessageBoxButton.OK, MessageBoxImage.Warning);
     }
 }
Ejemplo n.º 19
0
 private void GenerujLot(object sender, RoutedEventArgs e)
 {
     try
     {
         Lot      lot = new Lot();
         TextBox  textBox = (TextBox)Godzina;
         string[] godzina = textBox.Text.Split(':');
         int      godz, min;
         int      dlugosc = textBox.Text.Length;
         if (dlugosc != 5)
         {
             MessageBox.Show("Nieprawidłowy format godziny.", "Bląd", MessageBoxButton.OK, MessageBoxImage.Warning);
         }
         else
         {
             godz          = Int32.Parse(godzina[0]);
             min           = Int32.Parse(godzina[1]);
             lot.dataLotu  = new Data(Kalendarz.SelectedDate.Value.Year, Kalendarz.SelectedDate.Value.Month, Kalendarz.SelectedDate.Value.Day, godz, min);
             lot.trasaLotu = BOOKEDFLY.ListaTras.ElementAt(Trasy.SelectedIndex);
             if (lot.trasaLotu.odleglosc < 2000)
             {
                 lot.samolot = (Krotkodystansowy)Wybrane.SelectedItem;
             }
             else
             {
                 lot.samolot = (Dlugodystansowy)Wybrane.SelectedItem;
             }
             BOOKEDFLY.generujLot(lot);
             MessageBox.Show("Pomyślnie wygenerowano lot.", "Sukces", MessageBoxButton.OK, MessageBoxImage.Information);
         }
     }
     catch (IndexOutOfRangeException)
     {
         MessageBox.Show("Nieprawidłowy format godziny.", "Błąd", MessageBoxButton.OK, MessageBoxImage.Warning);
     }
     catch (Exception)
     {
         MessageBox.Show("Błąd w utworzeniu lotu.", "Błąd", MessageBoxButton.OK, MessageBoxImage.Warning);
     }
 }
Ejemplo n.º 20
0
 private void Sprzedaj(object sender, RoutedEventArgs e)
 {
     try
     {
         Bilet   bilet   = (Bilet)Bilety.SelectedItem;
         int     index   = Bilety.SelectedIndex;
         TextBox textBox = (TextBox)ile;
         int     liczba  = Int32.Parse(textBox.Text);
         if (liczba <= bilet.liczbaMiejsc)
         {
             bilet.odejmijMiejsce(liczba);
             if (bilet.liczbaMiejsc == 0)
             {
                 BOOKEDFLY.usunBilet(bilet);
                 CollectionViewSource.GetDefaultView(Bilety.ItemsSource).Refresh();
             }
             if (bilet.liczbaMiejsc < 0)
             {
                 MessageBox.Show("Błąd w sprzedaży biletu.", "Błąd", MessageBoxButton.OK, MessageBoxImage.Warning);
             }
             else
             {
                 BOOKEDFLY.pulaBiletow[index] = bilet;
                 MessageBox.Show("Sprzedano " + liczba + " biletów.", "Sukces", MessageBoxButton.OK, MessageBoxImage.Information);
                 CollectionViewSource.GetDefaultView(Bilety.ItemsSource).Refresh();
             }
         }
         else
         {
             MessageBox.Show("Błąd w sprzedaży biletu.", "Błąd", MessageBoxButton.OK, MessageBoxImage.Warning);
         }
     }
     catch (Exception)
     {
         MessageBox.Show("Błąd w sprzedaży biletu", "Błąd", MessageBoxButton.OK, MessageBoxImage.Warning);
     }
 }
Ejemplo n.º 21
0
 private void DodajSamolot(object sender, RoutedEventArgs e)
 {
     try
     {
         TextBox textBox  = (TextBox)Nazwa;
         TextBox textBox2 = (TextBox)Nazwa_firmy;
         TextBox textBox3 = (TextBox)Zasieg;
         TextBox textBox4 = (TextBox)Ilosc;
         if (String.IsNullOrEmpty(textBox.Text) || String.IsNullOrEmpty(textBox2.Text) || String.IsNullOrEmpty(textBox3.Text) || String.IsNullOrEmpty(textBox4.Text))
         {
             MessageBox.Show("Pola są puste, nie można dodać samolotu.", "Bląd", MessageBoxButton.OK, MessageBoxImage.Warning);
         }
         else
         {
             string nazwa        = textBox.Text;
             string nazwa_firmy  = textBox2.Text;
             double odleglosc    = Double.Parse(textBox3.Text);
             int    ilosc_miejsc = Int32.Parse(textBox4.Text);
             if (odleglosc < 2000)
             {
                 Krotkodystansowy samolot = new Krotkodystansowy(nazwa, nazwa_firmy, odleglosc, ilosc_miejsc);
                 BOOKEDFLY.dodajSamolotK(samolot);
                 MessageBox.Show("Dodano samolot krótkodystansowy.", "Sukces", MessageBoxButton.OK, MessageBoxImage.Information);
             }
             else
             {
                 Dlugodystansowy samolot = new Dlugodystansowy(nazwa, nazwa_firmy, odleglosc, ilosc_miejsc);
                 BOOKEDFLY.dodajSamolotD(samolot);
                 MessageBox.Show("Dodano samolot długodystansowy.", "Sukces", MessageBoxButton.OK, MessageBoxImage.Information);
             }
         }
     }
     catch (FormatException)
     {
         MessageBox.Show("Nieprawidłowa liczba w zasięgu lub ilości miejsc", "Bląd", MessageBoxButton.OK, MessageBoxImage.Warning);
     }
 }
Ejemplo n.º 22
0
 private void DodajFirme(object sender, RoutedEventArgs e)
 {
     try
     {
         TextBox textBox  = (TextBox)Nazwa;
         TextBox textBox2 = (TextBox)KRS;
         if (String.IsNullOrEmpty(textBox.Text) || String.IsNullOrEmpty(textBox2.Text))
         {
             MessageBox.Show("Pola są puste, nie można dodać firmy.", "Bląd", MessageBoxButton.OK, MessageBoxImage.Warning);
         }
         else
         {
             string nazwa   = textBox.Text;
             int    krs     = Int32.Parse(textBox2.Text);
             int    dlugosc = (int)Math.Floor(Math.Log10(krs)) + 1;
             if (dlugosc != 10)
             {
                 MessageBox.Show("Numer KRS powinien być dziesięciocyfrowy.", "Bląd", MessageBoxButton.OK, MessageBoxImage.Warning);
             }
             else
             {
                 FirmaPos firma = new FirmaPos
                 {
                     Nazwa = nazwa,
                     KRS   = krs
                 };
                 BOOKEDFLY.dodajFirme(firma);
                 MessageBox.Show("Dodano firmę.", "Sukces", MessageBoxButton.OK, MessageBoxImage.Information);
             }
         }
     }
     catch (Exception)
     {
         MessageBox.Show("Nieprawidłowe dane.", "Bląd", MessageBoxButton.OK, MessageBoxImage.Warning);
     }
 }
Ejemplo n.º 23
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();
        }