using EmployeeManagmentContracts.BusinessLogicContracts; using EmployeeManagmentContracts.ViewModels; 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 { /// /// Логика взаимодействия для AddSalaryWindow.xaml /// public partial class AddSalaryWindow : Window { private readonly ISalaryLogic _salaryLogic; private readonly IEmployeeLogic _employeeLogic; public AddSalaryWindow(ISalaryLogic salaryLogic, IEmployeeLogic employeeLogic) { _salaryLogic = salaryLogic; _employeeLogic = employeeLogic; InitializeComponent(); 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 salary = new SalaryViewModel { CountHours = int.Parse(HoursTextBox.Text), PriceHour = float.Parse(PriceTextBox.Text), Premium = string.IsNullOrEmpty(PremiumTextBox.Text) ? null : float.Parse(PremiumTextBox.Text), Date = DatePicker.SelectedDate.Value.ToUniversalTime(), EmployeeId = (int?)EmployeeComboBox.SelectedValue }; _salaryLogic.Insert(salary); MessageBox.Show("Зарплата успешно сохранена!"); Close(); } catch (Exception ex) { MessageBox.Show($"Ошибка: {ex.Message}"); } } } }