47 lines
1.5 KiB
C#
47 lines
1.5 KiB
C#
using Accounting_Time_It_Company.Repositories;
|
|
using Unity;
|
|
|
|
namespace Accounting_Time_It_Company.Forms
|
|
{
|
|
public partial class FormVacations : Form
|
|
{
|
|
private readonly IUnityContainer _container;
|
|
|
|
private readonly IVacationRepositories _vacationRepositories;
|
|
|
|
public FormVacations(IUnityContainer container, IVacationRepositories vacationRepositories)
|
|
{
|
|
InitializeComponent();
|
|
_container = container ?? throw new ArgumentNullException(nameof(container));
|
|
_vacationRepositories = vacationRepositories ?? throw new ArgumentNullException(nameof(vacationRepositories));
|
|
}
|
|
|
|
private void FormVacations_Load(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
LoadList();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
}
|
|
}
|
|
|
|
private void ButtonAdd_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
_container.Resolve<FormVacation>().ShowDialog();
|
|
LoadList();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
}
|
|
}
|
|
|
|
private void LoadList() => dataGridViewData.DataSource = _vacationRepositories.ReadVacations();
|
|
}
|
|
}
|