Compare commits
11 Commits
Author | SHA1 | Date | |
---|---|---|---|
2ef7829897 | |||
d243c03fc8 | |||
bd528d9f0d | |||
6030309361 | |||
0942dd8be3 | |||
7277ac5564 | |||
8435ad487f | |||
ad64ab16c4 | |||
6694e9c4a7 | |||
613ffd491f | |||
f0f3d6dc0e |
30
ProjectGarage/Entities/Driver.cs
Normal file
@ -0,0 +1,30 @@
|
||||
using ProjectGarage.Entities.Enums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectGarage.Entities;
|
||||
|
||||
public class Driver
|
||||
{
|
||||
public int Id { get;private set; }
|
||||
|
||||
public string Fname { get;private set; } = string.Empty;
|
||||
|
||||
public string Lname { get;private set; } = string.Empty;
|
||||
|
||||
public int TruckId { get;private set; }
|
||||
|
||||
public static Driver CreateDriver(int id, string fname, string lname, int truckid)
|
||||
{
|
||||
return new Driver
|
||||
{
|
||||
Id = id,
|
||||
Fname = fname,
|
||||
Lname = lname,
|
||||
TruckId = truckid
|
||||
};
|
||||
}
|
||||
}
|
19
ProjectGarage/Entities/Enums/FuelType.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectGarage.Entities.Enums;
|
||||
|
||||
[Flags]
|
||||
public enum FuelType
|
||||
{
|
||||
None = 0,
|
||||
Petrol_92 = 1,
|
||||
Petrol_95 = 2,
|
||||
Petrol_98 = 4,
|
||||
Petrol_100 = 8,
|
||||
Diesel_Summer = 16,
|
||||
Diesel_Winter = 32
|
||||
}
|
19
ProjectGarage/Entities/Enums/TruckType.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectGarage.Entities.Enums
|
||||
{
|
||||
public enum TruckType
|
||||
{
|
||||
None = 0,
|
||||
Mercedes = 1,
|
||||
SCANIA = 2,
|
||||
KAMAZ = 3,
|
||||
MAN = 4,
|
||||
Volvo = 5,
|
||||
SITRAC = 6
|
||||
}
|
||||
}
|
31
ProjectGarage/Entities/Fuel.cs
Normal file
@ -0,0 +1,31 @@
|
||||
using ProjectGarage.Entities.Enums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection.Metadata.Ecma335;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectGarage.Entities;
|
||||
|
||||
public class Fuel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public string FuelName { get; set; } = string.Empty;
|
||||
|
||||
public FuelType FuelType { get; set; }
|
||||
|
||||
public int Price { get; set; }
|
||||
|
||||
public static Fuel CreateFuel(int id, string name, FuelType type, int price)
|
||||
{
|
||||
return new Fuel
|
||||
{
|
||||
Id = id,
|
||||
FuelName = name,
|
||||
FuelType = type,
|
||||
Price = price
|
||||
};
|
||||
}
|
||||
}
|
23
ProjectGarage/Entities/FuelFuelReplenishment.cs
Normal file
@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectGarage.Entities;
|
||||
|
||||
public class FuelFuelReplenishment
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public int FuelId { get; private set; }
|
||||
public int Amount { get; private set; }
|
||||
public static FuelFuelReplenishment CreateElement(int id, int fuelId, int amount)
|
||||
{
|
||||
return new FuelFuelReplenishment
|
||||
{
|
||||
Id = id,
|
||||
FuelId = fuelId,
|
||||
Amount = amount
|
||||
};
|
||||
}
|
||||
}
|
26
ProjectGarage/Entities/FuelReplenishment.cs
Normal file
@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectGarage.Entities;
|
||||
|
||||
public class FuelReplenishment
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public int DriverId { get; private set; }
|
||||
public DateTime ReplenishmentDate { get; private set; }
|
||||
public IEnumerable<FuelFuelReplenishment> FuelFuelReplenishments { get; private set;} = [];
|
||||
|
||||
public static FuelReplenishment CreateOpeartion(int id, int driverId, IEnumerable<FuelFuelReplenishment> fuelFuelReplenishments)
|
||||
{
|
||||
return new FuelReplenishment
|
||||
{
|
||||
Id = id,
|
||||
DriverId = driverId,
|
||||
ReplenishmentDate = DateTime.Now,
|
||||
FuelFuelReplenishments = fuelFuelReplenishments
|
||||
};
|
||||
}
|
||||
}
|
31
ProjectGarage/Entities/Route.cs
Normal file
@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectGarage.Entities;
|
||||
|
||||
public class Route
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public string RouteName { get; set; } = string.Empty;
|
||||
|
||||
public string StartP { get; set; } = string.Empty;
|
||||
|
||||
public string FinalP { get; set; } = string.Empty;
|
||||
|
||||
public int Length { get; set; }
|
||||
|
||||
public static Route CreateRoute(int id,string name, string startp, string finalp, int len)
|
||||
{
|
||||
return new Route() {
|
||||
Id = id,
|
||||
RouteName = name,
|
||||
StartP = startp,
|
||||
FinalP = finalp,
|
||||
Length = len
|
||||
};
|
||||
}
|
||||
}
|
35
ProjectGarage/Entities/Transportation.cs
Normal file
@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectGarage.Entities;
|
||||
|
||||
public class Transportation
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public int FuelId { get; set; }
|
||||
|
||||
public int RouteId { get; set; }
|
||||
|
||||
public int DriverId { get; set; }
|
||||
|
||||
public int Amount { get; set; }
|
||||
|
||||
public DateTime TransportationDate { get; set; }
|
||||
|
||||
public static Transportation CreateTransportation(int id, int fuel_id, int route_id, int driver_id, int amount)
|
||||
{
|
||||
return new Transportation
|
||||
{
|
||||
Id = id,
|
||||
FuelId = fuel_id,
|
||||
RouteId = route_id,
|
||||
DriverId = driver_id,
|
||||
Amount = amount,
|
||||
TransportationDate = DateTime.Now
|
||||
};
|
||||
}
|
||||
}
|
30
ProjectGarage/Entities/Truck.cs
Normal file
@ -0,0 +1,30 @@
|
||||
using ProjectGarage.Entities.Enums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectGarage.Entities;
|
||||
|
||||
public class Truck
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
|
||||
public string Numbers { get; private set; } = string.Empty;
|
||||
|
||||
public TruckType Truck_Type { get; set; }
|
||||
|
||||
public int MaxFuel { get; private set; }
|
||||
|
||||
public static Truck CreateTruck(int id,string numbers, TruckType type, int maxFuel)
|
||||
{
|
||||
return new Truck()
|
||||
{
|
||||
Id = id,
|
||||
Numbers = numbers,
|
||||
Truck_Type = type,
|
||||
MaxFuel = maxFuel
|
||||
};
|
||||
}
|
||||
}
|
39
ProjectGarage/Form1.Designer.cs
generated
@ -1,39 +0,0 @@
|
||||
namespace ProjectGarage
|
||||
{
|
||||
partial class Form1
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||
this.Text = "Form1";
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
namespace ProjectGarage
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
public Form1()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
147
ProjectGarage/FormGarage.Designer.cs
generated
Normal file
@ -0,0 +1,147 @@
|
||||
namespace ProjectGarage
|
||||
{
|
||||
partial class FormGarage
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormGarage));
|
||||
menuStripGarage = new MenuStrip();
|
||||
справочникиToolStripMenuItem = new ToolStripMenuItem();
|
||||
водителиToolStripMenuItem = new ToolStripMenuItem();
|
||||
фурыToolStripMenuItem = new ToolStripMenuItem();
|
||||
маршрутыToolStripMenuItem = new ToolStripMenuItem();
|
||||
топливоToolStripMenuItem = new ToolStripMenuItem();
|
||||
операцииToolStripMenuItem = new ToolStripMenuItem();
|
||||
отправкаТопливаToolStripMenuItem = new ToolStripMenuItem();
|
||||
получениеТопливаToolStripMenuItem = new ToolStripMenuItem();
|
||||
отчетыToolStripMenuItem = new ToolStripMenuItem();
|
||||
menuStripGarage.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// menuStripGarage
|
||||
//
|
||||
menuStripGarage.ImageScalingSize = new Size(20, 20);
|
||||
menuStripGarage.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, операцииToolStripMenuItem, отчетыToolStripMenuItem });
|
||||
menuStripGarage.Location = new Point(0, 0);
|
||||
menuStripGarage.Name = "menuStripGarage";
|
||||
menuStripGarage.Size = new Size(612, 28);
|
||||
menuStripGarage.TabIndex = 0;
|
||||
menuStripGarage.Text = "menuStrip1";
|
||||
//
|
||||
// справочникиToolStripMenuItem
|
||||
//
|
||||
справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { водителиToolStripMenuItem, фурыToolStripMenuItem, маршрутыToolStripMenuItem, топливоToolStripMenuItem });
|
||||
справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
|
||||
справочникиToolStripMenuItem.Size = new Size(117, 24);
|
||||
справочникиToolStripMenuItem.Text = "Справочники";
|
||||
//
|
||||
// водителиToolStripMenuItem
|
||||
//
|
||||
водителиToolStripMenuItem.Name = "водителиToolStripMenuItem";
|
||||
водителиToolStripMenuItem.Size = new Size(224, 26);
|
||||
водителиToolStripMenuItem.Text = "Водители";
|
||||
водителиToolStripMenuItem.Click += DriversToolStripMenuItem_Click;
|
||||
//
|
||||
// фурыToolStripMenuItem
|
||||
//
|
||||
фурыToolStripMenuItem.Name = "фурыToolStripMenuItem";
|
||||
фурыToolStripMenuItem.Size = new Size(224, 26);
|
||||
фурыToolStripMenuItem.Text = "Фуры";
|
||||
фурыToolStripMenuItem.Click += TrucksToolStripMenuItem_Click;
|
||||
//
|
||||
// маршрутыToolStripMenuItem
|
||||
//
|
||||
маршрутыToolStripMenuItem.Name = "маршрутыToolStripMenuItem";
|
||||
маршрутыToolStripMenuItem.Size = new Size(224, 26);
|
||||
маршрутыToolStripMenuItem.Text = "Маршруты";
|
||||
маршрутыToolStripMenuItem.Click += RoutesToolStripMenuItem_Click;
|
||||
//
|
||||
// топливоToolStripMenuItem
|
||||
//
|
||||
топливоToolStripMenuItem.Name = "топливоToolStripMenuItem";
|
||||
топливоToolStripMenuItem.Size = new Size(224, 26);
|
||||
топливоToolStripMenuItem.Text = "Топливо";
|
||||
топливоToolStripMenuItem.Click += FuelsToolStripMenuItem_Click;
|
||||
//
|
||||
// операцииToolStripMenuItem
|
||||
//
|
||||
операцииToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { отправкаТопливаToolStripMenuItem, получениеТопливаToolStripMenuItem });
|
||||
операцииToolStripMenuItem.Name = "операцииToolStripMenuItem";
|
||||
операцииToolStripMenuItem.Size = new Size(95, 24);
|
||||
операцииToolStripMenuItem.Text = "Операции";
|
||||
//
|
||||
// отправкаТопливаToolStripMenuItem
|
||||
//
|
||||
отправкаТопливаToolStripMenuItem.Name = "отправкаТопливаToolStripMenuItem";
|
||||
отправкаТопливаToolStripMenuItem.Size = new Size(230, 26);
|
||||
отправкаТопливаToolStripMenuItem.Text = "Отправка топлива";
|
||||
отправкаТопливаToolStripMenuItem.Click += TransportationToolStripMenuItem_Click;
|
||||
//
|
||||
// получениеТопливаToolStripMenuItem
|
||||
//
|
||||
получениеТопливаToolStripMenuItem.Name = "получениеТопливаToolStripMenuItem";
|
||||
получениеТопливаToolStripMenuItem.Size = new Size(230, 26);
|
||||
получениеТопливаToolStripMenuItem.Text = "Получение топлива";
|
||||
получениеТопливаToolStripMenuItem.Click += ReplenishmentToolStripMenuItem_Click;
|
||||
//
|
||||
// отчетыToolStripMenuItem
|
||||
//
|
||||
отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem";
|
||||
отчетыToolStripMenuItem.Size = new Size(73, 24);
|
||||
отчетыToolStripMenuItem.Text = "Отчеты";
|
||||
//
|
||||
// FormGarage
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
BackgroundImage = (Image)resources.GetObject("$this.BackgroundImage");
|
||||
BackgroundImageLayout = ImageLayout.Stretch;
|
||||
ClientSize = new Size(612, 399);
|
||||
Controls.Add(menuStripGarage);
|
||||
Name = "FormGarage";
|
||||
StartPosition = FormStartPosition.CenterScreen;
|
||||
Text = "Гараж";
|
||||
menuStripGarage.ResumeLayout(false);
|
||||
menuStripGarage.PerformLayout();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private MenuStrip menuStripGarage;
|
||||
private ToolStripMenuItem справочникиToolStripMenuItem;
|
||||
private ToolStripMenuItem водителиToolStripMenuItem;
|
||||
private ToolStripMenuItem фурыToolStripMenuItem;
|
||||
private ToolStripMenuItem маршрутыToolStripMenuItem;
|
||||
private ToolStripMenuItem топливоToolStripMenuItem;
|
||||
private ToolStripMenuItem операцииToolStripMenuItem;
|
||||
private ToolStripMenuItem отправкаТопливаToolStripMenuItem;
|
||||
private ToolStripMenuItem получениеТопливаToolStripMenuItem;
|
||||
private ToolStripMenuItem отчетыToolStripMenuItem;
|
||||
}
|
||||
}
|
95
ProjectGarage/FormGarage.cs
Normal file
@ -0,0 +1,95 @@
|
||||
using ProjectGarage.Forms;
|
||||
using System.ComponentModel;
|
||||
using Unity;
|
||||
|
||||
namespace ProjectGarage
|
||||
{
|
||||
public partial class FormGarage : Form
|
||||
{
|
||||
private readonly IUnityContainer _container;
|
||||
|
||||
public FormGarage(IUnityContainer container)
|
||||
{
|
||||
InitializeComponent();
|
||||
_container = container ?? throw new ArgumentNullException(nameof(container));
|
||||
}
|
||||
|
||||
private void DriversToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
_container.Resolve<FormDrivers>().ShowDialog();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void TrucksToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
_container.Resolve<FormTrucks>().ShowDialog();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void RoutesToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
_container.Resolve<FormRoutes>().ShowDialog();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void FuelsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
_container.Resolve<FormFuels>().ShowDialog();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void TransportationToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
_container.Resolve<FormTransportations>().ShowDialog();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ReplenishmentToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
_container.Resolve<FormReplenishments>().ShowDialog();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
1175
ProjectGarage/FormGarage.resx
Normal file
142
ProjectGarage/Forms/FormDriver.Designer.cs
generated
Normal file
@ -0,0 +1,142 @@
|
||||
namespace ProjectGarage.Forms
|
||||
{
|
||||
partial class FormDriver
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
labelFirstName = new Label();
|
||||
textBoxFirstName = new TextBox();
|
||||
textBoxLastName = new TextBox();
|
||||
labelLastName = new Label();
|
||||
labelTruckID = new Label();
|
||||
buttonSaveDriver = new Button();
|
||||
buttonCancelDriver = new Button();
|
||||
comboBoxTruckID = new ComboBox();
|
||||
SuspendLayout();
|
||||
//
|
||||
// labelFirstName
|
||||
//
|
||||
labelFirstName.AutoSize = true;
|
||||
labelFirstName.Location = new Point(34, 24);
|
||||
labelFirstName.Name = "labelFirstName";
|
||||
labelFirstName.Size = new Size(39, 20);
|
||||
labelFirstName.TabIndex = 0;
|
||||
labelFirstName.Text = "Имя";
|
||||
//
|
||||
// textBoxFirstName
|
||||
//
|
||||
textBoxFirstName.Location = new Point(120, 24);
|
||||
textBoxFirstName.Name = "textBoxFirstName";
|
||||
textBoxFirstName.Size = new Size(183, 27);
|
||||
textBoxFirstName.TabIndex = 1;
|
||||
//
|
||||
// textBoxLastName
|
||||
//
|
||||
textBoxLastName.Location = new Point(120, 70);
|
||||
textBoxLastName.Name = "textBoxLastName";
|
||||
textBoxLastName.Size = new Size(183, 27);
|
||||
textBoxLastName.TabIndex = 3;
|
||||
//
|
||||
// labelLastName
|
||||
//
|
||||
labelLastName.AutoSize = true;
|
||||
labelLastName.Location = new Point(20, 73);
|
||||
labelLastName.Name = "labelLastName";
|
||||
labelLastName.Size = new Size(73, 20);
|
||||
labelLastName.TabIndex = 2;
|
||||
labelLastName.Text = "Фамилия";
|
||||
//
|
||||
// labelTruckID
|
||||
//
|
||||
labelTruckID.AutoSize = true;
|
||||
labelTruckID.Location = new Point(34, 121);
|
||||
labelTruckID.Name = "labelTruckID";
|
||||
labelTruckID.Size = new Size(44, 20);
|
||||
labelTruckID.TabIndex = 6;
|
||||
labelTruckID.Text = "Фура";
|
||||
//
|
||||
// buttonSaveDriver
|
||||
//
|
||||
buttonSaveDriver.Location = new Point(20, 158);
|
||||
buttonSaveDriver.Name = "buttonSaveDriver";
|
||||
buttonSaveDriver.Size = new Size(128, 39);
|
||||
buttonSaveDriver.TabIndex = 8;
|
||||
buttonSaveDriver.Text = "Сохранить";
|
||||
buttonSaveDriver.UseVisualStyleBackColor = true;
|
||||
buttonSaveDriver.Click += ButtonSaveDriver_Click;
|
||||
//
|
||||
// buttonCancelDriver
|
||||
//
|
||||
buttonCancelDriver.Location = new Point(175, 158);
|
||||
buttonCancelDriver.Name = "buttonCancelDriver";
|
||||
buttonCancelDriver.Size = new Size(128, 39);
|
||||
buttonCancelDriver.TabIndex = 9;
|
||||
buttonCancelDriver.Text = "Отмена";
|
||||
buttonCancelDriver.UseVisualStyleBackColor = true;
|
||||
buttonCancelDriver.Click += ButtonCancelDriver_Click;
|
||||
//
|
||||
// comboBoxTruckID
|
||||
//
|
||||
comboBoxTruckID.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboBoxTruckID.FormattingEnabled = true;
|
||||
comboBoxTruckID.Location = new Point(120, 113);
|
||||
comboBoxTruckID.Name = "comboBoxTruckID";
|
||||
comboBoxTruckID.Size = new Size(183, 28);
|
||||
comboBoxTruckID.TabIndex = 10;
|
||||
//
|
||||
// FormDriver
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(333, 218);
|
||||
Controls.Add(comboBoxTruckID);
|
||||
Controls.Add(buttonCancelDriver);
|
||||
Controls.Add(buttonSaveDriver);
|
||||
Controls.Add(labelTruckID);
|
||||
Controls.Add(textBoxLastName);
|
||||
Controls.Add(labelLastName);
|
||||
Controls.Add(textBoxFirstName);
|
||||
Controls.Add(labelFirstName);
|
||||
Name = "FormDriver";
|
||||
StartPosition = FormStartPosition.CenterParent;
|
||||
Text = "Водитель";
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Label labelFirstName;
|
||||
private TextBox textBoxFirstName;
|
||||
private TextBox textBoxLastName;
|
||||
private Label labelLastName;
|
||||
private Label labelTruckID;
|
||||
private Button buttonSaveDriver;
|
||||
private Button buttonCancelDriver;
|
||||
private ComboBox comboBoxTruckID;
|
||||
}
|
||||
}
|
87
ProjectGarage/Forms/FormDriver.cs
Normal file
@ -0,0 +1,87 @@
|
||||
using ProjectGarage.Entities;
|
||||
using ProjectGarage.Entities.Enums;
|
||||
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 FormDriver : Form
|
||||
{
|
||||
private readonly IDriverRepository _driverRepository;
|
||||
|
||||
private int? _driverId;
|
||||
|
||||
public int Id
|
||||
{
|
||||
set
|
||||
{
|
||||
try
|
||||
{
|
||||
var driver = _driverRepository.ReadDriverByID(value);
|
||||
if (driver == null)
|
||||
{
|
||||
throw new
|
||||
InvalidDataException(nameof(driver));
|
||||
}
|
||||
textBoxFirstName.Text = driver.Fname;
|
||||
textBoxLastName.Text = driver.Lname;
|
||||
comboBoxTruckID.SelectedItem = driver.TruckId;
|
||||
_driverId = value;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public FormDriver(IDriverRepository driverRepository, ITruckRepository truckRepository)
|
||||
{
|
||||
InitializeComponent();
|
||||
_driverRepository = driverRepository ?? throw new ArgumentNullException(nameof(driverRepository));
|
||||
comboBoxTruckID.DataSource = truckRepository.ReadTrucks();
|
||||
comboBoxTruckID.DisplayMember = "Numbers";
|
||||
comboBoxTruckID.ValueMember = "Id";
|
||||
}
|
||||
|
||||
private void ButtonSaveDriver_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(textBoxFirstName.Text) || string.IsNullOrWhiteSpace(textBoxLastName.Text)
|
||||
|| comboBoxTruckID.SelectedIndex < 0)
|
||||
{
|
||||
throw new Exception("Имеются незаполненные поля");
|
||||
}
|
||||
if (_driverId.HasValue)
|
||||
{
|
||||
_driverRepository.UpdateDriver(CreateDriver(_driverId.Value));
|
||||
}
|
||||
else
|
||||
{
|
||||
_driverRepository.CreateDriver(CreateDriver(0));
|
||||
}
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при сохранении",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonCancelDriver_Click(object sender, EventArgs e) => Close();
|
||||
|
||||
private Driver CreateDriver(int id) => Driver.CreateDriver(id, textBoxFirstName.Text,
|
||||
textBoxLastName.Text, (int)comboBoxTruckID.SelectedIndex);
|
||||
}
|
||||
}
|
126
ProjectGarage/Forms/FormDrivers.Designer.cs
generated
Normal file
@ -0,0 +1,126 @@
|
||||
namespace ProjectGarage.Forms
|
||||
{
|
||||
partial class FormDrivers
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
dataGridViewDrivers = new DataGridView();
|
||||
panelFormDriversButtons = new Panel();
|
||||
buttonUpdateDriver = new Button();
|
||||
buttonDeleteDriver = new Button();
|
||||
buttonAddDriver = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridViewDrivers).BeginInit();
|
||||
panelFormDriversButtons.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// dataGridViewDrivers
|
||||
//
|
||||
dataGridViewDrivers.AllowUserToAddRows = false;
|
||||
dataGridViewDrivers.AllowUserToDeleteRows = false;
|
||||
dataGridViewDrivers.AllowUserToResizeColumns = false;
|
||||
dataGridViewDrivers.AllowUserToResizeRows = false;
|
||||
dataGridViewDrivers.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||
dataGridViewDrivers.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridViewDrivers.Dock = DockStyle.Fill;
|
||||
dataGridViewDrivers.Location = new Point(0, 0);
|
||||
dataGridViewDrivers.Name = "dataGridViewDrivers";
|
||||
dataGridViewDrivers.ReadOnly = true;
|
||||
dataGridViewDrivers.RowHeadersVisible = false;
|
||||
dataGridViewDrivers.RowHeadersWidth = 51;
|
||||
dataGridViewDrivers.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||
dataGridViewDrivers.Size = new Size(648, 367);
|
||||
dataGridViewDrivers.TabIndex = 3;
|
||||
//
|
||||
// panelFormDriversButtons
|
||||
//
|
||||
panelFormDriversButtons.Controls.Add(buttonUpdateDriver);
|
||||
panelFormDriversButtons.Controls.Add(buttonDeleteDriver);
|
||||
panelFormDriversButtons.Controls.Add(buttonAddDriver);
|
||||
panelFormDriversButtons.Dock = DockStyle.Right;
|
||||
panelFormDriversButtons.Location = new Point(648, 0);
|
||||
panelFormDriversButtons.Name = "panelFormDriversButtons";
|
||||
panelFormDriversButtons.Size = new Size(161, 367);
|
||||
panelFormDriversButtons.TabIndex = 2;
|
||||
//
|
||||
// buttonUpdateDriver
|
||||
//
|
||||
buttonUpdateDriver.BackgroundImage = Properties.Resources.каранд;
|
||||
buttonUpdateDriver.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
buttonUpdateDriver.Location = new Point(35, 140);
|
||||
buttonUpdateDriver.Name = "buttonUpdateDriver";
|
||||
buttonUpdateDriver.Size = new Size(94, 75);
|
||||
buttonUpdateDriver.TabIndex = 2;
|
||||
buttonUpdateDriver.UseVisualStyleBackColor = true;
|
||||
buttonUpdateDriver.Click += ButtonUpdateDriver_Click;
|
||||
//
|
||||
// buttonDeleteDriver
|
||||
//
|
||||
buttonDeleteDriver.BackgroundImage = Properties.Resources.минусик;
|
||||
buttonDeleteDriver.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
buttonDeleteDriver.Location = new Point(35, 249);
|
||||
buttonDeleteDriver.Name = "buttonDeleteDriver";
|
||||
buttonDeleteDriver.Size = new Size(94, 78);
|
||||
buttonDeleteDriver.TabIndex = 1;
|
||||
buttonDeleteDriver.UseVisualStyleBackColor = true;
|
||||
buttonDeleteDriver.Click += ButtonDeleteDriver_Click;
|
||||
//
|
||||
// buttonAddDriver
|
||||
//
|
||||
buttonAddDriver.BackgroundImage = Properties.Resources.плюсик;
|
||||
buttonAddDriver.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
buttonAddDriver.Location = new Point(35, 23);
|
||||
buttonAddDriver.Name = "buttonAddDriver";
|
||||
buttonAddDriver.Size = new Size(94, 75);
|
||||
buttonAddDriver.TabIndex = 0;
|
||||
buttonAddDriver.UseVisualStyleBackColor = true;
|
||||
buttonAddDriver.Click += ButtonAddDriver_Click;
|
||||
//
|
||||
// FormDrivers
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(809, 367);
|
||||
Controls.Add(dataGridViewDrivers);
|
||||
Controls.Add(panelFormDriversButtons);
|
||||
Name = "FormDrivers";
|
||||
Text = "FormDrivers";
|
||||
Load += FormDrivers_Load;
|
||||
Click += FormDrivers_Load;
|
||||
((System.ComponentModel.ISupportInitialize)dataGridViewDrivers).EndInit();
|
||||
panelFormDriversButtons.ResumeLayout(false);
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DataGridView dataGridViewDrivers;
|
||||
private Panel panelFormDriversButtons;
|
||||
private Button buttonUpdateDriver;
|
||||
private Button buttonDeleteDriver;
|
||||
private Button buttonAddDriver;
|
||||
}
|
||||
}
|
112
ProjectGarage/Forms/FormDrivers.cs
Normal file
@ -0,0 +1,112 @@
|
||||
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;
|
||||
using Unity;
|
||||
|
||||
namespace ProjectGarage.Forms
|
||||
{
|
||||
public partial class FormDrivers : Form
|
||||
{
|
||||
private readonly IUnityContainer _container;
|
||||
private readonly IDriverRepository _driverRepository;
|
||||
|
||||
public FormDrivers(IUnityContainer container, IDriverRepository driverRepository)
|
||||
{
|
||||
InitializeComponent();
|
||||
_container = container ?? throw new ArgumentNullException(nameof(container));
|
||||
_driverRepository = driverRepository ?? throw new ArgumentNullException(nameof(driverRepository));
|
||||
}
|
||||
private void FormDrivers_Load(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
LoadList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при загрузке",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonAddDriver_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
_container.Resolve<FormDriver>().ShowDialog();
|
||||
LoadList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при добавлении",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonUpdateDriver_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (!TryGetIdentifierFromSelectedRow(out var findId))
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
var form = _container.Resolve<FormDriver>();
|
||||
form.Id = findId;
|
||||
form.ShowDialog();
|
||||
LoadList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при изменении",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonDeleteDriver_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (!TryGetIdentifierFromSelectedRow(out var findId))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (MessageBox.Show("Удалить запись?", "Удаление",
|
||||
MessageBoxButtons.YesNo) != DialogResult.Yes)
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
_driverRepository.DeleteDriver(findId);
|
||||
LoadList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при удалении",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void LoadList() => dataGridViewDrivers.DataSource = _driverRepository.ReadDrivers();
|
||||
|
||||
private bool TryGetIdentifierFromSelectedRow(out int id)
|
||||
{
|
||||
id = 0;
|
||||
if (dataGridViewDrivers.SelectedRows.Count < 1)
|
||||
{
|
||||
MessageBox.Show("Нет выбранной записи", "Ошибка",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return false;
|
||||
}
|
||||
id = Convert.ToInt32(dataGridViewDrivers.SelectedRows[0].Cells["Id"].Value);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
120
ProjectGarage/Forms/FormDrivers.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
144
ProjectGarage/Forms/FormFuel.Designer.cs
generated
Normal file
@ -0,0 +1,144 @@
|
||||
namespace ProjectGarage.Forms
|
||||
{
|
||||
partial class FormFuel
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
checkedListBoxFuel = new CheckedListBox();
|
||||
labelFuelType = new Label();
|
||||
labelFuelName = new Label();
|
||||
textBoxFuelName = new TextBox();
|
||||
numericUpDownFuelPrice = new NumericUpDown();
|
||||
labelFuelPrice = new Label();
|
||||
buttonFuelSave = new Button();
|
||||
buttonFuelCancel = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownFuelPrice).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// checkedListBoxFuel
|
||||
//
|
||||
checkedListBoxFuel.FormattingEnabled = true;
|
||||
checkedListBoxFuel.Location = new Point(121, 12);
|
||||
checkedListBoxFuel.Name = "checkedListBoxFuel";
|
||||
checkedListBoxFuel.Size = new Size(150, 114);
|
||||
checkedListBoxFuel.TabIndex = 0;
|
||||
//
|
||||
// labelFuelType
|
||||
//
|
||||
labelFuelType.AutoSize = true;
|
||||
labelFuelType.Location = new Point(12, 12);
|
||||
labelFuelType.Name = "labelFuelType";
|
||||
labelFuelType.Size = new Size(96, 20);
|
||||
labelFuelType.TabIndex = 1;
|
||||
labelFuelType.Text = "Тип топлива";
|
||||
//
|
||||
// labelFuelName
|
||||
//
|
||||
labelFuelName.AutoSize = true;
|
||||
labelFuelName.Location = new Point(21, 138);
|
||||
labelFuelName.Name = "labelFuelName";
|
||||
labelFuelName.Size = new Size(77, 20);
|
||||
labelFuelName.TabIndex = 2;
|
||||
labelFuelName.Text = "Название";
|
||||
//
|
||||
// textBoxFuelName
|
||||
//
|
||||
textBoxFuelName.Location = new Point(121, 138);
|
||||
textBoxFuelName.Name = "textBoxFuelName";
|
||||
textBoxFuelName.Size = new Size(150, 27);
|
||||
textBoxFuelName.TabIndex = 3;
|
||||
//
|
||||
// numericUpDownFuelPrice
|
||||
//
|
||||
numericUpDownFuelPrice.Location = new Point(121, 180);
|
||||
numericUpDownFuelPrice.Minimum = new decimal(new int[] { 1, 0, 0, 0 });
|
||||
numericUpDownFuelPrice.Name = "numericUpDownFuelPrice";
|
||||
numericUpDownFuelPrice.Size = new Size(150, 27);
|
||||
numericUpDownFuelPrice.TabIndex = 4;
|
||||
numericUpDownFuelPrice.Value = new decimal(new int[] { 1, 0, 0, 0 });
|
||||
//
|
||||
// labelFuelPrice
|
||||
//
|
||||
labelFuelPrice.AutoSize = true;
|
||||
labelFuelPrice.Location = new Point(8, 182);
|
||||
labelFuelPrice.Name = "labelFuelPrice";
|
||||
labelFuelPrice.Size = new Size(100, 20);
|
||||
labelFuelPrice.TabIndex = 5;
|
||||
labelFuelPrice.Text = "Цена за литр";
|
||||
//
|
||||
// buttonFuelSave
|
||||
//
|
||||
buttonFuelSave.Location = new Point(8, 219);
|
||||
buttonFuelSave.Name = "buttonFuelSave";
|
||||
buttonFuelSave.Size = new Size(121, 29);
|
||||
buttonFuelSave.TabIndex = 6;
|
||||
buttonFuelSave.Text = "Сохранить";
|
||||
buttonFuelSave.UseVisualStyleBackColor = true;
|
||||
buttonFuelSave.Click += ButtonFuelSave_Click;
|
||||
//
|
||||
// buttonFuelCancel
|
||||
//
|
||||
buttonFuelCancel.Location = new Point(152, 219);
|
||||
buttonFuelCancel.Name = "buttonFuelCancel";
|
||||
buttonFuelCancel.Size = new Size(119, 29);
|
||||
buttonFuelCancel.TabIndex = 7;
|
||||
buttonFuelCancel.Text = "Отмена";
|
||||
buttonFuelCancel.UseVisualStyleBackColor = true;
|
||||
buttonFuelCancel.Click += ButtonFuelCancel_Click;
|
||||
//
|
||||
// FormFuel
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(292, 260);
|
||||
Controls.Add(buttonFuelCancel);
|
||||
Controls.Add(buttonFuelSave);
|
||||
Controls.Add(labelFuelPrice);
|
||||
Controls.Add(numericUpDownFuelPrice);
|
||||
Controls.Add(textBoxFuelName);
|
||||
Controls.Add(labelFuelName);
|
||||
Controls.Add(labelFuelType);
|
||||
Controls.Add(checkedListBoxFuel);
|
||||
Name = "FormFuel";
|
||||
Text = "FormFuel";
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownFuelPrice).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private CheckedListBox checkedListBoxFuel;
|
||||
private Label labelFuelType;
|
||||
private Label labelFuelName;
|
||||
private TextBox textBoxFuelName;
|
||||
private NumericUpDown numericUpDownFuelPrice;
|
||||
private Label labelFuelPrice;
|
||||
private Button buttonFuelSave;
|
||||
private Button buttonFuelCancel;
|
||||
}
|
||||
}
|
103
ProjectGarage/Forms/FormFuel.cs
Normal file
@ -0,0 +1,103 @@
|
||||
using Microsoft.VisualBasic.FileIO;
|
||||
using ProjectGarage.Entities;
|
||||
using ProjectGarage.Entities.Enums;
|
||||
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;
|
||||
|
||||
namespace ProjectGarage.Forms
|
||||
{
|
||||
public partial class FormFuel : Form
|
||||
{
|
||||
private readonly IFuelRepository _fuelRepository;
|
||||
|
||||
private int? _fuelId;
|
||||
|
||||
public int Id
|
||||
{
|
||||
set
|
||||
{
|
||||
try
|
||||
{
|
||||
var fuel = _fuelRepository.ReadFuelByID(value);
|
||||
if (fuel == null)
|
||||
{
|
||||
throw new InvalidDataException(nameof(fuel));
|
||||
}
|
||||
foreach (FuelType elem in Enum.GetValues(typeof(FuelType)))
|
||||
{
|
||||
if ((elem & fuel.FuelType) != 0)
|
||||
{
|
||||
checkedListBoxFuel.SetItemChecked(checkedListBoxFuel.Items.IndexOf(elem), true);
|
||||
}
|
||||
}
|
||||
textBoxFuelName.Text = fuel.FuelName;
|
||||
numericUpDownFuelPrice.Value = fuel.Price;
|
||||
_fuelId = value;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public FormFuel(IFuelRepository fuelRepository)
|
||||
{
|
||||
InitializeComponent();
|
||||
_fuelRepository = fuelRepository ?? throw new ArgumentNullException(nameof(fuelRepository));
|
||||
foreach (var elem in Enum.GetValues(typeof(FuelType)))
|
||||
{
|
||||
checkedListBoxFuel.Items.Add(elem);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonFuelSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(textBoxFuelName.Text) ||
|
||||
checkedListBoxFuel.CheckedItems.Count == 0)
|
||||
{
|
||||
throw new Exception("Имеются незаполненные поля");
|
||||
}
|
||||
if (_fuelId.HasValue)
|
||||
{
|
||||
_fuelRepository.UpdateFuel(CreateFuel(_fuelId.Value));
|
||||
}
|
||||
else
|
||||
{
|
||||
_fuelRepository.CreateFuel(CreateFuel(0));
|
||||
}
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при сохранении",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void ButtonFuelCancel_Click(object sender, EventArgs e) => Close();
|
||||
|
||||
private Fuel CreateFuel(int id)
|
||||
{
|
||||
FuelType fuelType = FuelType.None;
|
||||
foreach (var elem in checkedListBoxFuel.CheckedItems)
|
||||
{
|
||||
fuelType |= (FuelType)elem;
|
||||
}
|
||||
return Fuel.CreateFuel(id, textBoxFuelName.Text, fuelType, Convert.ToInt32(numericUpDownFuelPrice.Value));
|
||||
}
|
||||
}
|
||||
}
|
120
ProjectGarage/Forms/FormFuel.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
125
ProjectGarage/Forms/FormFuels.Designer.cs
generated
Normal file
@ -0,0 +1,125 @@
|
||||
namespace ProjectGarage.Forms
|
||||
{
|
||||
partial class FormFuels
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
dataGridViewFuels = new DataGridView();
|
||||
panelFormFuelsButtons = new Panel();
|
||||
buttonUpdateFuel = new Button();
|
||||
buttonDeleteFuel = new Button();
|
||||
buttonAddFuel = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridViewFuels).BeginInit();
|
||||
panelFormFuelsButtons.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// dataGridViewFuels
|
||||
//
|
||||
dataGridViewFuels.AllowUserToAddRows = false;
|
||||
dataGridViewFuels.AllowUserToDeleteRows = false;
|
||||
dataGridViewFuels.AllowUserToResizeColumns = false;
|
||||
dataGridViewFuels.AllowUserToResizeRows = false;
|
||||
dataGridViewFuels.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||
dataGridViewFuels.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridViewFuels.Dock = DockStyle.Fill;
|
||||
dataGridViewFuels.Location = new Point(0, 0);
|
||||
dataGridViewFuels.Name = "dataGridViewFuels";
|
||||
dataGridViewFuels.ReadOnly = true;
|
||||
dataGridViewFuels.RowHeadersVisible = false;
|
||||
dataGridViewFuels.RowHeadersWidth = 51;
|
||||
dataGridViewFuels.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||
dataGridViewFuels.Size = new Size(648, 367);
|
||||
dataGridViewFuels.TabIndex = 5;
|
||||
//
|
||||
// panelFormFuelsButtons
|
||||
//
|
||||
panelFormFuelsButtons.Controls.Add(buttonUpdateFuel);
|
||||
panelFormFuelsButtons.Controls.Add(buttonDeleteFuel);
|
||||
panelFormFuelsButtons.Controls.Add(buttonAddFuel);
|
||||
panelFormFuelsButtons.Dock = DockStyle.Right;
|
||||
panelFormFuelsButtons.Location = new Point(648, 0);
|
||||
panelFormFuelsButtons.Name = "panelFormFuelsButtons";
|
||||
panelFormFuelsButtons.Size = new Size(161, 367);
|
||||
panelFormFuelsButtons.TabIndex = 4;
|
||||
//
|
||||
// buttonUpdateFuel
|
||||
//
|
||||
buttonUpdateFuel.BackgroundImage = Properties.Resources.каранд;
|
||||
buttonUpdateFuel.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
buttonUpdateFuel.Location = new Point(35, 140);
|
||||
buttonUpdateFuel.Name = "buttonUpdateFuel";
|
||||
buttonUpdateFuel.Size = new Size(94, 75);
|
||||
buttonUpdateFuel.TabIndex = 2;
|
||||
buttonUpdateFuel.UseVisualStyleBackColor = true;
|
||||
buttonUpdateFuel.Click += ButtonUpdateFuel_Click;
|
||||
//
|
||||
// buttonDeleteFuel
|
||||
//
|
||||
buttonDeleteFuel.BackgroundImage = Properties.Resources.минусик;
|
||||
buttonDeleteFuel.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
buttonDeleteFuel.Location = new Point(35, 249);
|
||||
buttonDeleteFuel.Name = "buttonDeleteFuel";
|
||||
buttonDeleteFuel.Size = new Size(94, 78);
|
||||
buttonDeleteFuel.TabIndex = 1;
|
||||
buttonDeleteFuel.UseVisualStyleBackColor = true;
|
||||
buttonDeleteFuel.Click += ButtonDeleteFuel_Click;
|
||||
//
|
||||
// buttonAddFuel
|
||||
//
|
||||
buttonAddFuel.BackgroundImage = Properties.Resources.плюсик;
|
||||
buttonAddFuel.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
buttonAddFuel.Location = new Point(35, 23);
|
||||
buttonAddFuel.Name = "buttonAddFuel";
|
||||
buttonAddFuel.Size = new Size(94, 75);
|
||||
buttonAddFuel.TabIndex = 0;
|
||||
buttonAddFuel.UseVisualStyleBackColor = true;
|
||||
buttonAddFuel.Click += ButtonAddFuel_Click;
|
||||
//
|
||||
// FormFuels
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(809, 367);
|
||||
Controls.Add(dataGridViewFuels);
|
||||
Controls.Add(panelFormFuelsButtons);
|
||||
Name = "FormFuels";
|
||||
Text = "FormFuels";
|
||||
Load += FormFeeds_Load;
|
||||
((System.ComponentModel.ISupportInitialize)dataGridViewFuels).EndInit();
|
||||
panelFormFuelsButtons.ResumeLayout(false);
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DataGridView dataGridViewFuels;
|
||||
private Panel panelFormFuelsButtons;
|
||||
private Button buttonUpdateFuel;
|
||||
private Button buttonDeleteFuel;
|
||||
private Button buttonAddFuel;
|
||||
}
|
||||
}
|
114
ProjectGarage/Forms/FormFuels.cs
Normal file
@ -0,0 +1,114 @@
|
||||
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 FormFuels : Form
|
||||
{
|
||||
private readonly IUnityContainer _container;
|
||||
private readonly IFuelRepository _fuelRepository;
|
||||
|
||||
public FormFuels(IUnityContainer container, IFuelRepository fuelRepository)
|
||||
{
|
||||
InitializeComponent();
|
||||
_container = container ?? throw new ArgumentNullException(nameof(container));
|
||||
_fuelRepository = fuelRepository ?? throw new ArgumentNullException(nameof(fuelRepository));
|
||||
}
|
||||
|
||||
private void FormFeeds_Load(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
LoadList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при загрузке",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonAddFuel_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
_container.Resolve<FormFuel>().ShowDialog();
|
||||
LoadList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при добавлении",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonUpdateFuel_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (!TryGetIdentifierFromSelectedRow(out var findId))
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
var form = _container.Resolve<FormFuel>();
|
||||
form.Id = findId;
|
||||
form.ShowDialog();
|
||||
LoadList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при изменении",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void ButtonDeleteFuel_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (!TryGetIdentifierFromSelectedRow(out var findId))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (MessageBox.Show("Удалить запись?", "Удаление",
|
||||
MessageBoxButtons.YesNo) != DialogResult.Yes)
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
_fuelRepository.DeleteFuel(findId);
|
||||
LoadList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при удалении",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadList() => dataGridViewFuels.DataSource = _fuelRepository.ReadFuels();
|
||||
|
||||
private bool TryGetIdentifierFromSelectedRow(out int id)
|
||||
{
|
||||
id = 0;
|
||||
if (dataGridViewFuels.SelectedRows.Count < 1)
|
||||
{
|
||||
MessageBox.Show("Нет выбранной записи", "Ошибка",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return false;
|
||||
}
|
||||
id = Convert.ToInt32(dataGridViewFuels.SelectedRows[0].Cells["Id"].Value);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
120
ProjectGarage/Forms/FormFuels.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
148
ProjectGarage/Forms/FormReplenishment.Designer.cs
generated
Normal file
@ -0,0 +1,148 @@
|
||||
namespace ProjectGarage.Forms
|
||||
{
|
||||
partial class FormReplenishment
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
comboBoxReplenishmentDriver = new ComboBox();
|
||||
labelReplenishmentDriver = new Label();
|
||||
groupBoxReplenishment = new GroupBox();
|
||||
dataGridViewReplenishment = new DataGridView();
|
||||
ColumnFuel = new DataGridViewComboBoxColumn();
|
||||
ColumnAmount = new DataGridViewTextBoxColumn();
|
||||
ButtonReplenishmentSave = new Button();
|
||||
ButtonReplenishmentCancel = new Button();
|
||||
groupBoxReplenishment.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridViewReplenishment).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// comboBoxReplenishmentDriver
|
||||
//
|
||||
comboBoxReplenishmentDriver.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboBoxReplenishmentDriver.FormattingEnabled = true;
|
||||
comboBoxReplenishmentDriver.Location = new Point(141, 16);
|
||||
comboBoxReplenishmentDriver.Name = "comboBoxReplenishmentDriver";
|
||||
comboBoxReplenishmentDriver.Size = new Size(151, 28);
|
||||
comboBoxReplenishmentDriver.TabIndex = 9;
|
||||
//
|
||||
// labelReplenishmentDriver
|
||||
//
|
||||
labelReplenishmentDriver.AutoSize = true;
|
||||
labelReplenishmentDriver.Location = new Point(21, 19);
|
||||
labelReplenishmentDriver.Name = "labelReplenishmentDriver";
|
||||
labelReplenishmentDriver.Size = new Size(74, 20);
|
||||
labelReplenishmentDriver.TabIndex = 8;
|
||||
labelReplenishmentDriver.Text = "Водитель";
|
||||
//
|
||||
// groupBoxReplenishment
|
||||
//
|
||||
groupBoxReplenishment.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||
groupBoxReplenishment.Controls.Add(dataGridViewReplenishment);
|
||||
groupBoxReplenishment.Location = new Point(21, 66);
|
||||
groupBoxReplenishment.Name = "groupBoxReplenishment";
|
||||
groupBoxReplenishment.Size = new Size(271, 288);
|
||||
groupBoxReplenishment.TabIndex = 10;
|
||||
groupBoxReplenishment.TabStop = false;
|
||||
groupBoxReplenishment.Text = "Пополнение топлива";
|
||||
//
|
||||
// dataGridViewReplenishment
|
||||
//
|
||||
dataGridViewReplenishment.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||
dataGridViewReplenishment.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridViewReplenishment.Columns.AddRange(new DataGridViewColumn[] { ColumnFuel, ColumnAmount });
|
||||
dataGridViewReplenishment.Dock = DockStyle.Fill;
|
||||
dataGridViewReplenishment.Location = new Point(3, 23);
|
||||
dataGridViewReplenishment.Name = "dataGridViewReplenishment";
|
||||
dataGridViewReplenishment.RowHeadersVisible = false;
|
||||
dataGridViewReplenishment.RowHeadersWidth = 51;
|
||||
dataGridViewReplenishment.Size = new Size(265, 262);
|
||||
dataGridViewReplenishment.TabIndex = 0;
|
||||
//
|
||||
// ColumnFuel
|
||||
//
|
||||
ColumnFuel.HeaderText = "Топливо";
|
||||
ColumnFuel.MinimumWidth = 6;
|
||||
ColumnFuel.Name = "ColumnFuel";
|
||||
//
|
||||
// ColumnAmount
|
||||
//
|
||||
ColumnAmount.HeaderText = "Кол-во";
|
||||
ColumnAmount.MinimumWidth = 6;
|
||||
ColumnAmount.Name = "ColumnAmount";
|
||||
//
|
||||
// ButtonReplenishmentSave
|
||||
//
|
||||
ButtonReplenishmentSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||
ButtonReplenishmentSave.Location = new Point(21, 360);
|
||||
ButtonReplenishmentSave.Name = "ButtonReplenishmentSave";
|
||||
ButtonReplenishmentSave.Size = new Size(134, 29);
|
||||
ButtonReplenishmentSave.TabIndex = 11;
|
||||
ButtonReplenishmentSave.Text = "Сохранить";
|
||||
ButtonReplenishmentSave.UseVisualStyleBackColor = true;
|
||||
ButtonReplenishmentSave.Click += ButtonReplenishmentSave_Click;
|
||||
//
|
||||
// ButtonReplenishmentCancel
|
||||
//
|
||||
ButtonReplenishmentCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
ButtonReplenishmentCancel.Location = new Point(161, 360);
|
||||
ButtonReplenishmentCancel.Name = "ButtonReplenishmentCancel";
|
||||
ButtonReplenishmentCancel.Size = new Size(131, 29);
|
||||
ButtonReplenishmentCancel.TabIndex = 13;
|
||||
ButtonReplenishmentCancel.Text = "Отмена";
|
||||
ButtonReplenishmentCancel.UseVisualStyleBackColor = true;
|
||||
ButtonReplenishmentCancel.Click += ButtonReplenishmentCancel_Click;
|
||||
//
|
||||
// FormReplenishment
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(315, 401);
|
||||
Controls.Add(ButtonReplenishmentCancel);
|
||||
Controls.Add(ButtonReplenishmentSave);
|
||||
Controls.Add(groupBoxReplenishment);
|
||||
Controls.Add(comboBoxReplenishmentDriver);
|
||||
Controls.Add(labelReplenishmentDriver);
|
||||
Name = "FormReplenishment";
|
||||
Text = "FormReplenishment";
|
||||
groupBoxReplenishment.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)dataGridViewReplenishment).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private ComboBox comboBoxReplenishmentDriver;
|
||||
private Label labelReplenishmentDriver;
|
||||
private GroupBox groupBoxReplenishment;
|
||||
private DataGridView dataGridViewReplenishment;
|
||||
private Button ButtonReplenishmentSave;
|
||||
private Button ButtonReplenishmentCancel;
|
||||
private DataGridViewComboBoxColumn ColumnFuel;
|
||||
private DataGridViewTextBoxColumn ColumnAmount;
|
||||
}
|
||||
}
|
72
ProjectGarage/Forms/FormReplenishment.cs
Normal file
@ -0,0 +1,72 @@
|
||||
using ProjectGarage.Entities;
|
||||
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;
|
||||
|
||||
namespace ProjectGarage.Forms
|
||||
{
|
||||
public partial class FormReplenishment : Form
|
||||
{
|
||||
private readonly IReplenishmentRepository _replenishmentRepository;
|
||||
|
||||
|
||||
public FormReplenishment(IReplenishmentRepository replenishmentRepository,
|
||||
IDriverRepository driverRepository, IFuelRepository fuelRepository)
|
||||
{
|
||||
InitializeComponent();
|
||||
_replenishmentRepository = replenishmentRepository ??
|
||||
throw new ArgumentNullException(nameof(replenishmentRepository));
|
||||
comboBoxReplenishmentDriver.DataSource = driverRepository.ReadDrivers();
|
||||
comboBoxReplenishmentDriver.DisplayMember = "Fname";
|
||||
comboBoxReplenishmentDriver.ValueMember = "Id";
|
||||
ColumnFuel.DataSource = fuelRepository.ReadFuels();
|
||||
ColumnFuel.DisplayMember = "FuelName";
|
||||
ColumnFuel.ValueMember = "Id";
|
||||
}
|
||||
|
||||
private void ButtonReplenishmentSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (dataGridViewReplenishment.RowCount < 1 ||
|
||||
comboBoxReplenishmentDriver.SelectedIndex < 0)
|
||||
{
|
||||
throw new Exception("Имеются незаполненные поля");
|
||||
}
|
||||
_replenishmentRepository.CreateFuelReplenishment(FuelReplenishment.CreateOpeartion(0,
|
||||
(int)comboBoxReplenishmentDriver.SelectedValue!, CreateListFuelFuelReplenishmentsFromDataGrid()));
|
||||
Close();
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonReplenishmentCancel_Click(object sender, EventArgs e) => Close();
|
||||
|
||||
private List<FuelFuelReplenishment> CreateListFuelFuelReplenishmentsFromDataGrid()
|
||||
{
|
||||
var list = new List<FuelFuelReplenishment>();
|
||||
foreach (DataGridViewRow row in dataGridViewReplenishment.Rows)
|
||||
{
|
||||
if (row.Cells["ColumnFuel"].Value == null ||
|
||||
row.Cells["ColumnAmount"].Value == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
list.Add(FuelFuelReplenishment.CreateElement(0, Convert.ToInt32(row.Cells["ColumnFuel"].Value),
|
||||
Convert.ToInt32(row.Cells["ColumnAmount"].Value)));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
}
|
132
ProjectGarage/Forms/FormReplenishment.resx
Normal file
@ -0,0 +1,132 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="ColumnFuel.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="ColumnAmount.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="ColumnFuel.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="ColumnAmount.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
</root>
|
109
ProjectGarage/Forms/FormReplenishments.Designer.cs
generated
Normal file
@ -0,0 +1,109 @@
|
||||
namespace ProjectGarage.Forms
|
||||
{
|
||||
partial class FormReplenishments
|
||||
{
|
||||
/// <summary>
|
||||
/// Обязательная переменная конструктора.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Освободить все используемые ресурсы.
|
||||
/// </summary>
|
||||
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Код, автоматически созданный конструктором компонентов
|
||||
|
||||
/// <summary>
|
||||
/// Требуемый метод для поддержки конструктора — не изменяйте
|
||||
/// содержимое этого метода с помощью редактора кода.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
buttonAddReplenishment = new Button();
|
||||
buttonDeleteReplenishment = new Button();
|
||||
panelFormReplenishmentssButtons = new Panel();
|
||||
dataGridViewReplenishments = new DataGridView();
|
||||
panelFormReplenishmentssButtons.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridViewReplenishments).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// buttonAddReplenishment
|
||||
//
|
||||
buttonAddReplenishment.BackgroundImage = Properties.Resources.плюсик;
|
||||
buttonAddReplenishment.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
buttonAddReplenishment.Location = new Point(35, 23);
|
||||
buttonAddReplenishment.Name = "buttonAddReplenishment";
|
||||
buttonAddReplenishment.Size = new Size(94, 75);
|
||||
buttonAddReplenishment.TabIndex = 0;
|
||||
buttonAddReplenishment.UseVisualStyleBackColor = true;
|
||||
buttonAddReplenishment.Click += ButtonAddReplenishment_Click;
|
||||
//
|
||||
// buttonDeleteReplenishment
|
||||
//
|
||||
buttonDeleteReplenishment.BackgroundImage = Properties.Resources.минусик;
|
||||
buttonDeleteReplenishment.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
buttonDeleteReplenishment.Location = new Point(35, 115);
|
||||
buttonDeleteReplenishment.Name = "buttonDeleteReplenishment";
|
||||
buttonDeleteReplenishment.Size = new Size(94, 78);
|
||||
buttonDeleteReplenishment.TabIndex = 1;
|
||||
buttonDeleteReplenishment.UseVisualStyleBackColor = true;
|
||||
buttonDeleteReplenishment.Click += ButtonDeleteReplenishment_Click;
|
||||
//
|
||||
// panelFormReplenishmentssButtons
|
||||
//
|
||||
panelFormReplenishmentssButtons.Controls.Add(buttonDeleteReplenishment);
|
||||
panelFormReplenishmentssButtons.Controls.Add(buttonAddReplenishment);
|
||||
panelFormReplenishmentssButtons.Dock = DockStyle.Right;
|
||||
panelFormReplenishmentssButtons.Location = new Point(641, 0);
|
||||
panelFormReplenishmentssButtons.Name = "panelFormReplenishmentssButtons";
|
||||
panelFormReplenishmentssButtons.Size = new Size(161, 406);
|
||||
panelFormReplenishmentssButtons.TabIndex = 6;
|
||||
//
|
||||
// dataGridViewReplenishments
|
||||
//
|
||||
dataGridViewReplenishments.AllowUserToAddRows = false;
|
||||
dataGridViewReplenishments.AllowUserToDeleteRows = false;
|
||||
dataGridViewReplenishments.AllowUserToResizeColumns = false;
|
||||
dataGridViewReplenishments.AllowUserToResizeRows = false;
|
||||
dataGridViewReplenishments.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||
dataGridViewReplenishments.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridViewReplenishments.Dock = DockStyle.Fill;
|
||||
dataGridViewReplenishments.Location = new Point(0, 0);
|
||||
dataGridViewReplenishments.Name = "dataGridViewReplenishments";
|
||||
dataGridViewReplenishments.ReadOnly = true;
|
||||
dataGridViewReplenishments.RowHeadersVisible = false;
|
||||
dataGridViewReplenishments.RowHeadersWidth = 51;
|
||||
dataGridViewReplenishments.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||
dataGridViewReplenishments.Size = new Size(641, 406);
|
||||
dataGridViewReplenishments.TabIndex = 7;
|
||||
//
|
||||
// FormReplenishments
|
||||
//
|
||||
ClientSize = new Size(802, 406);
|
||||
Controls.Add(dataGridViewReplenishments);
|
||||
Controls.Add(panelFormReplenishmentssButtons);
|
||||
Name = "FormReplenishments";
|
||||
Text = "Пополнения";
|
||||
Load += FormReplenishments_Load;
|
||||
panelFormReplenishmentssButtons.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)dataGridViewReplenishments).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Button buttonAddReplenishment;
|
||||
private Button buttonDeleteReplenishment;
|
||||
private Panel panelFormReplenishmentssButtons;
|
||||
private DataGridView dataGridViewReplenishments;
|
||||
}
|
||||
}
|
96
ProjectGarage/Forms/FormReplenishments.cs
Normal file
@ -0,0 +1,96 @@
|
||||
using ProjectGarage.Repositories;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Unity;
|
||||
|
||||
namespace ProjectGarage.Forms
|
||||
{
|
||||
public partial class FormReplenishments : Form
|
||||
{
|
||||
private readonly IUnityContainer _container;
|
||||
private readonly IReplenishmentRepository _replenishmentRepository;
|
||||
|
||||
public FormReplenishments(IUnityContainer container, IReplenishmentRepository replenishmentRepository)
|
||||
{
|
||||
InitializeComponent();
|
||||
_container = container ??
|
||||
throw new ArgumentNullException(nameof(container));
|
||||
_replenishmentRepository = replenishmentRepository ??
|
||||
throw new ArgumentNullException(nameof(replenishmentRepository));
|
||||
}
|
||||
private void FormReplenishments_Load(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
LoadList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при загрузке",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
public FormReplenishments(IContainer container)
|
||||
{
|
||||
container.Add(this);
|
||||
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void ButtonAddReplenishment_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
_container.Resolve<FormReplenishment>().ShowDialog();
|
||||
LoadList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonDeleteReplenishment_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (!TryGetIdentifierFromSelectedRow(out var findId))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes)
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
_replenishmentRepository.DeleteFuelReplenishment(findId);
|
||||
LoadList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при удалении",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
private void LoadList() => dataGridViewReplenishments.DataSource = _replenishmentRepository.ReadFuelReplenishment();
|
||||
|
||||
private bool TryGetIdentifierFromSelectedRow(out int id)
|
||||
{
|
||||
id = 0;
|
||||
if (dataGridViewReplenishments.SelectedRows.Count < 1)
|
||||
{
|
||||
MessageBox.Show("Нет выбранной записи", "Ошибка",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return false;
|
||||
}
|
||||
id =
|
||||
Convert.ToInt32(dataGridViewReplenishments.SelectedRows[0].Cells["Id"].Value);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
120
ProjectGarage/Forms/FormReplenishments.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
166
ProjectGarage/Forms/FormRoute.Designer.cs
generated
Normal file
@ -0,0 +1,166 @@
|
||||
namespace ProjectGarage.Forms
|
||||
{
|
||||
partial class FormRoute
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
labelRouteStart = new Label();
|
||||
labelRouteFinal = new Label();
|
||||
numericUpDownRouteLen = new NumericUpDown();
|
||||
labelRouteLen = new Label();
|
||||
buttonRouteSave = new Button();
|
||||
buttonRouteFinal = new Button();
|
||||
textBoxRouteStart = new TextBox();
|
||||
textBoxRouteFinal = new TextBox();
|
||||
textBoxRouteName = new TextBox();
|
||||
labelRouteName = new Label();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownRouteLen).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// labelRouteStart
|
||||
//
|
||||
labelRouteStart.AutoSize = true;
|
||||
labelRouteStart.Location = new Point(22, 62);
|
||||
labelRouteStart.Name = "labelRouteStart";
|
||||
labelRouteStart.Size = new Size(135, 20);
|
||||
labelRouteStart.TabIndex = 0;
|
||||
labelRouteStart.Text = "Начало маршрута";
|
||||
//
|
||||
// labelRouteFinal
|
||||
//
|
||||
labelRouteFinal.AutoSize = true;
|
||||
labelRouteFinal.Location = new Point(22, 104);
|
||||
labelRouteFinal.Name = "labelRouteFinal";
|
||||
labelRouteFinal.Size = new Size(127, 20);
|
||||
labelRouteFinal.TabIndex = 1;
|
||||
labelRouteFinal.Text = "Конец маршрута";
|
||||
//
|
||||
// numericUpDownRouteLen
|
||||
//
|
||||
numericUpDownRouteLen.Location = new Point(170, 145);
|
||||
numericUpDownRouteLen.Maximum = new decimal(new int[] { 10000, 0, 0, 0 });
|
||||
numericUpDownRouteLen.Minimum = new decimal(new int[] { 1, 0, 0, 0 });
|
||||
numericUpDownRouteLen.Name = "numericUpDownRouteLen";
|
||||
numericUpDownRouteLen.Size = new Size(150, 27);
|
||||
numericUpDownRouteLen.TabIndex = 2;
|
||||
numericUpDownRouteLen.Value = new decimal(new int[] { 1, 0, 0, 0 });
|
||||
//
|
||||
// labelRouteLen
|
||||
//
|
||||
labelRouteLen.AutoSize = true;
|
||||
labelRouteLen.Location = new Point(22, 145);
|
||||
labelRouteLen.Name = "labelRouteLen";
|
||||
labelRouteLen.Size = new Size(127, 20);
|
||||
labelRouteLen.TabIndex = 3;
|
||||
labelRouteLen.Text = "Длина маршрута";
|
||||
//
|
||||
// buttonRouteSave
|
||||
//
|
||||
buttonRouteSave.Location = new Point(22, 191);
|
||||
buttonRouteSave.Name = "buttonRouteSave";
|
||||
buttonRouteSave.Size = new Size(135, 29);
|
||||
buttonRouteSave.TabIndex = 4;
|
||||
buttonRouteSave.Text = "Сохранить";
|
||||
buttonRouteSave.UseVisualStyleBackColor = true;
|
||||
buttonRouteSave.Click += ButtonRouteSave_Click;
|
||||
//
|
||||
// buttonRouteFinal
|
||||
//
|
||||
buttonRouteFinal.Location = new Point(170, 191);
|
||||
buttonRouteFinal.Name = "buttonRouteFinal";
|
||||
buttonRouteFinal.Size = new Size(150, 29);
|
||||
buttonRouteFinal.TabIndex = 5;
|
||||
buttonRouteFinal.Text = "Отмена";
|
||||
buttonRouteFinal.UseVisualStyleBackColor = true;
|
||||
buttonRouteFinal.Click += ButtonRouteFinal_Click;
|
||||
//
|
||||
// textBoxRouteStart
|
||||
//
|
||||
textBoxRouteStart.Location = new Point(170, 62);
|
||||
textBoxRouteStart.Name = "textBoxRouteStart";
|
||||
textBoxRouteStart.Size = new Size(150, 27);
|
||||
textBoxRouteStart.TabIndex = 6;
|
||||
//
|
||||
// textBoxRouteFinal
|
||||
//
|
||||
textBoxRouteFinal.Location = new Point(170, 104);
|
||||
textBoxRouteFinal.Name = "textBoxRouteFinal";
|
||||
textBoxRouteFinal.Size = new Size(150, 27);
|
||||
textBoxRouteFinal.TabIndex = 7;
|
||||
//
|
||||
// textBoxRouteName
|
||||
//
|
||||
textBoxRouteName.Location = new Point(179, 12);
|
||||
textBoxRouteName.Name = "textBoxRouteName";
|
||||
textBoxRouteName.Size = new Size(141, 27);
|
||||
textBoxRouteName.TabIndex = 9;
|
||||
//
|
||||
// labelRouteName
|
||||
//
|
||||
labelRouteName.AutoSize = true;
|
||||
labelRouteName.Location = new Point(22, 19);
|
||||
labelRouteName.Name = "labelRouteName";
|
||||
labelRouteName.Size = new Size(151, 20);
|
||||
labelRouteName.TabIndex = 8;
|
||||
labelRouteName.Text = "Название маршрута";
|
||||
//
|
||||
// FormRoute
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(332, 240);
|
||||
Controls.Add(textBoxRouteName);
|
||||
Controls.Add(labelRouteName);
|
||||
Controls.Add(textBoxRouteFinal);
|
||||
Controls.Add(textBoxRouteStart);
|
||||
Controls.Add(buttonRouteFinal);
|
||||
Controls.Add(buttonRouteSave);
|
||||
Controls.Add(labelRouteLen);
|
||||
Controls.Add(numericUpDownRouteLen);
|
||||
Controls.Add(labelRouteFinal);
|
||||
Controls.Add(labelRouteStart);
|
||||
Name = "FormRoute";
|
||||
Text = "FormRoute";
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownRouteLen).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Label labelRouteStart;
|
||||
private Label labelRouteFinal;
|
||||
private NumericUpDown numericUpDownRouteLen;
|
||||
private Label labelRouteLen;
|
||||
private Button buttonRouteSave;
|
||||
private Button buttonRouteFinal;
|
||||
private TextBox textBoxRouteStart;
|
||||
private TextBox textBoxRouteFinal;
|
||||
private TextBox textBoxRouteName;
|
||||
private Label labelRouteName;
|
||||
}
|
||||
}
|
86
ProjectGarage/Forms/FormRoute.cs
Normal file
@ -0,0 +1,86 @@
|
||||
using ProjectGarage.Entities;
|
||||
using ProjectGarage.Entities.Enums;
|
||||
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;
|
||||
|
||||
namespace ProjectGarage.Forms
|
||||
{
|
||||
public partial class FormRoute : Form
|
||||
{
|
||||
private readonly IRouteRepository _routeRepository;
|
||||
private int? _routeId;
|
||||
|
||||
public int Id
|
||||
{
|
||||
set
|
||||
{
|
||||
try
|
||||
{
|
||||
var route = _routeRepository.ReadRouteByID(value);
|
||||
if (route == null)
|
||||
{
|
||||
throw new InvalidDataException(nameof(route));
|
||||
}
|
||||
|
||||
textBoxRouteName.Text = route.RouteName;
|
||||
textBoxRouteStart.Text = route.StartP;
|
||||
textBoxRouteFinal.Text = route.FinalP;
|
||||
numericUpDownRouteLen.Value = route.Length;
|
||||
_routeId = value;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public FormRoute(IRouteRepository routeRepository)
|
||||
{
|
||||
InitializeComponent();
|
||||
_routeRepository = routeRepository ??
|
||||
throw new ArgumentNullException(nameof(routeRepository));
|
||||
}
|
||||
|
||||
private void ButtonRouteSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(textBoxRouteStart.Text)
|
||||
|| string.IsNullOrWhiteSpace(textBoxRouteFinal.Text))
|
||||
{
|
||||
throw new Exception("Имеются незаполненные поля");
|
||||
}
|
||||
if (_routeId.HasValue)
|
||||
{
|
||||
_routeRepository.UpdateRoute(CreateRoute(_routeId.Value));
|
||||
}
|
||||
else
|
||||
{
|
||||
_routeRepository.CreateRoute(CreateRoute(0));
|
||||
}
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonRouteFinal_Click(object sender, EventArgs e) => Close();
|
||||
|
||||
private Route CreateRoute(int id) => Route.CreateRoute(id, textBoxRouteName.Text, textBoxRouteStart.Text,
|
||||
textBoxRouteFinal.Text, Convert.ToInt32(numericUpDownRouteLen.Value));
|
||||
}
|
||||
}
|
120
ProjectGarage/Forms/FormRoute.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
125
ProjectGarage/Forms/FormRoutes.Designer.cs
generated
Normal file
@ -0,0 +1,125 @@
|
||||
namespace ProjectGarage.Forms
|
||||
{
|
||||
partial class FormRoutes
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
dataGridViewRoutes = new DataGridView();
|
||||
panelFormRoutesButtons = new Panel();
|
||||
buttonUpdateRoute = new Button();
|
||||
buttonDeleteRoute = new Button();
|
||||
buttonAddRoute = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridViewRoutes).BeginInit();
|
||||
panelFormRoutesButtons.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// dataGridViewRoutes
|
||||
//
|
||||
dataGridViewRoutes.AllowUserToAddRows = false;
|
||||
dataGridViewRoutes.AllowUserToDeleteRows = false;
|
||||
dataGridViewRoutes.AllowUserToResizeColumns = false;
|
||||
dataGridViewRoutes.AllowUserToResizeRows = false;
|
||||
dataGridViewRoutes.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||
dataGridViewRoutes.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridViewRoutes.Dock = DockStyle.Fill;
|
||||
dataGridViewRoutes.Location = new Point(0, 0);
|
||||
dataGridViewRoutes.Name = "dataGridViewRoutes";
|
||||
dataGridViewRoutes.ReadOnly = true;
|
||||
dataGridViewRoutes.RowHeadersVisible = false;
|
||||
dataGridViewRoutes.RowHeadersWidth = 51;
|
||||
dataGridViewRoutes.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||
dataGridViewRoutes.Size = new Size(584, 355);
|
||||
dataGridViewRoutes.TabIndex = 5;
|
||||
//
|
||||
// panelFormRoutesButtons
|
||||
//
|
||||
panelFormRoutesButtons.Controls.Add(buttonUpdateRoute);
|
||||
panelFormRoutesButtons.Controls.Add(buttonDeleteRoute);
|
||||
panelFormRoutesButtons.Controls.Add(buttonAddRoute);
|
||||
panelFormRoutesButtons.Dock = DockStyle.Right;
|
||||
panelFormRoutesButtons.Location = new Point(584, 0);
|
||||
panelFormRoutesButtons.Name = "panelFormRoutesButtons";
|
||||
panelFormRoutesButtons.Size = new Size(161, 355);
|
||||
panelFormRoutesButtons.TabIndex = 4;
|
||||
//
|
||||
// buttonUpdateRoute
|
||||
//
|
||||
buttonUpdateRoute.BackgroundImage = Properties.Resources.каранд;
|
||||
buttonUpdateRoute.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
buttonUpdateRoute.Location = new Point(35, 140);
|
||||
buttonUpdateRoute.Name = "buttonUpdateRoute";
|
||||
buttonUpdateRoute.Size = new Size(94, 75);
|
||||
buttonUpdateRoute.TabIndex = 2;
|
||||
buttonUpdateRoute.UseVisualStyleBackColor = true;
|
||||
buttonUpdateRoute.Click += ButtonUpdateRoute_Click;
|
||||
//
|
||||
// buttonDeleteRoute
|
||||
//
|
||||
buttonDeleteRoute.BackgroundImage = Properties.Resources.минусик;
|
||||
buttonDeleteRoute.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
buttonDeleteRoute.Location = new Point(35, 249);
|
||||
buttonDeleteRoute.Name = "buttonDeleteRoute";
|
||||
buttonDeleteRoute.Size = new Size(94, 78);
|
||||
buttonDeleteRoute.TabIndex = 1;
|
||||
buttonDeleteRoute.UseVisualStyleBackColor = true;
|
||||
buttonDeleteRoute.Click += ButtonDeleteRoute_Click;
|
||||
//
|
||||
// buttonAddRoute
|
||||
//
|
||||
buttonAddRoute.BackgroundImage = Properties.Resources.плюсик;
|
||||
buttonAddRoute.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
buttonAddRoute.Location = new Point(35, 23);
|
||||
buttonAddRoute.Name = "buttonAddRoute";
|
||||
buttonAddRoute.Size = new Size(94, 75);
|
||||
buttonAddRoute.TabIndex = 0;
|
||||
buttonAddRoute.UseVisualStyleBackColor = true;
|
||||
buttonAddRoute.Click += ButtonAddRoute_Click;
|
||||
//
|
||||
// FormRoutes
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(745, 355);
|
||||
Controls.Add(dataGridViewRoutes);
|
||||
Controls.Add(panelFormRoutesButtons);
|
||||
Name = "FormRoutes";
|
||||
Text = "FormRoutes";
|
||||
Load += FormRoutes_Load;
|
||||
((System.ComponentModel.ISupportInitialize)dataGridViewRoutes).EndInit();
|
||||
panelFormRoutesButtons.ResumeLayout(false);
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DataGridView dataGridViewRoutes;
|
||||
private Panel panelFormRoutesButtons;
|
||||
private Button buttonUpdateRoute;
|
||||
private Button buttonDeleteRoute;
|
||||
private Button buttonAddRoute;
|
||||
}
|
||||
}
|
115
ProjectGarage/Forms/FormRoutes.cs
Normal file
@ -0,0 +1,115 @@
|
||||
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 System.Xml.Linq;
|
||||
using Unity;
|
||||
|
||||
namespace ProjectGarage.Forms
|
||||
{
|
||||
public partial class FormRoutes : Form
|
||||
{
|
||||
private readonly IUnityContainer _container;
|
||||
private readonly IRouteRepository _routeRepository;
|
||||
|
||||
public FormRoutes(IUnityContainer container, IRouteRepository routeRepository)
|
||||
{
|
||||
InitializeComponent();
|
||||
_container = container ?? throw new ArgumentNullException(nameof(container));
|
||||
_routeRepository = routeRepository ?? throw new ArgumentNullException(nameof(routeRepository));
|
||||
}
|
||||
private void ButtonAddRoute_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
_container.Resolve<FormRoute>().ShowDialog();
|
||||
LoadList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при добавлении",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
|
||||
}
|
||||
private void FormRoutes_Load(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
LoadList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при загрузке",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void ButtonDeleteRoute_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (!TryGetIdentifierFromSelectedRow(out var findId))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (MessageBox.Show("Удалить запись?", "Удаление",
|
||||
MessageBoxButtons.YesNo) != DialogResult.Yes)
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
_routeRepository.DeleteRoute(findId);
|
||||
LoadList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при удалении",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonUpdateRoute_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (!TryGetIdentifierFromSelectedRow(out var findId))
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
var form = _container.Resolve<FormRoute>();
|
||||
form.Id = findId;
|
||||
form.ShowDialog();
|
||||
LoadList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при изменении",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadList() => dataGridViewRoutes.DataSource = _routeRepository.ReadRoute();
|
||||
|
||||
private bool TryGetIdentifierFromSelectedRow(out int id)
|
||||
{
|
||||
id = 0;
|
||||
if (dataGridViewRoutes.SelectedRows.Count < 1)
|
||||
{
|
||||
MessageBox.Show("Нет выбранной записи", "Ошибка",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return false;
|
||||
}
|
||||
id =
|
||||
Convert.ToInt32(dataGridViewRoutes.SelectedRows[0].Cells["Id"].Value);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
120
ProjectGarage/Forms/FormRoutes.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
171
ProjectGarage/Forms/FormTransportation.Designer.cs
generated
Normal file
@ -0,0 +1,171 @@
|
||||
namespace ProjectGarage.Forms
|
||||
{
|
||||
partial class FormTransportation
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
labelFuel = new Label();
|
||||
labelDriver = new Label();
|
||||
labelRoute = new Label();
|
||||
label1 = new Label();
|
||||
numericUpDownAmountFuel = new NumericUpDown();
|
||||
comboBoxFuel = new ComboBox();
|
||||
comboBoxRoute = new ComboBox();
|
||||
comboBoxDriver = new ComboBox();
|
||||
buttonTransportationSave = new Button();
|
||||
buttonTransportationCancel = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownAmountFuel).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// labelFuel
|
||||
//
|
||||
labelFuel.AutoSize = true;
|
||||
labelFuel.Location = new Point(32, 26);
|
||||
labelFuel.Name = "labelFuel";
|
||||
labelFuel.Size = new Size(69, 20);
|
||||
labelFuel.TabIndex = 0;
|
||||
labelFuel.Text = "Топливо";
|
||||
//
|
||||
// labelDriver
|
||||
//
|
||||
labelDriver.AutoSize = true;
|
||||
labelDriver.Location = new Point(32, 70);
|
||||
labelDriver.Name = "labelDriver";
|
||||
labelDriver.Size = new Size(74, 20);
|
||||
labelDriver.TabIndex = 1;
|
||||
labelDriver.Text = "Водитель";
|
||||
//
|
||||
// labelRoute
|
||||
//
|
||||
labelRoute.AutoSize = true;
|
||||
labelRoute.Location = new Point(32, 116);
|
||||
labelRoute.Name = "labelRoute";
|
||||
labelRoute.Size = new Size(73, 20);
|
||||
labelRoute.TabIndex = 2;
|
||||
labelRoute.Text = "Маршрут";
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(12, 157);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(118, 20);
|
||||
label1.TabIndex = 3;
|
||||
label1.Text = "Объем топлива";
|
||||
//
|
||||
// numericUpDownAmountFuel
|
||||
//
|
||||
numericUpDownAmountFuel.Location = new Point(152, 155);
|
||||
numericUpDownAmountFuel.Minimum = new decimal(new int[] { 1, 0, 0, 0 });
|
||||
numericUpDownAmountFuel.Name = "numericUpDownAmountFuel";
|
||||
numericUpDownAmountFuel.Size = new Size(150, 27);
|
||||
numericUpDownAmountFuel.TabIndex = 4;
|
||||
numericUpDownAmountFuel.Value = new decimal(new int[] { 1, 0, 0, 0 });
|
||||
//
|
||||
// comboBoxFuel
|
||||
//
|
||||
comboBoxFuel.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboBoxFuel.FormattingEnabled = true;
|
||||
comboBoxFuel.Location = new Point(151, 23);
|
||||
comboBoxFuel.Name = "comboBoxFuel";
|
||||
comboBoxFuel.Size = new Size(151, 28);
|
||||
comboBoxFuel.TabIndex = 5;
|
||||
//
|
||||
// comboBoxRoute
|
||||
//
|
||||
comboBoxRoute.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboBoxRoute.FormattingEnabled = true;
|
||||
comboBoxRoute.Location = new Point(151, 113);
|
||||
comboBoxRoute.Name = "comboBoxRoute";
|
||||
comboBoxRoute.Size = new Size(151, 28);
|
||||
comboBoxRoute.TabIndex = 6;
|
||||
//
|
||||
// comboBoxDriver
|
||||
//
|
||||
comboBoxDriver.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboBoxDriver.FormattingEnabled = true;
|
||||
comboBoxDriver.Location = new Point(152, 67);
|
||||
comboBoxDriver.Name = "comboBoxDriver";
|
||||
comboBoxDriver.Size = new Size(151, 28);
|
||||
comboBoxDriver.TabIndex = 7;
|
||||
//
|
||||
// buttonTransportationSave
|
||||
//
|
||||
buttonTransportationSave.Location = new Point(12, 194);
|
||||
buttonTransportationSave.Name = "buttonTransportationSave";
|
||||
buttonTransportationSave.Size = new Size(135, 29);
|
||||
buttonTransportationSave.TabIndex = 8;
|
||||
buttonTransportationSave.Text = "Сохранить";
|
||||
buttonTransportationSave.UseVisualStyleBackColor = true;
|
||||
buttonTransportationSave.Click += ButtonTransportationSave_Click;
|
||||
//
|
||||
// buttonTransportationCancel
|
||||
//
|
||||
buttonTransportationCancel.Location = new Point(163, 194);
|
||||
buttonTransportationCancel.Name = "buttonTransportationCancel";
|
||||
buttonTransportationCancel.Size = new Size(140, 29);
|
||||
buttonTransportationCancel.TabIndex = 9;
|
||||
buttonTransportationCancel.Text = "Отмена";
|
||||
buttonTransportationCancel.UseVisualStyleBackColor = true;
|
||||
buttonTransportationCancel.Click += ButtonTransportationCancel_Click;
|
||||
//
|
||||
// FormTransportation
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(324, 244);
|
||||
Controls.Add(buttonTransportationCancel);
|
||||
Controls.Add(buttonTransportationSave);
|
||||
Controls.Add(comboBoxDriver);
|
||||
Controls.Add(comboBoxRoute);
|
||||
Controls.Add(comboBoxFuel);
|
||||
Controls.Add(numericUpDownAmountFuel);
|
||||
Controls.Add(label1);
|
||||
Controls.Add(labelRoute);
|
||||
Controls.Add(labelDriver);
|
||||
Controls.Add(labelFuel);
|
||||
Name = "FormTransportation";
|
||||
Text = "FormTransportation";
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownAmountFuel).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Label labelFuel;
|
||||
private Label labelDriver;
|
||||
private Label labelRoute;
|
||||
private Label label1;
|
||||
private NumericUpDown numericUpDownAmountFuel;
|
||||
private ComboBox comboBoxFuel;
|
||||
private ComboBox comboBoxRoute;
|
||||
private ComboBox comboBoxDriver;
|
||||
private Button buttonTransportationSave;
|
||||
private Button buttonTransportationCancel;
|
||||
}
|
||||
}
|
63
ProjectGarage/Forms/FormTransportation.cs
Normal file
@ -0,0 +1,63 @@
|
||||
using ProjectGarage.Entities;
|
||||
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;
|
||||
|
||||
namespace ProjectGarage.Forms
|
||||
{
|
||||
public partial class FormTransportation : Form
|
||||
{
|
||||
private readonly ITransportationRepository _transportationRepository;
|
||||
|
||||
public FormTransportation(ITransportationRepository transportationRepository,
|
||||
IFuelRepository fuelRepository, IDriverRepository driverRepository, IRouteRepository routeRepository)
|
||||
{
|
||||
InitializeComponent();
|
||||
_transportationRepository = transportationRepository ??
|
||||
throw new ArgumentNullException(nameof(transportationRepository));
|
||||
|
||||
comboBoxDriver.DataSource = driverRepository.ReadDrivers();
|
||||
comboBoxDriver.DisplayMember = "Fname";
|
||||
comboBoxDriver.ValueMember = "Id";
|
||||
|
||||
comboBoxFuel.DataSource = fuelRepository.ReadFuels();
|
||||
comboBoxFuel.DisplayMember = "FuelName";
|
||||
comboBoxFuel.ValueMember = "Id";
|
||||
|
||||
comboBoxRoute.DataSource = routeRepository.ReadRoute();
|
||||
comboBoxRoute.DisplayMember = "RouteName";
|
||||
comboBoxRoute.ValueMember = "Id";
|
||||
}
|
||||
|
||||
private void ButtonTransportationSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (comboBoxFuel.SelectedIndex < 0 || comboBoxDriver.SelectedIndex < 0 ||
|
||||
comboBoxRoute.SelectedIndex < 0)
|
||||
{
|
||||
throw new Exception("Имеются незаполненные поля");
|
||||
}
|
||||
_transportationRepository.CreateTransportation(Transportation.CreateTransportation(0,
|
||||
(int)comboBoxFuel.SelectedValue!, (int)comboBoxRoute.SelectedValue!,
|
||||
(int)comboBoxDriver.SelectedValue!, Convert.ToInt32(numericUpDownAmountFuel.Value)));
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при сохранении",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonTransportationCancel_Click(object sender, EventArgs e) => Close();
|
||||
}
|
||||
}
|
120
ProjectGarage/Forms/FormTransportation.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
97
ProjectGarage/Forms/FormTransportations.Designer.cs
generated
Normal file
@ -0,0 +1,97 @@
|
||||
namespace ProjectGarage.Forms
|
||||
{
|
||||
partial class FormTransportations
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
buttonAddTransportation = new Button();
|
||||
dataGridViewTransportations = new DataGridView();
|
||||
panelFormTransportationsButtons = new Panel();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridViewTransportations).BeginInit();
|
||||
panelFormTransportationsButtons.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// buttonAddTransportation
|
||||
//
|
||||
buttonAddTransportation.BackgroundImage = Properties.Resources.плюсик;
|
||||
buttonAddTransportation.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
buttonAddTransportation.Location = new Point(35, 23);
|
||||
buttonAddTransportation.Name = "buttonAddTransportation";
|
||||
buttonAddTransportation.Size = new Size(94, 75);
|
||||
buttonAddTransportation.TabIndex = 0;
|
||||
buttonAddTransportation.UseVisualStyleBackColor = true;
|
||||
buttonAddTransportation.Click += ButtonAddTransportation_Click;
|
||||
//
|
||||
// dataGridViewTransportations
|
||||
//
|
||||
dataGridViewTransportations.AllowUserToAddRows = false;
|
||||
dataGridViewTransportations.AllowUserToDeleteRows = false;
|
||||
dataGridViewTransportations.AllowUserToResizeColumns = false;
|
||||
dataGridViewTransportations.AllowUserToResizeRows = false;
|
||||
dataGridViewTransportations.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||
dataGridViewTransportations.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridViewTransportations.Dock = DockStyle.Fill;
|
||||
dataGridViewTransportations.Location = new Point(0, 0);
|
||||
dataGridViewTransportations.Name = "dataGridViewTransportations";
|
||||
dataGridViewTransportations.ReadOnly = true;
|
||||
dataGridViewTransportations.RowHeadersVisible = false;
|
||||
dataGridViewTransportations.RowHeadersWidth = 51;
|
||||
dataGridViewTransportations.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||
dataGridViewTransportations.Size = new Size(847, 450);
|
||||
dataGridViewTransportations.TabIndex = 7;
|
||||
//
|
||||
// panelFormTransportationsButtons
|
||||
//
|
||||
panelFormTransportationsButtons.Controls.Add(buttonAddTransportation);
|
||||
panelFormTransportationsButtons.Dock = DockStyle.Right;
|
||||
panelFormTransportationsButtons.Location = new Point(847, 0);
|
||||
panelFormTransportationsButtons.Name = "panelFormTransportationsButtons";
|
||||
panelFormTransportationsButtons.Size = new Size(161, 450);
|
||||
panelFormTransportationsButtons.TabIndex = 6;
|
||||
//
|
||||
// FormTransportations
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(1008, 450);
|
||||
Controls.Add(dataGridViewTransportations);
|
||||
Controls.Add(panelFormTransportationsButtons);
|
||||
Name = "FormTransportations";
|
||||
Text = "FormTransportations";
|
||||
Load += FormTransportations_Load;
|
||||
((System.ComponentModel.ISupportInitialize)dataGridViewTransportations).EndInit();
|
||||
panelFormTransportationsButtons.ResumeLayout(false);
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Button buttonAddTransportation;
|
||||
private DataGridView dataGridViewTransportations;
|
||||
private Panel panelFormTransportationsButtons;
|
||||
}
|
||||
}
|
57
ProjectGarage/Forms/FormTransportations.cs
Normal file
@ -0,0 +1,57 @@
|
||||
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();
|
||||
}
|
||||
}
|
120
ProjectGarage/Forms/FormTransportations.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
146
ProjectGarage/Forms/FormTruck.Designer.cs
generated
Normal file
@ -0,0 +1,146 @@
|
||||
namespace ProjectGarage.Forms
|
||||
{
|
||||
partial class FormTruck
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
labelTruckBrand = new Label();
|
||||
textBoxTruckNumbers = new TextBox();
|
||||
labelTruckNumbers = new Label();
|
||||
labelMaxFuel = new Label();
|
||||
numericUpDownMaxFuel = new NumericUpDown();
|
||||
buttonTruckSave = new Button();
|
||||
buttonTruckCancel = new Button();
|
||||
comboBoxTruckType = new ComboBox();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownMaxFuel).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// labelTruckBrand
|
||||
//
|
||||
labelTruckBrand.AutoSize = true;
|
||||
labelTruckBrand.Location = new Point(43, 76);
|
||||
labelTruckBrand.Name = "labelTruckBrand";
|
||||
labelTruckBrand.Size = new Size(54, 20);
|
||||
labelTruckBrand.TabIndex = 10;
|
||||
labelTruckBrand.Text = "Марка";
|
||||
//
|
||||
// textBoxTruckNumbers
|
||||
//
|
||||
textBoxTruckNumbers.Location = new Point(158, 30);
|
||||
textBoxTruckNumbers.Name = "textBoxTruckNumbers";
|
||||
textBoxTruckNumbers.Size = new Size(183, 27);
|
||||
textBoxTruckNumbers.TabIndex = 9;
|
||||
//
|
||||
// labelTruckNumbers
|
||||
//
|
||||
labelTruckNumbers.AutoSize = true;
|
||||
labelTruckNumbers.Location = new Point(26, 30);
|
||||
labelTruckNumbers.Name = "labelTruckNumbers";
|
||||
labelTruckNumbers.Size = new Size(106, 20);
|
||||
labelTruckNumbers.TabIndex = 8;
|
||||
labelTruckNumbers.Text = "Номера фуры";
|
||||
//
|
||||
// labelMaxFuel
|
||||
//
|
||||
labelMaxFuel.AutoSize = true;
|
||||
labelMaxFuel.Location = new Point(12, 122);
|
||||
labelMaxFuel.Name = "labelMaxFuel";
|
||||
labelMaxFuel.Size = new Size(129, 20);
|
||||
labelMaxFuel.TabIndex = 14;
|
||||
labelMaxFuel.Text = "Объем цистерны";
|
||||
//
|
||||
// numericUpDownMaxFuel
|
||||
//
|
||||
numericUpDownMaxFuel.Location = new Point(158, 115);
|
||||
numericUpDownMaxFuel.Maximum = new decimal(new int[] { 3000, 0, 0, 0 });
|
||||
numericUpDownMaxFuel.Minimum = new decimal(new int[] { 1, 0, 0, 0 });
|
||||
numericUpDownMaxFuel.Name = "numericUpDownMaxFuel";
|
||||
numericUpDownMaxFuel.Size = new Size(183, 27);
|
||||
numericUpDownMaxFuel.TabIndex = 15;
|
||||
numericUpDownMaxFuel.Value = new decimal(new int[] { 1, 0, 0, 0 });
|
||||
//
|
||||
// buttonTruckSave
|
||||
//
|
||||
buttonTruckSave.Location = new Point(12, 170);
|
||||
buttonTruckSave.Name = "buttonTruckSave";
|
||||
buttonTruckSave.Size = new Size(156, 37);
|
||||
buttonTruckSave.TabIndex = 16;
|
||||
buttonTruckSave.Text = "Сохранить";
|
||||
buttonTruckSave.UseVisualStyleBackColor = true;
|
||||
buttonTruckSave.Click += ButtonTruckSave_Click;
|
||||
//
|
||||
// buttonTruckCancel
|
||||
//
|
||||
buttonTruckCancel.Location = new Point(196, 170);
|
||||
buttonTruckCancel.Name = "buttonTruckCancel";
|
||||
buttonTruckCancel.Size = new Size(156, 37);
|
||||
buttonTruckCancel.TabIndex = 17;
|
||||
buttonTruckCancel.Text = "Отмена";
|
||||
buttonTruckCancel.UseVisualStyleBackColor = true;
|
||||
buttonTruckCancel.Click += ButtonTruckCancel_Click;
|
||||
//
|
||||
// comboBoxTruckType
|
||||
//
|
||||
comboBoxTruckType.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboBoxTruckType.FormattingEnabled = true;
|
||||
comboBoxTruckType.Location = new Point(158, 68);
|
||||
comboBoxTruckType.Name = "comboBoxTruckType";
|
||||
comboBoxTruckType.Size = new Size(183, 28);
|
||||
comboBoxTruckType.TabIndex = 18;
|
||||
//
|
||||
// FormTruck
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(364, 222);
|
||||
Controls.Add(comboBoxTruckType);
|
||||
Controls.Add(buttonTruckCancel);
|
||||
Controls.Add(buttonTruckSave);
|
||||
Controls.Add(numericUpDownMaxFuel);
|
||||
Controls.Add(labelMaxFuel);
|
||||
Controls.Add(labelTruckBrand);
|
||||
Controls.Add(textBoxTruckNumbers);
|
||||
Controls.Add(labelTruckNumbers);
|
||||
Name = "FormTruck";
|
||||
StartPosition = FormStartPosition.CenterParent;
|
||||
Text = "Фура";
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownMaxFuel).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
private Label labelTruckBrand;
|
||||
private TextBox textBoxTruckNumbers;
|
||||
private Label labelTruckNumbers;
|
||||
private Label labelMaxFuel;
|
||||
private NumericUpDown numericUpDownMaxFuel;
|
||||
private Button buttonTruckSave;
|
||||
private Button buttonTruckCancel;
|
||||
private ComboBox comboBoxTruckType;
|
||||
}
|
||||
}
|
75
ProjectGarage/Forms/FormTruck.cs
Normal file
@ -0,0 +1,75 @@
|
||||
using ProjectGarage.Entities;
|
||||
using ProjectGarage.Entities.Enums;
|
||||
using ProjectGarage.Repositories;
|
||||
|
||||
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;
|
||||
comboBoxTruckType.SelectedItem = truck.Truck_Type;
|
||||
numericUpDownMaxFuel.Value = truck.MaxFuel;
|
||||
_truckId = value;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public FormTruck(ITruckRepository truckRepository)
|
||||
{
|
||||
InitializeComponent();
|
||||
_truckRepository = truckRepository ??
|
||||
throw new ArgumentNullException(nameof(truckRepository));
|
||||
comboBoxTruckType.DataSource = Enum.GetValues(typeof(TruckType));
|
||||
}
|
||||
|
||||
private void ButtonTruckSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(textBoxTruckNumbers.Text)
|
||||
|| comboBoxTruckType.SelectedIndex < 1)
|
||||
{
|
||||
throw new Exception("Имеются незаполненные поля");
|
||||
}
|
||||
if (_truckId.HasValue)
|
||||
{
|
||||
_truckRepository.UpdateTruck(CreateTruck(_truckId.Value));
|
||||
}
|
||||
else
|
||||
{
|
||||
_truckRepository.CreateTruck(CreateTruck(0));
|
||||
}
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonTruckCancel_Click(object sender, EventArgs e) => Close();
|
||||
|
||||
private Truck CreateTruck(int id) => Truck.CreateTruck(id, textBoxTruckNumbers.Text,
|
||||
(TruckType)comboBoxTruckType.SelectedItem!, Convert.ToInt32(numericUpDownMaxFuel.Value));
|
||||
}
|
||||
}
|
120
ProjectGarage/Forms/FormTruck.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
126
ProjectGarage/Forms/FormTrucks.Designer.cs
generated
Normal file
@ -0,0 +1,126 @@
|
||||
namespace ProjectGarage.Forms
|
||||
{
|
||||
partial class FormTrucks
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
panelFormTrucksButtons = new Panel();
|
||||
buttonUpdateTruck = new Button();
|
||||
buttonDeleteTruck = new Button();
|
||||
buttonAddTruck = new Button();
|
||||
dataGridViewTrucks = new DataGridView();
|
||||
panelFormTrucksButtons.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridViewTrucks).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// panelFormTrucksButtons
|
||||
//
|
||||
panelFormTrucksButtons.Controls.Add(buttonUpdateTruck);
|
||||
panelFormTrucksButtons.Controls.Add(buttonDeleteTruck);
|
||||
panelFormTrucksButtons.Controls.Add(buttonAddTruck);
|
||||
panelFormTrucksButtons.Dock = DockStyle.Right;
|
||||
panelFormTrucksButtons.Location = new Point(565, 0);
|
||||
panelFormTrucksButtons.Name = "panelFormTrucksButtons";
|
||||
panelFormTrucksButtons.Size = new Size(161, 360);
|
||||
panelFormTrucksButtons.TabIndex = 0;
|
||||
//
|
||||
// buttonUpdateTruck
|
||||
//
|
||||
buttonUpdateTruck.BackgroundImage = Properties.Resources.каранд;
|
||||
buttonUpdateTruck.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
buttonUpdateTruck.Location = new Point(35, 140);
|
||||
buttonUpdateTruck.Name = "buttonUpdateTruck";
|
||||
buttonUpdateTruck.Size = new Size(94, 75);
|
||||
buttonUpdateTruck.TabIndex = 2;
|
||||
buttonUpdateTruck.UseVisualStyleBackColor = true;
|
||||
buttonUpdateTruck.Click += ButtonUpdateTruck_Click;
|
||||
//
|
||||
// buttonDeleteTruck
|
||||
//
|
||||
buttonDeleteTruck.BackgroundImage = Properties.Resources.минусик;
|
||||
buttonDeleteTruck.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
buttonDeleteTruck.Location = new Point(35, 247);
|
||||
buttonDeleteTruck.Name = "buttonDeleteTruck";
|
||||
buttonDeleteTruck.Size = new Size(94, 78);
|
||||
buttonDeleteTruck.TabIndex = 1;
|
||||
buttonDeleteTruck.UseVisualStyleBackColor = true;
|
||||
buttonDeleteTruck.Click += ButtonDeleteTruck_Click;
|
||||
//
|
||||
// buttonAddTruck
|
||||
//
|
||||
buttonAddTruck.BackgroundImage = Properties.Resources.плюсик;
|
||||
buttonAddTruck.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
buttonAddTruck.Location = new Point(35, 23);
|
||||
buttonAddTruck.Name = "buttonAddTruck";
|
||||
buttonAddTruck.Size = new Size(94, 75);
|
||||
buttonAddTruck.TabIndex = 0;
|
||||
buttonAddTruck.UseVisualStyleBackColor = true;
|
||||
buttonAddTruck.Click += ButtonAddTruck_Click;
|
||||
//
|
||||
// dataGridViewTrucks
|
||||
//
|
||||
dataGridViewTrucks.AllowUserToAddRows = false;
|
||||
dataGridViewTrucks.AllowUserToDeleteRows = false;
|
||||
dataGridViewTrucks.AllowUserToResizeColumns = false;
|
||||
dataGridViewTrucks.AllowUserToResizeRows = false;
|
||||
dataGridViewTrucks.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||
dataGridViewTrucks.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridViewTrucks.Dock = DockStyle.Fill;
|
||||
dataGridViewTrucks.Location = new Point(0, 0);
|
||||
dataGridViewTrucks.Name = "dataGridViewTrucks";
|
||||
dataGridViewTrucks.ReadOnly = true;
|
||||
dataGridViewTrucks.RowHeadersVisible = false;
|
||||
dataGridViewTrucks.RowHeadersWidth = 51;
|
||||
dataGridViewTrucks.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||
dataGridViewTrucks.Size = new Size(565, 360);
|
||||
dataGridViewTrucks.TabIndex = 1;
|
||||
//
|
||||
// FormTrucks
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(726, 360);
|
||||
Controls.Add(dataGridViewTrucks);
|
||||
Controls.Add(panelFormTrucksButtons);
|
||||
Name = "FormTrucks";
|
||||
StartPosition = FormStartPosition.CenterParent;
|
||||
Text = "Фуры";
|
||||
Load += FormTrucks_Load;
|
||||
panelFormTrucksButtons.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)dataGridViewTrucks).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Panel panelFormTrucksButtons;
|
||||
private Button buttonUpdateTruck;
|
||||
private Button buttonDeleteTruck;
|
||||
private Button buttonAddTruck;
|
||||
private DataGridView dataGridViewTrucks;
|
||||
}
|
||||
}
|
110
ProjectGarage/Forms/FormTrucks.cs
Normal file
@ -0,0 +1,110 @@
|
||||
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;
|
||||
using Unity;
|
||||
|
||||
namespace ProjectGarage.Forms
|
||||
{
|
||||
public partial class FormTrucks : Form
|
||||
{
|
||||
private readonly IUnityContainer _container;
|
||||
|
||||
private readonly ITruckRepository _truckRepository;
|
||||
|
||||
public FormTrucks(IUnityContainer container, ITruckRepository truckRepository)
|
||||
{
|
||||
InitializeComponent();
|
||||
_container = container ?? throw new ArgumentNullException(nameof(container));
|
||||
_truckRepository = truckRepository ?? throw new ArgumentNullException(nameof(truckRepository));
|
||||
}
|
||||
private void FormTrucks_Load(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
LoadList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonAddTruck_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
_container.Resolve<FormTruck>().ShowDialog();
|
||||
LoadList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonDeleteTruck_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (!TryGetIDFromSelectedRow(out var findid))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
_truckRepository.DeleteTruck(findid);
|
||||
LoadList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonUpdateTruck_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (!TryGetIDFromSelectedRow(out var findid))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var form = _container.Resolve<FormTruck>();
|
||||
form.Id = findid;
|
||||
form.ShowDialog();
|
||||
LoadList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadList() => dataGridViewTrucks.DataSource = _truckRepository.ReadTrucks();
|
||||
|
||||
private bool TryGetIDFromSelectedRow(out int id)
|
||||
{
|
||||
id = 0;
|
||||
if (dataGridViewTrucks.SelectedRows.Count < 1)
|
||||
{
|
||||
MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
id = Convert.ToInt32(dataGridViewTrucks.SelectedRows[0].Cells["Id"].Value);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
120
ProjectGarage/Forms/FormTrucks.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
@ -1,3 +1,12 @@
|
||||
using ProjectGarage.Repositories;
|
||||
using ProjectGarage.Repositories.Implementations;
|
||||
using Unity.Lifetime;
|
||||
using Unity;
|
||||
using Unity.Microsoft.Logging;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Serilog;
|
||||
|
||||
namespace ProjectGarage
|
||||
{
|
||||
internal static class Program
|
||||
@ -11,7 +20,36 @@ namespace ProjectGarage
|
||||
// To customize application configuration such as set high DPI settings or default font,
|
||||
// see https://aka.ms/applicationconfiguration.
|
||||
ApplicationConfiguration.Initialize();
|
||||
Application.Run(new Form1());
|
||||
Application.Run(CreateContainer().Resolve<FormGarage>());
|
||||
}
|
||||
|
||||
private static IUnityContainer CreateContainer()
|
||||
{
|
||||
var container = new UnityContainer();
|
||||
container.AddExtension(new LoggingExtension(CreateLoggerFactory()));
|
||||
|
||||
container.RegisterType<ITruckRepository, TruckRepository>();
|
||||
container.RegisterType<IFuelRepository, FuelRepository>();
|
||||
container.RegisterType<IRouteRepository, RouteRepository>();
|
||||
container.RegisterType<IDriverRepository, DriverRepository>();
|
||||
container.RegisterType<ITransportationRepository, TransportationRepository>();
|
||||
container.RegisterType<IReplenishmentRepository, ReplenishmentRepository>();
|
||||
|
||||
container.RegisterType<IConnectionString, ConnectionString>();
|
||||
|
||||
return container;
|
||||
}
|
||||
|
||||
private static LoggerFactory CreateLoggerFactory()
|
||||
{
|
||||
var loggerFactory = new LoggerFactory();
|
||||
loggerFactory.AddSerilog(new LoggerConfiguration()
|
||||
.ReadFrom.Configuration(new ConfigurationBuilder()
|
||||
.SetBasePath(Directory.GetCurrentDirectory())
|
||||
.AddJsonFile("appsettings.json")
|
||||
.Build())
|
||||
.CreateLogger());
|
||||
return loggerFactory;
|
||||
}
|
||||
}
|
||||
}
|
@ -8,4 +8,41 @@
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Dapper" Version="2.1.35" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="9.0.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="Npgsql" Version="9.0.1" />
|
||||
<PackageReference Include="Serilog" Version="4.0.2" />
|
||||
<PackageReference Include="Serilog.Extensions.Logging" Version="8.0.0" />
|
||||
<PackageReference Include="Serilog.Settings.Configuration" Version="8.0.4" />
|
||||
<PackageReference Include="Serilog.Sinks.File" Version="6.0.0" />
|
||||
<PackageReference Include="System.Data.SqlClient" Version="4.9.0" />
|
||||
<PackageReference Include="Unity" Version="5.11.10" />
|
||||
<PackageReference Include="Unity.Microsoft.Logging" Version="5.11.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Update="Properties\Resources.Designer.cs">
|
||||
<DesignTime>True</DesignTime>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Update="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="appsettings.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
93
ProjectGarage/Properties/Resources.Designer.cs
generated
Normal file
@ -0,0 +1,93 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// Этот код создан программой.
|
||||
// Исполняемая версия:4.0.30319.42000
|
||||
//
|
||||
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
|
||||
// повторной генерации кода.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace ProjectGarage.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д.
|
||||
/// </summary>
|
||||
// Этот класс создан автоматически классом StronglyTypedResourceBuilder
|
||||
// с помощью такого средства, как ResGen или Visual Studio.
|
||||
// Чтобы добавить или удалить член, измените файл .ResX и снова запустите ResGen
|
||||
// с параметром /str или перестройте свой проект VS.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ProjectGarage.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Перезаписывает свойство CurrentUICulture текущего потока для всех
|
||||
/// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap каранд {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("каранд", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap минусик {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("минусик", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap плюсик {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("плюсик", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
130
ProjectGarage/Properties/Resources.resx
Normal file
@ -0,0 +1,130 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="минусик" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\минусик.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="плюсик" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\плюсик.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="каранд" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\каранд.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
</root>
|
12
ProjectGarage/Repositories/IConnectionString.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectGarage.Repositories;
|
||||
|
||||
public interface IConnectionString
|
||||
{
|
||||
public string ConnectionString { get; }
|
||||
}
|
21
ProjectGarage/Repositories/IDriverRepository.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using ProjectGarage.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectGarage.Repositories;
|
||||
|
||||
public interface IDriverRepository
|
||||
{
|
||||
IEnumerable<Driver> ReadDrivers();
|
||||
|
||||
Driver ReadDriverByID(int id);
|
||||
|
||||
void CreateDriver(Driver driver);
|
||||
|
||||
void UpdateDriver(Driver driver);
|
||||
|
||||
void DeleteDriver(int id);
|
||||
}
|
21
ProjectGarage/Repositories/IFuelRepository.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using ProjectGarage.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectGarage.Repositories;
|
||||
|
||||
public interface IFuelRepository
|
||||
{
|
||||
IEnumerable<Fuel> ReadFuels();
|
||||
|
||||
Fuel ReadFuelByID(int id);
|
||||
|
||||
void CreateFuel(Fuel fuel);
|
||||
|
||||
void UpdateFuel(Fuel fuel);
|
||||
|
||||
void DeleteFuel(int id);
|
||||
}
|
17
ProjectGarage/Repositories/IReplenishmentRepository.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using ProjectGarage.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectGarage.Repositories;
|
||||
|
||||
public interface IReplenishmentRepository
|
||||
{
|
||||
IEnumerable<FuelReplenishment> ReadFuelReplenishment(DateTime? dateForm = null, DateTime? dateTo = null, int? fuelId = null,
|
||||
int? driverId = null, int? routeId = null);
|
||||
void CreateFuelReplenishment(FuelReplenishment fuelReplenishment);
|
||||
|
||||
void DeleteFuelReplenishment(int id);
|
||||
}
|
21
ProjectGarage/Repositories/IRouteRepository.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using ProjectGarage.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectGarage.Repositories;
|
||||
|
||||
public interface IRouteRepository
|
||||
{
|
||||
IEnumerable<Route> ReadRoute(string? startPoint = null,string? finalPoint = null);
|
||||
|
||||
Route ReadRouteByID(int id);
|
||||
|
||||
void CreateRoute(Route route);
|
||||
|
||||
void UpdateRoute(Route route);
|
||||
|
||||
void DeleteRoute(int id);
|
||||
}
|
15
ProjectGarage/Repositories/ITransportationRepository.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using ProjectGarage.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectGarage.Repositories;
|
||||
|
||||
public interface ITransportationRepository
|
||||
{
|
||||
IEnumerable<Transportation> ReadTransportation(DateTime? dateForm = null, DateTime? dateTo = null, int? fuelId = null,
|
||||
int? driverId = null, int? routeId = null);
|
||||
void CreateTransportation(Transportation transportation);
|
||||
}
|
21
ProjectGarage/Repositories/ITruckRepository.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using ProjectGarage.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectGarage.Repositories;
|
||||
|
||||
public interface ITruckRepository
|
||||
{
|
||||
IEnumerable<Truck> ReadTrucks();
|
||||
|
||||
Truck ReadTruckByID(int id);
|
||||
|
||||
void CreateTruck(Truck truck);
|
||||
|
||||
void UpdateTruck(Truck truck);
|
||||
|
||||
void DeleteTruck(int id);
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectGarage.Repositories.Implementations;
|
||||
|
||||
public class ConnectionString : IConnectionString
|
||||
{
|
||||
string IConnectionString.ConnectionString => "Host=localhost;Port=5432;Username=postgres;Password=postgres;Database=garage";
|
||||
}
|
131
ProjectGarage/Repositories/Implementations/DriverRepository.cs
Normal file
@ -0,0 +1,131 @@
|
||||
using Dapper;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json;
|
||||
using Npgsql;
|
||||
using ProjectGarage.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectGarage.Repositories.Implementations;
|
||||
|
||||
public class DriverRepository : IDriverRepository
|
||||
{
|
||||
public readonly IConnectionString _connectionString;
|
||||
|
||||
private readonly ILogger<DriverRepository> _logger;
|
||||
|
||||
public DriverRepository(IConnectionString connectionString, ILogger<DriverRepository> logger)
|
||||
{
|
||||
_connectionString = connectionString;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public void CreateDriver(Driver driver)
|
||||
{
|
||||
_logger.LogInformation("Добавление объект");
|
||||
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(driver));
|
||||
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var queryInsert = @"
|
||||
INSERT INTO driver (Fname, Lname, TruckId) VALUES
|
||||
(@Fname, @Lname, @TruckId);";
|
||||
connection.Execute(queryInsert, driver);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при добавлении объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateDriver(Driver driver)
|
||||
{
|
||||
_logger.LogInformation("Редактирование объекта");
|
||||
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(driver));
|
||||
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var queryUpdate = @"
|
||||
UPDATE driver
|
||||
SET
|
||||
Fname=@Fname,
|
||||
Lname=@Lname,
|
||||
TruckId=@TruckId
|
||||
WHERE Id=@Id";
|
||||
connection.Execute(queryUpdate, driver);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при редактировании объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public void DeleteDriver(int id)
|
||||
{
|
||||
_logger.LogInformation("Удаление объекта");
|
||||
_logger.LogDebug("Объект: {id}", id);
|
||||
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var queryDelete = @"
|
||||
DELETE FROM driver
|
||||
WHERE Id=@id";
|
||||
connection.Execute(queryDelete, new { id });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при удалении объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public Driver ReadDriverByID(int id)
|
||||
{
|
||||
_logger.LogInformation("Получение объекта по идентификатору");
|
||||
_logger.LogDebug("Объект: {id}", id);
|
||||
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var querySelect = @"
|
||||
SELECT * FROM driver
|
||||
WHERE Id=@id";
|
||||
var driver = connection.QueryFirst<Driver>(querySelect, new { id });
|
||||
_logger.LogDebug("Найденный объект: {json}", JsonConvert.SerializeObject(driver));
|
||||
|
||||
return driver;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при поиске объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<Driver> ReadDrivers()
|
||||
{
|
||||
_logger.LogInformation("Получение всех объектов");
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var querySelect = @"SELECT * FROM driver";
|
||||
var drivers = connection.Query<Driver>(querySelect);
|
||||
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(drivers));
|
||||
return drivers;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при чтении объектов");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
129
ProjectGarage/Repositories/Implementations/FuelRepository.cs
Normal file
@ -0,0 +1,129 @@
|
||||
using Dapper;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json;
|
||||
using Npgsql;
|
||||
using ProjectGarage.Entities;
|
||||
using ProjectGarage.Entities.Enums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectGarage.Repositories.Implementations;
|
||||
|
||||
public class FuelRepository : IFuelRepository
|
||||
{
|
||||
public readonly IConnectionString _connectionString;
|
||||
|
||||
private readonly ILogger<FuelRepository> _logger;
|
||||
|
||||
public FuelRepository(IConnectionString connectionString, ILogger<FuelRepository> logger)
|
||||
{
|
||||
_connectionString = connectionString;
|
||||
_logger = logger;
|
||||
}
|
||||
public void CreateFuel(Fuel fuel)
|
||||
{
|
||||
_logger.LogInformation("Добавление объект");
|
||||
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(fuel));
|
||||
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var queryInsert = @"
|
||||
INSERT INTO fuel (FuelName, FuelType, Price) VALUES
|
||||
(@FuelName, @FuelType, @Price);";
|
||||
connection.Execute(queryInsert, fuel);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при добавлении объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
public void UpdateFuel(Fuel fuel)
|
||||
{
|
||||
_logger.LogInformation("Редактирование объекта");
|
||||
_logger.LogDebug("Объект: {json}",
|
||||
JsonConvert.SerializeObject(fuel));
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var queryUpdate = @"
|
||||
UPDATE fuel
|
||||
SET
|
||||
FuelName=@FuelName,
|
||||
FuelType=@FuelType,
|
||||
Price=@Price
|
||||
WHERE Id=@Id";
|
||||
connection.Execute(queryUpdate, fuel);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при редактировании объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public void DeleteFuel(int id)
|
||||
{
|
||||
_logger.LogInformation("Удаление объекта");
|
||||
_logger.LogDebug("Объект: {id}", id);
|
||||
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var queryDelete = @"
|
||||
DELETE FROM fuel
|
||||
WHERE Id=@id";
|
||||
connection.Execute(queryDelete, new { id });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при удалении объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public Fuel ReadFuelByID(int id)
|
||||
{
|
||||
_logger.LogInformation("Получение объекта по идентификатору");
|
||||
_logger.LogDebug("Объект: {id}", id);
|
||||
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var querySelect = @"
|
||||
SELECT * FROM fuel
|
||||
WHERE Id=@id";
|
||||
var fuel = connection.QueryFirst<Fuel>(querySelect, new { id });
|
||||
_logger.LogDebug("Найденный объект: {json}", JsonConvert.SerializeObject(fuel));
|
||||
|
||||
return fuel;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при поиске объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<Fuel> ReadFuels()
|
||||
{
|
||||
_logger.LogInformation("Получение всех объектов");
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var querySelect = @"SELECT * FROM fuel";
|
||||
var fuels = connection.Query<Fuel>(querySelect);
|
||||
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(fuels));
|
||||
return fuels;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при чтении объектов");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,101 @@
|
||||
using Dapper;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json;
|
||||
using Npgsql;
|
||||
using ProjectGarage.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectGarage.Repositories.Implementations;
|
||||
|
||||
public class ReplenishmentRepository : IReplenishmentRepository
|
||||
{
|
||||
private readonly IConnectionString _connectionString;
|
||||
|
||||
private readonly ILogger<ReplenishmentRepository> _logger;
|
||||
|
||||
public ReplenishmentRepository(IConnectionString connectionString, ILogger<ReplenishmentRepository> logger)
|
||||
{
|
||||
_connectionString = connectionString;
|
||||
_logger = logger;
|
||||
}
|
||||
public void CreateFuelReplenishment(FuelReplenishment replenishment)
|
||||
{
|
||||
_logger.LogInformation("Добавление объекта");
|
||||
_logger.LogDebug("Объект: {json}",
|
||||
JsonConvert.SerializeObject(replenishment));
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
connection.Open();
|
||||
using var transaction = connection.BeginTransaction();
|
||||
var queryInsert = @"
|
||||
INSERT INTO fuelreplenishment (DriverId, ReplenishmentDate)
|
||||
VALUES (@DriverId, @ReplenishmentDate);
|
||||
SELECT MAX(Id) FROM fuelreplenishment";
|
||||
var ReplenishmentId = connection.QueryFirst<int>(queryInsert, replenishment, transaction);
|
||||
var querySubInsert = @"
|
||||
INSERT INTO fuel_fuelreplenishment (ReplenishmentId, FuelId, Amount)
|
||||
VALUES (@ReplenishmentId, @FuelId, @Amount)";
|
||||
foreach (var elem in replenishment.FuelFuelReplenishments)
|
||||
{
|
||||
connection.Execute(querySubInsert, new
|
||||
{
|
||||
ReplenishmentId,
|
||||
elem.FuelId,
|
||||
elem.Amount
|
||||
}, transaction);
|
||||
}
|
||||
transaction.Commit();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при добавлении объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public void DeleteFuelReplenishment(int id)
|
||||
{
|
||||
_logger.LogInformation("Удаление объекта");
|
||||
_logger.LogDebug("Объект: {id}", id);
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var queryDelete = @"
|
||||
DELETE FROM fuelreplenishment
|
||||
WHERE Id=@id";
|
||||
connection.Execute(queryDelete, new { id });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при удалении объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<FuelReplenishment> ReadFuelReplenishment(DateTime? dateForm = null,
|
||||
DateTime? dateTo = null, int? fuelId = null, int? driverId = null, int? routeId = null)
|
||||
{
|
||||
_logger.LogInformation("Получение всех объектов");
|
||||
try
|
||||
{
|
||||
using var connection = new
|
||||
NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var querySelect = @"SELECT * FROM fuelreplenishment";
|
||||
var replenishments = connection.Query<FuelReplenishment>(querySelect);
|
||||
_logger.LogDebug("Полученные объекты: {json}",
|
||||
JsonConvert.SerializeObject(replenishments));
|
||||
return replenishments;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при чтении объектов");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
129
ProjectGarage/Repositories/Implementations/RouteRepository.cs
Normal file
@ -0,0 +1,129 @@
|
||||
using Dapper;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json;
|
||||
using Npgsql;
|
||||
using ProjectGarage.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectGarage.Repositories.Implementations;
|
||||
|
||||
public class RouteRepository : IRouteRepository
|
||||
{
|
||||
public readonly IConnectionString _connectionString;
|
||||
|
||||
private readonly ILogger<RouteRepository> _logger;
|
||||
|
||||
public RouteRepository(IConnectionString connectionString, ILogger<RouteRepository> logger)
|
||||
{
|
||||
_connectionString = connectionString;
|
||||
_logger = logger;
|
||||
}
|
||||
public void CreateRoute(Route route)
|
||||
{
|
||||
_logger.LogInformation("Добавление объект");
|
||||
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(route));
|
||||
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var queryInsert = @"
|
||||
INSERT INTO route (RouteName, Startp, Finalp, Length) VALUES
|
||||
(@RouteName, @Startp, @Finalp, @Length);";
|
||||
connection.Execute(queryInsert, route);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при добавлении объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
public void UpdateRoute(Route route)
|
||||
{
|
||||
_logger.LogInformation("Редактирование объекта");
|
||||
_logger.LogDebug("Объект: {json}",
|
||||
JsonConvert.SerializeObject(route));
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var queryUpdate = @"
|
||||
UPDATE route
|
||||
SET
|
||||
RouteName=@RouteName,
|
||||
Startp=@Startp,
|
||||
Finalp=@Finalp,
|
||||
Length=@Length
|
||||
WHERE Id=@Id";
|
||||
connection.Execute(queryUpdate, route);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при редактировании объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public void DeleteRoute(int id)
|
||||
{
|
||||
_logger.LogInformation("Удаление объекта");
|
||||
_logger.LogDebug("Объект: {id}", id);
|
||||
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var queryDelete = @"
|
||||
DELETE FROM route
|
||||
WHERE Id=@id";
|
||||
connection.Execute(queryDelete, new { id });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при удалении объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public Route ReadRouteByID(int id)
|
||||
{
|
||||
_logger.LogInformation("Получение объекта по идентификатору");
|
||||
_logger.LogDebug("Объект: {id}", id);
|
||||
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var querySelect = @"
|
||||
SELECT * FROM route
|
||||
WHERE Id=@id";
|
||||
var route = connection.QueryFirst<Route>(querySelect, new { id });
|
||||
_logger.LogDebug("Найденный объект: {json}", JsonConvert.SerializeObject(route));
|
||||
|
||||
return route;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при поиске объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<Route> ReadRoute(string? startPoint = null, string? finalPoint = null)
|
||||
{
|
||||
_logger.LogInformation("Получение всех объектов");
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var querySelect = @"SELECT * FROM route";
|
||||
var routes = connection.Query<Route>(querySelect);
|
||||
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(routes));
|
||||
return routes;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при чтении объектов");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
using Dapper;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json;
|
||||
using Npgsql;
|
||||
using ProjectGarage.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectGarage.Repositories.Implementations;
|
||||
|
||||
public class TransportationRepository : ITransportationRepository
|
||||
{
|
||||
private readonly IConnectionString _connectionString;
|
||||
|
||||
private readonly ILogger<TransportationRepository> _logger;
|
||||
|
||||
public TransportationRepository(IConnectionString connectionString, ILogger<TransportationRepository> logger)
|
||||
{
|
||||
_connectionString = connectionString;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public void CreateTransportation(Transportation transportation)
|
||||
{
|
||||
_logger.LogInformation("Добавление объекта");
|
||||
_logger.LogDebug("Объект: {json}",
|
||||
JsonConvert.SerializeObject(transportation));
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var queryInsert = @"
|
||||
INSERT INTO transportation (DriverId, RouteId, FuelId, Amount, TransportationDate)
|
||||
VALUES (@DriverId, @RouteId, @FuelId, @Amount, @TransportationDate)";
|
||||
connection.Execute(queryInsert, transportation);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при добавлении объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<Transportation> ReadTransportation(DateTime? dateForm = null, DateTime? dateTo = null,
|
||||
int? fuelId = null, int? driverId = null, int? routeId = null)
|
||||
{
|
||||
_logger.LogInformation("Получение всех объектов");
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var querySelect = "SELECT * FROM transportation";
|
||||
var transportations = connection.Query<Transportation>(querySelect);
|
||||
_logger.LogDebug("Полученные объекты: {json}",
|
||||
JsonConvert.SerializeObject(transportations));
|
||||
return transportations;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при чтении объектов");
|
||||
throw;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
130
ProjectGarage/Repositories/Implementations/TruckRepository.cs
Normal file
@ -0,0 +1,130 @@
|
||||
using Dapper;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json;
|
||||
using Npgsql;
|
||||
using ProjectGarage.Entities;
|
||||
using ProjectGarage.Entities.Enums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectGarage.Repositories.Implementations;
|
||||
|
||||
public class TruckRepository : ITruckRepository
|
||||
{
|
||||
public readonly IConnectionString _connectionString;
|
||||
|
||||
private readonly ILogger<TruckRepository> _logger;
|
||||
|
||||
public TruckRepository(IConnectionString connectionString, ILogger<TruckRepository> logger)
|
||||
{
|
||||
_connectionString = connectionString;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public void CreateTruck(Truck truck)
|
||||
{
|
||||
_logger.LogInformation("Добавление объект");
|
||||
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(truck));
|
||||
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var queryInsert = @"
|
||||
INSERT INTO truck (Numbers, Truck_Type, MaxFuel) VALUES
|
||||
(@Numbers, @Truck_Type, @MaxFuel);";
|
||||
connection.Execute(queryInsert, truck);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при добавлении объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
public void UpdateTruck(Truck truck)
|
||||
{
|
||||
_logger.LogInformation("Редактирование объекта");
|
||||
_logger.LogDebug("Объект: {json}",
|
||||
JsonConvert.SerializeObject(truck));
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var queryUpdate = @"
|
||||
UPDATE truck
|
||||
SET
|
||||
Numbers=@Numbers,
|
||||
Truck_Type=@Truck_Type,
|
||||
MaxFuel=@MaxFuel
|
||||
WHERE Id=@Id";
|
||||
connection.Execute(queryUpdate, truck);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при редактировании объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public void DeleteTruck(int id)
|
||||
{
|
||||
_logger.LogInformation("Удаление объекта");
|
||||
_logger.LogDebug("Объект: {id}", id);
|
||||
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var queryDelete = @"
|
||||
DELETE FROM truck
|
||||
WHERE Id=@id";
|
||||
connection.Execute(queryDelete, new { id });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при удалении объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public Truck ReadTruckByID(int id)
|
||||
{
|
||||
_logger.LogInformation("Получение объекта по идентификатору");
|
||||
_logger.LogDebug("Объект: {id}", id);
|
||||
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var querySelect = @"
|
||||
SELECT * FROM truck
|
||||
WHERE Id=@id";
|
||||
var truck = connection.QueryFirst<Truck>(querySelect, new { id });
|
||||
_logger.LogDebug("Найденный объект: {json}", JsonConvert.SerializeObject(truck));
|
||||
|
||||
return truck;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при поиске объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<Truck> ReadTrucks()
|
||||
{
|
||||
_logger.LogInformation("Получение всех объектов");
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var querySelect = @"SELECT * FROM truck";
|
||||
var trucks = connection.Query<Truck>(querySelect);
|
||||
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(trucks));
|
||||
return trucks;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при чтении объектов");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
BIN
ProjectGarage/Resources/каранд.jpg
Normal file
After Width: | Height: | Size: 30 KiB |
BIN
ProjectGarage/Resources/минусик.jpg
Normal file
After Width: | Height: | Size: 32 KiB |
BIN
ProjectGarage/Resources/плюсик.jpg
Normal file
After Width: | Height: | Size: 35 KiB |
15
ProjectGarage/appsettings.json
Normal file
@ -0,0 +1,15 @@
|
||||
{
|
||||
"Serilog": {
|
||||
"Using": [ "Serilog.Sinks.File" ],
|
||||
"MinimumLevel": "Debug",
|
||||
"WriteTo": [
|
||||
{
|
||||
"Name": "File",
|
||||
"Args": {
|
||||
"path": "Logs/garage.txt",
|
||||
"rollingInterval": "Day"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
BIN
каранд.jpg
Normal file
After Width: | Height: | Size: 30 KiB |
BIN
минусик.jpg
Normal file
After Width: | Height: | Size: 32 KiB |
BIN
плюсик.jpg
Normal file
After Width: | Height: | Size: 35 KiB |
BIN
филмор1.jpg
Normal file
After Width: | Height: | Size: 61 KiB |