diff --git a/EmployeeManagmentDataBaseImplement/Implements/EmployeeStorage.cs b/EmployeeManagmentDataBaseImplement/Implements/EmployeeStorage.cs
index dfcbeb2..ef13084 100644
--- a/EmployeeManagmentDataBaseImplement/Implements/EmployeeStorage.cs
+++ b/EmployeeManagmentDataBaseImplement/Implements/EmployeeStorage.cs
@@ -70,10 +70,13 @@ namespace EmployeeManagmentDataBaseImplement.Implements
PartTimeJob = entity.PartTimeJob,
Bid = entity.Bid,
PhysicalPersonsId = entity.PhisicalPersonsId,
- PhysicalPersonName = $"{entity.PhisicalPerson.Surname} {entity.PhisicalPerson.Name}"
+ PhysicalPersonName = entity.PhisicalPerson != null
+ ? $"{entity.PhisicalPerson.Surname} {entity.PhisicalPerson.Name}"
+ : "Не указано" // Обработка отсутствующего физического лица
};
}
+
// Добавить нового сотрудника
public void Insert(EmployeeViewModel model)
{
diff --git a/EmployeeManagmentView/Employee/DeleteEmployeeWindow.xaml b/EmployeeManagmentView/Employee/DeleteEmployeeWindow.xaml
index 6f2688d..a700642 100644
--- a/EmployeeManagmentView/Employee/DeleteEmployeeWindow.xaml
+++ b/EmployeeManagmentView/Employee/DeleteEmployeeWindow.xaml
@@ -1,12 +1,52 @@
+ Title="Удаление сотрудников"
+ Height="500" Width="800"
+ ResizeMode="NoResize"
+ WindowStartupLocation="CenterScreen"
+ Background="#0D2D4F">
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/EmployeeManagmentView/Employee/DeleteEmployeeWindow.xaml.cs b/EmployeeManagmentView/Employee/DeleteEmployeeWindow.xaml.cs
index 6689486..c74f43b 100644
--- a/EmployeeManagmentView/Employee/DeleteEmployeeWindow.xaml.cs
+++ b/EmployeeManagmentView/Employee/DeleteEmployeeWindow.xaml.cs
@@ -1,32 +1,68 @@
using EmployeeManagmentContracts.BusinessLogicContracts;
-using System;
+using EmployeeManagmentContracts.ViewModels;
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
{
- ///
- /// Логика взаимодействия для DeleteEmployeeWindow.xaml
- ///
public partial class DeleteEmployeeWindow : Window
{
-
private readonly IEmployeeLogic _employeeLogic;
+ private IEnumerable _allEmployees; // Список сотрудников для фильтрации
public DeleteEmployeeWindow(IEmployeeLogic employeeLogic)
{
_employeeLogic = employeeLogic;
InitializeComponent();
+ LoadEmployees();
+ }
+
+ private void LoadEmployees()
+ {
+ _allEmployees = _employeeLogic.GetFullList(); // Загрузка всех данных
+ EmployeesDataGrid.ItemsSource = _allEmployees;
+ }
+
+ private void DeleteButton_Click(object sender, RoutedEventArgs e)
+ {
+ if (EmployeesDataGrid.SelectedItem is EmployeeViewModel selectedEmployee)
+ {
+ // Удаление сотрудника
+ _employeeLogic.Delete(selectedEmployee.Id);
+ MessageBox.Show("Сотрудник успешно удален!");
+ LoadEmployees(); // Перезагрузка данных после удаления
+ SearchTextBox.Text = string.Empty; // Очистка поля поиска
+ }
+ else
+ {
+ MessageBox.Show("Пожалуйста, выберите сотрудника для удаления.");
+ }
+ }
+
+ 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;
+ }
}
}
}