58 lines
1.7 KiB
C#
58 lines
1.7 KiB
C#
using ProjectFuel.Repositories;
|
|
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 FormTrips : Form
|
|
|
|
{
|
|
private readonly IUnityContainer _container;
|
|
|
|
private readonly ITripRepository _tripRepository;
|
|
public FormTrips(IUnityContainer container, ITripRepository tripRepository)
|
|
{
|
|
InitializeComponent();
|
|
_container = container ??
|
|
throw new ArgumentNullException(nameof(container));
|
|
|
|
_tripRepository = tripRepository ??
|
|
throw new ArgumentNullException(nameof(tripRepository));
|
|
}
|
|
private void FormTrips_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<FormTrip>().ShowDialog();
|
|
LoadList();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show(ex.Message, "Ошибка при добавлении",
|
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
}
|
|
}
|
|
private void LoadList() => dataGridViewTrips.DataSource = _tripRepository.ReadTrips();
|
|
}
|
|
}
|