PIbd-13_Baryshev_D.A._Garage_LabWork_1 #1

Closed
xysiboi wants to merge 5 commits from LabWork_1 into main
73 changed files with 6268 additions and 75 deletions

View File

@ -0,0 +1,33 @@
using ProjectGarage.Entities.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectGarage.Entities;
public class Driver
{
public int Id { get;private set; }
public string First_name { get;private set; } = string.Empty;
public string Last_name { get;private set; } = string.Empty;
public string Phone_Number { get;private set; } = string.Empty;
public int TruckId { get;private set; }
public static Driver CreateDriver(int id, string fname, string lname ,string phone_num, int tryckid)
{
return new Driver
{
Id = id,
First_name = fname,
Last_name = lname,
Phone_Number = phone_num ?? string.Empty,
TruckId = tryckid
};
}
}

View File

@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectGarage.Entities.Enums;
[Flags]
public enum FuelType
{
None = 0,
Petrol_92 = 1,
Petrol_95 = 2,
Petrol_98 = 4,
Petrol_100 = 8,
Diesel_Summer = 16,
Diesel_Winter = 32
}

View 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
}
}

View File

@ -0,0 +1,31 @@
using ProjectGarage.Entities.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection.Metadata.Ecma335;
using System.Text;
using System.Threading.Tasks;
namespace ProjectGarage.Entities;
public class Fuel
{
public int Id { get; set; }
public string Name { get; set; } = string.Empty;
public FuelType Type { get; set; }
public int Price { get; set; }
public static Fuel CreateFuel(int id, string name, FuelType type, int price)
{
return new Fuel
{
Id = id,
Name = name,
Type = type,
Price = price
};
}
}

View File

@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectGarage.Entities;
public class FuelFuelReplenishment
{
public int Id { get; private set; }
public int FuelId { get; private set; }
public int Amount { get; private set; }
public static FuelFuelReplenishment CreateElement(int id, int fuelId, int amount)
{
return new FuelFuelReplenishment
{
Id = id,
FuelId = fuelId,
Amount = amount
};
}
}

View File

@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectGarage.Entities;
public class FuelReplenishment
{
public int Id { get; private set; }
public int DriverId { get; private set; }
public DateTime Date { get; private set; }
public IEnumerable<FuelFuelReplenishment> FuelFuelReplenishments { get; private set;} = [];
public static FuelReplenishment CreateOpeartion(int id, int driverId, IEnumerable<FuelFuelReplenishment> fuelFuelReplenishments)
{
return new FuelReplenishment
{
Id = id,
DriverId = driverId,
Date = DateTime.Now,
FuelFuelReplenishments = fuelFuelReplenishments
};
}
}

View File

@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectGarage.Entities;
public class Route
{
public int Id { get; set; }
public string Name { get; set; } = string.Empty;
public string StartPoint { get; set; } = string.Empty;
public string FinalPoint { get; set; } = string.Empty;
public int Length { get; set; }
public static Route CreateRoute(int id, string startp, string finalp, int len)
{
return new Route() {
Id = id,
Name = startp + " - " + finalp,
StartPoint = startp,
FinalPoint = finalp,
Length = len
};
}
}

View File

@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectGarage.Entities;
public class Transportation
{
public int Id { get; set; }
public int FuelId { get; set; }
public int RouteId { get; set; }
public int DriverId { get; set; }
public int Amount { get; set; }
public DateTime TransportationDate { get; set; }
public static Transportation CreateTransportation(int id, int fuel_id, int route_id, int driver_id, int amount)
{
return new Transportation
{
Id = id,
FuelId = fuel_id,
RouteId = route_id,
DriverId = driver_id,
Amount = amount,
TransportationDate = DateTime.Now
};
}
}

View File

@ -0,0 +1,30 @@
using ProjectGarage.Entities.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectGarage.Entities;
public class Truck
{
public int Id { get; private set; }
public string Numbers { get; private set; } = string.Empty;
public TruckType Type { get; set; }
public int MaxFuel { get; private set; }
public static Truck CreateTruck(int id,string numbers, TruckType type, int maxFuel)
{
return new Truck()
{
Id = id,
Numbers = numbers,
Type = type,
MaxFuel = maxFuel
};
}
}

View File

@ -1,39 +0,0 @@
namespace ProjectGarage
{
partial class Form1
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Text = "Form1";
}
#endregion
}
}

View File

@ -1,10 +0,0 @@
namespace ProjectGarage
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
}

147
ProjectGarage/FormGarage.Designer.cs generated Normal file
View File

@ -0,0 +1,147 @@
namespace ProjectGarage
{
partial class FormGarage
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormGarage));
menuStripGarage = new MenuStrip();
справочникиToolStripMenuItem = new ToolStripMenuItem();
водителиToolStripMenuItem = new ToolStripMenuItem();
фурыToolStripMenuItem = new ToolStripMenuItem();
маршрутыToolStripMenuItem = new ToolStripMenuItem();
топливоToolStripMenuItem = new ToolStripMenuItem();
операцииToolStripMenuItem = new ToolStripMenuItem();
отправкаТопливаToolStripMenuItem = new ToolStripMenuItem();
получениеТопливаToolStripMenuItem = new ToolStripMenuItem();
отчетыToolStripMenuItem = new ToolStripMenuItem();
menuStripGarage.SuspendLayout();
SuspendLayout();
//
// menuStripGarage
//
menuStripGarage.ImageScalingSize = new Size(20, 20);
menuStripGarage.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, операцииToolStripMenuItem, отчетыToolStripMenuItem });
menuStripGarage.Location = new Point(0, 0);
menuStripGarage.Name = "menuStripGarage";
menuStripGarage.Size = new Size(612, 28);
menuStripGarage.TabIndex = 0;
menuStripGarage.Text = "menuStrip1";
//
// справочникиToolStripMenuItem
//
справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { водителиToolStripMenuItem, фурыToolStripMenuItem, маршрутыToolStripMenuItem, топливоToolStripMenuItem });
справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
справочникиToolStripMenuItem.Size = new Size(117, 24);
справочникиToolStripMenuItem.Text = "Справочники";
//
// водителиToolStripMenuItem
//
водителиToolStripMenuItem.Name = одителиToolStripMenuItem";
водителиToolStripMenuItem.Size = new Size(224, 26);
водителиToolStripMenuItem.Text = "Водители";
водителиToolStripMenuItem.Click += DriversToolStripMenuItem_Click;
//
// фурыToolStripMenuItem
//
фурыToolStripMenuItem.Name = урыToolStripMenuItem";
фурыToolStripMenuItem.Size = new Size(224, 26);
фурыToolStripMenuItem.Text = "Фуры";
фурыToolStripMenuItem.Click += TrucksToolStripMenuItem_Click;
//
// маршрутыToolStripMenuItem
//
маршрутыToolStripMenuItem.Name = аршрутыToolStripMenuItem";
маршрутыToolStripMenuItem.Size = new Size(224, 26);
маршрутыToolStripMenuItem.Text = "Маршруты";
маршрутыToolStripMenuItem.Click += RoutesToolStripMenuItem_Click;
//
// топливоToolStripMenuItem
//
топливоToolStripMenuItem.Name = опливоToolStripMenuItem";
топливоToolStripMenuItem.Size = new Size(224, 26);
топливоToolStripMenuItem.Text = "Топливо";
топливоToolStripMenuItem.Click += FuelsToolStripMenuItem_Click;
//
// операцииToolStripMenuItem
//
операцииToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { отправкаТопливаToolStripMenuItem, получениеТопливаToolStripMenuItem });
операцииToolStripMenuItem.Name = "операцииToolStripMenuItem";
операцииToolStripMenuItem.Size = new Size(95, 24);
операцииToolStripMenuItem.Text = "Операции";
//
// отправкаТопливаToolStripMenuItem
//
отправкаТопливаToolStripMenuItem.Name = "отправкаТопливаToolStripMenuItem";
отправкаТопливаToolStripMenuItem.Size = new Size(230, 26);
отправкаТопливаToolStripMenuItem.Text = "Отправка топлива";
отправкаТопливаToolStripMenuItem.Click += TransportationToolStripMenuItem_Click;
//
// получениеТопливаToolStripMenuItem
//
получениеТопливаToolStripMenuItem.Name = "получениеТопливаToolStripMenuItem";
получениеТопливаToolStripMenuItem.Size = new Size(230, 26);
получениеТопливаToolStripMenuItem.Text = "Получение топлива";
получениеТопливаToolStripMenuItem.Click += ReplenishmentToolStripMenuItem_Click;
//
// отчетыToolStripMenuItem
//
отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem";
отчетыToolStripMenuItem.Size = new Size(73, 24);
отчетыToolStripMenuItem.Text = "Отчеты";
//
// FormGarage
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
BackgroundImage = (Image)resources.GetObject("$this.BackgroundImage");
BackgroundImageLayout = ImageLayout.Stretch;
ClientSize = new Size(612, 399);
Controls.Add(menuStripGarage);
Name = "FormGarage";
StartPosition = FormStartPosition.CenterScreen;
Text = "Гараж";
menuStripGarage.ResumeLayout(false);
menuStripGarage.PerformLayout();
ResumeLayout(false);
PerformLayout();
}
#endregion
private MenuStrip menuStripGarage;
private ToolStripMenuItem справочникиToolStripMenuItem;
private ToolStripMenuItem водителиToolStripMenuItem;
private ToolStripMenuItem фурыToolStripMenuItem;
private ToolStripMenuItem маршрутыToolStripMenuItem;
private ToolStripMenuItem топливоToolStripMenuItem;
private ToolStripMenuItem операцииToolStripMenuItem;
private ToolStripMenuItem отправкаТопливаToolStripMenuItem;
private ToolStripMenuItem получениеТопливаToolStripMenuItem;
private ToolStripMenuItem отчетыToolStripMenuItem;
}
}

