почти все
This commit is contained in:
parent
6694e9c4a7
commit
ad64ab16c4
@ -17,9 +17,9 @@ public class Driver
|
|||||||
|
|
||||||
public string Phone_Number { get;private set; } = string.Empty;
|
public string Phone_Number { get;private set; } = string.Empty;
|
||||||
|
|
||||||
public int TruckID { get; set; }
|
public int TruckId { get;private set; }
|
||||||
|
|
||||||
public static Driver CreateDriver(int id, string fname, string lname ,string phone_num, int truck_id)
|
public static Driver CreateDriver(int id, string fname, string lname ,string phone_num, int tryckid)
|
||||||
{
|
{
|
||||||
return new Driver
|
return new Driver
|
||||||
{
|
{
|
||||||
@ -27,7 +27,7 @@ public class Driver
|
|||||||
First_name = fname,
|
First_name = fname,
|
||||||
Last_name = lname,
|
Last_name = lname,
|
||||||
Phone_Number = phone_num ?? string.Empty,
|
Phone_Number = phone_num ?? string.Empty,
|
||||||
TruckID = truck_id
|
TruckId = tryckid
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
18
ProjectGarage/Entities/Enums/TruckType.cs
Normal file
18
ProjectGarage/Entities/Enums/TruckType.cs
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
@ -20,7 +20,7 @@ public class Transportation
|
|||||||
|
|
||||||
public DateTime TransportationDate { get; set; }
|
public DateTime TransportationDate { get; set; }
|
||||||
|
|
||||||
public Transportation CreateTransportation(int id, int fuel_id, int route_id, int driver_id, int amount)
|
public static Transportation CreateTransportation(int id, int fuel_id, int route_id, int driver_id, int amount)
|
||||||
{
|
{
|
||||||
return new Transportation
|
return new Transportation
|
||||||
{
|
{
|
||||||
|
@ -13,24 +13,18 @@ public class Truck
|
|||||||
|
|
||||||
public string Numbers { get; private set; } = string.Empty;
|
public string Numbers { get; private set; } = string.Empty;
|
||||||
|
|
||||||
public string Brand { get; private set; } = string.Empty;
|
public TruckType Type { get; set; }
|
||||||
|
|
||||||
public string Model { get; private set; } = string.Empty;
|
|
||||||
|
|
||||||
public int MaxFuel { get; private set; }
|
public int MaxFuel { get; private set; }
|
||||||
|
|
||||||
public bool HasDriver { get; private set; }
|
public static Truck CreateTruck(int id,string numbers, TruckType type, int maxFuel)
|
||||||
|
|
||||||
public static Truck CreateTruck(int id,string numbers, string brand, string model, int maxFuel)
|
|
||||||
{
|
{
|
||||||
return new Truck()
|
return new Truck()
|
||||||
{
|
{
|
||||||
Id = id,
|
Id = id,
|
||||||
Numbers = numbers,
|
Numbers = numbers,
|
||||||
Brand = brand,
|
Type = type,
|
||||||
Model = model,
|
MaxFuel = maxFuel
|
||||||
MaxFuel = maxFuel,
|
|
||||||
HasDriver = false
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
2
ProjectGarage/Forms/FormDriver.Designer.cs
generated
2
ProjectGarage/Forms/FormDriver.Designer.cs
generated
@ -124,7 +124,7 @@
|
|||||||
comboBoxTruckID.FormattingEnabled = true;
|
comboBoxTruckID.FormattingEnabled = true;
|
||||||
comboBoxTruckID.Location = new Point(120, 156);
|
comboBoxTruckID.Location = new Point(120, 156);
|
||||||
comboBoxTruckID.Name = "comboBoxTruckID";
|
comboBoxTruckID.Name = "comboBoxTruckID";
|
||||||
comboBoxTruckID.Size = new Size(151, 28);
|
comboBoxTruckID.Size = new Size(183, 28);
|
||||||
comboBoxTruckID.TabIndex = 10;
|
comboBoxTruckID.TabIndex = 10;
|
||||||
//
|
//
|
||||||
// FormDriver
|
// FormDriver
|
||||||
|
@ -33,7 +33,7 @@ namespace ProjectGarage.Forms
|
|||||||
}
|
}
|
||||||
textBoxFirstName.Text = driver.First_name;
|
textBoxFirstName.Text = driver.First_name;
|
||||||
textBoxLastName.Text = driver.Last_name;
|
textBoxLastName.Text = driver.Last_name;
|
||||||
comboBoxTruckID.SelectedItem = driver.Id;//TODO НЕ ЗАБУДЬ
|
//comboBoxTruckID.SelectedItem = driver.TruckId;
|
||||||
_driverId = value;
|
_driverId = value;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -44,12 +44,13 @@ namespace ProjectGarage.Forms
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public FormDriver(IDriverRepository driverRepository)
|
public FormDriver(IDriverRepository driverRepository, ITruckRepository truckRepository)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_driverRepository = driverRepository ?? throw new ArgumentNullException(nameof(driverRepository));
|
_driverRepository = driverRepository ?? throw new ArgumentNullException(nameof(driverRepository));
|
||||||
comboBoxTruckID.DataSource = Enum.GetValues(typeof(FuelType));//TODO НЕ ЗАБУДЬ
|
comboBoxTruckID.DataSource = truckRepository.ReadTrucks();//
|
||||||
|
comboBoxTruckID.DisplayMember = "Numbers";
|
||||||
|
comboBoxTruckID.ValueMember = "Id";
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ButtonSaveDriver_Click(object sender, EventArgs e)
|
private void ButtonSaveDriver_Click(object sender, EventArgs e)
|
||||||
@ -57,7 +58,7 @@ namespace ProjectGarage.Forms
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(textBoxFirstName.Text) || string.IsNullOrWhiteSpace(textBoxLastName.Text)
|
if (string.IsNullOrWhiteSpace(textBoxFirstName.Text) || string.IsNullOrWhiteSpace(textBoxLastName.Text)
|
||||||
|| comboBoxTruckID.SelectedIndex < 1)//TODO НЕ ЗАБУДЬ
|
|| comboBoxTruckID.SelectedIndex < 0)//
|
||||||
{
|
{
|
||||||
throw new Exception("Имеются незаполненные поля");
|
throw new Exception("Имеются незаполненные поля");
|
||||||
}
|
}
|
||||||
@ -78,14 +79,9 @@ namespace ProjectGarage.Forms
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ButtonCancelDriver_Click(object sender, EventArgs e) => Close();
|
||||||
private void ButtonCancelDriver_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private Driver CreateDriver(int id) => Driver.CreateDriver(id, textBoxFirstName.Text,
|
private Driver CreateDriver(int id) => Driver.CreateDriver(id, textBoxFirstName.Text,
|
||||||
textBoxLastName.Text, textBoxPhoneNum.Text, (int)(FuelType)comboBoxTruckID.SelectedItem!);//TODO НЕ ЗАБУДЬ
|
textBoxLastName.Text, textBoxPhoneNum.Text, (int)comboBoxTruckID.SelectedIndex!);//
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
125
ProjectGarage/Forms/FormDrivers.Designer.cs
generated
Normal file
125
ProjectGarage/Forms/FormDrivers.Designer.cs
generated
Normal file
@ -0,0 +1,125 @@
|
|||||||
|
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(639, 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(639, 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(800, 367);
|
||||||
|
Controls.Add(dataGridViewDrivers);
|
||||||
|
Controls.Add(panelFormDriversButtons);
|
||||||
|
Name = "FormDrivers";
|
||||||
|
Text = "FormDrivers";
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
114
ProjectGarage/Forms/FormDrivers.cs
Normal file
114
ProjectGarage/Forms/FormDrivers.cs
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
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
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
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;
|
||||||
|
}
|
||||||
|
}
|
104
ProjectGarage/Forms/FormFuel.cs
Normal file
104
ProjectGarage/Forms/FormFuel.cs
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
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.Type) != 0)
|
||||||
|
{
|
||||||
|
checkedListBoxFuel.SetItemChecked(checkedListBoxFuel.Items.IndexOf(elem), true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
textBoxFuelName.Text = fuel.Name;
|
||||||
|
_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
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
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
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
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>
|
143
ProjectGarage/Forms/FormRoute.Designer.cs
generated
Normal file
143
ProjectGarage/Forms/FormRoute.Designer.cs
generated
Normal file
@ -0,0 +1,143 @@
|
|||||||
|
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();
|
||||||
|
((System.ComponentModel.ISupportInitialize)numericUpDownRouteLen).BeginInit();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// labelRouteStart
|
||||||
|
//
|
||||||
|
labelRouteStart.AutoSize = true;
|
||||||
|
labelRouteStart.Location = new Point(12, 20);
|
||||||
|
labelRouteStart.Name = "labelRouteStart";
|
||||||
|
labelRouteStart.Size = new Size(135, 20);
|
||||||
|
labelRouteStart.TabIndex = 0;
|
||||||
|
labelRouteStart.Text = "Начало маршрута";
|
||||||
|
//
|
||||||
|
// labelRouteFinal
|
||||||
|
//
|
||||||
|
labelRouteFinal.AutoSize = true;
|
||||||
|
labelRouteFinal.Location = new Point(12, 62);
|
||||||
|
labelRouteFinal.Name = "labelRouteFinal";
|
||||||
|
labelRouteFinal.Size = new Size(127, 20);
|
||||||
|
labelRouteFinal.TabIndex = 1;
|
||||||
|
labelRouteFinal.Text = "Конец маршрута";
|
||||||
|
//
|
||||||
|
// numericUpDownRouteLen
|
||||||
|
//
|
||||||
|
numericUpDownRouteLen.Location = new Point(160, 103);
|
||||||
|
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(12, 103);
|
||||||
|
labelRouteLen.Name = "labelRouteLen";
|
||||||
|
labelRouteLen.Size = new Size(127, 20);
|
||||||
|
labelRouteLen.TabIndex = 3;
|
||||||
|
labelRouteLen.Text = "Длина маршрута";
|
||||||
|
//
|
||||||
|
// buttonRouteSave
|
||||||
|
//
|
||||||
|
buttonRouteSave.Location = new Point(12, 149);
|
||||||
|
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(160, 149);
|
||||||
|
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(160, 20);
|
||||||
|
textBoxRouteStart.Name = "textBoxRouteStart";
|
||||||
|
textBoxRouteStart.Size = new Size(150, 27);
|
||||||
|
textBoxRouteStart.TabIndex = 6;
|
||||||
|
//
|
||||||
|
// textBoxRouteFinal
|
||||||
|
//
|
||||||
|
textBoxRouteFinal.Location = new Point(160, 62);
|
||||||
|
textBoxRouteFinal.Name = "textBoxRouteFinal";
|
||||||
|
textBoxRouteFinal.Size = new Size(150, 27);
|
||||||
|
textBoxRouteFinal.TabIndex = 7;
|
||||||
|
//
|
||||||
|
// FormRoute
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(332, 199);
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
85
ProjectGarage/Forms/FormRoute.cs
Normal file
85
ProjectGarage/Forms/FormRoute.cs
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
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));
|
||||||
|
}
|
||||||
|
|
||||||
|
textBoxRouteStart.Text = route.StartPoint;
|
||||||
|
textBoxRouteFinal.Text = route.FinalPoint;
|
||||||
|
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, textBoxRouteStart.Text,
|
||||||
|
textBoxRouteFinal.Text, Convert.ToInt32(numericUpDownRouteLen.Value));
|
||||||
|
}
|
||||||
|
}
|
120
ProjectGarage/Forms/FormRoute.resx
Normal file
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>
|
124
ProjectGarage/Forms/FormRoutes.Designer.cs
generated
Normal file
124
ProjectGarage/Forms/FormRoutes.Designer.cs
generated
Normal file
@ -0,0 +1,124 @@
|
|||||||
|
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";
|
||||||
|
((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;
|
||||||
|
}
|
||||||
|
}
|
91
ProjectGarage/Forms/FormRoutes.cs
Normal file
91
ProjectGarage/Forms/FormRoutes.cs
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
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
|
||||||
|
{
|
||||||
|
LoadList();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка при загрузке",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonUpdateRoute_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_container.Resolve<FormRoute>().ShowDialog();
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
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
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
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
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 = "First_name";
|
||||||
|
comboBoxDriver.ValueMember = "Id";
|
||||||
|
|
||||||
|
comboBoxFuel.DataSource = fuelRepository.ReadFuels();
|
||||||
|
comboBoxFuel.DisplayMember = "Name";
|
||||||
|
comboBoxFuel.ValueMember = "Id";
|
||||||
|
|
||||||
|
comboBoxRoute.DataSource = routeRepository.ReadRoute();
|
||||||
|
comboBoxRoute.DisplayMember = "Name";
|
||||||
|
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
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>
|
96
ProjectGarage/Forms/FormTransportations.Designer.cs
generated
Normal file
96
ProjectGarage/Forms/FormTransportations.Designer.cs
generated
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
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(639, 450);
|
||||||
|
dataGridViewTransportations.TabIndex = 7;
|
||||||
|
//
|
||||||
|
// panelFormTransportationsButtons
|
||||||
|
//
|
||||||
|
panelFormTransportationsButtons.Controls.Add(buttonAddTransportation);
|
||||||
|
panelFormTransportationsButtons.Dock = DockStyle.Right;
|
||||||
|
panelFormTransportationsButtons.Location = new Point(639, 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(800, 450);
|
||||||
|
Controls.Add(dataGridViewTransportations);
|
||||||
|
Controls.Add(panelFormTransportationsButtons);
|
||||||
|
Name = "FormTransportations";
|
||||||
|
Text = "FormTransportations";
|
||||||
|
((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
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<FormTransportations>().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
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>
|
57
ProjectGarage/Forms/FormTruck.Designer.cs
generated
57
ProjectGarage/Forms/FormTruck.Designer.cs
generated
@ -28,9 +28,6 @@
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
textBoxTruckModel = new TextBox();
|
|
||||||
labelTruckModel = new Label();
|
|
||||||
textBoxTruckBrand = new TextBox();
|
|
||||||
labelTruckBrand = new Label();
|
labelTruckBrand = new Label();
|
||||||
textBoxTruckNumbers = new TextBox();
|
textBoxTruckNumbers = new TextBox();
|
||||||
labelTruckNumbers = new Label();
|
labelTruckNumbers = new Label();
|
||||||
@ -38,32 +35,10 @@
|
|||||||
numericUpDownMaxFuel = new NumericUpDown();
|
numericUpDownMaxFuel = new NumericUpDown();
|
||||||
buttonTruckSave = new Button();
|
buttonTruckSave = new Button();
|
||||||
buttonTruckCancel = new Button();
|
buttonTruckCancel = new Button();
|
||||||
|
comboBoxTruckType = new ComboBox();
|
||||||
((System.ComponentModel.ISupportInitialize)numericUpDownMaxFuel).BeginInit();
|
((System.ComponentModel.ISupportInitialize)numericUpDownMaxFuel).BeginInit();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
// textBoxTruckModel
|
|
||||||
//
|
|
||||||
textBoxTruckModel.Location = new Point(158, 114);
|
|
||||||
textBoxTruckModel.Name = "textBoxTruckModel";
|
|
||||||
textBoxTruckModel.Size = new Size(183, 27);
|
|
||||||
textBoxTruckModel.TabIndex = 13;
|
|
||||||
//
|
|
||||||
// labelTruckModel
|
|
||||||
//
|
|
||||||
labelTruckModel.AutoSize = true;
|
|
||||||
labelTruckModel.Location = new Point(43, 121);
|
|
||||||
labelTruckModel.Name = "labelTruckModel";
|
|
||||||
labelTruckModel.Size = new Size(63, 20);
|
|
||||||
labelTruckModel.TabIndex = 12;
|
|
||||||
labelTruckModel.Text = "Модель";
|
|
||||||
//
|
|
||||||
// textBoxTruckBrand
|
|
||||||
//
|
|
||||||
textBoxTruckBrand.Location = new Point(158, 73);
|
|
||||||
textBoxTruckBrand.Name = "textBoxTruckBrand";
|
|
||||||
textBoxTruckBrand.Size = new Size(183, 27);
|
|
||||||
textBoxTruckBrand.TabIndex = 11;
|
|
||||||
//
|
|
||||||
// labelTruckBrand
|
// labelTruckBrand
|
||||||
//
|
//
|
||||||
labelTruckBrand.AutoSize = true;
|
labelTruckBrand.AutoSize = true;
|
||||||
@ -92,7 +67,7 @@
|
|||||||
// labelMaxFuel
|
// labelMaxFuel
|
||||||
//
|
//
|
||||||
labelMaxFuel.AutoSize = true;
|
labelMaxFuel.AutoSize = true;
|
||||||
labelMaxFuel.Location = new Point(12, 163);
|
labelMaxFuel.Location = new Point(12, 122);
|
||||||
labelMaxFuel.Name = "labelMaxFuel";
|
labelMaxFuel.Name = "labelMaxFuel";
|
||||||
labelMaxFuel.Size = new Size(129, 20);
|
labelMaxFuel.Size = new Size(129, 20);
|
||||||
labelMaxFuel.TabIndex = 14;
|
labelMaxFuel.TabIndex = 14;
|
||||||
@ -100,16 +75,16 @@
|
|||||||
//
|
//
|
||||||
// numericUpDownMaxFuel
|
// numericUpDownMaxFuel
|
||||||
//
|
//
|
||||||
numericUpDownMaxFuel.Location = new Point(158, 156);
|
numericUpDownMaxFuel.Location = new Point(158, 115);
|
||||||
numericUpDownMaxFuel.Minimum = new decimal(new int[] { 1, 0, 0, 0 });
|
numericUpDownMaxFuel.Minimum = new decimal(new int[] { 1, 0, 0, 0 });
|
||||||
numericUpDownMaxFuel.Name = "numericUpDownMaxFuel";
|
numericUpDownMaxFuel.Name = "numericUpDownMaxFuel";
|
||||||
numericUpDownMaxFuel.Size = new Size(117, 27);
|
numericUpDownMaxFuel.Size = new Size(183, 27);
|
||||||
numericUpDownMaxFuel.TabIndex = 15;
|
numericUpDownMaxFuel.TabIndex = 15;
|
||||||
numericUpDownMaxFuel.Value = new decimal(new int[] { 1, 0, 0, 0 });
|
numericUpDownMaxFuel.Value = new decimal(new int[] { 1, 0, 0, 0 });
|
||||||
//
|
//
|
||||||
// buttonTruckSave
|
// buttonTruckSave
|
||||||
//
|
//
|
||||||
buttonTruckSave.Location = new Point(12, 211);
|
buttonTruckSave.Location = new Point(12, 170);
|
||||||
buttonTruckSave.Name = "buttonTruckSave";
|
buttonTruckSave.Name = "buttonTruckSave";
|
||||||
buttonTruckSave.Size = new Size(156, 37);
|
buttonTruckSave.Size = new Size(156, 37);
|
||||||
buttonTruckSave.TabIndex = 16;
|
buttonTruckSave.TabIndex = 16;
|
||||||
@ -119,7 +94,7 @@
|
|||||||
//
|
//
|
||||||
// buttonTruckCancel
|
// buttonTruckCancel
|
||||||
//
|
//
|
||||||
buttonTruckCancel.Location = new Point(196, 211);
|
buttonTruckCancel.Location = new Point(196, 170);
|
||||||
buttonTruckCancel.Name = "buttonTruckCancel";
|
buttonTruckCancel.Name = "buttonTruckCancel";
|
||||||
buttonTruckCancel.Size = new Size(156, 37);
|
buttonTruckCancel.Size = new Size(156, 37);
|
||||||
buttonTruckCancel.TabIndex = 17;
|
buttonTruckCancel.TabIndex = 17;
|
||||||
@ -127,18 +102,25 @@
|
|||||||
buttonTruckCancel.UseVisualStyleBackColor = true;
|
buttonTruckCancel.UseVisualStyleBackColor = true;
|
||||||
buttonTruckCancel.Click += ButtonTruckCancel_Click;
|
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
|
// FormTruck
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(364, 260);
|
ClientSize = new Size(364, 222);
|
||||||
|
Controls.Add(comboBoxTruckType);
|
||||||
Controls.Add(buttonTruckCancel);
|
Controls.Add(buttonTruckCancel);
|
||||||
Controls.Add(buttonTruckSave);
|
Controls.Add(buttonTruckSave);
|
||||||
Controls.Add(numericUpDownMaxFuel);
|
Controls.Add(numericUpDownMaxFuel);
|
||||||
Controls.Add(labelMaxFuel);
|
Controls.Add(labelMaxFuel);
|
||||||
Controls.Add(textBoxTruckModel);
|
|
||||||
Controls.Add(labelTruckModel);
|
|
||||||
Controls.Add(textBoxTruckBrand);
|
|
||||||
Controls.Add(labelTruckBrand);
|
Controls.Add(labelTruckBrand);
|
||||||
Controls.Add(textBoxTruckNumbers);
|
Controls.Add(textBoxTruckNumbers);
|
||||||
Controls.Add(labelTruckNumbers);
|
Controls.Add(labelTruckNumbers);
|
||||||
@ -151,10 +133,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private TextBox textBoxTruckModel;
|
|
||||||
private Label labelTruckModel;
|
|
||||||
private TextBox textBoxTruckBrand;
|
|
||||||
private Label labelTruckBrand;
|
private Label labelTruckBrand;
|
||||||
private TextBox textBoxTruckNumbers;
|
private TextBox textBoxTruckNumbers;
|
||||||
private Label labelTruckNumbers;
|
private Label labelTruckNumbers;
|
||||||
@ -162,5 +140,6 @@
|
|||||||
private NumericUpDown numericUpDownMaxFuel;
|
private NumericUpDown numericUpDownMaxFuel;
|
||||||
private Button buttonTruckSave;
|
private Button buttonTruckSave;
|
||||||
private Button buttonTruckCancel;
|
private Button buttonTruckCancel;
|
||||||
|
private ComboBox comboBoxTruckType;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,4 +1,5 @@
|
|||||||
using ProjectGarage.Entities;
|
using ProjectGarage.Entities;
|
||||||
|
using ProjectGarage.Entities.Enums;
|
||||||
using ProjectGarage.Repositories;
|
using ProjectGarage.Repositories;
|
||||||
|
|
||||||
namespace ProjectGarage.Forms
|
namespace ProjectGarage.Forms
|
||||||
@ -21,8 +22,7 @@ namespace ProjectGarage.Forms
|
|||||||
}
|
}
|
||||||
|
|
||||||
textBoxTruckNumbers.Text = truck.Numbers;
|
textBoxTruckNumbers.Text = truck.Numbers;
|
||||||
textBoxTruckBrand.Text = truck.Brand;
|
comboBoxTruckType.SelectedItem = truck.Type;
|
||||||
textBoxTruckModel.Text = truck.Model;
|
|
||||||
numericUpDownMaxFuel.Value = truck.MaxFuel;
|
numericUpDownMaxFuel.Value = truck.MaxFuel;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -38,6 +38,7 @@ namespace ProjectGarage.Forms
|
|||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_truckRepository = truckRepository ??
|
_truckRepository = truckRepository ??
|
||||||
throw new ArgumentNullException(nameof(truckRepository));
|
throw new ArgumentNullException(nameof(truckRepository));
|
||||||
|
comboBoxTruckType.DataSource = Enum.GetValues(typeof(TruckType));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ButtonTruckSave_Click(object sender, EventArgs e)
|
private void ButtonTruckSave_Click(object sender, EventArgs e)
|
||||||
@ -45,8 +46,7 @@ namespace ProjectGarage.Forms
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(textBoxTruckNumbers.Text)
|
if (string.IsNullOrWhiteSpace(textBoxTruckNumbers.Text)
|
||||||
|| string.IsNullOrWhiteSpace(textBoxTruckBrand.Text)
|
|| comboBoxTruckType.SelectedIndex < 1)
|
||||||
|| string.IsNullOrWhiteSpace(textBoxTruckModel.Text))
|
|
||||||
{
|
{
|
||||||
throw new Exception("Имеются незаполненные поля");
|
throw new Exception("Имеются незаполненные поля");
|
||||||
}
|
}
|
||||||
@ -69,7 +69,6 @@ namespace ProjectGarage.Forms
|
|||||||
private void ButtonTruckCancel_Click(object sender, EventArgs e) => Close();
|
private void ButtonTruckCancel_Click(object sender, EventArgs e) => Close();
|
||||||
|
|
||||||
private Truck CreateTruck(int id) => Truck.CreateTruck(id, textBoxTruckNumbers.Text,
|
private Truck CreateTruck(int id) => Truck.CreateTruck(id, textBoxTruckNumbers.Text,
|
||||||
textBoxTruckBrand.Text, textBoxTruckModel.Text, Convert.ToInt32(numericUpDownMaxFuel.Value));
|
(TruckType)comboBoxTruckType.SelectedItem!, Convert.ToInt32(numericUpDownMaxFuel.Value));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
6
ProjectGarage/Forms/FormTrucks.Designer.cs
generated
6
ProjectGarage/Forms/FormTrucks.Designer.cs
generated
@ -43,7 +43,7 @@
|
|||||||
panelFormTrucksButtons.Controls.Add(buttonDeleteTruck);
|
panelFormTrucksButtons.Controls.Add(buttonDeleteTruck);
|
||||||
panelFormTrucksButtons.Controls.Add(buttonAddTruck);
|
panelFormTrucksButtons.Controls.Add(buttonAddTruck);
|
||||||
panelFormTrucksButtons.Dock = DockStyle.Right;
|
panelFormTrucksButtons.Dock = DockStyle.Right;
|
||||||
panelFormTrucksButtons.Location = new Point(441, 0);
|
panelFormTrucksButtons.Location = new Point(565, 0);
|
||||||
panelFormTrucksButtons.Name = "panelFormTrucksButtons";
|
panelFormTrucksButtons.Name = "panelFormTrucksButtons";
|
||||||
panelFormTrucksButtons.Size = new Size(161, 360);
|
panelFormTrucksButtons.Size = new Size(161, 360);
|
||||||
panelFormTrucksButtons.TabIndex = 0;
|
panelFormTrucksButtons.TabIndex = 0;
|
||||||
@ -96,14 +96,14 @@
|
|||||||
dataGridViewTrucks.RowHeadersVisible = false;
|
dataGridViewTrucks.RowHeadersVisible = false;
|
||||||
dataGridViewTrucks.RowHeadersWidth = 51;
|
dataGridViewTrucks.RowHeadersWidth = 51;
|
||||||
dataGridViewTrucks.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
dataGridViewTrucks.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||||
dataGridViewTrucks.Size = new Size(441, 360);
|
dataGridViewTrucks.Size = new Size(565, 360);
|
||||||
dataGridViewTrucks.TabIndex = 1;
|
dataGridViewTrucks.TabIndex = 1;
|
||||||
//
|
//
|
||||||
// FormTrucks
|
// FormTrucks
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(602, 360);
|
ClientSize = new Size(726, 360);
|
||||||
Controls.Add(dataGridViewTrucks);
|
Controls.Add(dataGridViewTrucks);
|
||||||
Controls.Add(panelFormTrucksButtons);
|
Controls.Add(panelFormTrucksButtons);
|
||||||
Name = "FormTrucks";
|
Name = "FormTrucks";
|
||||||
|
@ -99,7 +99,7 @@ namespace ProjectGarage.Forms
|
|||||||
id = 0;
|
id = 0;
|
||||||
if (dataGridViewTrucks.SelectedRows.Count < 1)
|
if (dataGridViewTrucks.SelectedRows.Count < 1)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK,MessageBoxIcon.Error);
|
MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ public interface IRouteRepository
|
|||||||
{
|
{
|
||||||
IEnumerable<Route> ReadRoute(string? startPoint = null,string? finalPoint = null);
|
IEnumerable<Route> ReadRoute(string? startPoint = null,string? finalPoint = null);
|
||||||
|
|
||||||
void ReadRouteByID(int id);
|
Route ReadRouteByID(int id);
|
||||||
|
|
||||||
void CreateRoute(Route route);
|
void CreateRoute(Route route);
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ public class DriverRepository : IDriverRepository
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public Driver ReadDriverByID(int id) => Driver.CreateDriver(0, string.Empty, string.Empty, string.Empty, 0);
|
public Driver ReadDriverByID(int id) => Driver.CreateDriver(0, string.Empty, string.Empty, string.Empty);
|
||||||
|
|
||||||
public IEnumerable<Driver> ReadDrivers() => [];
|
public IEnumerable<Driver> ReadDrivers() => [];
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ public class RouteRepository : IRouteRepository
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ReadRouteByID(int id) => Route.CreateRoute(0, string.Empty, string.Empty, 0);
|
public Route ReadRouteByID(int id) => Route.CreateRoute(0, string.Empty, string.Empty, 0);
|
||||||
|
|
||||||
public IEnumerable<Route> ReadRoute(string? startPoint = null, string? finalPoint = null)
|
public IEnumerable<Route> ReadRoute(string? startPoint = null, string? finalPoint = null)
|
||||||
{
|
{
|
||||||
|
@ -13,6 +13,11 @@ public class TransportationRepository : ITransportationRepository
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void DeleteTransportation(int id)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
public IEnumerable<Transportation> ReadTransportation(DateTime? dateForm = null, DateTime? dateTo = null, int? fuelId = null, int? driverId = null, int? routeId = null)
|
public IEnumerable<Transportation> ReadTransportation(DateTime? dateForm = null, DateTime? dateTo = null, int? fuelId = null, int? driverId = null, int? routeId = null)
|
||||||
{
|
{
|
||||||
return [];
|
return [];
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using ProjectGarage.Entities;
|
using ProjectGarage.Entities;
|
||||||
|
using ProjectGarage.Entities.Enums;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -17,7 +18,7 @@ public class TruckRepository : ITruckRepository
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public Truck ReadTruckByID(int id) => Truck.CreateTruck(0, string.Empty, string.Empty, string.Empty, 0);
|
public Truck ReadTruckByID(int id) => Truck.CreateTruck(0, string.Empty, TruckType.None, 0);
|
||||||
|
|
||||||
public IEnumerable<Truck> ReadTrucks() => [];
|
public IEnumerable<Truck> ReadTrucks() => [];
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user