diff --git a/EmployeeManagmentView/PhysicalPerson/DeletePhysicalPersonWindow.xaml b/EmployeeManagmentView/PhysicalPerson/DeletePhysicalPersonWindow.xaml
new file mode 100644
index 0000000..4fb005c
--- /dev/null
+++ b/EmployeeManagmentView/PhysicalPerson/DeletePhysicalPersonWindow.xaml
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/EmployeeManagmentView/PhysicalPerson/DeletePhysicalPersonWindow.xaml.cs b/EmployeeManagmentView/PhysicalPerson/DeletePhysicalPersonWindow.xaml.cs
new file mode 100644
index 0000000..0d21282
--- /dev/null
+++ b/EmployeeManagmentView/PhysicalPerson/DeletePhysicalPersonWindow.xaml.cs
@@ -0,0 +1,40 @@
+using EmployeeManagmentContracts.BusinessLogicContracts;
+using EmployeeManagmentContracts.ViewModels;
+using System.Windows;
+
+namespace EmployeeManagmentView.PhysicalPerson
+{
+ public partial class DeletePhysicalPersonWindow : Window
+ {
+ private readonly IPhisicalPersonLogic _phisicalPersonLogic;
+
+ public DeletePhysicalPersonWindow(IPhisicalPersonLogic phisicalPersonLogic)
+ {
+ _phisicalPersonLogic = phisicalPersonLogic;
+ InitializeComponent();
+ LoadPhysicalPersons();
+ }
+
+ private void LoadPhysicalPersons()
+ {
+ PhysicalPersonsDataGrid.ItemsSource = _phisicalPersonLogic.GetFullList();
+ }
+
+ 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("Пожалуйста, выберите физическое лицо для удаления.");
+ }
+ }
+ }
+}
diff --git a/EmployeeManagmentView/PhysicalPerson/EditPhysicalPersonWindow.xaml b/EmployeeManagmentView/PhysicalPerson/EditPhysicalPersonWindow.xaml
new file mode 100644
index 0000000..17c4d6a
--- /dev/null
+++ b/EmployeeManagmentView/PhysicalPerson/EditPhysicalPersonWindow.xaml
@@ -0,0 +1,130 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/EmployeeManagmentView/PhysicalPerson/EditPhysicalPersonWindow.xaml.cs b/EmployeeManagmentView/PhysicalPerson/EditPhysicalPersonWindow.xaml.cs
new file mode 100644
index 0000000..50b8ec8
--- /dev/null
+++ b/EmployeeManagmentView/PhysicalPerson/EditPhysicalPersonWindow.xaml.cs
@@ -0,0 +1,87 @@
+using System.Collections.Generic;
+using System.Windows;
+using System.Windows.Controls;
+using EmployeeManagmentContracts.BusinessLogicContracts;
+using EmployeeManagmentContracts.ViewModels;
+
+namespace EmployeeManagmentView.PhysicalPerson
+{
+ public partial class EditPhysicalPersonWindow : Window
+ {
+ private readonly IPhisicalPersonLogic _phisicalPersonLogic;
+ private List _physicalPersons;
+
+ public EditPhysicalPersonWindow(IPhisicalPersonLogic phisicalPersonLogic)
+ {
+ _phisicalPersonLogic = phisicalPersonLogic;
+ InitializeComponent();
+ LoadPhysicalPersons();
+ }
+
+ // Загрузка всех физ.лиц в ComboBox
+ private void LoadPhysicalPersons()
+ {
+ _physicalPersons = _phisicalPersonLogic.GetFullList();
+ PhysicalPersonComboBox.ItemsSource = _physicalPersons;
+ PhysicalPersonComboBox.DisplayMemberPath = "Name"; // "FullName" - свойство с именем
+ PhysicalPersonComboBox.SelectedValuePath = "Id"; // "Id" - идентификатор физ.лица
+ }
+
+ // Событие при выборе физ.лица
+ private void PhysicalPersonComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
+ {
+ if (PhysicalPersonComboBox.SelectedValue is int selectedPersonId)
+ {
+ LoadPerson(selectedPersonId);
+ }
+ }
+
+ // Загрузка данных выбранного физ.лица в поля
+ private void LoadPerson(int personId)
+ {
+ var person = _phisicalPersonLogic.GetElement(personId);
+ if (person != null)
+ {
+ NameTextBox.Text = person.Name;
+ SurnameTextBox.Text = person.Surname;
+ PatronomicTextBox.Text = person.Patronymic;
+ BirthdayPicker.SelectedDate = person.Birthday;
+ GenderComboBox.Text = person.Gender;
+ AddressTextBox.Text = person.Address;
+ TelephoneTextBox.Text = person.Telephone;
+ }
+ }
+
+ private void SaveButton_Click(object sender, RoutedEventArgs e)
+ {
+ if (PhysicalPersonComboBox.SelectedValue is int selectedPersonId)
+ {
+ try
+ {
+ var updatedPerson = new PhisicalPersonViewModel
+ {
+ Id = selectedPersonId,
+ Name = NameTextBox.Text,
+ Surname = SurnameTextBox.Text,
+ Patronymic = PatronomicTextBox.Text,
+ Birthday = BirthdayPicker.SelectedDate.Value.ToUniversalTime(),
+ Gender = GenderComboBox.Text,
+ Address = AddressTextBox.Text,
+ Telephone = TelephoneTextBox.Text
+ };
+
+ _phisicalPersonLogic.Update(updatedPerson);
+ MessageBox.Show("Данные успешно обновлены!");
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show($"Ошибка: {ex.Message}");
+ }
+ }
+ else
+ {
+ MessageBox.Show("Выберите физическое лицо перед сохранением!", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Warning);
+ }
+ }
+ }
+}
diff --git a/EmployeeManagmentView/PhysicalPerson/PhysicalPersonManagementWindow.xaml b/EmployeeManagmentView/PhysicalPerson/PhysicalPersonManagementWindow.xaml
index c8f194c..eebfb3d 100644
--- a/EmployeeManagmentView/PhysicalPerson/PhysicalPersonManagementWindow.xaml
+++ b/EmployeeManagmentView/PhysicalPerson/PhysicalPersonManagementWindow.xaml
@@ -21,7 +21,8 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
Width="250" Height="40"
Margin="0,0,0,10"
Background="#004890" Foreground="#FFFFFF"
- Style="{StaticResource RoundedButtonStyle}" />
+ Style="{StaticResource RoundedButtonStyle}"
+ Click ="OpenDeletePhysicalPersonWindow"/>
+ Background="#004890" Foreground="#FFFFFF"
+ Click="OpenEditPhysicalPersonWindow"/>
+ Background="#004890" Foreground="#FFFFFF"
+ Click="OpenViewPhysicalPersonsWindow"/>
diff --git a/EmployeeManagmentView/PhysicalPerson/PhysicalPersonManagementWindow.xaml.cs b/EmployeeManagmentView/PhysicalPerson/PhysicalPersonManagementWindow.xaml.cs
index 6270a70..7d62333 100644
--- a/EmployeeManagmentView/PhysicalPerson/PhysicalPersonManagementWindow.xaml.cs
+++ b/EmployeeManagmentView/PhysicalPerson/PhysicalPersonManagementWindow.xaml.cs
@@ -15,24 +15,62 @@ namespace EmployeeManagmentView.PhysicalPerson
private void OpenAddPhysicalPersonWindow(object sender, RoutedEventArgs e)
{
- // Проверяем, если окно уже открыто
foreach (Window window in Application.Current.Windows)
{
- if (window is AddPhysicalPersonWindow)
+ if (window is AddPhysicalPersonWindow existingWindow)
{
- // Если окно уже открыто, активируем его и ставим на передний план
- window.Activate();
- window.WindowStartupLocation = WindowStartupLocation.CenterScreen;
- window.Topmost = true; // Ставим окно на передний план
+ existingWindow.Activate();
return;
}
}
- // Если окно не найдено, открываем новое
- var physicalPersonWindow = new AddPhysicalPersonWindow(_phisicalPersonLogic);
- physicalPersonWindow.Topmost = true;
- physicalPersonWindow.Show();
+ var addWindow = new AddPhysicalPersonWindow(_phisicalPersonLogic);
+ addWindow.Show();
}
+ private void OpenDeletePhysicalPersonWindow(object sender, RoutedEventArgs e)
+ {
+ foreach (Window window in Application.Current.Windows)
+ {
+ if (window is DeletePhysicalPersonWindow existingWindow)
+ {
+ existingWindow.Activate();
+ return;
+ }
+ }
+
+ var deleteWindow = new DeletePhysicalPersonWindow(_phisicalPersonLogic);
+ deleteWindow.Show();
+ }
+
+ private void OpenEditPhysicalPersonWindow(object sender, RoutedEventArgs e)
+ {
+ foreach (Window window in Application.Current.Windows)
+ {
+ if (window is EditPhysicalPersonWindow existingWindow)
+ {
+ existingWindow.Activate();
+ return;
+ }
+ }
+
+ var editWindow = new EditPhysicalPersonWindow(_phisicalPersonLogic);
+ editWindow.Show();
+ }
+
+ private void OpenViewPhysicalPersonsWindow(object sender, RoutedEventArgs e)
+ {
+ foreach (Window window in Application.Current.Windows)
+ {
+ if (window is ViewPhysicalPersonsWindow existingWindow)
+ {
+ existingWindow.Activate();
+ return;
+ }
+ }
+
+ var viewWindow = new ViewPhysicalPersonsWindow(_phisicalPersonLogic);
+ viewWindow.Show();
+ }
}
}
diff --git a/EmployeeManagmentView/PhysicalPerson/ViewPhysicalPersonsWindow.xaml b/EmployeeManagmentView/PhysicalPerson/ViewPhysicalPersonsWindow.xaml
new file mode 100644
index 0000000..6dcf5d0
--- /dev/null
+++ b/EmployeeManagmentView/PhysicalPerson/ViewPhysicalPersonsWindow.xaml
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/EmployeeManagmentView/PhysicalPerson/ViewPhysicalPersonsWindow.xaml.cs b/EmployeeManagmentView/PhysicalPerson/ViewPhysicalPersonsWindow.xaml.cs
new file mode 100644
index 0000000..b5266a1
--- /dev/null
+++ b/EmployeeManagmentView/PhysicalPerson/ViewPhysicalPersonsWindow.xaml.cs
@@ -0,0 +1,22 @@
+using EmployeeManagmentContracts.BusinessLogicContracts;
+using System.Windows;
+
+namespace EmployeeManagmentView.PhysicalPerson
+{
+ public partial class ViewPhysicalPersonsWindow : Window
+ {
+ private readonly IPhisicalPersonLogic _phisicalPersonLogic;
+
+ public ViewPhysicalPersonsWindow(IPhisicalPersonLogic phisicalPersonLogic)
+ {
+ _phisicalPersonLogic = phisicalPersonLogic;
+ InitializeComponent();
+ LoadPhysicalPersons();
+ }
+
+ private void LoadPhysicalPersons()
+ {
+ PhysicalPersonsDataGrid.ItemsSource = _phisicalPersonLogic.GetFullList();
+ }
+ }
+}