View File

@ -0,0 +1,95 @@
using ProjectGarage.Forms;
using System.ComponentModel;
using Unity;
namespace ProjectGarage
{
public partial class FormGarage : Form
{
private readonly IUnityContainer _container;
public FormGarage(IUnityContainer container)
{
InitializeComponent();
_container = container ?? throw new ArgumentNullException(nameof(container));
}
private void DriversToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormDrivers>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void TrucksToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormTrucks>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void RoutesToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormRoutes>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void FuelsToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormFuels>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void TransportationToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormTransportations>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ReplenishmentToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormReplenishments>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}

File diff suppressed because it is too large Load Diff

165
ProjectGarage/Forms/FormDriver.Designer.cs generated Normal file
View File

@ -0,0 +1,165 @@
namespace ProjectGarage.Forms
{
partial class FormDriver
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
labelFirstName = new Label();
textBoxFirstName = new TextBox();
textBoxLastName = new TextBox();
labelLastName = new Label();
textBoxPhoneNum = new TextBox();
labelPhoneNum = new Label();
labelTruckID = new Label();
buttonSaveDriver = new Button();
buttonCancelDriver = new Button();
comboBoxTruckID = new ComboBox();
SuspendLayout();
//
// labelFirstName
//
labelFirstName.AutoSize = true;
labelFirstName.Location = new Point(34, 24);
labelFirstName.Name = "labelFirstName";
labelFirstName.Size = new Size(39, 20);
labelFirstName.TabIndex = 0;
labelFirstName.Text = "Имя";
//
// textBoxFirstName
//
textBoxFirstName.Location = new Point(120, 24);
textBoxFirstName.Name = "textBoxFirstName";
textBoxFirstName.Size = new Size(183, 27);
textBoxFirstName.TabIndex = 1;
//
// textBoxLastName
//
textBoxLastName.Location = new Point(120, 70);
textBoxLastName.Name = "textBoxLastName";
textBoxLastName.Size = new Size(183, 27);
textBoxLastName.TabIndex = 3;
//
// labelLastName
//
labelLastName.AutoSize = true;
labelLastName.Location = new Point(20, 73);
labelLastName.Name = "labelLastName";
labelLastName.Size = new Size(73, 20);
labelLastName.TabIndex = 2;
labelLastName.Text = "Фамилия";
//
// textBoxPhoneNum
//
textBoxPhoneNum.Location = new Point(120, 115);
textBoxPhoneNum.Name = "textBoxPhoneNum";
textBoxPhoneNum.Size = new Size(183, 27);
textBoxPhoneNum.TabIndex = 5;
textBoxPhoneNum.Text = "+7";
//
// labelPhoneNum
//
labelPhoneNum.AutoSize = true;
labelPhoneNum.Location = new Point(20, 118);
labelPhoneNum.Name = "labelPhoneNum";
labelPhoneNum.Size = new Size(69, 20);
labelPhoneNum.TabIndex = 4;
labelPhoneNum.Text = "Телефон";
//
// labelTruckID
//
labelTruckID.AutoSize = true;
labelTruckID.Location = new Point(34, 164);
labelTruckID.Name = "labelTruckID";
labelTruckID.Size = new Size(44, 20);
labelTruckID.TabIndex = 6;
labelTruckID.Text = "Фура";
//
// buttonSaveDriver
//
buttonSaveDriver.Location = new Point(20, 231);
buttonSaveDriver.Name = "buttonSaveDriver";
buttonSaveDriver.Size = new Size(128, 39);
buttonSaveDriver.TabIndex = 8;
buttonSaveDriver.Text = "Сохранить";
buttonSaveDriver.UseVisualStyleBackColor = true;
buttonSaveDriver.Click += ButtonSaveDriver_Click;
//
// buttonCancelDriver
//
buttonCancelDriver.Location = new Point(175, 231);
buttonCancelDriver.Name = "buttonCancelDriver";
buttonCancelDriver.Size = new Size(128, 39);
buttonCancelDriver.TabIndex = 9;
buttonCancelDriver.Text = "Отмена";
buttonCancelDriver.UseVisualStyleBackColor = true;
buttonCancelDriver.Click += ButtonCancelDriver_Click;
//
// comboBoxTruckID
//
comboBoxTruckID.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxTruckID.FormattingEnabled = true;
comboBoxTruckID.Location = new Point(120, 156);
comboBoxTruckID.Name = "comboBoxTruckID";
comboBoxTruckID.Size = new Size(183, 28);
comboBoxTruckID.TabIndex = 10;
//
// FormDriver
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(333, 302);
Controls.Add(comboBoxTruckID);
Controls.Add(buttonCancelDriver);
Controls.Add(buttonSaveDriver);
Controls.Add(labelTruckID);
Controls.Add(textBoxPhoneNum);
Controls.Add(labelPhoneNum);
Controls.Add(textBoxLastName);
Controls.Add(labelLastName);
Controls.Add(textBoxFirstName);
Controls.Add(labelFirstName);
Name = "FormDriver";
StartPosition = FormStartPosition.CenterParent;
Text = "Водитель";
ResumeLayout(false);
PerformLayout();
}
#endregion
private Label labelFirstName;
private TextBox textBoxFirstName;
private TextBox textBoxLastName;
private Label labelLastName;
private TextBox textBoxPhoneNum;
private Label labelPhoneNum;
private Label labelTruckID;
private Button buttonSaveDriver;
private Button buttonCancelDriver;
private ComboBox comboBoxTruckID;
}
}

