serch_chinit

This commit is contained in:
irreaaa 2025-04-02 14:50:36 +03:00
parent e614e1d967
commit e890f9c7b8
16 changed files with 39 additions and 4 deletions

View File

@ -11,7 +11,7 @@
<StackPanel DockPanel.Dock="Top" Margin="10" HorizontalAlignment="Center" Orientation="Horizontal"> <StackPanel DockPanel.Dock="Top" Margin="10" HorizontalAlignment="Center" Orientation="Horizontal">
<StackPanel Orientation="Vertical" Margin="5"> <StackPanel Orientation="Vertical" Margin="5">
<TextBlock Text=""/> <TextBlock Text=""/>
<AutoCompleteBox x:Name="SearchBox" Watermark="Поиск" FilterMode="StartsWith" HorizontalAlignment="Center" Margin="5" Width="200"/> <AutoCompleteBox x:Name="SearchBox" Watermark="Поиск" FilterMode="StartsWith" HorizontalAlignment="Center" Margin="5" Width="200" SelectionChanged="SearchBox_SelectionChanged"/>
</StackPanel> </StackPanel>
<StackPanel Orientation="Vertical" Margin="5"> <StackPanel Orientation="Vertical" Margin="5">
<TextBlock Text="Тип агента"/> <TextBlock Text="Тип агента"/>

View File

@ -23,12 +23,47 @@ namespace demofinish
InitializeComponent(); InitializeComponent();
LoadAgents(); LoadAgents();
ComboboxAgentType(); ComboboxAgentType();
SearchFiels();
TypeAgentCombobox.SelectionChanged += TypeAgentCombobox_SelectionChanged; TypeAgentCombobox.SelectionChanged += TypeAgentCombobox_SelectionChanged;
NameComboBox.SelectionChanged += SortName_SelectedChanged; NameComboBox.SelectionChanged += SortName_SelectedChanged;
PriorityCombobox.SelectionChanged += PrioritySort_SelectedChanged; PriorityCombobox.SelectionChanged += PrioritySort_SelectedChanged;
} }
private void SearchFiels()
{
using var context = new User1Context();
var searchItems = context.Agents
.Select(a => a.Title)
.Union(context.Agents.Select(a => a.Phone))
.Union(context.Agents.Select(a => a.Email))
.Where(x => !string.IsNullOrEmpty(x))
.ToList();
SearchBox.ItemsSource = searchItems;
SearchBox.SelectionChanged += SearchBox_SelectionChanged;
}
private void SearchBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (SearchBox.SelectedItem == null) return;
string searchValue = SearchBox.SelectedItem.ToString();
var filtered = agentsList
.Where(a => a.Title == searchValue ||
a.Phone == searchValue ||
a.Email == searchValue)
.ToList();
AgentListBox.ItemsSource = filtered;
}
@ -228,7 +263,7 @@ namespace demofinish
} }

View File

@ -13,7 +13,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("demofinish")] [assembly: System.Reflection.AssemblyCompanyAttribute("demofinish")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+8c009e6908c827bf6a1d1272b6019949a641ac9c")] [assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+e614e1d9670ca3d82ea9fb11a721ac6aa3759c6b")]
[assembly: System.Reflection.AssemblyProductAttribute("demofinish")] [assembly: System.Reflection.AssemblyProductAttribute("demofinish")]
[assembly: System.Reflection.AssemblyTitleAttribute("demofinish")] [assembly: System.Reflection.AssemblyTitleAttribute("demofinish")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

View File

@ -1 +1 @@
af193fa632a0477765702f8f317fecad5f881bbfcdd590732dcd8277d098e7e3 98cabbc2382a7d2381155a98b2d991d5943cbb52108528ae0db6acb26db80740