2024-11-30 15:36:29 +04:00
|
|
|
|
using EmployeeManagmentContracts.BusinessLogicContracts;
|
|
|
|
|
using EmployeeManagmentContracts.ViewModels;
|
|
|
|
|
using System.Windows;
|
|
|
|
|
|
|
|
|
|
namespace EmployeeManagmentView.PhysicalPerson
|
|
|
|
|
{
|
|
|
|
|
public partial class DeletePhysicalPersonWindow : Window
|
|
|
|
|
{
|
|
|
|
|
private readonly IPhisicalPersonLogic _phisicalPersonLogic;
|
2024-11-30 16:06:37 +04:00
|
|
|
|
private IEnumerable<PhisicalPersonViewModel> _allPersons; // Храним все записи для фильтрации
|
2024-11-30 15:36:29 +04:00
|
|
|
|
|
|
|
|
|
public DeletePhysicalPersonWindow(IPhisicalPersonLogic phisicalPersonLogic)
|
|
|
|
|
{
|
|
|
|
|
_phisicalPersonLogic = phisicalPersonLogic;
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
LoadPhysicalPersons();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void LoadPhysicalPersons()
|
|
|
|
|
{
|
2024-11-30 16:06:37 +04:00
|
|
|
|
_allPersons = _phisicalPersonLogic.GetFullList();
|
|
|
|
|
PhysicalPersonsDataGrid.ItemsSource = _allPersons;
|
2024-11-30 15:36:29 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void DeleteButton_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (PhysicalPersonsDataGrid.SelectedItem != null)
|
|
|
|
|
{
|
|
|
|
|
var selectedPerson = PhysicalPersonsDataGrid.SelectedItem as PhisicalPersonViewModel;
|
|
|
|
|
if (selectedPerson != null)
|
|
|
|
|
{
|
|
|
|
|
_phisicalPersonLogic.Delete(selectedPerson.Id); // Используем Id для удаления
|
|
|
|
|
LoadPhysicalPersons(); // Перезагружаем список
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("Пожалуйста, выберите физическое лицо для удаления.");
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-11-30 16:06:37 +04:00
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-11-30 15:36:29 +04:00
|
|
|
|
}
|
|
|
|
|
}
|