View File

@ -0,0 +1,87 @@
using ProjectGarage.Entities;
using ProjectGarage.Entities.Enums;
using ProjectGarage.Repositories;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ProjectGarage.Forms
{
public partial class FormDriver : Form
{
private readonly IDriverRepository _driverRepository;
private int? _driverId;
public int Id
{
set
{
try
{
var driver = _driverRepository.ReadDriverByID(value);
if (driver == null)
{
throw new
InvalidDataException(nameof(driver));
}
textBoxFirstName.Text = driver.First_name;
textBoxLastName.Text = driver.Last_name;
//comboBoxTruckID.SelectedItem = driver.TruckId;
Review

Закомментированного кода быть не должно

Закомментированного кода быть не должно
_driverId = value;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
}
public FormDriver(IDriverRepository driverRepository, ITruckRepository truckRepository)
{
InitializeComponent();
_driverRepository = driverRepository ?? throw new ArgumentNullException(nameof(driverRepository));
comboBoxTruckID.DataSource = truckRepository.ReadTrucks();//
comboBoxTruckID.DisplayMember = "Numbers";
comboBoxTruckID.ValueMember = "Id";
}
private void ButtonSaveDriver_Click(object sender, EventArgs e)
{
try
{
if (string.IsNullOrWhiteSpace(textBoxFirstName.Text) || string.IsNullOrWhiteSpace(textBoxLastName.Text)
|| comboBoxTruckID.SelectedIndex < 0)//
{
throw new Exception("Имеются незаполненные поля");
}
if (_driverId.HasValue)
{
_driverRepository.UpdateDriver(CreateDriver(_driverId.Value));
}
else
{
_driverRepository.CreateDriver(CreateDriver(0));
}
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при сохранении",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonCancelDriver_Click(object sender, EventArgs e) => Close();
private Driver CreateDriver(int id) => Driver.CreateDriver(id, textBoxFirstName.Text,
textBoxLastName.Text, textBoxPhoneNum.Text, (int)comboBoxTruckID.SelectedIndex!);//
}
}

View File

@ -1,17 +1,17 @@
<?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
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>
@ -26,36 +26,36 @@
<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
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
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
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
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
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
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
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->

View File

@ -0,0 +1,126 @@
namespace ProjectGarage.Forms
{
partial class FormDrivers
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
dataGridViewDrivers = new DataGridView();
panelFormDriversButtons = new Panel();
buttonUpdateDriver = new Button();
buttonDeleteDriver = new Button();
buttonAddDriver = new Button();
((System.ComponentModel.ISupportInitialize)dataGridViewDrivers).BeginInit();
panelFormDriversButtons.SuspendLayout();
SuspendLayout();
//
// dataGridViewDrivers
//
dataGridViewDrivers.AllowUserToAddRows = false;
dataGridViewDrivers.AllowUserToDeleteRows = false;
dataGridViewDrivers.AllowUserToResizeColumns = false;
dataGridViewDrivers.AllowUserToResizeRows = false;
dataGridViewDrivers.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridViewDrivers.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridViewDrivers.Dock = DockStyle.Fill;
dataGridViewDrivers.Location = new Point(0, 0);
dataGridViewDrivers.Name = "dataGridViewDrivers";
dataGridViewDrivers.ReadOnly = true;
dataGridViewDrivers.RowHeadersVisible = false;
dataGridViewDrivers.RowHeadersWidth = 51;
dataGridViewDrivers.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridViewDrivers.Size = new Size(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";
Review

Заголовок формы оформлен неверно

Заголовок формы оформлен неверно
Load += FormDrivers_Load;
Click += FormDrivers_Load;
((System.ComponentModel.ISupportInitialize)dataGridViewDrivers).EndInit();
panelFormDriversButtons.ResumeLayout(false);
ResumeLayout(false);
}
#endregion
private DataGridView dataGridViewDrivers;
private Panel panelFormDriversButtons;
private Button buttonUpdateDriver;
private Button buttonDeleteDriver;
private Button buttonAddDriver;
}
}

View 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;
}
}
}

View 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
View 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;
}
}

View File

@ -0,0 +1,101 @@
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));
}
}
}

View 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
View 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;
}
}

View 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;
}
}
}

View 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>

View File

@ -0,0 +1,148 @@
namespace ProjectGarage.Forms
{
partial class FormReplenishment
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
comboBoxReplenishmentDriver = new ComboBox();
labelReplenishmentDriver = new Label();
groupBoxReplenishment = new GroupBox();
dataGridViewReplenishment = new DataGridView();
ColumnFuel = new DataGridViewComboBoxColumn();
ColumnAmount = new DataGridViewTextBoxColumn();
ButtonReplenishmentSave = new Button();
ButtonReplenishmentCancel = new Button();
groupBoxReplenishment.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridViewReplenishment).BeginInit();
SuspendLayout();
//
// comboBoxReplenishmentDriver
//
comboBoxReplenishmentDriver.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxReplenishmentDriver.FormattingEnabled = true;
comboBoxReplenishmentDriver.Location = new Point(141, 16);
comboBoxReplenishmentDriver.Name = "comboBoxReplenishmentDriver";
comboBoxReplenishmentDriver.Size = new Size(151, 28);
comboBoxReplenishmentDriver.TabIndex = 9;
//
// labelReplenishmentDriver
//
labelReplenishmentDriver.AutoSize = true;
labelReplenishmentDriver.Location = new Point(21, 19);
labelReplenishmentDriver.Name = "labelReplenishmentDriver";
labelReplenishmentDriver.Size = new Size(74, 20);
labelReplenishmentDriver.TabIndex = 8;
labelReplenishmentDriver.Text = "Водитель";
//
// groupBoxReplenishment
//
groupBoxReplenishment.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
groupBoxReplenishment.Controls.Add(dataGridViewReplenishment);
groupBoxReplenishment.Location = new Point(21, 66);
groupBoxReplenishment.Name = "groupBoxReplenishment";
groupBoxReplenishment.Size = new Size(271, 288);
groupBoxReplenishment.TabIndex = 10;
groupBoxReplenishment.TabStop = false;
groupBoxReplenishment.Text = "Пополнение топлива";
//
// dataGridViewReplenishment
//
dataGridViewReplenishment.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridViewReplenishment.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridViewReplenishment.Columns.AddRange(new DataGridViewColumn[] { ColumnFuel, ColumnAmount });
dataGridViewReplenishment.Dock = DockStyle.Fill;
dataGridViewReplenishment.Location = new Point(3, 23);
dataGridViewReplenishment.Name = "dataGridViewReplenishment";
dataGridViewReplenishment.RowHeadersVisible = false;
dataGridViewReplenishment.RowHeadersWidth = 51;
dataGridViewReplenishment.Size = new Size(265, 262);
dataGridViewReplenishment.TabIndex = 0;
//
// ColumnFuel
//
ColumnFuel.HeaderText = "Топливо";
ColumnFuel.MinimumWidth = 6;
ColumnFuel.Name = "ColumnFuel";
//
// ColumnAmount
//
ColumnAmount.HeaderText = "Кол-во";
ColumnAmount.MinimumWidth = 6;
ColumnAmount.Name = "ColumnAmount";
//
// ButtonReplenishmentSave
//
ButtonReplenishmentSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
ButtonReplenishmentSave.Location = new Point(21, 360);
ButtonReplenishmentSave.Name = "ButtonReplenishmentSave";
ButtonReplenishmentSave.Size = new Size(134, 29);
ButtonReplenishmentSave.TabIndex = 11;
ButtonReplenishmentSave.Text = "Сохранить";
ButtonReplenishmentSave.UseVisualStyleBackColor = true;
ButtonReplenishmentSave.Click += ButtonReplenishmentSave_Click;
//
// ButtonReplenishmentCancel
//
ButtonReplenishmentCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
ButtonReplenishmentCancel.Location = new Point(161, 360);
ButtonReplenishmentCancel.Name = "ButtonReplenishmentCancel";
ButtonReplenishmentCancel.Size = new Size(131, 29);
ButtonReplenishmentCancel.TabIndex = 13;
ButtonReplenishmentCancel.Text = "Отмена";
ButtonReplenishmentCancel.UseVisualStyleBackColor = true;
ButtonReplenishmentCancel.Click += ButtonReplenishmentCancel_Click;
//
// FormReplenishment
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(315, 401);
Controls.Add(ButtonReplenishmentCancel);
Controls.Add(ButtonReplenishmentSave);
Controls.Add(groupBoxReplenishment);
Controls.Add(comboBoxReplenishmentDriver);
Controls.Add(labelReplenishmentDriver);
Name = "FormReplenishment";
Text = "FormReplenishment";
groupBoxReplenishment.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)dataGridViewReplenishment).EndInit();
ResumeLayout(false);
PerformLayout();
}
#endregion
private ComboBox comboBoxReplenishmentDriver;
private Label labelReplenishmentDriver;
private GroupBox groupBoxReplenishment;
private DataGridView dataGridViewReplenishment;
private Button ButtonReplenishmentSave;
private Button ButtonReplenishmentCancel;
private DataGridViewComboBoxColumn ColumnFuel;
private DataGridViewTextBoxColumn ColumnAmount;
}
}

