using MyApp.ExampleDataSetTableAdapters; using MyApp.Services; using System.Linq; using System.Windows; using System.Windows.Controls; using System.Windows.Input; using System.Windows.Media; using System.Windows.Navigation; namespace MyApp.UserPages { public partial class UserProducts : Page { ProductTableAdapter productTableAdapter = new ProductTableAdapter(); public UserProducts() { InitializeComponent(); Product_DG.ItemsSource = productTableAdapter.GetData(); SortCB.ItemsSource = SearchAndSort.FullSortBy; } private void StartSearchButton_Click(object sender, RoutedEventArgs e) { if (SearchTB.Text != "Поиск..." & SearchTB.Text != "") { SearchAndSort.Search(productTableAdapter, Product_DG, SearchTB.Text); } else { Product_DG.ItemsSource = productTableAdapter.GetData(); } } private void CB_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (SortCB.SelectedItem != null) { ForSortCB.Visibility = Visibility.Collapsed; } if (SortCB.SelectedItem.ToString() == "По алфавиту") { SearchAndSort.SortByAlphabet(productTableAdapter, Product_DG); } if (SortCB.SelectedItem.ToString() == "По стоимости") { SearchAndSort.SortByCost(productTableAdapter, Product_DG); } } //Прочие события private void Button_Click(object sender, RoutedEventArgs e) { Window ownerWindow = Application.Current.Windows.OfType<Window>().SingleOrDefault(w => w.Title == "MainWindow"); ownerWindow.Close(); } private void Button_Click_1(object sender, RoutedEventArgs e) { Window ownerWindow = Application.Current.Windows.OfType<Window>().SingleOrDefault(w => w.Title == "MainWindow"); ownerWindow.WindowState = WindowState.Minimized; } private void SearchTB_MouseEnter(object sender, MouseEventArgs e) { if (SearchTB.Text == "Поиск...") { SearchTB.Text = ""; SearchTB.Foreground = Brushes.White; } } private void SearchTB_MouseLeave(object sender, MouseEventArgs e) { if (SearchTB.Text == "") { SearchTB.Text = "Поиск..."; SolidColorBrush sb = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#6BFFFFFF")); SearchTB.Foreground = sb; } } private void ProductsPageButton_Click(object sender, RoutedEventArgs e) { NavigationService.Navigate(new UserProducts()); } private void OrdersPageButton_Click(object sender, RoutedEventArgs e) { NavigationService.Navigate(new UserOrders()); } } }