Procházet zdrojové kódy

Поиск +фильтрация

Данила Чирков před 2 roky
rodič
revize
24c7cc830e

+ 15 - 3
UP2022Ex/FrameFolder/AgentInfoFrame.xaml

@@ -5,7 +5,7 @@
       xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
       xmlns:local="clr-namespace:UP2022Ex.FrameFolder"
       mc:Ignorable="d" 
-      d:DesignHeight="450" d:DesignWidth="800"
+      d:DesignHeight="300" d:DesignWidth="800"
       Title="AgentInfoFrame">
 
     <Grid>
@@ -16,13 +16,24 @@
                     <ComboBoxItem>Наименование</ComboBoxItem>
                     <ComboBoxItem>Размер скидки</ComboBoxItem>
                     <ComboBoxItem>Приоритет</ComboBoxItem>
-                </ComboBox>
+                    </ComboBox>
                 <Button Name="BUp" Click="BUP_Click">Воз</Button>
                 <Button Name="BDown" Click="BDown_Click">Уб</Button>
 
+
+                <ComboBox Width="100" Name="CBFilt" SelectionChanged="CBFilt_SelectionChanged">
+                    <ComboBoxItem>Все типы</ComboBoxItem>
+                    <ComboBoxItem>МФО</ComboBoxItem>
+                    <ComboBoxItem>ПАО</ComboBoxItem>
+                    <ComboBoxItem>ООО</ComboBoxItem>
+                    <ComboBoxItem>ЗАО</ComboBoxItem>
+                    <ComboBoxItem>ОАО</ComboBoxItem>
+                    <ComboBoxItem>МКК</ComboBoxItem>
+                </ComboBox>
+                <TextBox Width="200" Name="TBOXSearch" TextChanged="TBOXSearch_TextChanged"></TextBox>
             </StackPanel>
 
-                <ListView x:Name="LVAgent" Height="300" ScrollViewer.VerticalScrollBarVisibility="Visible" ScrollViewer.HorizontalScrollBarVisibility="Disabled">
+                <ListView x:Name="LVAgent" Height="200" ScrollViewer.VerticalScrollBarVisibility="Visible" ScrollViewer.HorizontalScrollBarVisibility="Disabled">
                 <ListView.ItemTemplate>
                     <DataTemplate>
                         <Border BorderBrush="Black" BorderThickness="2" Background="{Binding ColorCell}"> 
@@ -47,6 +58,7 @@
                     </DataTemplate>
                 </ListView.ItemTemplate>
             </ListView>
+            <Button x:Name="BAdd" Click="BAdd_Click">Добавить</Button>
         </StackPanel>
     </Grid>
 </Page>

+ 66 - 0
UP2022Ex/FrameFolder/AgentInfoFrame.xaml.cs

@@ -27,6 +27,7 @@ namespace UP2022Ex.FrameFolder
             _TemporraryFilter = _StartFilter;
             LVAgent.ItemsSource = _StartFilter;
             CBSort.SelectedIndex = 0;
+            CBFilt.SelectedIndex = 0;
         }
 
         public void Sort()
@@ -45,6 +46,53 @@ namespace UP2022Ex.FrameFolder
             }
         }
 
+        public void Filt()
+        {
+
+            switch (CBFilt.SelectedIndex)
+            {
+                case 0:
+                    _TemporraryFilter = _StartFilter;
+                    break;
+                case 1:
+                    _TemporraryFilter = _StartFilter.Where(x => x.AgentTypeID == 1).ToList();
+                    break;
+                case 2:
+                    _TemporraryFilter = _StartFilter.Where(x => x.AgentTypeID == 2).ToList();
+                    break;
+                case 3:
+                    _TemporraryFilter = _StartFilter.Where(x => x.AgentTypeID == 3).ToList();
+                    break;
+                case 4:
+                    _TemporraryFilter = _StartFilter.Where(x => x.AgentTypeID == 4).ToList();
+                    break;
+                case 5:
+                    _TemporraryFilter = _StartFilter.Where(x => x.AgentTypeID == 5).ToList();
+                    break;
+                case 6:
+                    _TemporraryFilter = _StartFilter.Where(x => x.AgentTypeID == 6).ToList();
+                    break;
+
+            }
+            string SearchStr = TBOXSearch.Text;
+            if (!string.IsNullOrWhiteSpace(TBOXSearch.Text))
+            {
+                _TemporraryFilter = _StartFilter.Where(x => x.Title.Contains(SearchStr)|| x.Title.ToLower().Contains(SearchStr) || x.Email.Contains(SearchStr) || x.Email.ToLower().Contains(SearchStr) || x.Phone.Contains(SearchStr) || x.Phone.ToLower().Contains(SearchStr)).ToList();
+            }
+            if (_UpAndDown == 1)
+            {
+                _UpAndDown *= -1;
+                Sort();
+            }
+            else
+            {
+                _UpAndDown *= -1;
+                Sort();
+                _TemporraryFilter.Reverse();
+            }
+            LVAgent.ItemsSource = _TemporraryFilter;
+        }
+
         private void CBSort_SelectionChanged(object sender, SelectionChangedEventArgs e)
         {
             Sort();
@@ -70,5 +118,23 @@ namespace UP2022Ex.FrameFolder
             }
             LVAgent.Items.Refresh();
         }
+
+        private void CBFilt_SelectionChanged(object sender, SelectionChangedEventArgs e)
+        {
+            Filt();
+            LVAgent.Items.Refresh();
+        }
+
+        private void BAdd_Click(object sender, RoutedEventArgs e)
+        {
+            WindowFolder.AddWindow NewWindow = new WindowFolder.AddWindow();
+            NewWindow.Show();
+        }
+
+        private void TBOXSearch_TextChanged(object sender, TextChangedEventArgs e)
+        {
+            Filt();
+            LVAgent.Items.Refresh();
+        }
     }
 }

+ 7 - 0
UP2022Ex/UP2022Ex.csproj

@@ -111,6 +111,9 @@
     <Compile Include="Supplier.cs">
       <DependentUpon>Model1.tt</DependentUpon>
     </Compile>
+    <Compile Include="WindowFolder\AddWindow.xaml.cs">
+      <DependentUpon>AddWindow.xaml</DependentUpon>
+    </Compile>
     <Page Include="FrameFolder\AgentInfoFrame.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
@@ -131,6 +134,10 @@
       <DependentUpon>MainWindow.xaml</DependentUpon>
       <SubType>Code</SubType>
     </Compile>
+    <Page Include="WindowFolder\AddWindow.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
   </ItemGroup>
   <ItemGroup>
     <Compile Include="Model1.Context.cs">

+ 12 - 0
UP2022Ex/WindowFolder/AddWindow.xaml

@@ -0,0 +1,12 @@
+<Window x:Class="UP2022Ex.WindowFolder.AddWindow"
+        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+        xmlns:local="clr-namespace:UP2022Ex.WindowFolder"
+        mc:Ignorable="d"
+        Title="AddWindow" Height="450" Width="800">
+    <Grid>
+        
+    </Grid>
+</Window>

+ 27 - 0
UP2022Ex/WindowFolder/AddWindow.xaml.cs

@@ -0,0 +1,27 @@
+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.Shapes;
+
+namespace UP2022Ex.WindowFolder
+{
+    /// <summary>
+    /// Логика взаимодействия для AddWindow.xaml
+    /// </summary>
+    public partial class AddWindow : Window
+    {
+        public AddWindow()
+        {
+            InitializeComponent();
+        }
+    }
+}