2024-12-01 16:34:36 +04:00
|
|
|
|
using EmployeeManagmentContracts.BusinessLogicContracts;
|
2024-12-02 23:48:58 +04:00
|
|
|
|
using EmployeeManagmentContracts.ViewModels;
|
2024-12-01 16:34:36 +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.Salary
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Логика взаимодействия для ViewSalaryWindow.xaml
|
|
|
|
|
/// </summary>
|
|
|
|
|
public partial class ViewSalaryWindow : Window
|
|
|
|
|
{
|
|
|
|
|
|
2024-12-02 23:48:58 +04:00
|
|
|
|
|
2024-12-01 16:34:36 +04:00
|
|
|
|
private readonly ISalaryLogic _salaryLogic;
|
2024-12-02 23:48:58 +04:00
|
|
|
|
private IEnumerable<SalaryViewModel> _allSalaries;
|
2024-12-01 16:34:36 +04:00
|
|
|
|
|
|
|
|
|
public ViewSalaryWindow(ISalaryLogic salaryLogic)
|
|
|
|
|
{
|
|
|
|
|
_salaryLogic = salaryLogic;
|
|
|
|
|
InitializeComponent();
|
2024-12-02 23:48:58 +04:00
|
|
|
|
LoadSalaries();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void LoadSalaries()
|
|
|
|
|
{
|
|
|
|
|
_allSalaries = _salaryLogic.GetFullList(); // Загрузка всех данных
|
|
|
|
|
SalariesDataGrid.ItemsSource = _allSalaries;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void SearchTextBox_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
string query = SearchTextBox.Text.ToLower();
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(query))
|
|
|
|
|
{
|
|
|
|
|
// Отображаем все записи
|
|
|
|
|
SalariesDataGrid.ItemsSource = _allSalaries;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// Фильтрация по всем полям сущности
|
|
|
|
|
var filteredList = _allSalaries.Where(sal =>
|
|
|
|
|
(sal.EmployeeName?.ToLower().Contains(query) ?? false) ||
|
|
|
|
|
sal.CountHours.ToString().Contains(query) ||
|
|
|
|
|
sal.PriceHour.ToString().Contains(query) ||
|
|
|
|
|
sal.Passed.ToString().ToLower().Contains(query) ||
|
|
|
|
|
(sal.Premium.HasValue && sal.Premium.Value.ToString().Contains(query)) ||
|
|
|
|
|
(sal.Date.HasValue && sal.Date.Value.ToString("dd.MM.yyyy").Contains(query))
|
|
|
|
|
).ToList();
|
|
|
|
|
|
|
|
|
|
SalariesDataGrid.ItemsSource = filteredList;
|
|
|
|
|
}
|
2024-12-01 16:34:36 +04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|