View File

@ -0,0 +1,72 @@
using ProjectGarage.Entities;
using ProjectGarage.Repositories;
using ProjectGarage.Repositories.Implementations;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ProjectGarage.Forms
{
public partial class FormReplenishment : Form
{
private readonly IReplenishmentRepository _replenishmentRepository;
public FormReplenishment(IReplenishmentRepository replenishmentRepository,
IDriverRepository driverRepository, IFuelRepository fuelRepository)
{
InitializeComponent();
_replenishmentRepository = replenishmentRepository ??
throw new ArgumentNullException(nameof(replenishmentRepository));
comboBoxReplenishmentDriver.DataSource = driverRepository.ReadDrivers();
comboBoxReplenishmentDriver.DisplayMember = "First_name";
comboBoxReplenishmentDriver.ValueMember = "Id";
ColumnFuel.DataSource = fuelRepository.ReadFuels();
ColumnFuel.DisplayMember = "Name";
ColumnFuel.ValueMember = "Id";
}
private void ButtonReplenishmentSave_Click(object sender, EventArgs e)
{
try
{
if (dataGridViewReplenishment.RowCount < 1 ||
comboBoxReplenishmentDriver.SelectedIndex < 0)
{
throw new Exception("Имеются незаполненные поля");
}
_replenishmentRepository.CreateFuelReplenishment(FuelReplenishment.CreateOpeartion(0,
(int)comboBoxReplenishmentDriver.SelectedValue!, CreateListFuelFuelReplenishmentsFromDataGrid()));
Close();
}
catch(Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonReplenishmentCancel_Click(object sender, EventArgs e) => Close();
private List<FuelFuelReplenishment> CreateListFuelFuelReplenishmentsFromDataGrid()
{
var list = new List<FuelFuelReplenishment>();
foreach (DataGridViewRow row in dataGridViewReplenishment.Rows)
{
if (row.Cells["ColumnFeed"].Value == null ||
row.Cells["ColumnCount"].Value == null)
{
continue;
}
list.Add(FuelFuelReplenishment.CreateElement(0, Convert.ToInt32(row.Cells["ColumnFeed"].Value),
Convert.ToInt32(row.Cells["ColumnCount"].Value)));
}
return list;
}
}
}

View File

@ -0,0 +1,132 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="ColumnFuel.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="ColumnAmount.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="ColumnFuel.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="ColumnAmount.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root>

View File

@ -0,0 +1,109 @@
namespace ProjectGarage.Forms
{
partial class FormReplenishments
{
/// <summary>
/// Обязательная переменная конструктора.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Освободить все используемые ресурсы.
/// </summary>
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Код, автоматически созданный конструктором компонентов
/// <summary>
/// Требуемый метод для поддержки конструктора — не изменяйте
/// содержимое этого метода с помощью редактора кода.
/// </summary>
private void InitializeComponent()
{
buttonAddReplenishment = new Button();
buttonDeleteReplenishment = new Button();
panelFormReplenishmentssButtons = new Panel();
dataGridViewReplenishments = new DataGridView();
panelFormReplenishmentssButtons.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridViewReplenishments).BeginInit();
SuspendLayout();
//
// buttonAddReplenishment
//
buttonAddReplenishment.BackgroundImage = Properties.Resources.плюсик;
buttonAddReplenishment.BackgroundImageLayout = ImageLayout.Stretch;
buttonAddReplenishment.Location = new Point(35, 23);
buttonAddReplenishment.Name = "buttonAddReplenishment";
buttonAddReplenishment.Size = new Size(94, 75);
buttonAddReplenishment.TabIndex = 0;
buttonAddReplenishment.UseVisualStyleBackColor = true;
buttonAddReplenishment.Click += ButtonAddReplenishment_Click;
//
// buttonDeleteReplenishment
//
buttonDeleteReplenishment.BackgroundImage = Properties.Resources.минусик;
buttonDeleteReplenishment.BackgroundImageLayout = ImageLayout.Stretch;
buttonDeleteReplenishment.Location = new Point(35, 115);
buttonDeleteReplenishment.Name = "buttonDeleteReplenishment";
buttonDeleteReplenishment.Size = new Size(94, 78);
buttonDeleteReplenishment.TabIndex = 1;
buttonDeleteReplenishment.UseVisualStyleBackColor = true;
buttonDeleteReplenishment.Click += ButtonDeleteReplenishment_Click;
//
// panelFormReplenishmentssButtons
//
panelFormReplenishmentssButtons.Controls.Add(buttonDeleteReplenishment);
panelFormReplenishmentssButtons.Controls.Add(buttonAddReplenishment);
panelFormReplenishmentssButtons.Dock = DockStyle.Right;
panelFormReplenishmentssButtons.Location = new Point(641, 0);
panelFormReplenishmentssButtons.Name = "panelFormReplenishmentssButtons";
panelFormReplenishmentssButtons.Size = new Size(161, 406);
panelFormReplenishmentssButtons.TabIndex = 6;
//
// dataGridViewReplenishments
//
dataGridViewReplenishments.AllowUserToAddRows = false;
dataGridViewReplenishments.AllowUserToDeleteRows = false;
dataGridViewReplenishments.AllowUserToResizeColumns = false;
dataGridViewReplenishments.AllowUserToResizeRows = false;
dataGridViewReplenishments.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridViewReplenishments.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridViewReplenishments.Dock = DockStyle.Fill;
dataGridViewReplenishments.Location = new Point(0, 0);
dataGridViewReplenishments.Name = "dataGridViewReplenishments";
dataGridViewReplenishments.ReadOnly = true;
dataGridViewReplenishments.RowHeadersVisible = false;
dataGridViewReplenishments.RowHeadersWidth = 51;
dataGridViewReplenishments.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridViewReplenishments.Size = new Size(641, 406);
dataGridViewReplenishments.TabIndex = 7;
//
// FormReplenishments
//
ClientSize = new Size(802, 406);
Controls.Add(dataGridViewReplenishments);
Controls.Add(panelFormReplenishmentssButtons);
Name = "FormReplenishments";
Text = "Пополнения";
Load += FormReplenishments_Load;
panelFormReplenishmentssButtons.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)dataGridViewReplenishments).EndInit();
ResumeLayout(false);
}
#endregion
private Button buttonAddReplenishment;
private Button buttonDeleteReplenishment;
private Panel panelFormReplenishmentssButtons;
private DataGridView dataGridViewReplenishments;
}
}

