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