123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using System.Windows.Navigation;
- using System.Windows.Shapes;
- namespace ПодготовкаКДемо1.Pages
- {
- /// <summary>
- /// Логика взаимодействия для ListTourPage.xaml
- /// </summary>
- public partial class ListTourPage : Page
- {
- public ListTourPage()
- {
- InitializeComponent();
- ListTours.ItemsSource = Tour.getListTour();
- ComboBoxSelectType.DisplayMemberPath = "Tour";
- ComboBoxSelectType.SelectedValuePath = "id";
- List<TypeTour> typeTours = BaseConnect.BaseModel.TypeTour.ToList();
- TypeTour typeTour = new TypeTour();
- typeTour.Tour = "Все";
- typeTours.Insert(0, typeTour);
- ComboBoxSelectType.ItemsSource = typeTours;
- decimal price=0;
- foreach (Tour tour in Tour.getListTour())
- {
- price += tour.Price;
- }
- AllPrice.Text = "Общая цена: " + Math.Round(price, 2).ToString() + " руб";
- }
- private void TextBoxSearch_TextChanged(object sender, TextChangedEventArgs e)
- {
- Filter();
- }
- private void Filter()
- {
- List<Tour> tours = Tour.getListTour();
- if (TextBoxSearch.Text != "")
- {
- tours = tours.Where(x=>x.Name.Contains(TextBoxSearch.Text)).ToList();
- }
- if (ComboBoxSelectType.SelectedItem != null&& ComboBoxSelectType.SelectedIndex !=0)
- {
- TypeTour typeTour = BaseConnect.BaseModel.TypeTour.FirstOrDefault(x => x.id == ComboBoxSelectType.SelectedIndex);
- tours = tours.Where(x => x.TypeTour.Contains(typeTour.Tour)).ToList();
- }
- if (ComboBoxSelectType.SelectedIndex == 0)
- {
- if (TextBoxSearch.Text != "")
- {
- tours = tours.Where(x => x.Name.Contains(TextBoxSearch.Text)).ToList();
- }
- else
- {
- tours = Tour.getListTour();
- RadioUp.IsChecked = false;
- RadioDown.IsChecked = false;
- }
- }
- if ((bool)CheckBoxIsActual.IsChecked)
- {
- tours = tours.Where(x=>x.IsActual==true).ToList();
- }
- ListTours.ItemsSource = tours;
- }
- private void ComboBoxSelectType_SelectionChanged(object sender, SelectionChangedEventArgs e)
- {
- Filter();
- }
- private void CheckBoxIsActual_Checked(object sender, RoutedEventArgs e)
- {
- Filter();
- }
- private void RadioButton_Checked(object sender, RoutedEventArgs e)
- {
- RadioDown.IsChecked = false;
- List<Tour> tours = (List<Tour>)ListTours.ItemsSource;
- tours=tours.OrderBy(x=>x.Price).ToList();
- ListTours.ItemsSource = tours;
- }
- private void RadioButton_Checked_1(object sender, RoutedEventArgs e)
- {
- RadioUp.IsChecked = false;
- List<Tour> tours = (List<Tour>)ListTours.ItemsSource;
- tours=tours.OrderBy(x => x.Price).ToList();
- tours.Reverse();
- ListTours.ItemsSource = tours;
- }
- }
- }
|