80 lines
2.8 KiB
C#
80 lines
2.8 KiB
C#
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
|
|
{
|
|
/// <summary>
|
|
/// Логика взаимодействия для EditSalaryWindow.xaml
|
|
/// </summary>
|
|
public partial class EditSalaryWindow : Window
|
|
{
|
|
|
|
private readonly ISalaryLogic _salaryLogic;
|
|
private readonly IEmployeeLogic _employeeLogic;
|
|
private List<EmployeeViewModel> _employees;
|
|
|
|
public EditSalaryWindow(ISalaryLogic salaryLogic, IEmployeeLogic employeeLogic)
|
|
{
|
|
_salaryLogic = salaryLogic;
|
|
_employeeLogic = employeeLogic;
|
|
InitializeComponent();
|
|
LoadEmployees();
|
|
}
|
|
|
|
private void LoadEmployees()
|
|
{
|
|
_employees = _employeeLogic.GetFullList();
|
|
EmployeeComboBox.ItemsSource = _employees;
|
|
EmployeeComboBox.DisplayMemberPath = "NameJob";
|
|
EmployeeComboBox.SelectedValuePath = "Id";
|
|
}
|
|
private void EmployeeComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void SaveButton_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
if (EmployeeComboBox.SelectedValue is int selectedEmployeeId)
|
|
{
|
|
try
|
|
{
|
|
var newSalary = new SalaryViewModel
|
|
{
|
|
CountHours = int.Parse(CountHoursTextBox.Text),
|
|
PriceHour = float.Parse(PriceHourTextBox.Text),
|
|
Premium = string.IsNullOrEmpty(PremiumTextBox.Text) ? (float?)null : float.Parse(PremiumTextBox.Text),
|
|
Date = DatePicker.SelectedDate,
|
|
Passed = PassedCheckBox.IsChecked ?? false,
|
|
EmployeeId = selectedEmployeeId
|
|
};
|
|
|
|
_salaryLogic.Insert(newSalary);
|
|
MessageBox.Show("Зарплата успешно добавлена!");
|
|
this.Close();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show($"Ошибка: {ex.Message}");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show("Выберите сотрудника перед сохранением!", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Warning);
|
|
}
|
|
}
|
|
}
|
|
} |