62 lines
1.7 KiB
C#
62 lines
1.7 KiB
C#
using ProjectGarage.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;
|
|
|
|
namespace ProjectGarage.Forms
|
|
{
|
|
public partial class FormTruck : Form
|
|
{
|
|
|
|
private readonly ITruckRepository _truckRepository;
|
|
private int? _truckId;
|
|
public int Id
|
|
{
|
|
set
|
|
{
|
|
try
|
|
{
|
|
var truck = _truckRepository.ReadTruckByID(value);
|
|
if (truck == null)
|
|
{
|
|
throw new InvalidDataException(nameof(truck));
|
|
}
|
|
|
|
textBoxTruckNumbers.Text = truck.Numbers;
|
|
textBoxTruckBrand.Text = truck.Brand;
|
|
textBoxTruckModel.Text = truck.Model;
|
|
numericUpDownMaxFuel.Value = truck.MaxFuel;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|
|
public FormTruck(ITruckRepository truckRepository)
|
|
{
|
|
InitializeComponent();
|
|
_truckRepository = truckRepository ??
|
|
throw new ArgumentNullException(nameof(truckRepository));
|
|
}
|
|
|
|
private void buttonTruckSave_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void buttonTruckCancel_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
}
|
|
}
|