63 lines
2.1 KiB
C#
63 lines
2.1 KiB
C#
using ProjectGarage.Repositories;
|
|
using ProjectGarage.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 ProjectGarage.Forms
|
|
{
|
|
public partial class FormTransportations : Form
|
|
{
|
|
private readonly IUnityContainer _container;
|
|
private readonly ITransportationRepository _transportationRepository;
|
|
|
|
public FormTransportations(IUnityContainer container, ITransportationRepository transportationRepository)
|
|
{
|
|
InitializeComponent();
|
|
_container = container ?? throw new ArgumentNullException(nameof(container));
|
|
_transportationRepository = transportationRepository ??
|
|
throw new
|
|
ArgumentNullException(nameof(transportationRepository));
|
|
}
|
|
private void FormTransportations_Load(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
LoadList();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show(ex.Message, "Ошибка при загрузке",
|
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
}
|
|
}
|
|
|
|
private void ButtonAddTransportation_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
_container.Resolve<FormTransportation>().ShowDialog();
|
|
LoadList();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
}
|
|
}
|
|
|
|
private void LoadList()
|
|
{
|
|
dataGridViewTransportations.DataSource = _transportationRepository.ReadTransportation();
|
|
dataGridViewTransportations.Columns["Id"].Visible = false;
|
|
dataGridViewTransportations.Columns["TransportationDate"].DefaultCellStyle.Format = "dd MMMM yyyy hh:mm";
|
|
}
|
|
}
|
|
}
|