View File

@ -0,0 +1,96 @@
using ProjectGarage.Repositories;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Unity;
namespace ProjectGarage.Forms
{
public partial class FormReplenishments : Form
{
private readonly IUnityContainer _container;
private readonly IReplenishmentRepository _replenishmentRepository;
public FormReplenishments(IUnityContainer container, IReplenishmentRepository replenishmentRepository)
{
InitializeComponent();
_container = container ??
throw new ArgumentNullException(nameof(container));
_replenishmentRepository = replenishmentRepository ??
throw new ArgumentNullException(nameof(replenishmentRepository));
}
private void FormReplenishments_Load(object sender, EventArgs e)
{
try
{
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при загрузке",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
public FormReplenishments(IContainer container)
{
container.Add(this);
InitializeComponent();
}
private void ButtonAddReplenishment_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormReplenishment>().ShowDialog();
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonDeleteReplenishment_Click(object sender, EventArgs e)
{
if (!TryGetIdentifierFromSelectedRow(out var findId))
{
return;
}
if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes)
{
return;
}
try
{
_replenishmentRepository.DeleteFuelReplenishment(findId);
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при удалении",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void LoadList() => dataGridViewReplenishments.DataSource = _replenishmentRepository.ReadFuelReplenishment();
private bool TryGetIdentifierFromSelectedRow(out int id)
{
id = 0;
if (dataGridViewReplenishments.SelectedRows.Count < 1)
{
MessageBox.Show("Нет выбранной записи", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
id =
Convert.ToInt32(dataGridViewReplenishments.SelectedRows[0].Cells["Id"].Value);
return true;
}
}
}

View 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
View 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;
}
}

View 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));
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

125
ProjectGarage/Forms/FormRoutes.Designer.cs generated Normal file
View File

@ -0,0 +1,125 @@
namespace ProjectGarage.Forms
{
partial class FormRoutes
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
dataGridViewRoutes = new DataGridView();
panelFormRoutesButtons = new Panel();
buttonUpdateRoute = new Button();
buttonDeleteRoute = new Button();
buttonAddRoute = new Button();
((System.ComponentModel.ISupportInitialize)dataGridViewRoutes).BeginInit();
panelFormRoutesButtons.SuspendLayout();
SuspendLayout();
//
// dataGridViewRoutes
//
dataGridViewRoutes.AllowUserToAddRows = false;
dataGridViewRoutes.AllowUserToDeleteRows = false;
dataGridViewRoutes.AllowUserToResizeColumns = false;
dataGridViewRoutes.AllowUserToResizeRows = false;
dataGridViewRoutes.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridViewRoutes.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridViewRoutes.Dock = DockStyle.Fill;
dataGridViewRoutes.Location = new Point(0, 0);
dataGridViewRoutes.Name = "dataGridViewRoutes";
dataGridViewRoutes.ReadOnly = true;
dataGridViewRoutes.RowHeadersVisible = false;
dataGridViewRoutes.RowHeadersWidth = 51;
dataGridViewRoutes.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridViewRoutes.Size = new Size(584, 355);
dataGridViewRoutes.TabIndex = 5;
//
// panelFormRoutesButtons
//
panelFormRoutesButtons.Controls.Add(buttonUpdateRoute);
panelFormRoutesButtons.Controls.Add(buttonDeleteRoute);
panelFormRoutesButtons.Controls.Add(buttonAddRoute);
panelFormRoutesButtons.Dock = DockStyle.Right;
panelFormRoutesButtons.Location = new Point(584, 0);
panelFormRoutesButtons.Name = "panelFormRoutesButtons";
panelFormRoutesButtons.Size = new Size(161, 355);
panelFormRoutesButtons.TabIndex = 4;
//
// buttonUpdateRoute
//
buttonUpdateRoute.BackgroundImage = Properties.Resources.каранд;
buttonUpdateRoute.BackgroundImageLayout = ImageLayout.Stretch;
buttonUpdateRoute.Location = new Point(35, 140);
buttonUpdateRoute.Name = "buttonUpdateRoute";
buttonUpdateRoute.Size = new Size(94, 75);
buttonUpdateRoute.TabIndex = 2;
buttonUpdateRoute.UseVisualStyleBackColor = true;
buttonUpdateRoute.Click += ButtonUpdateRoute_Click;
//
// buttonDeleteRoute
//
buttonDeleteRoute.BackgroundImage = Properties.Resources.минусик;
buttonDeleteRoute.BackgroundImageLayout = ImageLayout.Stretch;
buttonDeleteRoute.Location = new Point(35, 249);
buttonDeleteRoute.Name = "buttonDeleteRoute";
buttonDeleteRoute.Size = new Size(94, 78);
buttonDeleteRoute.TabIndex = 1;
buttonDeleteRoute.UseVisualStyleBackColor = true;
buttonDeleteRoute.Click += ButtonDeleteRoute_Click;
//
// buttonAddRoute
//
buttonAddRoute.BackgroundImage = Properties.Resources.плюсик;
buttonAddRoute.BackgroundImageLayout = ImageLayout.Stretch;
buttonAddRoute.Location = new Point(35, 23);
buttonAddRoute.Name = "buttonAddRoute";
buttonAddRoute.Size = new Size(94, 75);
buttonAddRoute.TabIndex = 0;
buttonAddRoute.UseVisualStyleBackColor = true;
buttonAddRoute.Click += ButtonAddRoute_Click;
//
// FormRoutes
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(745, 355);
Controls.Add(dataGridViewRoutes);
Controls.Add(panelFormRoutesButtons);
Name = "FormRoutes";
Text = "FormRoutes";
Load += FormRoutes_Load;
((System.ComponentModel.ISupportInitialize)dataGridViewRoutes).EndInit();
panelFormRoutesButtons.ResumeLayout(false);
ResumeLayout(false);
}
#endregion
private DataGridView dataGridViewRoutes;
private Panel panelFormRoutesButtons;
private Button buttonUpdateRoute;
private Button buttonDeleteRoute;
private Button buttonAddRoute;
}
}

View File

@ -0,0 +1,106 @@
using ProjectGarage.Repositories;
using ProjectGarage.Repositories.Implementations;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Xml.Linq;
using Unity;
namespace ProjectGarage.Forms
{
public partial class FormRoutes : Form
{
private readonly IUnityContainer _container;
private readonly IRouteRepository _routeRepository;
public FormRoutes(IUnityContainer container, IRouteRepository routeRepository)
{
InitializeComponent();
_container = container ?? throw new ArgumentNullException(nameof(container));
_routeRepository = routeRepository ?? throw new ArgumentNullException(nameof(routeRepository));
}
private void ButtonAddRoute_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormRoute>().ShowDialog();
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при добавлении",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void FormRoutes_Load(object sender, EventArgs e)
{
try
{
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при загрузке",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void 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;
}
}
}

View 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>

View 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;
}
}

View 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();
}
}

