ISEbd-22_Rozhkov.I.E._Simple/GasStation/Forms/FormSellings.cs

50 lines
1.5 KiB
C#
Raw Normal View History

2024-11-15 18:27:06 +04:00
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);
}
}
}
}