Доделал поиск. Мб по коду, но так то работает.
This commit is contained in:
parent
7db0881977
commit
43903ceb95
@ -15,9 +15,17 @@
|
|||||||
Foreground="#FFFFFF"
|
Foreground="#FFFFFF"
|
||||||
Margin="0,20,0,0" />
|
Margin="0,20,0,0" />
|
||||||
|
|
||||||
|
<!-- Поиск -->
|
||||||
|
<TextBox x:Name="SearchTextBox"
|
||||||
|
Width="560"
|
||||||
|
VerticalAlignment="Top"
|
||||||
|
Margin="0,60,0,0"
|
||||||
|
HorizontalAlignment="Center"
|
||||||
|
TextChanged="SearchTextBox_TextChanged" />
|
||||||
|
|
||||||
<!-- Таблица для отображения -->
|
<!-- Таблица для отображения -->
|
||||||
<DataGrid x:Name="PhysicalPersonsDataGrid"
|
<DataGrid x:Name="PhysicalPersonsDataGrid"
|
||||||
Margin="20,60,20,80"
|
Margin="20,100,20,80"
|
||||||
AutoGenerateColumns="True"
|
AutoGenerateColumns="True"
|
||||||
Background="#FFFFFF"
|
Background="#FFFFFF"
|
||||||
Foreground="#000000" />
|
Foreground="#000000" />
|
||||||
|
@ -7,6 +7,7 @@ namespace EmployeeManagmentView.PhysicalPerson
|
|||||||
public partial class DeletePhysicalPersonWindow : Window
|
public partial class DeletePhysicalPersonWindow : Window
|
||||||
{
|
{
|
||||||
private readonly IPhisicalPersonLogic _phisicalPersonLogic;
|
private readonly IPhisicalPersonLogic _phisicalPersonLogic;
|
||||||
|
private IEnumerable<PhisicalPersonViewModel> _allPersons; // Храним все записи для фильтрации
|
||||||
|
|
||||||
public DeletePhysicalPersonWindow(IPhisicalPersonLogic phisicalPersonLogic)
|
public DeletePhysicalPersonWindow(IPhisicalPersonLogic phisicalPersonLogic)
|
||||||
{
|
{
|
||||||
@ -17,7 +18,8 @@ namespace EmployeeManagmentView.PhysicalPerson
|
|||||||
|
|
||||||
private void LoadPhysicalPersons()
|
private void LoadPhysicalPersons()
|
||||||
{
|
{
|
||||||
PhysicalPersonsDataGrid.ItemsSource = _phisicalPersonLogic.GetFullList();
|
_allPersons = _phisicalPersonLogic.GetFullList();
|
||||||
|
PhysicalPersonsDataGrid.ItemsSource = _allPersons;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DeleteButton_Click(object sender, RoutedEventArgs e)
|
private void DeleteButton_Click(object sender, RoutedEventArgs e)
|
||||||
@ -36,5 +38,29 @@ namespace EmployeeManagmentView.PhysicalPerson
|
|||||||
MessageBox.Show("Пожалуйста, выберите физическое лицо для удаления.");
|
MessageBox.Show("Пожалуйста, выберите физическое лицо для удаления.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void SearchTextBox_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e)
|
||||||
|
{
|
||||||
|
string searchQuery = SearchTextBox.Text.ToLower(); // Получаем текст для поиска
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(searchQuery))
|
||||||
|
{
|
||||||
|
// Если поле пустое, показываем все записи
|
||||||
|
PhysicalPersonsDataGrid.ItemsSource = _allPersons;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Фильтруем записи по всем полям
|
||||||
|
var filteredList = _allPersons.Where(p =>
|
||||||
|
p.FullName.ToLower().Contains(searchQuery) || // Поиск по ФИО
|
||||||
|
p.Address.ToLower().Contains(searchQuery) || // Поиск по адресу
|
||||||
|
p.Telephone.Contains(searchQuery) || // Поиск по телефону
|
||||||
|
p.Gender.ToLower().Contains(searchQuery) || // Поиск по полу
|
||||||
|
p.Birthday.ToString("dd.MM.yyyy").Contains(searchQuery) // Поиск по дате рождения
|
||||||
|
).ToList();
|
||||||
|
|
||||||
|
PhysicalPersonsDataGrid.ItemsSource = filteredList;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,6 @@
|
|||||||
Background="#0D2D4F">
|
Background="#0D2D4F">
|
||||||
|
|
||||||
<Grid>
|
<Grid>
|
||||||
|
|
||||||
<!-- Заголовок окна -->
|
<!-- Заголовок окна -->
|
||||||
<TextBlock Text="Редактирование физического лица"
|
<TextBlock Text="Редактирование физического лица"
|
||||||
HorizontalAlignment="Center" VerticalAlignment="Top"
|
HorizontalAlignment="Center" VerticalAlignment="Top"
|
||||||
@ -16,10 +15,7 @@
|
|||||||
Foreground="#FFFFFF"
|
Foreground="#FFFFFF"
|
||||||
Margin="0,20,0,0" />
|
Margin="0,20,0,0" />
|
||||||
|
|
||||||
<!-- Остальная часть как в AddPhysicalPersonWindow.xaml -->
|
|
||||||
<!-- Сетка для ввода данных в два столбца -->
|
|
||||||
<Grid Margin="0,60">
|
<Grid Margin="0,60">
|
||||||
|
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="Auto"/>
|
<RowDefinition Height="Auto"/>
|
||||||
<RowDefinition Height="Auto"/>
|
<RowDefinition Height="Auto"/>
|
||||||
@ -40,49 +36,49 @@
|
|||||||
<StackPanel Grid.Row="0" Grid.Column="0" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,10">
|
<StackPanel Grid.Row="0" Grid.Column="0" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,10">
|
||||||
<Label Content="Имя" Foreground="White" HorizontalAlignment="Center"/>
|
<Label Content="Имя" Foreground="White" HorizontalAlignment="Center"/>
|
||||||
<TextBox x:Name="NameTextBox"
|
<TextBox x:Name="NameTextBox"
|
||||||
Width="250" Height="40"
|
Width="250" Height="40"
|
||||||
Style="{StaticResource RoundedTextBoxStyle}"
|
Style="{StaticResource RoundedTextBoxStyle}"
|
||||||
Margin="0,5"
|
Margin="0,5"
|
||||||
ToolTip="Введите имя" HorizontalAlignment="Center"/>
|
ToolTip="Введите имя" HorizontalAlignment="Center"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
<!-- Поле для фамилии -->
|
<!-- Поле для фамилии -->
|
||||||
<StackPanel Grid.Row="0" Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,10">
|
<StackPanel Grid.Row="0" Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,10">
|
||||||
<Label Content="Фамилия" Foreground="White" HorizontalAlignment="Center"/>
|
<Label Content="Фамилия" Foreground="White" HorizontalAlignment="Center"/>
|
||||||
<TextBox x:Name="SurnameTextBox"
|
<TextBox x:Name="SurnameTextBox"
|
||||||
Width="250" Height="40"
|
Width="250" Height="40"
|
||||||
Style="{StaticResource RoundedTextBoxStyle}"
|
Style="{StaticResource RoundedTextBoxStyle}"
|
||||||
Margin="0,5"
|
Margin="0,5"
|
||||||
ToolTip="Введите фамилию" HorizontalAlignment="Center"/>
|
ToolTip="Введите фамилию" HorizontalAlignment="Center"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
<!-- Поле для отчества -->
|
<!-- Поле для отчества -->
|
||||||
<StackPanel Grid.Row="1" Grid.Column="0" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,10">
|
<StackPanel Grid.Row="1" Grid.Column="0" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,10">
|
||||||
<Label Content="Отчество" Foreground="White" HorizontalAlignment="Center"/>
|
<Label Content="Отчество" Foreground="White" HorizontalAlignment="Center"/>
|
||||||
<TextBox x:Name="PatronomicTextBox"
|
<TextBox x:Name="PatronomicTextBox"
|
||||||
Width="250" Height="40"
|
Width="250" Height="40"
|
||||||
Style="{StaticResource RoundedTextBoxStyle}"
|
Style="{StaticResource RoundedTextBoxStyle}"
|
||||||
Margin="0,5"
|
Margin="0,5"
|
||||||
ToolTip="Введите отчество" HorizontalAlignment="Center"/>
|
ToolTip="Введите отчество" HorizontalAlignment="Center"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
<!-- Поле для выбора даты рождения -->
|
<!-- Поле для выбора даты рождения -->
|
||||||
<StackPanel Grid.Row="1" Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,10">
|
<StackPanel Grid.Row="1" Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,10">
|
||||||
<Label Content="Дата рождения" Foreground="White" HorizontalAlignment="Center"/>
|
<Label Content="Дата рождения" Foreground="White" HorizontalAlignment="Center"/>
|
||||||
<DatePicker x:Name="BirthdayPicker"
|
<DatePicker x:Name="BirthdayPicker"
|
||||||
Width="250" Height="40"
|
Width="250" Height="40"
|
||||||
Margin="0,5"
|
Margin="0,5"
|
||||||
ToolTip="Выберите дату рождения" HorizontalAlignment="Center"/>
|
ToolTip="Выберите дату рождения" HorizontalAlignment="Center"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
<!-- Поле для выбора пола -->
|
<!-- Поле для выбора пола -->
|
||||||
<StackPanel Grid.Row="2" Grid.Column="0" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,10">
|
<StackPanel Grid.Row="2" Grid.Column="0" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,10">
|
||||||
<Label Content="Пол" Foreground="White" HorizontalAlignment="Center"/>
|
<Label Content="Пол" Foreground="White" HorizontalAlignment="Center"/>
|
||||||
<ComboBox x:Name="GenderComboBox"
|
<ComboBox x:Name="GenderComboBox"
|
||||||
Width="250" Height="40"
|
Width="250" Height="40"
|
||||||
Margin="0,5"
|
Margin="0,5"
|
||||||
ToolTip="Выберите пол"
|
ToolTip="Выберите пол"
|
||||||
Background="White" HorizontalAlignment="Center">
|
Background="White" HorizontalAlignment="Center">
|
||||||
<ComboBoxItem Content="Мужчина"/>
|
<ComboBoxItem Content="Мужчина"/>
|
||||||
<ComboBoxItem Content="Женщина"/>
|
<ComboBoxItem Content="Женщина"/>
|
||||||
</ComboBox>
|
</ComboBox>
|
||||||
@ -92,31 +88,43 @@
|
|||||||
<StackPanel Grid.Row="2" Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,10">
|
<StackPanel Grid.Row="2" Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,10">
|
||||||
<Label Content="Адрес" Foreground="White" HorizontalAlignment="Center"/>
|
<Label Content="Адрес" Foreground="White" HorizontalAlignment="Center"/>
|
||||||
<TextBox x:Name="AddressTextBox"
|
<TextBox x:Name="AddressTextBox"
|
||||||
Width="250" Height="40"
|
Width="250" Height="40"
|
||||||
Style="{StaticResource RoundedTextBoxStyle}"
|
Style="{StaticResource RoundedTextBoxStyle}"
|
||||||
Margin="0,5"
|
Margin="0,5"
|
||||||
ToolTip="Введите адрес" HorizontalAlignment="Center"/>
|
ToolTip="Введите адрес" HorizontalAlignment="Center"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
<!-- Поле для телефона -->
|
<!-- Поле для телефона -->
|
||||||
<StackPanel Grid.Row="3" Grid.Column="0" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,10">
|
<StackPanel Grid.Row="3" Grid.Column="0" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,10">
|
||||||
<Label Content="Телефон" Foreground="White" HorizontalAlignment="Center"/>
|
<Label Content="Телефон" Foreground="White" HorizontalAlignment="Center"/>
|
||||||
<TextBox x:Name="TelephoneTextBox"
|
<TextBox x:Name="TelephoneTextBox"
|
||||||
Width="250" Height="40"
|
Width="250" Height="40"
|
||||||
Style="{StaticResource RoundedTextBoxStyle}"
|
Style="{StaticResource RoundedTextBoxStyle}"
|
||||||
Margin="0,5"
|
Margin="0,5"
|
||||||
ToolTip="Введите номер телефона" HorizontalAlignment="Center"/>
|
ToolTip="Введите номер телефона" HorizontalAlignment="Center"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
|
<!-- Поле для поиска физических лиц -->
|
||||||
<StackPanel Grid.Row="3" Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,10">
|
<StackPanel Grid.Row="3" Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,10">
|
||||||
|
<Label Content="Поиск физического лица" Foreground="White" HorizontalAlignment="Center"/>
|
||||||
|
<TextBox x:Name="SearchTextBox"
|
||||||
|
Width="250" Height="40"
|
||||||
|
Margin="0,5"
|
||||||
|
ToolTip="Введите для поиска"
|
||||||
|
HorizontalAlignment="Center"
|
||||||
|
TextChanged="SearchTextBox_TextChanged"/>
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
|
<!-- Поле для выбора физического лица -->
|
||||||
|
<StackPanel Grid.Row="4" Grid.Column="0" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,10">
|
||||||
<Label Content="Выберите физическое лицо" Foreground="White" HorizontalAlignment="Center"/>
|
<Label Content="Выберите физическое лицо" Foreground="White" HorizontalAlignment="Center"/>
|
||||||
<ComboBox x:Name="PhysicalPersonComboBox"
|
<ComboBox x:Name="PhysicalPersonComboBox"
|
||||||
Width="400" Height="40"
|
Width="400" Height="40"
|
||||||
SelectionChanged="PhysicalPersonComboBox_SelectionChanged"
|
SelectionChanged="PhysicalPersonComboBox_SelectionChanged"
|
||||||
ToolTip="Выберите физическое лицо" HorizontalAlignment="Center"/>
|
ToolTip="Выберите физическое лицо" HorizontalAlignment="Center"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
|
|
||||||
<!-- Кнопка для сохранения изменений -->
|
<!-- Кнопка для сохранения изменений -->
|
||||||
<Button Content="Сохранить изменения"
|
<Button Content="Сохранить изменения"
|
||||||
Width="250" Height="40"
|
Width="250" Height="40"
|
||||||
@ -125,6 +133,5 @@
|
|||||||
Background="#004890" Foreground="#FFFFFF"
|
Background="#004890" Foreground="#FFFFFF"
|
||||||
Click="SaveButton_Click"
|
Click="SaveButton_Click"
|
||||||
HorizontalAlignment="Center" Margin="0,10,0,10"/>
|
HorizontalAlignment="Center" Margin="0,10,0,10"/>
|
||||||
|
|
||||||
</Grid>
|
</Grid>
|
||||||
</Window>
|
</Window>
|
||||||
|
@ -23,8 +23,8 @@ namespace EmployeeManagmentView.PhysicalPerson
|
|||||||
{
|
{
|
||||||
_physicalPersons = _phisicalPersonLogic.GetFullList();
|
_physicalPersons = _phisicalPersonLogic.GetFullList();
|
||||||
PhysicalPersonComboBox.ItemsSource = _physicalPersons;
|
PhysicalPersonComboBox.ItemsSource = _physicalPersons;
|
||||||
PhysicalPersonComboBox.DisplayMemberPath = "FullNameWithBirthday";
|
PhysicalPersonComboBox.DisplayMemberPath = "FullNameWithBirthday";
|
||||||
PhysicalPersonComboBox.SelectedValuePath = "Id";
|
PhysicalPersonComboBox.SelectedValuePath = "Id";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Событие при выборе физ.лица
|
// Событие при выборе физ.лица
|
||||||
@ -52,6 +52,23 @@ namespace EmployeeManagmentView.PhysicalPerson
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Фильтрация списка физических лиц по всем полям
|
||||||
|
private void SearchTextBox_TextChanged(object sender, TextChangedEventArgs e)
|
||||||
|
{
|
||||||
|
var searchText = SearchTextBox.Text.ToLower();
|
||||||
|
var filteredPersons = _physicalPersons
|
||||||
|
.Where(p => p.Name.ToLower().Contains(searchText) ||
|
||||||
|
p.Surname.ToLower().Contains(searchText) ||
|
||||||
|
p.Patronymic.ToLower().Contains(searchText) ||
|
||||||
|
p.Gender.ToLower().Contains(searchText) ||
|
||||||
|
p.Address.ToLower().Contains(searchText) ||
|
||||||
|
p.Telephone.ToLower().Contains(searchText) ||
|
||||||
|
p.Birthday.ToString("dd.MM.yyyy").Contains(searchText) // Поиск по дате рождения
|
||||||
|
).ToList();
|
||||||
|
|
||||||
|
PhysicalPersonComboBox.ItemsSource = filteredPersons;
|
||||||
|
}
|
||||||
|
|
||||||
private void SaveButton_Click(object sender, RoutedEventArgs e)
|
private void SaveButton_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
if (PhysicalPersonComboBox.SelectedValue is int selectedPersonId)
|
if (PhysicalPersonComboBox.SelectedValue is int selectedPersonId)
|
||||||
|
@ -15,9 +15,17 @@
|
|||||||
Foreground="#FFFFFF"
|
Foreground="#FFFFFF"
|
||||||
Margin="0,20,0,0" />
|
Margin="0,20,0,0" />
|
||||||
|
|
||||||
|
<!-- Поиск -->
|
||||||
|
<TextBox x:Name="SearchTextBox"
|
||||||
|
Width="560"
|
||||||
|
VerticalAlignment="Top"
|
||||||
|
Margin="0,60,0,0"
|
||||||
|
HorizontalAlignment="Center"
|
||||||
|
TextChanged="SearchTextBox_TextChanged" Height="20" />
|
||||||
|
|
||||||
<!-- Таблица для отображения -->
|
<!-- Таблица для отображения -->
|
||||||
<DataGrid x:Name="PhysicalPersonsDataGrid"
|
<DataGrid x:Name="PhysicalPersonsDataGrid"
|
||||||
Margin="20,60,20,20"
|
Margin="20,100,20,20"
|
||||||
AutoGenerateColumns="True"
|
AutoGenerateColumns="True"
|
||||||
Background="#FFFFFF"
|
Background="#FFFFFF"
|
||||||
Foreground="#000000" />
|
Foreground="#000000" />
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
using EmployeeManagmentContracts.BusinessLogicContracts;
|
using EmployeeManagmentContracts.BusinessLogicContracts;
|
||||||
|
using EmployeeManagmentContracts.ViewModels;
|
||||||
|
using System.Linq;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
|
|
||||||
namespace EmployeeManagmentView.PhysicalPerson
|
namespace EmployeeManagmentView.PhysicalPerson
|
||||||
@ -6,6 +8,7 @@ namespace EmployeeManagmentView.PhysicalPerson
|
|||||||
public partial class ViewPhysicalPersonsWindow : Window
|
public partial class ViewPhysicalPersonsWindow : Window
|
||||||
{
|
{
|
||||||
private readonly IPhisicalPersonLogic _phisicalPersonLogic;
|
private readonly IPhisicalPersonLogic _phisicalPersonLogic;
|
||||||
|
private IEnumerable<PhisicalPersonViewModel> _allPersons; // Храним все записи для фильтрации
|
||||||
|
|
||||||
public ViewPhysicalPersonsWindow(IPhisicalPersonLogic phisicalPersonLogic)
|
public ViewPhysicalPersonsWindow(IPhisicalPersonLogic phisicalPersonLogic)
|
||||||
{
|
{
|
||||||
@ -16,7 +19,34 @@ namespace EmployeeManagmentView.PhysicalPerson
|
|||||||
|
|
||||||
private void LoadPhysicalPersons()
|
private void LoadPhysicalPersons()
|
||||||
{
|
{
|
||||||
PhysicalPersonsDataGrid.ItemsSource = _phisicalPersonLogic.GetFullList();
|
_allPersons = _phisicalPersonLogic.GetFullList();
|
||||||
|
PhysicalPersonsDataGrid.ItemsSource = _allPersons;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SearchTextBox_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e)
|
||||||
|
{
|
||||||
|
string searchQuery = SearchTextBox.Text.ToLower(); // Получаем текст для поиска
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(searchQuery))
|
||||||
|
{
|
||||||
|
// Если поле пустое, показываем все записи
|
||||||
|
PhysicalPersonsDataGrid.ItemsSource = _allPersons;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Фильтруем записи по всем полям
|
||||||
|
var filteredList = _allPersons.Where(p =>
|
||||||
|
p.Name.ToLower().Contains(searchQuery) ||
|
||||||
|
p.Surname.ToLower().Contains(searchQuery) ||
|
||||||
|
p.Patronymic.ToLower().Contains(searchQuery) || // Поиск по ФИО
|
||||||
|
p.Address.ToLower().Contains(searchQuery) || // Поиск по адресу
|
||||||
|
p.Telephone.Contains(searchQuery) || // Поиск по телефону
|
||||||
|
p.Gender.ToLower().Contains(searchQuery) || // Поиск по полу
|
||||||
|
p.Birthday.ToString("dd.MM.yyyy").Contains(searchQuery) // Поиск по дате рождения
|
||||||
|
).ToList();
|
||||||
|
|
||||||
|
PhysicalPersonsDataGrid.ItemsSource = filteredList;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user