65 lines
1.8 KiB
C#
65 lines
1.8 KiB
C#
using ProjectFuel.Entities;
|
|
using ProjectFuel.Repositories;
|
|
using ProjectFuel.Repositories.Implementations;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
using Unity;
|
|
|
|
namespace ProjectFuel.Forms_
|
|
{
|
|
public partial class FormRefills : Form
|
|
{
|
|
private readonly IUnityContainer _container;
|
|
|
|
private readonly IRefillRepository _refillRepository;
|
|
public FormRefills(IUnityContainer container, IRefillRepository refillRepository)
|
|
{
|
|
InitializeComponent();
|
|
_container = container ??
|
|
throw new ArgumentNullException(nameof(container));
|
|
|
|
_refillRepository = refillRepository ??
|
|
throw new ArgumentNullException(nameof(refillRepository));
|
|
}
|
|
private void FormRefills_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<FormRefill>().ShowDialog();
|
|
LoadList();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show(ex.Message, "Ошибка при добавлении",
|
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void LoadList() => dataGridView.DataSource = _refillRepository.ReadRefills();
|
|
|
|
|
|
}
|
|
}
|
|
|