2024-12-01 15:14:20 +04:00
|
|
|
|
using EmployeeManagmentContracts.BusinessLogicContracts;
|
2024-12-01 15:51:49 +04:00
|
|
|
|
using EmployeeManagmentContracts.ViewModels;
|
2024-12-01 15:14:20 +04:00
|
|
|
|
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 EmployeeManagmentView.Employee
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Логика взаимодействия для ViewEmployeeWindow.xaml
|
|
|
|
|
/// </summary>
|
|
|
|
|
public partial class ViewEmployeeWindow : Window
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
private readonly IEmployeeLogic _employeeLogic;
|
2024-12-01 15:51:49 +04:00
|
|
|
|
private IEnumerable<EmployeeViewModel> _allEmployees; // Список сотрудников для фильтрации
|
2024-12-01 15:14:20 +04:00
|
|
|
|
|
|
|
|
|
public ViewEmployeeWindow(IEmployeeLogic employeeLogic)
|
|
|
|
|
{
|
|
|
|
|
_employeeLogic = employeeLogic;
|
|
|
|
|
InitializeComponent();
|
2024-12-01 15:51:49 +04:00
|
|
|
|
LoadEmployees();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void LoadEmployees()
|
|
|
|
|
{
|
|
|
|
|
_allEmployees = _employeeLogic.GetFullList(); // Загрузка всех данных
|
|
|
|
|
EmployeesDataGrid.ItemsSource = _allEmployees;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void SearchTextBox_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
string query = SearchTextBox.Text.ToLower();
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(query))
|
|
|
|
|
{
|
|
|
|
|
// Отображаем все записи
|
|
|
|
|
EmployeesDataGrid.ItemsSource = _allEmployees;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// Фильтрация по всем полям сущности
|
|
|
|
|
var filteredList = _allEmployees.Where(emp =>
|
|
|
|
|
(emp.NameJob?.ToLower().Contains(query) ?? false) ||
|
|
|
|
|
(emp.PartTimeJob?.ToLower().Contains(query) ?? false) ||
|
|
|
|
|
(emp.PhysicalPersonName?.ToLower().Contains(query) ?? false) ||
|
|
|
|
|
(emp.StartJob.HasValue && emp.StartJob.Value.ToString("dd.MM.yyyy").Contains(query)) ||
|
|
|
|
|
(emp.EndJob.HasValue && emp.EndJob.Value.ToString("dd.MM.yyyy").Contains(query)) ||
|
|
|
|
|
emp.Bid.ToString().Contains(query)
|
|
|
|
|
).ToList();
|
|
|
|
|
|
|
|
|
|
EmployeesDataGrid.ItemsSource = filteredList;
|
|
|
|
|
}
|
2024-12-01 15:14:20 +04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|