View 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>

View File

@ -0,0 +1,97 @@
namespace ProjectGarage.Forms
{
partial class FormTransportations
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
buttonAddTransportation = new Button();
dataGridViewTransportations = new DataGridView();
panelFormTransportationsButtons = new Panel();
((System.ComponentModel.ISupportInitialize)dataGridViewTransportations).BeginInit();
panelFormTransportationsButtons.SuspendLayout();
SuspendLayout();
//
// buttonAddTransportation
//
buttonAddTransportation.BackgroundImage = Properties.Resources.плюсик;
buttonAddTransportation.BackgroundImageLayout = ImageLayout.Stretch;
buttonAddTransportation.Location = new Point(35, 23);
buttonAddTransportation.Name = "buttonAddTransportation";
buttonAddTransportation.Size = new Size(94, 75);
buttonAddTransportation.TabIndex = 0;
buttonAddTransportation.UseVisualStyleBackColor = true;
buttonAddTransportation.Click += ButtonAddTransportation_Click;
//
// dataGridViewTransportations
//
dataGridViewTransportations.AllowUserToAddRows = false;
dataGridViewTransportations.AllowUserToDeleteRows = false;
dataGridViewTransportations.AllowUserToResizeColumns = false;
dataGridViewTransportations.AllowUserToResizeRows = false;
dataGridViewTransportations.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridViewTransportations.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridViewTransportations.Dock = DockStyle.Fill;
dataGridViewTransportations.Location = new Point(0, 0);
dataGridViewTransportations.Name = "dataGridViewTransportations";
dataGridViewTransportations.ReadOnly = true;
dataGridViewTransportations.RowHeadersVisible = false;
dataGridViewTransportations.RowHeadersWidth = 51;
dataGridViewTransportations.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridViewTransportations.Size = new Size(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";
Load += FormTransportations_Load;
((System.ComponentModel.ISupportInitialize)dataGridViewTransportations).EndInit();
panelFormTransportationsButtons.ResumeLayout(false);
ResumeLayout(false);
}
#endregion
private Button buttonAddTransportation;
private DataGridView dataGridViewTransportations;
private Panel panelFormTransportationsButtons;
}
}

View File

@ -0,0 +1,57 @@
using ProjectGarage.Repositories;
using ProjectGarage.Repositories.Implementations;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Unity;
namespace ProjectGarage.Forms
{
public partial class FormTransportations : Form
{
private readonly IUnityContainer _container;
private readonly ITransportationRepository _transportationRepository;
public FormTransportations(IUnityContainer container, ITransportationRepository transportationRepository)
{
InitializeComponent();
_container = container ?? throw new ArgumentNullException(nameof(container));
_transportationRepository = transportationRepository ??
throw new
ArgumentNullException(nameof(transportationRepository));
}
private void FormTransportations_Load(object sender, EventArgs e)
{
try
{
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при загрузке",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonAddTransportation_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormTransportation>().ShowDialog();
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void LoadList() => dataGridViewTransportations.DataSource = _transportationRepository.ReadTransportation();
}
}

View 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>

145
ProjectGarage/Forms/FormTruck.Designer.cs generated Normal file
View File

@ -0,0 +1,145 @@
namespace ProjectGarage.Forms
{
partial class FormTruck
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
labelTruckBrand = new Label();
textBoxTruckNumbers = new TextBox();
labelTruckNumbers = new Label();
labelMaxFuel = new Label();
numericUpDownMaxFuel = new NumericUpDown();
buttonTruckSave = new Button();
buttonTruckCancel = new Button();
comboBoxTruckType = new ComboBox();
((System.ComponentModel.ISupportInitialize)numericUpDownMaxFuel).BeginInit();
SuspendLayout();
//
// labelTruckBrand
//
labelTruckBrand.AutoSize = true;
labelTruckBrand.Location = new Point(43, 76);
labelTruckBrand.Name = "labelTruckBrand";
labelTruckBrand.Size = new Size(54, 20);
labelTruckBrand.TabIndex = 10;
labelTruckBrand.Text = "Марка";
//
// textBoxTruckNumbers
//
textBoxTruckNumbers.Location = new Point(158, 30);
textBoxTruckNumbers.Name = "textBoxTruckNumbers";
textBoxTruckNumbers.Size = new Size(183, 27);
textBoxTruckNumbers.TabIndex = 9;
//
// labelTruckNumbers
//
labelTruckNumbers.AutoSize = true;
labelTruckNumbers.Location = new Point(26, 30);
labelTruckNumbers.Name = "labelTruckNumbers";
labelTruckNumbers.Size = new Size(106, 20);
labelTruckNumbers.TabIndex = 8;
labelTruckNumbers.Text = "Номера фуры";
//
// labelMaxFuel
//
labelMaxFuel.AutoSize = true;
labelMaxFuel.Location = new Point(12, 122);
labelMaxFuel.Name = "labelMaxFuel";
labelMaxFuel.Size = new Size(129, 20);
labelMaxFuel.TabIndex = 14;
labelMaxFuel.Text = "Объем цистерны";
//
// numericUpDownMaxFuel
//
numericUpDownMaxFuel.Location = new Point(158, 115);
numericUpDownMaxFuel.Minimum = new decimal(new int[] { 1, 0, 0, 0 });
numericUpDownMaxFuel.Name = "numericUpDownMaxFuel";
numericUpDownMaxFuel.Size = new Size(183, 27);
numericUpDownMaxFuel.TabIndex = 15;
numericUpDownMaxFuel.Value = new decimal(new int[] { 1, 0, 0, 0 });
//
// buttonTruckSave
//
buttonTruckSave.Location = new Point(12, 170);
buttonTruckSave.Name = "buttonTruckSave";
buttonTruckSave.Size = new Size(156, 37);
buttonTruckSave.TabIndex = 16;
buttonTruckSave.Text = "Сохранить";
buttonTruckSave.UseVisualStyleBackColor = true;
buttonTruckSave.Click += ButtonTruckSave_Click;
//
// buttonTruckCancel
//
buttonTruckCancel.Location = new Point(196, 170);
buttonTruckCancel.Name = "buttonTruckCancel";
buttonTruckCancel.Size = new Size(156, 37);
buttonTruckCancel.TabIndex = 17;
buttonTruckCancel.Text = "Отмена";
buttonTruckCancel.UseVisualStyleBackColor = true;
buttonTruckCancel.Click += ButtonTruckCancel_Click;
//
// comboBoxTruckType
//
comboBoxTruckType.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxTruckType.FormattingEnabled = true;
comboBoxTruckType.Location = new Point(158, 68);
comboBoxTruckType.Name = "comboBoxTruckType";
comboBoxTruckType.Size = new Size(183, 28);
comboBoxTruckType.TabIndex = 18;
//
// FormTruck
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(364, 222);
Controls.Add(comboBoxTruckType);
Controls.Add(buttonTruckCancel);
Controls.Add(buttonTruckSave);
Controls.Add(numericUpDownMaxFuel);
Controls.Add(labelMaxFuel);
Controls.Add(labelTruckBrand);
Controls.Add(textBoxTruckNumbers);
Controls.Add(labelTruckNumbers);
Name = "FormTruck";
StartPosition = FormStartPosition.CenterParent;
Text = "Фура";
((System.ComponentModel.ISupportInitialize)numericUpDownMaxFuel).EndInit();
ResumeLayout(false);
PerformLayout();
}
#endregion
private Label labelTruckBrand;
private TextBox textBoxTruckNumbers;
private Label labelTruckNumbers;
private Label labelMaxFuel;
private NumericUpDown numericUpDownMaxFuel;
private Button buttonTruckSave;
private Button buttonTruckCancel;
private ComboBox comboBoxTruckType;
}
}

