diff --git a/EmployeeManagmentView/Employee/EditEmployeeWindow.xaml b/EmployeeManagmentView/Employee/EditEmployeeWindow.xaml
index d0671ad..26b000e 100644
--- a/EmployeeManagmentView/Employee/EditEmployeeWindow.xaml
+++ b/EmployeeManagmentView/Employee/EditEmployeeWindow.xaml
@@ -1,12 +1,118 @@
-
-
+ Title="Редактирование сотрудника"
+ Height="704" Width="600"
+ ResizeMode="NoResize"
+ WindowStartupLocation="CenterScreen"
+ Background="#0D2D4F">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
\ No newline at end of file
diff --git a/EmployeeManagmentView/Employee/EditEmployeeWindow.xaml.cs b/EmployeeManagmentView/Employee/EditEmployeeWindow.xaml.cs
index 420a64e..0f7e4b5 100644
--- a/EmployeeManagmentView/Employee/EditEmployeeWindow.xaml.cs
+++ b/EmployeeManagmentView/Employee/EditEmployeeWindow.xaml.cs
@@ -1,4 +1,5 @@
using EmployeeManagmentContracts.BusinessLogicContracts;
+using EmployeeManagmentContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -22,11 +23,97 @@ namespace EmployeeManagmentView.Employee
{
private readonly IEmployeeLogic _employeeLogic;
+ private readonly IPhisicalPersonLogic _physicalPersonLogic;
+ private List _employees;
- public EditEmployeeWindow(IEmployeeLogic employeeLogic)
+ public EditEmployeeWindow(IEmployeeLogic employeeLogic, IPhisicalPersonLogic physicalPersonLogic)
{
_employeeLogic = employeeLogic;
+ _physicalPersonLogic = physicalPersonLogic;
InitializeComponent();
+ LoadEmployees();
+ LoadPhysicalPersons();
+ }
+
+ private void LoadEmployees()
+ {
+ _employees = _employeeLogic.GetFullList();
+ EmployeeComboBox.ItemsSource = _employees;
+ EmployeeComboBox.DisplayMemberPath = "NameJob";
+ EmployeeComboBox.SelectedValuePath = "Id";
+ }
+
+ private void LoadPhysicalPersons()
+ {
+ var physicalPersons = _physicalPersonLogic.GetFullList();
+ PhysicalPersonComboBox.ItemsSource = physicalPersons;
+ PhysicalPersonComboBox.DisplayMemberPath = "FullNameWithBirthday";
+ PhysicalPersonComboBox.SelectedValuePath = "Id";
+ }
+
+ private void EmployeeComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
+ {
+ if (EmployeeComboBox.SelectedValue is int selectedEmployeeId)
+ {
+ LoadEmployee(selectedEmployeeId);
+ }
+ }
+
+ private void LoadEmployee(int employeeId)
+ {
+ var employee = _employeeLogic.GetElement(employeeId);
+ if (employee != null)
+ {
+ JobNameTextBox.Text = employee.NameJob;
+ StartJobPicker.SelectedDate = employee.StartJob;
+ EndJobPicker.SelectedDate = employee.EndJob;
+ PartTimeTextBox.Text = employee.PartTimeJob;
+ BidTextBox.Text = employee.Bid.ToString();
+ PhysicalPersonComboBox.SelectedValue = employee.PhysicalPersonsId;
+ }
+ }
+
+ private void SearchTextBox_TextChanged(object sender, TextChangedEventArgs e)
+ {
+ var searchText = SearchTextBox.Text.ToLower();
+ var filteredEmployees = _employees
+ .Where(emp => emp.NameJob.ToLower().Contains(searchText) ||
+ emp.PhysicalPersonName?.ToLower().Contains(searchText) == true)
+ .ToList();
+
+ EmployeeComboBox.ItemsSource = filteredEmployees;
+ }
+
+ private void SaveButton_Click(object sender, RoutedEventArgs e)
+ {
+ if (EmployeeComboBox.SelectedValue is int selectedEmployeeId)
+ {
+ try
+ {
+ var updatedEmployee = new EmployeeViewModel
+ {
+ Id = selectedEmployeeId,
+ NameJob = JobNameTextBox.Text,
+ StartJob = StartJobPicker.SelectedDate,
+ EndJob = EndJobPicker.SelectedDate,
+ PartTimeJob = PartTimeTextBox.Text,
+ Bid = float.Parse(BidTextBox.Text),
+ PhysicalPersonsId = PhysicalPersonComboBox.SelectedValue as int?
+ };
+
+ _employeeLogic.Update(updatedEmployee);
+ MessageBox.Show("Данные успешно обновлены!");
+ this.Close();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show($"Ошибка: {ex.Message}");
+ }
+ }
+ else
+ {
+ MessageBox.Show("Выберите сотрудника перед сохранением!", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Warning);
+ }
}
}
-}
+}
\ No newline at end of file
diff --git a/EmployeeManagmentView/Employee/EmployeeManagementWindow.xaml.cs b/EmployeeManagmentView/Employee/EmployeeManagementWindow.xaml.cs
index afc724b..379b655 100644
--- a/EmployeeManagmentView/Employee/EmployeeManagementWindow.xaml.cs
+++ b/EmployeeManagmentView/Employee/EmployeeManagementWindow.xaml.cs
@@ -74,7 +74,7 @@ namespace EmployeeManagmentView.Employee
}
}
- var editWindow = new EditEmployeeWindow(_employeeLogic);
+ var editWindow = new EditEmployeeWindow(_employeeLogic, _phisicalPersonLogic);
editWindow.Show();
}
diff --git a/EmployeeManagmentView/Employee/ViewEmployeeWindow.xaml b/EmployeeManagmentView/Employee/ViewEmployeeWindow.xaml
index 9668c15..653d7fa 100644
--- a/EmployeeManagmentView/Employee/ViewEmployeeWindow.xaml
+++ b/EmployeeManagmentView/Employee/ViewEmployeeWindow.xaml
@@ -1,12 +1,43 @@
+ Title="Удаление сотрудников"
+ Height="500" Width="800"
+ ResizeMode="NoResize"
+ WindowStartupLocation="CenterScreen"
+ Background="#0D2D4F">
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
\ No newline at end of file
diff --git a/EmployeeManagmentView/Employee/ViewEmployeeWindow.xaml.cs b/EmployeeManagmentView/Employee/ViewEmployeeWindow.xaml.cs
index 5f295a6..4d6d738 100644
--- a/EmployeeManagmentView/Employee/ViewEmployeeWindow.xaml.cs
+++ b/EmployeeManagmentView/Employee/ViewEmployeeWindow.xaml.cs
@@ -1,4 +1,5 @@
using EmployeeManagmentContracts.BusinessLogicContracts;
+using EmployeeManagmentContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -22,11 +23,45 @@ namespace EmployeeManagmentView.Employee
{
private readonly IEmployeeLogic _employeeLogic;
+ private IEnumerable _allEmployees; // Список сотрудников для фильтрации
public ViewEmployeeWindow(IEmployeeLogic employeeLogic)
{
_employeeLogic = employeeLogic;
InitializeComponent();
+ 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;
+ }
}
}
}