133 lines
3.0 KiB
C#
133 lines
3.0 KiB
C#
using Microsoft.Extensions.Logging;
|
|
using TransportCompanyContracts.BusinessLogicsContracts;
|
|
|
|
namespace TransportCompany
|
|
{
|
|
public partial class FormTrucking : Form
|
|
{
|
|
private readonly ILogger _logger;
|
|
|
|
private readonly ITruckingLogic _truckingLogic;
|
|
|
|
public FormTrucking(ILogger<FormTrucking> logger, ITruckingLogic truckingLogic)
|
|
{
|
|
InitializeComponent();
|
|
|
|
_logger = logger;
|
|
_truckingLogic = truckingLogic;
|
|
}
|
|
|
|
private void FormMain_Load(object sender, EventArgs e)
|
|
{
|
|
LoadData();
|
|
}
|
|
|
|
private void LoadData()
|
|
{
|
|
_logger.LogInformation("Çàãðóçêà ïåðåâîçîê");
|
|
|
|
try
|
|
{
|
|
var list = _truckingLogic.ReadList(null);
|
|
|
|
if (list != null)
|
|
{
|
|
dataGridView.DataSource = list;
|
|
dataGridView.Columns["ClientId"].Visible = false;
|
|
dataGridView.Columns["CargoId"].Visible = false;
|
|
dataGridView.Columns["TransportId"].Visible = false;
|
|
dataGridView.Columns["TransportationId"].Visible = false;
|
|
}
|
|
|
|
_logger.LogInformation("Çàãðóçêà ïåðåâîçîê");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
_logger.LogError(ex, "Îøèáêà çàãðóçêè ïåðåâîçîê");
|
|
MessageBox.Show(ex.Message, "Îøèáêà", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
}
|
|
}
|
|
|
|
private void ButtonCreateTrucking_Click(object sender, EventArgs e)
|
|
{
|
|
var service = Program.ServiceProvider?.GetService(typeof(FormCreateTrucking));
|
|
|
|
if (service is FormCreateTrucking form)
|
|
{
|
|
form.ShowDialog();
|
|
LoadData();
|
|
}
|
|
}
|
|
|
|
private void TransportToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
var service = Program.ServiceProvider?.GetService(typeof(FormTransport));
|
|
|
|
if (service is FormTransport form)
|
|
{
|
|
form.ShowDialog();
|
|
LoadData();
|
|
}
|
|
}
|
|
|
|
private void CargoToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
var service = Program.ServiceProvider?.GetService(typeof(FormCargo));
|
|
|
|
if (service is FormCargo form)
|
|
{
|
|
form.ShowDialog();
|
|
LoadData();
|
|
}
|
|
}
|
|
|
|
private void ClientToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
var service = Program.ServiceProvider?.GetService(typeof(FormClients));
|
|
|
|
if (service is FormClients form)
|
|
{
|
|
form.ShowDialog();
|
|
LoadData();
|
|
}
|
|
}
|
|
|
|
private void TypeTransportationToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
var service = Program.ServiceProvider?.GetService(typeof(FormTypeTransportation));
|
|
|
|
if (service is FormTypeTransportation form)
|
|
{
|
|
form.ShowDialog();
|
|
LoadData();
|
|
}
|
|
}
|
|
|
|
private void GenerationClientsToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
var service = Program.ServiceProvider?.GetService(typeof(FormRandomCreateClient));
|
|
|
|
if (service is FormRandomCreateClient form)
|
|
{
|
|
form.ShowDialog();
|
|
LoadData();
|
|
}
|
|
}
|
|
|
|
private void GenerationTruckingsToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
var service = Program.ServiceProvider?.GetService(typeof(FormRandomCreateTrucking));
|
|
|
|
if (service is FormRandomCreateTrucking form)
|
|
{
|
|
form.ShowDialog();
|
|
LoadData();
|
|
}
|
|
}
|
|
|
|
private void ButtonUpdate_Click(object sender, EventArgs e)
|
|
{
|
|
LoadData();
|
|
}
|
|
}
|
|
} |