Esempio n. 1
0
        private void btnFilter_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                bool onlyFree = (bool)chbFreeRoomOnly.IsChecked;

                StringBuilder category = new StringBuilder();

                if (!(bool)chbEconom.IsChecked && !(bool)chbStandard.IsChecked && !(bool)chbSuit.IsChecked && !(bool)chbFamily.IsChecked)
                {
                    category.Append("EconomStandardSuitFamily");
                }
                else
                {
                    if ((bool)chbEconom.IsChecked)
                    {
                        category.Append("Econom");
                    }
                    if ((bool)chbStandard.IsChecked)
                    {
                        category.Append("Standard");
                    }
                    if ((bool)chbSuit.IsChecked)
                    {
                        category.Append("Suit");
                    }
                    if ((bool)chbFamily.IsChecked)
                    {
                        category.Append("Family");
                    }
                }

                int places = int.Parse(cbPlaces.SelectedValue.ToString());

                int priceLow = 0;

                if (tbLowPrice.Text != "")
                {
                    priceLow = int.Parse(tbLowPrice.Text);
                }

                int priceUp = 100000;

                if (tbUpPrice.Text != "")
                {
                    priceUp = int.Parse(tbUpPrice.Text);
                }

                var roomsRep = new SqlRoomRepository(connection);

                rooms = roomsRep.FilterRooms(category.ToString(), places, priceLow, priceUp, onlyFree);

                dgRooms.ItemsSource = rooms;
            }
            catch
            {
                MessageBox.Show("Some problem occured. Check input please.", "Error", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }