diff --git a/FuelAndLubricants/FuelAndLubricants/FormFuelAndLubricants.Designer.cs b/FuelAndLubricants/FuelAndLubricants/FormFuelAndLubricants.Designer.cs index 95ed9e6..2e506cc 100644 --- a/FuelAndLubricants/FuelAndLubricants/FormFuelAndLubricants.Designer.cs +++ b/FuelAndLubricants/FuelAndLubricants/FormFuelAndLubricants.Designer.cs @@ -30,14 +30,14 @@ { menuStrip = new MenuStrip(); справочникиToolStripMenuItem = new ToolStripMenuItem(); + CarsToolStripMenuItem = new ToolStripMenuItem(); + DriversToolStripMenuItem = new ToolStripMenuItem(); + FuelToolStripMenuItem = new ToolStripMenuItem(); + RoutesToolStripMenuItem = new ToolStripMenuItem(); операцииToolStripMenuItem = new ToolStripMenuItem(); + RefillToolStripMenuItem = new ToolStripMenuItem(); + TripToolStripMenuItem = new ToolStripMenuItem(); отчетыToolStripMenuItem = new ToolStripMenuItem(); - машиныToolStripMenuItem = new ToolStripMenuItem(); - водителиToolStripMenuItem = new ToolStripMenuItem(); - топливоToolStripMenuItem = new ToolStripMenuItem(); - маршрутыToolStripMenuItem = new ToolStripMenuItem(); - заправкаToolStripMenuItem = new ToolStripMenuItem(); - поездкаToolStripMenuItem = new ToolStripMenuItem(); menuStrip.SuspendLayout(); SuspendLayout(); // @@ -52,60 +52,66 @@ // // справочникиToolStripMenuItem // - справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { машиныToolStripMenuItem, водителиToolStripMenuItem, топливоToolStripMenuItem, маршрутыToolStripMenuItem }); + справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { CarsToolStripMenuItem, DriversToolStripMenuItem, FuelToolStripMenuItem, RoutesToolStripMenuItem }); справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem"; справочникиToolStripMenuItem.Size = new Size(94, 20); справочникиToolStripMenuItem.Text = "Справочники"; // + // CarsToolStripMenuItem + // + CarsToolStripMenuItem.Name = "CarsToolStripMenuItem"; + CarsToolStripMenuItem.Size = new Size(180, 22); + CarsToolStripMenuItem.Text = "Машины"; + CarsToolStripMenuItem.Click += CarsToolStripMenuItem_Click; + // + // DriversToolStripMenuItem + // + DriversToolStripMenuItem.Name = "DriversToolStripMenuItem"; + DriversToolStripMenuItem.Size = new Size(180, 22); + DriversToolStripMenuItem.Text = "Водители"; + DriversToolStripMenuItem.Click += DriversToolStripMenuItem_Click; + // + // FuelToolStripMenuItem + // + FuelToolStripMenuItem.Name = "FuelToolStripMenuItem"; + FuelToolStripMenuItem.Size = new Size(180, 22); + FuelToolStripMenuItem.Text = "Топливо"; + FuelToolStripMenuItem.Click += FuelToolStripMenuItem_Click; + // + // RoutesToolStripMenuItem + // + RoutesToolStripMenuItem.Name = "RoutesToolStripMenuItem"; + RoutesToolStripMenuItem.Size = new Size(180, 22); + RoutesToolStripMenuItem.Text = "Маршруты"; + RoutesToolStripMenuItem.Click += RoutesToolStripMenuItem_Click; + // // операцииToolStripMenuItem // - операцииToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { заправкаToolStripMenuItem, поездкаToolStripMenuItem }); + операцииToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { RefillToolStripMenuItem, TripToolStripMenuItem }); операцииToolStripMenuItem.Name = "операцииToolStripMenuItem"; операцииToolStripMenuItem.Size = new Size(75, 20); операцииToolStripMenuItem.Text = "Операции"; // + // RefillToolStripMenuItem + // + RefillToolStripMenuItem.Name = "RefillToolStripMenuItem"; + RefillToolStripMenuItem.Size = new Size(180, 22); + RefillToolStripMenuItem.Text = "Заправка"; + RefillToolStripMenuItem.Click += RefillToolStripMenuItem_Click; + // + // TripToolStripMenuItem + // + TripToolStripMenuItem.Name = "TripToolStripMenuItem"; + TripToolStripMenuItem.Size = new Size(180, 22); + TripToolStripMenuItem.Text = "Поездка"; + TripToolStripMenuItem.Click += TripToolStripMenuItem_Click; + // // отчетыToolStripMenuItem // отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem"; отчетыToolStripMenuItem.Size = new Size(60, 20); отчетыToolStripMenuItem.Text = "Отчеты"; // - // машиныToolStripMenuItem - // - машиныToolStripMenuItem.Name = "машиныToolStripMenuItem"; - машиныToolStripMenuItem.Size = new Size(180, 22); - машиныToolStripMenuItem.Text = "Машины"; - // - // водителиToolStripMenuItem - // - водителиToolStripMenuItem.Name = "водителиToolStripMenuItem"; - водителиToolStripMenuItem.Size = new Size(180, 22); - водителиToolStripMenuItem.Text = "Водители"; - // - // топливоToolStripMenuItem - // - топливоToolStripMenuItem.Name = "топливоToolStripMenuItem"; - топливоToolStripMenuItem.Size = new Size(180, 22); - топливоToolStripMenuItem.Text = "Топливо"; - // - // маршрутыToolStripMenuItem - // - маршрутыToolStripMenuItem.Name = "маршрутыToolStripMenuItem"; - маршрутыToolStripMenuItem.Size = new Size(180, 22); - маршрутыToolStripMenuItem.Text = "Маршруты"; - // - // заправкаToolStripMenuItem - // - заправкаToolStripMenuItem.Name = "заправкаToolStripMenuItem"; - заправкаToolStripMenuItem.Size = new Size(180, 22); - заправкаToolStripMenuItem.Text = "Заправка"; - // - // поездкаToolStripMenuItem - // - поездкаToolStripMenuItem.Name = "поездкаToolStripMenuItem"; - поездкаToolStripMenuItem.Size = new Size(180, 22); - поездкаToolStripMenuItem.Text = "Поездка"; - // // FormFuelAndLubricants // AutoScaleDimensions = new SizeF(7F, 15F); @@ -128,13 +134,13 @@ private MenuStrip menuStrip; private ToolStripMenuItem справочникиToolStripMenuItem; - private ToolStripMenuItem машиныToolStripMenuItem; - private ToolStripMenuItem водителиToolStripMenuItem; - private ToolStripMenuItem топливоToolStripMenuItem; - private ToolStripMenuItem маршрутыToolStripMenuItem; + private ToolStripMenuItem CarsToolStripMenuItem; + private ToolStripMenuItem DriversToolStripMenuItem; + private ToolStripMenuItem FuelToolStripMenuItem; + private ToolStripMenuItem RoutesToolStripMenuItem; private ToolStripMenuItem операцииToolStripMenuItem; - private ToolStripMenuItem заправкаToolStripMenuItem; - private ToolStripMenuItem поездкаToolStripMenuItem; + private ToolStripMenuItem RefillToolStripMenuItem; + private ToolStripMenuItem TripToolStripMenuItem; private ToolStripMenuItem отчетыToolStripMenuItem; } } diff --git a/FuelAndLubricants/FuelAndLubricants/FormFuelAndLubricants.cs b/FuelAndLubricants/FuelAndLubricants/FormFuelAndLubricants.cs index 584f691..5ec2c97 100644 --- a/FuelAndLubricants/FuelAndLubricants/FormFuelAndLubricants.cs +++ b/FuelAndLubricants/FuelAndLubricants/FormFuelAndLubricants.cs @@ -1,10 +1,102 @@ +using FuelAndLubricants.Forms; +using Unity; + namespace FuelAndLubricants { public partial class FormFuelAndLubricants : Form { - public FormFuelAndLubricants() + private readonly IUnityContainer _container; + + public FormFuelAndLubricants(IUnityContainer container) { InitializeComponent(); + _container = container ?? + throw new ArgumentNullException(nameof(container)); + + } + + private void CarsToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + } + + private void DriversToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + } + + private void FuelToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + } + + private void RoutesToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + } + + private void RefillToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + } + + private void TripToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } } } diff --git a/FuelAndLubricants/FuelAndLubricants/Program.cs b/FuelAndLubricants/FuelAndLubricants/Program.cs index 3f63e1b..5ab9ffd 100644 --- a/FuelAndLubricants/FuelAndLubricants/Program.cs +++ b/FuelAndLubricants/FuelAndLubricants/Program.cs @@ -22,7 +22,7 @@ namespace FuelAndLubricants { var container = new UnityContainer(); - container.RegisterType(); + container.RegisterType(); container.RegisterType(); container.RegisterType(); container.RegisterType(); diff --git a/FuelAndLubricants/FuelAndLubricants/Repositories/Implementations/CarRepository.cs b/FuelAndLubricants/FuelAndLubricants/Repositories/Implementations/CarRepository.cs index e780ce9..5759289 100644 --- a/FuelAndLubricants/FuelAndLubricants/Repositories/Implementations/CarRepository.cs +++ b/FuelAndLubricants/FuelAndLubricants/Repositories/Implementations/CarRepository.cs @@ -2,7 +2,7 @@ namespace FuelAndLubricants.Repositories.Implementations; -public class CarRepository : IRouteRepository +public class CarRepository : ICarRepository { public void CreateCar(Car car) { diff --git a/FuelAndLubricants/FuelAndLubricants/Repositories/Implementations/FuelRepository.cs b/FuelAndLubricants/FuelAndLubricants/Repositories/Implementations/FuelRepository.cs index d2ad30b..54b793b 100644 --- a/FuelAndLubricants/FuelAndLubricants/Repositories/Implementations/FuelRepository.cs +++ b/FuelAndLubricants/FuelAndLubricants/Repositories/Implementations/FuelRepository.cs @@ -4,7 +4,7 @@ namespace FuelAndLubricants.Repositories.Implementations; public class FuelRepository : IFuelRepository { - public void CreateDriver(Fuel_And_Lubricants fuel) + public void CreateFuel(Fuel_And_Lubricants fuel) { }