user228 1 gadu atpakaļ
revīzija
809d262db2
5 mainītis faili ar 177 papildinājumiem un 0 dzēšanām
  1. BIN
      Screenshot_1.png
  2. BIN
      Screenshot_2.png
  3. BIN
      Screenshot_3.png
  4. 177 0
      search.txt
  5. BIN
      макеты.png

BIN
Screenshot_1.png


BIN
Screenshot_2.png


BIN
Screenshot_3.png


+ 177 - 0
search.txt

@@ -0,0 +1,177 @@
+сортировка по выбранной дате в date picker
+   <DatePicker Name="datePicker" SelectedDateChanged="datePicker_SelectedDateChanged"></DatePicker>
+     private void datePicker_SelectedDateChanged(object sender, SelectionChangedEventArgs e)
+        {
+            filtres();
+        }
+
+   private void filtresMethod()
+        {
+            List<Order> orders = db.tbe.Order.ToList();
+            List<OrderProduct> orderProducts = db.tbe.OrderProduct.ToList();
+            List<Product> products = db.tbe.Product.ToList();
+
+
+            if (datePicker.SelectedDate.HasValue)
+            {
+                DateTime selectedDate = datePicker.SelectedDate.Value;
+
+                // Фильтрация заказов по выбранной дате
+                var filteredOrders = orders.Where(x => x.OrderDeliveryDate.Date == selectedDate.Date).ToList();
+
+                // Сортировка заказов по выбранной дате
+                filteredOrders = filteredOrders.OrderBy(x => Math.Abs((x.OrderDeliveryDate - selectedDate).TotalDays)).ToList();
+
+                // Получение идентификаторов продуктов для отфильтрованных заказов
+                var productArticleNumbers = filteredOrders
+                    .Join(orderProducts, o => o.OrderID, op => op.OrderID, (o, op) => op.ProductArticleNumber)
+                    .ToList();
+
+                // Получение связанных продуктов
+                var filteredProducts = products
+                    .Join(productArticleNumbers, p => p.ProductArticleNumber, pa => pa, (p, pa) => p)
+                    .ToList();
+
+                // Установка источника данных для lvProduct с использованием информации о продукте
+                lvProduct.ItemsSource = filteredProducts;
+            }
+            else
+            {
+                // Если дата не выбрана, используйте список продуктов
+                if (cmbSorted.SelectedItem != null)
+                {
+                    ComboBoxItem comboBoxItem = (ComboBoxItem)cmbSorted.SelectedItem;
+                    switch (comboBoxItem.Content)
+                    {
+                        case "По умолчанию":
+                            // Ничего не делаем
+                            break;
+                        case "По возрастанию стоимости":
+                            products = products.OrderBy(x => x.ProductCost).ToList();
+                            break;
+                        case "По убыванию стоимости":
+                            products = products.OrderByDescending(x => x.ProductCost).ToList();
+                            break;
+                    }
+                }
+
+                if (cmbFiltres.SelectedItem != null)
+                {
+                    ComboBoxItem comboBoxItem = (ComboBoxItem)cmbFiltres.SelectedItem;
+                    switch (comboBoxItem.Content)
+                    {
+                        case "Все диапазоны":
+                            // Ничего не делаем
+                            break;
+                        case "0-9,99%":
+                            products = products.Where(x => x.ProductDiscountAmount >= 0 && x.ProductDiscountAmount <= 9.99).ToList();
+                            break;
+                        case "10-14,99%":
+                            products = products.Where(x => x.ProductDiscountAmount >= 10 && x.ProductDiscountAmount <= 14.99).ToList();
+                            break;
+                        case "15% и более":
+                            products = products.Where(x => x.ProductDiscountAmount >= 15).ToList();
+                            break;
+                    }
+                }
+
+                if (tbSearch.Text != null && !string.IsNullOrEmpty(tbSearch.Text))
+                {
+                    products = products.Where(x => x.ProductName.ToLower().Contains(tbSearch.Text)).ToList();
+                }
+
+                if (products.Count == 0)
+                {
+                    MessageBox.Show("Отсутствуют критерии, удовлетворяющие результатам поиска!");
+                }
+
+                lvProduct.ItemsSource = products;
+            }
+
+            tblast.Text = lvProduct.Items.Count.ToString();
+        }
+
+поиск по календарю
+
+<Window x:Class="CalendarSearch.MainWindow"
+        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+        Title="Calendar Search" Height="350" Width="500">
+    <Grid>
+        <Grid.RowDefinitions>
+            <RowDefinition Height="Auto"/>
+            <RowDefinition Height="*"/>
+        </Grid.RowDefinitions>
+        
+        <StackPanel Grid.Row="0" Orientation="Horizontal" HorizontalAlignment="Center">
+            <TextBox x:Name="searchTextBox" Width="200" Margin="5"/>
+            <Button Content="Search" Click="SearchButton_Click" Margin="5"/>
+        </StackPanel>
+        
+        <Calendar x:Name="calendar" Grid.Row="1" SelectionMode="SingleDate"/>
+    </Grid>
+</Window>
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Windows;
+using System.Windows.Controls;
+
+namespace CalendarSearch
+{
+    public partial class MainWindow : Window
+    {
+        public MainWindow()
+        {
+            InitializeComponent();
+        }
+        
+        private void SearchButton_Click(object sender, RoutedEventArgs e)
+        {
+            DateTime selectedDate = calendar.SelectedDate ?? DateTime.Today;
+            string searchKeyword = searchTextBox.Text.ToLower();
+            
+            List<DateTime> matchingDates = GetMatchingDates(selectedDate, searchKeyword);
+            
+            if (matchingDates.Any())
+            {
+                MessageBox.Show($"Found {matchingDates.Count} matching dates:\n{string.Join("\n", matchingDates)}");
+            }
+            else
+            {
+                MessageBox.Show("No matching dates found.");
+            }
+        }
+        
+        private List<DateTime> GetMatchingDates(DateTime selectedDate, string searchKeyword)
+        {
+            List<DateTime> matchingDates = new List<DateTime>();
+            
+            // Perform your search logic here
+            // You can search for dates in a specific range, or search in your data source, etc.
+            // For demonstration purposes, let's assume we have a list of dates to search through
+            
+            List<DateTime> datesToSearch = new List<DateTime>
+            {
+                new DateTime(2023, 1, 1),
+                new DateTime(2023, 1, 15),
+                new DateTime(2023, 2, 3),
+                new DateTime(2023, 2, 15),
+                new DateTime(2023, 3, 5),
+                new DateTime(2023, 3, 15),
+                new DateTime(2023, 4, 7),
+                new DateTime(2023, 4, 15)
+            };
+            
+            foreach (DateTime date in datesToSearch)
+            {
+                if (date.ToString().ToLower().Contains(searchKeyword))
+                {
+                    matchingDates.Add(date);
+                }
+            }
+            
+            return matchingDates;
+        }
+    }
+}

BIN
макеты.png