Exemple #1
0
        public OknoOferty()
        {
            InitializeComponent();

            if (File.Exists("listaOfert.xml")) // sprawdzenie, czy plik został już utworzony - jesli tak, odczytuje
            {
                _wszystkieOferty = (OfertyRazem)OfertyRazem.OdczytajXMLOferty("listaOfert.xml");
                _nowaLista       = (OfertyRazem)_wszystkieOferty.Clone();
            }
            else
            {
                string message = "Nie znaleziono zadnych ofert. Sprobuj je najpierw dodac.";
                string title   = "Brak danych";
                MessageBox.Show(message, title, MessageBoxButton.OK, MessageBoxImage.Error);
            }

            if (_wszystkieOferty.ListaOfert.Count > 0)
            {
                ListViewOferty.ItemsSource = new ObservableCollection <Oferta>(_wszystkieOferty.ListaOfert.Where(x => x.czyAktywna == true)); //wyswietlenie aktywnych ofert
            }
        }
Exemple #2
0
        //filtrowanie zlozone
        private void ButtonFiltruj_Click(object sender, RoutedEventArgs e)
        {
            _nowaLista = (OfertyRazem)_wszystkieOferty.Clone();

            if (_nowaLista.ListaOfert.Count == 0)
            {
                string message = "Nie znaleziono zadnych ofert. Sprobuj je najpierw dodac.";
                string title   = "Brak danych";
                MessageBox.Show(message, title, MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            //otwiera wszystkie ify po kolei, zatem lista nieruchomosci bedzie sie aktualizowac z kazda kolejna.
            //sprawdzamy, czy checkbox jest zaznaczony - wtedy filtrujemy po archiwum

            if (CheckBoxArchiwum.IsChecked == false)
            {
                _nowaLista.ListaOfert = _nowaLista.PrzegladajOferty(true);
                lblOferty.Content     = "Oferty - aktywne";
            }
            else
            {
                _nowaLista.ListaOfert = _nowaLista.PrzegladajOferty(false);
                lblOferty.Content     = "Oferty - archiwum";
            }

            if (TextBoxImieKlienta.Text != "")
            {
                _nowaLista.ListaOfert = _nowaLista.filtrujImieKlienta(TextBoxImieKlienta.Text);
            }

            if (TextBoxNazwiskoKlienta.Text != "")
            {
                _nowaLista.ListaOfert = _nowaLista.filtrujNazwiskoKlienta(TextBoxNazwiskoKlienta.Text);
            }

            if (TextBoxImieOpiekuna.Text != "")
            {
                _nowaLista.ListaOfert = _nowaLista.filtrujImieOpiekuna(TextBoxImieOpiekuna.Text);
            }

            if (TextBoxNazwiskoOpiekuna.Text != "")
            {
                _nowaLista.ListaOfert = _nowaLista.filtrujNazwiskoOpiekuna(TextBoxNazwiskoOpiekuna.Text);
            }

            if (TextBoxData.Text != "")
            {
                DateTime dataFiltr;
                DateTime.TryParseExact(TextBoxData.Text, new[] { "dd-MM-yyyy" }, null, System.Globalization.DateTimeStyles.None, out dataFiltr);
                if (dataFiltr.Year == 1)
                {
                    string message = "Data powinna zostać wpisana w formacie dd-MM-yyyy";
                    string title   = "Zła forma";
                    MessageBox.Show(message, title, MessageBoxButton.OK, MessageBoxImage.Error);
                    TextBoxData.Focus(); // po kliknieciu OK na MessageBox, kursor ustawia sie automatycznie w odpowiednim polu
                    return;
                }
                _nowaLista.ListaOfert = _nowaLista.filtrujDate(dataFiltr);
            }
            ListViewOferty.ItemsSource = new ObservableCollection <Oferta>(_nowaLista.ListaOfert);
        }