2024-12-01 16:34:36 +04:00
|
|
|
|
using EmployeeManagmentBusinessLogic.BusinessLogic;
|
|
|
|
|
using EmployeeManagmentContracts.BusinessLogicContracts;
|
2024-12-01 17:14:10 +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.Vacation
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Логика взаимодействия для AddVacationWindow.xaml
|
|
|
|
|
/// </summary>
|
|
|
|
|
public partial class AddVacationWindow : Window
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
private readonly IVacationLogic _vacationLogic;
|
2024-12-01 17:14:10 +04:00
|
|
|
|
private readonly IEmployeeLogic _employeeLogic;
|
2024-12-01 16:34:36 +04:00
|
|
|
|
|
2024-12-01 17:14:10 +04:00
|
|
|
|
public AddVacationWindow(IVacationLogic vacationLogic, IEmployeeLogic employeeLogic)
|
2024-12-01 16:34:36 +04:00
|
|
|
|
{
|
|
|
|
|
_vacationLogic = vacationLogic;
|
2024-12-01 17:14:10 +04:00
|
|
|
|
_employeeLogic = employeeLogic;
|
2024-12-01 16:34:36 +04:00
|
|
|
|
InitializeComponent();
|
2024-12-01 17:14:10 +04:00
|
|
|
|
LoadEmployees();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void LoadEmployees()
|
|
|
|
|
{
|
|
|
|
|
var employees = _employeeLogic.GetFullList();
|
|
|
|
|
EmployeeComboBox.ItemsSource = employees;
|
|
|
|
|
EmployeeComboBox.DisplayMemberPath = "NameJob";
|
|
|
|
|
EmployeeComboBox.SelectedValuePath = "Id";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void SaveButton_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var vacation = new VacationViewModel
|
|
|
|
|
{
|
|
|
|
|
StartData = StartDatePicker.SelectedDate.Value.ToUniversalTime(),
|
|
|
|
|
EndData = EndDatePicker.SelectedDate.Value.ToUniversalTime(),
|
|
|
|
|
Passed = PassedCheckBox.IsChecked ?? false,
|
|
|
|
|
EmployeeId = (int?)EmployeeComboBox.SelectedValue
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
_vacationLogic.Insert(vacation);
|
|
|
|
|
MessageBox.Show("Отпуск успешно сохранен!");
|
|
|
|
|
Close();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show($"Ошибка: {ex.Message}");
|
|
|
|
|
}
|
2024-12-01 16:34:36 +04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|