View File

@ -0,0 +1,74 @@
using ProjectGarage.Entities;
using ProjectGarage.Entities.Enums;
using ProjectGarage.Repositories;
namespace ProjectGarage.Forms
{
public partial class FormTruck : Form
{
private readonly ITruckRepository _truckRepository;
private int? _truckId;
public int Id
{
set
{
try
{
var truck = _truckRepository.ReadTruckByID(value);
if (truck == null)
{
throw new InvalidDataException(nameof(truck));
}
textBoxTruckNumbers.Text = truck.Numbers;
comboBoxTruckType.SelectedItem = truck.Type;
numericUpDownMaxFuel.Value = truck.MaxFuel;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
}
public FormTruck(ITruckRepository truckRepository)
{
InitializeComponent();
_truckRepository = truckRepository ??
throw new ArgumentNullException(nameof(truckRepository));
comboBoxTruckType.DataSource = Enum.GetValues(typeof(TruckType));
}
private void ButtonTruckSave_Click(object sender, EventArgs e)
{
try
{
if (string.IsNullOrWhiteSpace(textBoxTruckNumbers.Text)
|| comboBoxTruckType.SelectedIndex < 1)
{
throw new Exception("Имеются незаполненные поля");
}
if (_truckId.HasValue)
{
_truckRepository.UpdateTruck(CreateTruck(_truckId.Value));
}
else
{
_truckRepository.CreateTruck(CreateTruck(0));
}
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonTruckCancel_Click(object sender, EventArgs e) => Close();
private Truck CreateTruck(int id) => Truck.CreateTruck(id, textBoxTruckNumbers.Text,
(TruckType)comboBoxTruckType.SelectedItem!, Convert.ToInt32(numericUpDownMaxFuel.Value));
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

126
ProjectGarage/Forms/FormTrucks.Designer.cs generated Normal file
View File

@ -0,0 +1,126 @@
namespace ProjectGarage.Forms
{
partial class FormTrucks
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
panelFormTrucksButtons = new Panel();
buttonUpdateTruck = new Button();
buttonDeleteTruck = new Button();
buttonAddTruck = new Button();
dataGridViewTrucks = new DataGridView();
panelFormTrucksButtons.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridViewTrucks).BeginInit();
SuspendLayout();
//
// panelFormTrucksButtons
//
panelFormTrucksButtons.Controls.Add(buttonUpdateTruck);
panelFormTrucksButtons.Controls.Add(buttonDeleteTruck);
panelFormTrucksButtons.Controls.Add(buttonAddTruck);
panelFormTrucksButtons.Dock = DockStyle.Right;
panelFormTrucksButtons.Location = new Point(565, 0);
panelFormTrucksButtons.Name = "panelFormTrucksButtons";
panelFormTrucksButtons.Size = new Size(161, 360);
panelFormTrucksButtons.TabIndex = 0;
//
// buttonUpdateTruck
//
buttonUpdateTruck.BackgroundImage = Properties.Resources.каранд;
buttonUpdateTruck.BackgroundImageLayout = ImageLayout.Stretch;
buttonUpdateTruck.Location = new Point(35, 140);
buttonUpdateTruck.Name = "buttonUpdateTruck";
buttonUpdateTruck.Size = new Size(94, 75);
buttonUpdateTruck.TabIndex = 2;
buttonUpdateTruck.UseVisualStyleBackColor = true;
buttonUpdateTruck.Click += ButtonUpdateTruck_Click;
//
// buttonDeleteTruck
//
buttonDeleteTruck.BackgroundImage = Properties.Resources.минусик;
buttonDeleteTruck.BackgroundImageLayout = ImageLayout.Stretch;
buttonDeleteTruck.Location = new Point(35, 247);
buttonDeleteTruck.Name = "buttonDeleteTruck";
buttonDeleteTruck.Size = new Size(94, 78);
buttonDeleteTruck.TabIndex = 1;
buttonDeleteTruck.UseVisualStyleBackColor = true;
buttonDeleteTruck.Click += ButtonDeleteTruck_Click;
//
// buttonAddTruck
//
buttonAddTruck.BackgroundImage = Properties.Resources.плюсик;
buttonAddTruck.BackgroundImageLayout = ImageLayout.Stretch;
buttonAddTruck.Location = new Point(35, 23);
buttonAddTruck.Name = "buttonAddTruck";
buttonAddTruck.Size = new Size(94, 75);
buttonAddTruck.TabIndex = 0;
buttonAddTruck.UseVisualStyleBackColor = true;
buttonAddTruck.Click += ButtonAddTruck_Click;
//
// dataGridViewTrucks
//
dataGridViewTrucks.AllowUserToAddRows = false;
dataGridViewTrucks.AllowUserToDeleteRows = false;
dataGridViewTrucks.AllowUserToResizeColumns = false;
dataGridViewTrucks.AllowUserToResizeRows = false;
dataGridViewTrucks.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridViewTrucks.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridViewTrucks.Dock = DockStyle.Fill;
dataGridViewTrucks.Location = new Point(0, 0);
dataGridViewTrucks.Name = "dataGridViewTrucks";
dataGridViewTrucks.ReadOnly = true;
dataGridViewTrucks.RowHeadersVisible = false;
dataGridViewTrucks.RowHeadersWidth = 51;
dataGridViewTrucks.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridViewTrucks.Size = new Size(565, 360);
dataGridViewTrucks.TabIndex = 1;
//
// FormTrucks
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(726, 360);
Controls.Add(dataGridViewTrucks);
Controls.Add(panelFormTrucksButtons);
Name = "FormTrucks";
StartPosition = FormStartPosition.CenterParent;
Text = "Фуры";
Load += FormTrucks_Load;
panelFormTrucksButtons.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)dataGridViewTrucks).EndInit();
ResumeLayout(false);
}
#endregion
private Panel panelFormTrucksButtons;
private Button buttonUpdateTruck;
private Button buttonDeleteTruck;
private Button buttonAddTruck;
private DataGridView dataGridViewTrucks;
}
}

View File

@ -0,0 +1,110 @@
using ProjectGarage.Repositories;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Unity;
namespace ProjectGarage.Forms
{
public partial class FormTrucks : Form
{
private readonly IUnityContainer _container;
private readonly ITruckRepository _truckRepository;
public FormTrucks(IUnityContainer container, ITruckRepository truckRepository)
{
InitializeComponent();
_container = container ?? throw new ArgumentNullException(nameof(container));
_truckRepository = truckRepository ?? throw new ArgumentNullException(nameof(truckRepository));
}
private void FormTrucks_Load(object sender, EventArgs e)
{
try
{
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при закгрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonAddTruck_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormTruck>().ShowDialog();
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonDeleteTruck_Click(object sender, EventArgs e)
{
if (!TryGetIDFromSelectedRow(out var findid))
{
return;
}
if (MessageBox.Show("Удалить звпись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes)
{
return;
}
try
{
_truckRepository.DeleteTruck(findid);
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonUpdateTruck_Click(object sender, EventArgs e)
{
if (!TryGetIDFromSelectedRow(out var findid))
{
return;
}
try
{
var form = _container.Resolve<FormTruck>();
form.Id = findid;
form.ShowDialog();
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void LoadList() => dataGridViewTrucks.DataSource = _truckRepository.ReadTrucks();
private bool TryGetIDFromSelectedRow(out int id)
{
id = 0;
if (dataGridViewTrucks.SelectedRows.Count < 1)
{
MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
id = Convert.ToInt32(dataGridViewTrucks.SelectedRows[0].Cells["Id"].Value);
return true;
}
}
}

View 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>

View File

@ -1,3 +1,7 @@
using ProjectGarage.Repositories;
using ProjectGarage.Repositories.Implementations;
using Unity;
namespace ProjectGarage
{
internal static class Program
@ -11,7 +15,21 @@ namespace ProjectGarage
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
Application.Run(new Form1());
Application.Run(CreateContainer().Resolve<FormGarage>());
}
private static IUnityContainer CreateContainer()
{
var container = new UnityContainer();
container.RegisterType<ITruckRepository, TruckRepository>();
container.RegisterType<IFuelRepository, FuelRepository>();
container.RegisterType<IRouteRepository, RouteRepository>();
container.RegisterType<IDriverRepository, DriverRepository>();
container.RegisterType<ITransportationRepository, TransportationRepository>();
container.RegisterType<IReplenishmentRepository, FuelReplishmentRepository>();
return container;
}
}
}

View File

@ -8,4 +8,23 @@
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Unity" Version="5.11.10" />
</ItemGroup>
<ItemGroup>
<Compile Update="Properties\Resources.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
</Project>

View File

@ -0,0 +1,93 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Этот код создан программой.
// Исполняемая версия:4.0.30319.42000
//
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
// повторной генерации кода.
// </auto-generated>
//------------------------------------------------------------------------------
namespace ProjectGarage.Properties {
using System;
/// <summary>
/// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д.
/// </summary>
// Этот класс создан автоматически классом StronglyTypedResourceBuilder
// с помощью такого средства, как ResGen или Visual Studio.
// Чтобы добавить или удалить член, измените файл .ResX и снова запустите ResGen
// с параметром /str или перестройте свой проект VS.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ProjectGarage.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Перезаписывает свойство CurrentUICulture текущего потока для всех
/// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap каранд {
get {
object obj = ResourceManager.GetObject("каранд", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap минусик {
get {
object obj = ResourceManager.GetObject("минусик", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap плюсик {
get {
object obj = ResourceManager.GetObject("плюсик", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
}
}

View File

@ -0,0 +1,130 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="минусик" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\минусик.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="плюсик" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\плюсик.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="каранд" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\каранд.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

View File

@ -0,0 +1,21 @@
using ProjectGarage.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectGarage.Repositories;
public interface IDriverRepository
{
IEnumerable<Driver> ReadDrivers();
Driver ReadDriverByID(int id);
void CreateDriver(Driver driver);
void UpdateDriver(Driver driver);
void DeleteDriver(int id);
}

View File

@ -0,0 +1,21 @@
using ProjectGarage.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectGarage.Repositories;
public interface IFuelRepository
{
IEnumerable<Fuel> ReadFuels();
Fuel ReadFuelByID(int id);
void CreateFuel(Fuel fuel);
void UpdateFuel(Fuel fuel);
void DeleteFuel(int id);
}

View File

@ -0,0 +1,17 @@
using ProjectGarage.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectGarage.Repositories;
public interface IReplenishmentRepository
{
IEnumerable<FuelReplenishment> ReadFuelReplenishment(DateTime? dateForm = null, DateTime? dateTo = null, int? fuelId = null,
int? driverId = null, int? routeId = null);
void CreateFuelReplenishment(FuelReplenishment fuelReplenishment);
void DeleteFuelReplenishment(int id);
}

View File

@ -0,0 +1,21 @@
using ProjectGarage.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectGarage.Repositories;
public interface IRouteRepository
{
IEnumerable<Route> ReadRoute(string? startPoint = null,string? finalPoint = null);
Route ReadRouteByID(int id);
void CreateRoute(Route route);
void UpdateRoute(Route route);
void DeleteRoute(int id);
}

View File

@ -0,0 +1,17 @@
using ProjectGarage.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectGarage.Repositories;
public interface ITransportationRepository
{
IEnumerable<Transportation> ReadTransportation(DateTime? dateForm = null, DateTime? dateTo = null, int? fuelId = null,
int? driverId = null, int? routeId = null);
void CreateTransportation(Transportation transportation);
void DeleteTransportation(int id);
}

View File

@ -0,0 +1,21 @@
using ProjectGarage.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectGarage.Repositories;
public interface ITruckRepository
{
IEnumerable<Truck> ReadTrucks();
Truck ReadTruckByID(int id);
void CreateTruck(Truck truck);
void UpdateTruck(Truck truck);
void DeleteTruck(int id);
}

View File

@ -0,0 +1,27 @@
using ProjectGarage.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectGarage.Repositories.Implementations;
public class DriverRepository : IDriverRepository
{
public void CreateDriver(Driver driver)
{
}
public void DeleteDriver(int id)
{
}
public Driver ReadDriverByID(int id) => Driver.CreateDriver(0, string.Empty, string.Empty, string.Empty, 0);
public IEnumerable<Driver> ReadDrivers() => [];
public void UpdateDriver(Driver driver)
{
}
}

View File

@ -0,0 +1,28 @@
using ProjectGarage.Entities;
using ProjectGarage.Entities.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectGarage.Repositories.Implementations;
public class FuelRepository : IFuelRepository
{
public void CreateFuel(Fuel fuel)
{
}
public void DeleteFuel(int id)
{
}
public Fuel ReadFuelByID(int id) => Fuel.CreateFuel(0, string.Empty, FuelType.None, 0);
public IEnumerable<Fuel> ReadFuels() => [];
public void UpdateFuel(Fuel fuel)
{
}
}

View File

@ -0,0 +1,24 @@
using ProjectGarage.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectGarage.Repositories.Implementations;
public class FuelReplishmentRepository : IReplenishmentRepository
{
public void CreateFuelReplenishment(FuelReplenishment fuelReplenishment)
{
}
public void DeleteFuelReplenishment(int id)
{
}
public IEnumerable<FuelReplenishment> ReadFuelReplenishment(DateTime? dateForm = null, DateTime? dateTo = null, int? fuelId = null, int? driverId = null, int? routeId = null)
{
return [];
}
}

View File

@ -0,0 +1,34 @@
using ProjectGarage.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectGarage.Repositories.Implementations;
public class RouteRepository : IRouteRepository
{
public void CreateFuelReplenishment(FuelReplenishment fuelReplenishment)
{
}
public void CreateRoute(Route route)
{
}
public void DeleteRoute(int id)
{
}
public Route ReadRouteByID(int id) => Route.CreateRoute(0, string.Empty, string.Empty, 0);
public IEnumerable<Route> ReadRoute(string? startPoint = null, string? finalPoint = null)
{
return [];
}
public void UpdateRoute(Route route)
{
}
}

View File

@ -0,0 +1,25 @@
using ProjectGarage.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectGarage.Repositories.Implementations;
public class TransportationRepository : ITransportationRepository
{
public void CreateTransportation(Transportation transportation)
{
}
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)
{
return [];
}
}

View File

@ -0,0 +1,28 @@
using ProjectGarage.Entities;
using ProjectGarage.Entities.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectGarage.Repositories.Implementations;
public class TruckRepository : ITruckRepository
{
public void CreateTruck(Truck truck)
{
}
public void DeleteTruck(int id)
{
}
public Truck ReadTruckByID(int id) => Truck.CreateTruck(0, string.Empty, TruckType.None, 0);
public IEnumerable<Truck> ReadTrucks() => [];
public void UpdateTruck(Truck truck)
{
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

BIN
каранд.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

BIN
минусик.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

BIN
плюсик.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

BIN
филмор1.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB