Коммит всей фазы

This commit is contained in:
Anastasia_52 2024-12-16 22:25:06 +04:00
parent fbd52f6b2a
commit 2c89c1bea9
73 changed files with 5322 additions and 77 deletions

View File

@ -0,0 +1,32 @@
using ProjectGSM.Entities.Enums;
using Microsoft.VisualBasic;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectGSM.Entities;
public class Car
{
public int Car_ID { get; private set; }
public string Car_Mark { get; private set; } = string.Empty;
public string Car_Model { get; private set; } = string.Empty;
public Car_Type Car_Type { get; private set; }
public СategoryRights License { get; private set; }
public float Consumption_Rate { get; private set; }
public static Car CreateEntity(int car_ID, string car_mark, string car_model, Car_Type car_type, СategoryRights license, float consumption)
{
return new Car
{
Car_ID = car_ID,
Car_Mark = car_mark ?? string.Empty,
Car_Model = car_model ?? string.Empty,
Car_Type = car_type,
License = license,
Consumption_Rate = consumption
};
}
}

View File

@ -0,0 +1,27 @@
using ProjectGSM.Entities.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectGSM.Entities;
public class Driver
{
public int Driver_ID { get; private set; }
public string Firstname { get; private set; } = string.Empty;
public string Secondname { get; private set; } = string.Empty;
public СategoryRights Driver_License { get; private set; }
public static Driver CreateEntity(int driver_ID, string firstname, string secondname, СategoryRights license)
{
return new Driver
{
Driver_ID = driver_ID,
Firstname = firstname ?? string.Empty,
Secondname = secondname ?? string.Empty,
Driver_License = license
};
}
}

View File

@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectGSM.Entities.Enums;
public enum Car_Type
{
None = 0,
Passender_car = 1,
Truck = 2,
Bus = 3
}

View File

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectGSM.Entities.Enums;
public enum FuelType
{
None = 0,
Petrol = 1,
Diesel = 2
}

View File

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectGSM.Entities.Enums;
[Flags]
public enum СategoryRights
{
None = 0,
A = 1,
B = 2,
C = 4,
D = 8
}

View File

@ -0,0 +1,29 @@
using Microsoft.VisualBasic.FileIO;
using ProjectGSM.Entities.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms.VisualStyles;
namespace ProjectGSM.Entities;
public class PetrolStation
{
public int Fuel_ID { get; private set; }
public FuelType Fuel_Type { get; private set; }
public float Price_Per_Liter { get; private set; }
public float Amount { get; private set; }
public static PetrolStation CreateEntity(int fuel_id, FuelType type, float price, float amount)
{
return new PetrolStation
{
Fuel_ID = fuel_id,
Fuel_Type = type,
Price_Per_Liter = price,
Amount = amount
};
}
}

View File

@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectGSM.Entities;
public class Refill
{
public int Refill_ID { get; private set; }
public DateTime Refill_Date { get; private set; }
public float Quantity { get; private set; }
public int Fuel_ID { get; private set; }
public int Car_ID { get; private set; }
public static Refill CreateOperation(int refill_ID, DateTime refill_date, float quantity, int fuel_id, int car_id)
{
return new Refill
{
Refill_ID = refill_ID,
Refill_Date = refill_date,
Quantity = quantity,
Fuel_ID = fuel_id,
Car_ID = car_id
};
}
}

View File

@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectGSM.Entities;
public class Route
{
public int Route_ID { get; private set; }
public string Start_Point { get; private set; } = string.Empty;
public string End_Point { get; private set; } = string.Empty;
public float Route_Length { get; private set; }
public static Route CreateEntity(int route_id, string start_point, string end_point, float length)
{
return new Route
{
Route_ID = route_id,
Start_Point = start_point ?? string.Empty,
End_Point = end_point ?? string.Empty,
Route_Length = length
};
}
}

View File

@ -0,0 +1,33 @@
using ProjectGSM.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectGSM.Entities;
public class RouteSheet
{
public int Trip_ID { get; private set; }
public DateTime Start_Date { get; private set; }
public DateTime End_Date { get; private set; }
public float Fuel_Consumption { get; private set; }
public int Car_ID { get; private set; }
public int Driver_ID { get; private set; }
public IEnumerable<Route> Routes { get; private set; } = [];
public static RouteSheet CreateOperation(int trip_id, DateTime start_date, DateTime end_date, float consumption, int car_id, int driver_id, IEnumerable<Route> routes)
{
return new RouteSheet
{
Trip_ID = trip_id,
Start_Date = start_date,
End_Date = end_date,
Fuel_Consumption = consumption,
Car_ID = car_id,
Driver_ID = driver_id,
Routes = routes
};
}
}

View File

@ -1,39 +0,0 @@
namespace ProjectGSM
{
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 ProjectGSM
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
}

147
ProjectGSM/FormGSM.Designer.cs generated Normal file
View File

@ -0,0 +1,147 @@
namespace ProjectGSM
{
partial class FormGSM
{
/// <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()
{
menuStrip = new MenuStrip();
справочникиToolStripMenuItem = new ToolStripMenuItem();
CarsToolStripMenuItem = new ToolStripMenuItem();
DriversToolStripMenuItem = new ToolStripMenuItem();
FuelToolStripMenuItem = new ToolStripMenuItem();
RoutesToolStripMenuItem = new ToolStripMenuItem();
операцииToolStripMenuItem = new ToolStripMenuItem();
RefillToolStripMenuItem = new ToolStripMenuItem();
TripToolStripMenuItem = new ToolStripMenuItem();
отчётыToolStripMenuItem = new ToolStripMenuItem();
menuStrip.SuspendLayout();
SuspendLayout();
//
// menuStrip
//
menuStrip.ImageScalingSize = new Size(20, 20);
menuStrip.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, операцииToolStripMenuItem, отчётыToolStripMenuItem });
menuStrip.Location = new Point(0, 0);
menuStrip.Name = "menuStrip";
menuStrip.Size = new Size(782, 28);
menuStrip.TabIndex = 0;
menuStrip.Text = "menuStrip1";
//
// справочникиToolStripMenuItem
//
справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { CarsToolStripMenuItem, DriversToolStripMenuItem, FuelToolStripMenuItem, RoutesToolStripMenuItem });
справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
справочникиToolStripMenuItem.Size = new Size(120, 24);
справочникиToolStripMenuItem.Text = "Справочники:";
//
// CarsToolStripMenuItem
//
CarsToolStripMenuItem.Name = "CarsToolStripMenuItem";
CarsToolStripMenuItem.Size = new Size(224, 26);
CarsToolStripMenuItem.Text = "Машина";
CarsToolStripMenuItem.Click += CarsToolStripMenuItem_Click;
//
// DriversToolStripMenuItem
//
DriversToolStripMenuItem.Name = "DriversToolStripMenuItem";
DriversToolStripMenuItem.Size = new Size(224, 26);
DriversToolStripMenuItem.Text = "Водитель";
DriversToolStripMenuItem.Click += DriversToolStripMenuItem_Click;
//
// FuelToolStripMenuItem
//
FuelToolStripMenuItem.Name = "FuelToolStripMenuItem";
FuelToolStripMenuItem.Size = new Size(224, 26);
FuelToolStripMenuItem.Text = "Заправка";
FuelToolStripMenuItem.Click += FuelToolStripMenuItem_Click;
//
// RoutesToolStripMenuItem
//
RoutesToolStripMenuItem.Name = "RoutesToolStripMenuItem";
RoutesToolStripMenuItem.Size = new Size(224, 26);
RoutesToolStripMenuItem.Text = "Маршрут";
RoutesToolStripMenuItem.Click += RoutesToolStripMenuItem_Click;
//
// операцииToolStripMenuItem
//
операцииToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { RefillToolStripMenuItem, TripToolStripMenuItem });
операцииToolStripMenuItem.Name = "операцииToolStripMenuItem";
операцииToolStripMenuItem.Size = new Size(98, 24);
операцииToolStripMenuItem.Text = "Операции:";
//
// RefillToolStripMenuItem
//
RefillToolStripMenuItem.Name = "RefillToolStripMenuItem";
RefillToolStripMenuItem.Size = new Size(224, 26);
RefillToolStripMenuItem.Text = "Пополнение";
RefillToolStripMenuItem.Click += RefillToolStripMenuItem_Click;
//
// TripToolStripMenuItem
//
TripToolStripMenuItem.Name = "TripToolStripMenuItem";
TripToolStripMenuItem.Size = new Size(224, 26);
TripToolStripMenuItem.Text = "Выбор поездки";
TripToolStripMenuItem.Click += TripToolStripMenuItem_Click;
//
// отчётыToolStripMenuItem
//
отчётыToolStripMenuItem.Name = "отчётыToolStripMenuItem";
отчётыToolStripMenuItem.Size = new Size(73, 24);
отчётыToolStripMenuItem.Text = "Отчёты";
//
// FormGSM
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
BackgroundImage = Properties.Resources._5332808188908660305;
BackgroundImageLayout = ImageLayout.Stretch;
ClientSize = new Size(782, 403);
Controls.Add(menuStrip);
MainMenuStrip = menuStrip;
Name = "FormGSM";
StartPosition = FormStartPosition.CenterScreen;
Text = "Отчёт ГСМ";
menuStrip.ResumeLayout(false);
menuStrip.PerformLayout();
ResumeLayout(false);
PerformLayout();
}
#endregion
private MenuStrip menuStrip;
private ToolStripMenuItem справочникиToolStripMenuItem;
private ToolStripMenuItem CarsToolStripMenuItem;
private ToolStripMenuItem DriversToolStripMenuItem;
private ToolStripMenuItem FuelToolStripMenuItem;
private ToolStripMenuItem операцииToolStripMenuItem;
private ToolStripMenuItem RefillToolStripMenuItem;
private ToolStripMenuItem TripToolStripMenuItem;
private ToolStripMenuItem отчётыToolStripMenuItem;
private ToolStripMenuItem RoutesToolStripMenuItem;
}
}

96
ProjectGSM/FormGSM.cs Normal file
View File

@ -0,0 +1,96 @@
using ProjectGSM.Forms;
using Unity;
namespace ProjectGSM
{
public partial class FormGSM : Form
{
private readonly IUnityContainer _container;
public FormGSM(IUnityContainer container)
{
InitializeComponent();
_container = container ??
throw new ArgumentNullException(nameof(container));
}
private void CarsToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormCars>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "?????? ??? ????????",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
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 FuelToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormPetrolStations>().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 RefillToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormRefills>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "?????? ??? ????????",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void TripToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormRouteSheets>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "?????? ??? ????????",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}

123
ProjectGSM/FormGSM.resx Normal file
View File

@ -0,0 +1,123 @@
<?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="menuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

189
ProjectGSM/Forms/FormCar.Designer.cs generated Normal file
View File

@ -0,0 +1,189 @@
namespace ProjectGSM.Forms
{
partial class FormCar
{
/// <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()
{
Car_Mark = new Label();
Car_Model = new Label();
Car_Type = new Label();
labelСategoryRights = new Label();
Consumption_Rate = new Label();
textBoxCarModel = new TextBox();
textBoxCarMark = new TextBox();
comboBoxCarType = new ComboBox();
checkedListBoxСategoryRights = new CheckedListBox();
numericUpDownConsumptionRate = new NumericUpDown();
CarSave = new Button();
buttonCancel = new Button();
((System.ComponentModel.ISupportInitialize)numericUpDownConsumptionRate).BeginInit();
SuspendLayout();
//
// Car_Mark
//
Car_Mark.AutoSize = true;
Car_Mark.Location = new Point(24, 21);
Car_Mark.Name = "Car_Mark";
Car_Mark.Size = new Size(121, 20);
Car_Mark.TabIndex = 0;
Car_Mark.Text = "Марка машины:";
//
// Car_Model
//
Car_Model.AutoSize = true;
Car_Model.Location = new Point(24, 57);
Car_Model.Name = "Car_Model";
Car_Model.Size = new Size(130, 20);
Car_Model.TabIndex = 1;
Car_Model.Text = "Модель машины:";
//
// Car_Type
//
Car_Type.AutoSize = true;
Car_Type.Location = new Point(24, 93);
Car_Type.Name = "Car_Type";
Car_Type.Size = new Size(102, 20);
Car_Type.TabIndex = 2;
Car_Type.Text = "Тип машины:";
//
// labelСategoryRights
//
labelСategoryRights.AutoSize = true;
labelСategoryRights.Location = new Point(24, 130);
labelСategoryRights.Name = "labelСategoryRights";
labelСategoryRights.Size = new Size(84, 20);
labelСategoryRights.TabIndex = 3;
labelСategoryRights.Text = "Категория:";
//
// Consumption_Rate
//
Consumption_Rate.AutoSize = true;
Consumption_Rate.Location = new Point(24, 259);
Consumption_Rate.Name = "Consumption_Rate";
Consumption_Rate.Size = new Size(120, 20);
Consumption_Rate.TabIndex = 4;
Consumption_Rate.Text = "Расход топлива:";
//
// textBoxCarModel
//
textBoxCarModel.Location = new Point(172, 57);
textBoxCarModel.Name = "textBoxCarModel";
textBoxCarModel.Size = new Size(151, 27);
textBoxCarModel.TabIndex = 5;
//
// textBoxCarMark
//
textBoxCarMark.Location = new Point(172, 21);
textBoxCarMark.Name = "textBoxCarMark";
textBoxCarMark.Size = new Size(151, 27);
textBoxCarMark.TabIndex = 6;
//
// comboBoxCarType
//
comboBoxCarType.FormattingEnabled = true;
comboBoxCarType.Location = new Point(172, 93);
comboBoxCarType.Name = "comboBoxCarType";
comboBoxCarType.Size = new Size(151, 28);
comboBoxCarType.TabIndex = 7;
//
// checkedListBoxСategoryRights
//
checkedListBoxСategoryRights.FormattingEnabled = true;
checkedListBoxСategoryRights.Location = new Point(172, 127);
checkedListBoxСategoryRights.Name = "checkedListBoxСategoryRights";
checkedListBoxСategoryRights.Size = new Size(150, 114);
checkedListBoxСategoryRights.TabIndex = 8;
//
// numericUpDownConsumptionRate
//
numericUpDownConsumptionRate.DecimalPlaces = 2;
numericUpDownConsumptionRate.Location = new Point(173, 257);
numericUpDownConsumptionRate.Name = "numericUpDownConsumptionRate";
numericUpDownConsumptionRate.Size = new Size(150, 27);
numericUpDownConsumptionRate.TabIndex = 9;
//
// CarSave
//
CarSave.Location = new Point(50, 321);
CarSave.Name = "CarSave";
CarSave.Size = new Size(94, 29);
CarSave.TabIndex = 10;
CarSave.Text = "Сохранить";
CarSave.UseVisualStyleBackColor = true;
CarSave.Click += CarSave_Click;
//
// buttonCancel
//
buttonCancel.Location = new Point(199, 321);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(94, 29);
buttonCancel.TabIndex = 11;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += buttonCancel_Click;
//
// FormCar
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(409, 380);
Controls.Add(buttonCancel);
Controls.Add(CarSave);
Controls.Add(numericUpDownConsumptionRate);
Controls.Add(checkedListBoxСategoryRights);
Controls.Add(comboBoxCarType);
Controls.Add(textBoxCarMark);
Controls.Add(textBoxCarModel);
Controls.Add(Consumption_Rate);
Controls.Add(labelСategoryRights);
Controls.Add(Car_Type);
Controls.Add(Car_Model);
Controls.Add(Car_Mark);
Name = "FormCar";
StartPosition = FormStartPosition.CenterParent;
Text = "Машина";
((System.ComponentModel.ISupportInitialize)numericUpDownConsumptionRate).EndInit();
ResumeLayout(false);
PerformLayout();
}
#endregion
private Label Car_Mark;
private Label Car_Model;
private Label Car_Type;
private Label labelСategoryRights;
private Label Consumption_Rate;
private TextBox textBoxCarModel;
private TextBox textBoxCarMark;
private ComboBox comboBoxCarType;
private CheckedListBox checkedListBoxСategoryRights;
private NumericUpDown numericUpDownConsumptionRate;
private Button CarSave;
private Button buttonCancel;
}
}

100
ProjectGSM/Forms/FormCar.cs Normal file
View File

@ -0,0 +1,100 @@
using ProjectGSM.Entities.Enums;
using ProjectGSM.Entities;
using ProjectGSM.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 ProjectGSM.Forms
{
public partial class FormCar : Form
{
private readonly ICarRepository _carRepository;
private int? _carId;
public int Id
{
set
{
try
{
var car = _carRepository.ReadCarByID(value);
if (car == null)
throw new InvalidOperationException(nameof(car));
foreach (СategoryRights elem in Enum.GetValues(typeof(СategoryRights)))
{
if ((elem & car.License) != 0)
{
checkedListBoxСategoryRights.SetItemChecked(checkedListBoxСategoryRights.Items.IndexOf(elem), true);
}
}
textBoxCarMark.Text = car.Car_Mark;
textBoxCarModel.Text = car.Car_Model;
comboBoxCarType.SelectedItem = car.Car_Type;
numericUpDownConsumptionRate.Value = (decimal)car.Consumption_Rate;
_carId = value;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
}
public FormCar(ICarRepository carRepository)
{
InitializeComponent();
_carRepository = carRepository ??
throw new ArgumentNullException(nameof(carRepository));
foreach (var elem in Enum.GetValues(typeof(СategoryRights)))
checkedListBoxСategoryRights.Items.Add(elem);
comboBoxCarType.DataSource = Enum.GetValues(typeof(Car_Type));
}
private Car CreateCar(int id)
{
СategoryRights categoryRights = СategoryRights.None;
foreach (var elem in checkedListBoxСategoryRights.CheckedItems)
{
categoryRights |= (СategoryRights)elem;
}
return Car.CreateEntity(id, textBoxCarMark.Text, textBoxCarModel.Text, (Car_Type)comboBoxCarType.SelectedItem!, categoryRights, (float)numericUpDownConsumptionRate.Value);
}
private void buttonCancel_Click(object sender, EventArgs e) => Close();
private void CarSave_Click(object sender, EventArgs e)
{
try
{
if (string.IsNullOrWhiteSpace(textBoxCarMark.Text) || string.IsNullOrWhiteSpace(textBoxCarModel.Text) || comboBoxCarType.SelectedIndex < 1 || checkedListBoxСategoryRights.CheckedItems.Count == 0)
throw new Exception("Имеются незаполненные поля");
if (_carId.HasValue)
_carRepository.UpdateCar(CreateCar(_carId.Value));
else
_carRepository.CreateCar(CreateCar(0));
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}

View File

@ -1,17 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
<!--
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.
-->

127
ProjectGSM/Forms/FormCars.Designer.cs generated Normal file
View File

@ -0,0 +1,127 @@
namespace ProjectGSM.Forms
{
partial class FormCars
{
/// <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()
{
panel1 = new Panel();
buttonDel = new Button();
buttonUpd = new Button();
buttonAdd = new Button();
dataGridView = new DataGridView();
panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
SuspendLayout();
//
// panel1
//
panel1.Controls.Add(buttonDel);
panel1.Controls.Add(buttonUpd);
panel1.Controls.Add(buttonAdd);
panel1.Dock = DockStyle.Right;
panel1.Location = new Point(641, 0);
panel1.Name = "panel1";
panel1.Size = new Size(159, 450);
panel1.TabIndex = 0;
//
// buttonDel
//
buttonDel.BackgroundImage = Properties.Resources.минус;
buttonDel.BackgroundImageLayout = ImageLayout.Stretch;
buttonDel.Location = new Point(46, 257);
buttonDel.Name = "buttonDel";
buttonDel.Size = new Size(79, 82);
buttonDel.TabIndex = 2;
buttonDel.UseVisualStyleBackColor = true;
buttonDel.Click += buttonDel_Click;
//
// buttonUpd
//
buttonUpd.BackgroundImage = Properties.Resources.кисть;
buttonUpd.BackgroundImageLayout = ImageLayout.Stretch;
buttonUpd.Location = new Point(46, 152);
buttonUpd.Name = "buttonUpd";
buttonUpd.Size = new Size(79, 82);
buttonUpd.TabIndex = 1;
buttonUpd.UseVisualStyleBackColor = true;
buttonUpd.Click += buttonUpd_Click;
//
// buttonAdd
//
buttonAdd.BackgroundImage = Properties.Resources.Плюс;
buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
buttonAdd.Location = new Point(46, 45);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(79, 82);
buttonAdd.TabIndex = 0;
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += buttonAdd_Click;
//
// dataGridView
//
dataGridView.AllowUserToAddRows = false;
dataGridView.AllowUserToDeleteRows = false;
dataGridView.AllowUserToResizeColumns = false;
dataGridView.AllowUserToResizeRows = false;
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Dock = DockStyle.Fill;
dataGridView.Location = new Point(0, 0);
dataGridView.MultiSelect = false;
dataGridView.Name = "dataGridView";
dataGridView.ReadOnly = true;
dataGridView.RowHeadersVisible = false;
dataGridView.RowHeadersWidth = 51;
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridView.Size = new Size(641, 450);
dataGridView.TabIndex = 1;
//
// FormCars
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450);
Controls.Add(dataGridView);
Controls.Add(panel1);
Name = "FormCars";
StartPosition = FormStartPosition.CenterParent;
Text = "Машины";
Load += FormCars_Load;
panel1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false);
}
#endregion
private Panel panel1;
private Button buttonAdd;
private Button buttonDel;
private Button buttonUpd;
private DataGridView dataGridView;
}
}

View File

@ -0,0 +1,111 @@
using ProjectGSM.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 ProjectGSM.Forms
{
public partial class FormCars : Form
{
private readonly IUnityContainer _container;
private readonly ICarRepository _carRepository;
public FormCars(IUnityContainer container, ICarRepository carRepository)
{
InitializeComponent();
_container = container ??
throw new ArgumentNullException(nameof(container));
_carRepository = carRepository ??
throw new ArgumentNullException(nameof(carRepository));
}
private void LoadList() => dataGridView.DataSource = _carRepository.ReadCars();
private bool TryGetIdentifierFromSelectedRow(out int id)
{
id = 0;
if (dataGridView.SelectedRows.Count < 1)
{
MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Car_ID"].Value);
return true;
}
private void buttonUpd_Click(object sender, EventArgs e)
{
if (!TryGetIdentifierFromSelectedRow(out var findId))
return;
try
{
var form = _container.Resolve<FormCar>();
form.Id = findId;
form.ShowDialog();
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при изменении",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonDel_Click(object sender, EventArgs e)
{
if (!TryGetIdentifierFromSelectedRow(out var findId))
return;
if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes)
return;
try
{
_carRepository.DeleteCar(findId);
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void FormCars_Load(object sender, EventArgs e)
{
try
{
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonAdd_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormCar>().ShowDialog();
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}

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>

141
ProjectGSM/Forms/FormDriver.Designer.cs generated Normal file
View File

@ -0,0 +1,141 @@
namespace ProjectGSM.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()
{
label1 = new Label();
label2 = new Label();
label3 = new Label();
buttonSave = new Button();
buttonCancel = new Button();
textBoxDriverSecondname = new TextBox();
textBoxDriverFirstname = new TextBox();
checkedListBoxСategoryRights = new CheckedListBox();
SuspendLayout();
//
// label1
//
label1.AutoSize = true;
label1.Location = new Point(34, 26);
label1.Name = "label1";
label1.Size = new Size(42, 20);
label1.TabIndex = 0;
label1.Text = "Имя:";
//
// label2
//
label2.AutoSize = true;
label2.Location = new Point(34, 68);
label2.Name = "label2";
label2.Size = new Size(76, 20);
label2.TabIndex = 1;
label2.Text = "Фамилия:";
//
// label3
//
label3.AutoSize = true;
label3.Location = new Point(34, 120);
label3.Name = "label3";
label3.Size = new Size(122, 20);
label3.TabIndex = 2;
label3.Text = "Категория прав:";
//
// buttonSave
//
buttonSave.Location = new Point(47, 284);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(94, 29);
buttonSave.TabIndex = 3;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += buttonSave_Click;
//
// buttonCancel
//
buttonCancel.Location = new Point(185, 284);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(94, 29);
buttonCancel.TabIndex = 4;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += buttonCancel_Click;
//
// textBoxDriverSecondname
//
textBoxDriverSecondname.Location = new Point(165, 68);
textBoxDriverSecondname.Name = "textBoxDriverSecondname";
textBoxDriverSecondname.Size = new Size(150, 27);
textBoxDriverSecondname.TabIndex = 5;
//
// textBoxDriverFirstname
//
textBoxDriverFirstname.Location = new Point(165, 23);
textBoxDriverFirstname.Name = "textBoxDriverFirstname";
textBoxDriverFirstname.Size = new Size(150, 27);
textBoxDriverFirstname.TabIndex = 6;
//
// checkedListBoxСategoryRights
//
checkedListBoxСategoryRights.FormattingEnabled = true;
checkedListBoxСategoryRights.Location = new Point(165, 120);
checkedListBoxСategoryRights.Name = "checkedListBoxСategoryRights";
checkedListBoxСategoryRights.Size = new Size(150, 114);
checkedListBoxСategoryRights.TabIndex = 7;
//
// FormDriver
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(383, 350);
Controls.Add(checkedListBoxСategoryRights);
Controls.Add(textBoxDriverFirstname);
Controls.Add(textBoxDriverSecondname);
Controls.Add(buttonCancel);
Controls.Add(buttonSave);
Controls.Add(label3);
Controls.Add(label2);
Controls.Add(label1);
Name = "FormDriver";
StartPosition = FormStartPosition.CenterParent;
Text = "Водитель";
ResumeLayout(false);
PerformLayout();
}
#endregion
private Label label1;
private Label label2;
private Label label3;
private Button buttonSave;
private Button buttonCancel;
private TextBox textBoxDriverSecondname;
private TextBox textBoxDriverFirstname;
private CheckedListBox checkedListBoxСategoryRights;
}
}

View File

@ -0,0 +1,97 @@
using ProjectGSM.Entities.Enums;
using ProjectGSM.Entities;
using ProjectGSM.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 ProjectGSM.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 InvalidOperationException(nameof(driver));
foreach (СategoryRights elem in Enum.GetValues(typeof(СategoryRights)))
{
if ((elem & driver.Driver_License) != 0)
{
checkedListBoxСategoryRights.SetItemChecked(checkedListBoxСategoryRights.Items.IndexOf(elem), true);
}
}
textBoxDriverFirstname.Text = driver.Firstname;
textBoxDriverSecondname.Text = driver.Secondname;
_driverId = value;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
}
public FormDriver(IDriverRepository driverRepository)
{
InitializeComponent();
_driverRepository = driverRepository ??
throw new ArgumentNullException(nameof(driverRepository));
foreach (var elem in Enum.GetValues(typeof(СategoryRights)))
checkedListBoxСategoryRights.Items.Add(elem);
}
private Driver CreateDriver(int id)
{
СategoryRights categoryRights = СategoryRights.None;
foreach (var elem in checkedListBoxСategoryRights.CheckedItems)
{
categoryRights |= (СategoryRights)elem;
}
return Driver.CreateEntity(id, textBoxDriverFirstname.Text, textBoxDriverSecondname.Text, categoryRights);
}
private void buttonSave_Click(object sender, EventArgs e)
{
try
{
if (string.IsNullOrWhiteSpace(textBoxDriverFirstname.Text) || string.IsNullOrWhiteSpace(textBoxDriverSecondname.Text) || checkedListBoxСategoryRights.CheckedItems.Count == 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 buttonCancel_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>

127
ProjectGSM/Forms/FormDrivers.Designer.cs generated Normal file
View File

@ -0,0 +1,127 @@
namespace ProjectGSM.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()
{
panel1 = new Panel();
buttonDel = new Button();
buttonUpd = new Button();
buttonAdd = new Button();
dataGridView = new DataGridView();
panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
SuspendLayout();
//
// panel1
//
panel1.Controls.Add(buttonDel);
panel1.Controls.Add(buttonUpd);
panel1.Controls.Add(buttonAdd);
panel1.Dock = DockStyle.Right;
panel1.Location = new Point(640, 0);
panel1.Name = "panel1";
panel1.Size = new Size(160, 450);
panel1.TabIndex = 0;
//
// buttonDel
//
buttonDel.BackgroundImage = Properties.Resources.минус;
buttonDel.BackgroundImageLayout = ImageLayout.Stretch;
buttonDel.Location = new Point(45, 268);
buttonDel.Name = "buttonDel";
buttonDel.Size = new Size(79, 82);
buttonDel.TabIndex = 3;
buttonDel.UseVisualStyleBackColor = true;
buttonDel.Click += buttonDel_Click;
//
// buttonUpd
//
buttonUpd.BackgroundImage = Properties.Resources.кисть;
buttonUpd.BackgroundImageLayout = ImageLayout.Stretch;
buttonUpd.Location = new Point(45, 148);
buttonUpd.Name = "buttonUpd";
buttonUpd.Size = new Size(79, 82);
buttonUpd.TabIndex = 2;
buttonUpd.UseVisualStyleBackColor = true;
buttonUpd.Click += buttonUpd_Click;
//
// buttonAdd
//
buttonAdd.BackgroundImage = Properties.Resources.Плюс;
buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
buttonAdd.Location = new Point(45, 37);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(79, 82);
buttonAdd.TabIndex = 1;
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += buttonAdd_Click;
//
// dataGridView
//
dataGridView.AllowUserToAddRows = false;
dataGridView.AllowUserToDeleteRows = false;
dataGridView.AllowUserToResizeColumns = false;
dataGridView.AllowUserToResizeRows = false;
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Dock = DockStyle.Fill;
dataGridView.Location = new Point(0, 0);
dataGridView.MultiSelect = false;
dataGridView.Name = "dataGridView";
dataGridView.ReadOnly = true;
dataGridView.RowHeadersVisible = false;
dataGridView.RowHeadersWidth = 51;
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridView.Size = new Size(640, 450);
dataGridView.TabIndex = 2;
//
// FormDrivers
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450);
Controls.Add(dataGridView);
Controls.Add(panel1);
Name = "FormDrivers";
StartPosition = FormStartPosition.CenterParent;
Text = "Водители";
Load += FormDrivers_Load;
panel1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false);
}
#endregion
private Panel panel1;
private Button buttonAdd;
private Button buttonUpd;
private Button buttonDel;
private DataGridView dataGridView;
}
}

View File

@ -0,0 +1,108 @@
using ProjectGSM.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 ProjectGSM.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 LoadList() => dataGridView.DataSource = _driverRepository.ReadDrivers();
private bool TryGetIdentifierFromSelectedRow(out int id)
{
id = 0;
if (dataGridView.SelectedRows.Count < 1)
{
MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Driver_ID"].Value);
return true;
}
private void buttonAdd_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormDriver>().ShowDialog();
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonUpd_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 buttonDel_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 FormDrivers_Load(object sender, EventArgs e)
{
try
{
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}

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,147 @@
namespace ProjectGSM.Forms
{
partial class FormPetrolStation
{
/// <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()
{
label1 = new Label();
label2 = new Label();
label3 = new Label();
comboBoxType = new ComboBox();
numericUpDownPrice = new NumericUpDown();
numericUpDownAmount = new NumericUpDown();
buttonSave = new Button();
buttonCancel = new Button();
((System.ComponentModel.ISupportInitialize)numericUpDownPrice).BeginInit();
((System.ComponentModel.ISupportInitialize)numericUpDownAmount).BeginInit();
SuspendLayout();
//
// label1
//
label1.AutoSize = true;
label1.Location = new Point(25, 28);
label1.Name = "label1";
label1.Size = new Size(99, 20);
label1.TabIndex = 0;
label1.Text = "Тип топлива:";
//
// label2
//
label2.AutoSize = true;
label2.Location = new Point(25, 83);
label2.Name = "label2";
label2.Size = new Size(48, 20);
label2.TabIndex = 1;
label2.Text = "Цена:";
//
// label3
//
label3.AutoSize = true;
label3.Location = new Point(25, 146);
label3.Name = "label3";
label3.Size = new Size(93, 20);
label3.TabIndex = 2;
label3.Text = "Количество:";
//
// comboBoxType
//
comboBoxType.FormattingEnabled = true;
comboBoxType.Location = new Point(156, 28);
comboBoxType.Name = "comboBoxType";
comboBoxType.Size = new Size(151, 28);
comboBoxType.TabIndex = 3;
//
// numericUpDownPrice
//
numericUpDownPrice.DecimalPlaces = 2;
numericUpDownPrice.Location = new Point(157, 83);
numericUpDownPrice.Name = "numericUpDownPrice";
numericUpDownPrice.Size = new Size(150, 27);
numericUpDownPrice.TabIndex = 4;
//
// numericUpDownAmount
//
numericUpDownAmount.DecimalPlaces = 2;
numericUpDownAmount.Location = new Point(157, 139);
numericUpDownAmount.Name = "numericUpDownAmount";
numericUpDownAmount.Size = new Size(150, 27);
numericUpDownAmount.TabIndex = 5;
//
// buttonSave
//
buttonSave.Location = new Point(40, 229);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(94, 29);
buttonSave.TabIndex = 6;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += buttonSave_Click;
//
// buttonCancel
//
buttonCancel.Location = new Point(170, 229);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(94, 29);
buttonCancel.TabIndex = 7;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += buttonCancel_Click;
//
// FormPetrolStation
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(353, 331);
Controls.Add(buttonCancel);
Controls.Add(buttonSave);
Controls.Add(numericUpDownAmount);
Controls.Add(numericUpDownPrice);
Controls.Add(comboBoxType);
Controls.Add(label3);
Controls.Add(label2);
Controls.Add(label1);
Name = "FormPetrolStation";
StartPosition = FormStartPosition.CenterParent;
Text = "Топливо";
((System.ComponentModel.ISupportInitialize)numericUpDownPrice).EndInit();
((System.ComponentModel.ISupportInitialize)numericUpDownAmount).EndInit();
ResumeLayout(false);
PerformLayout();
}
#endregion
private Label label1;
private Label label2;
private Label label3;
private ComboBox comboBoxType;
private NumericUpDown numericUpDownPrice;
private NumericUpDown numericUpDownAmount;
private Button buttonSave;
private Button buttonCancel;
}
}

View File

@ -0,0 +1,81 @@
using ProjectGSM.Entities.Enums;
using ProjectGSM.Entities;
using ProjectGSM.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 ProjectGSM.Forms
{
public partial class FormPetrolStation : Form
{
private readonly IPetrolStationRepository _petrolStationRepository;
private int? _fuelId;
public int Id
{
set
{
try
{
var fuel = _petrolStationRepository.ReadPetrolStationByID(value);
if (fuel == null)
throw new InvalidOperationException(nameof(fuel));
comboBoxType.SelectedItem = fuel.Fuel_Type;
numericUpDownPrice.Value = (decimal)fuel.Price_Per_Liter;
numericUpDownAmount.Value = (decimal)fuel.Amount;
_fuelId = value;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
}
public FormPetrolStation(IPetrolStationRepository petrolStationRepository)
{
InitializeComponent();
_petrolStationRepository = petrolStationRepository ??
throw new ArgumentNullException(nameof(petrolStationRepository));
comboBoxType.DataSource = Enum.GetValues(typeof(FuelType));
}
private PetrolStation CreateFuel(int id)
{
return PetrolStation.CreateEntity(id, (FuelType)comboBoxType.SelectedItem!, (float)numericUpDownPrice.Value, (float)numericUpDownAmount.Value);
}
private void buttonSave_Click(object sender, EventArgs e)
{
try
{
if (comboBoxType.SelectedIndex < 1)
throw new Exception("Имеются незаполненные поля");
if (_fuelId.HasValue)
_petrolStationRepository.UpdatePetrolStation(CreateFuel(_fuelId.Value));
else
_petrolStationRepository.CreatePetrolStation(CreateFuel(0));
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonCancel_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,127 @@
namespace ProjectGSM.Forms
{
partial class FormPetrolStations
{
/// <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()
{
panel1 = new Panel();
buttonDel = new Button();
buttonUpd = new Button();
buttonAdd = new Button();
dataGridView = new DataGridView();
panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
SuspendLayout();
//
// panel1
//
panel1.Controls.Add(buttonDel);
panel1.Controls.Add(buttonUpd);
panel1.Controls.Add(buttonAdd);
panel1.Dock = DockStyle.Right;
panel1.Location = new Point(649, 0);
panel1.Name = "panel1";
panel1.Size = new Size(151, 450);
panel1.TabIndex = 0;
//
// buttonDel
//
buttonDel.BackgroundImage = Properties.Resources.минус;
buttonDel.BackgroundImageLayout = ImageLayout.Stretch;
buttonDel.Location = new Point(35, 289);
buttonDel.Name = "buttonDel";
buttonDel.Size = new Size(79, 82);
buttonDel.TabIndex = 4;
buttonDel.UseVisualStyleBackColor = true;
buttonDel.Click += buttonDel_Click;
//
// buttonUpd
//
buttonUpd.BackgroundImage = Properties.Resources.кисть;
buttonUpd.BackgroundImageLayout = ImageLayout.Stretch;
buttonUpd.Location = new Point(35, 168);
buttonUpd.Name = "buttonUpd";
buttonUpd.Size = new Size(79, 82);
buttonUpd.TabIndex = 3;
buttonUpd.UseVisualStyleBackColor = true;
buttonUpd.Click += buttonUpd_Click;
//
// buttonAdd
//
buttonAdd.BackgroundImage = Properties.Resources.Плюс;
buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
buttonAdd.Location = new Point(35, 53);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(79, 82);
buttonAdd.TabIndex = 2;
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += buttonAdd_Click;
//
// dataGridView
//
dataGridView.AllowUserToAddRows = false;
dataGridView.AllowUserToDeleteRows = false;
dataGridView.AllowUserToResizeColumns = false;
dataGridView.AllowUserToResizeRows = false;
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Dock = DockStyle.Fill;
dataGridView.Location = new Point(0, 0);
dataGridView.MultiSelect = false;
dataGridView.Name = "dataGridView";
dataGridView.ReadOnly = true;
dataGridView.RowHeadersVisible = false;
dataGridView.RowHeadersWidth = 51;
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridView.Size = new Size(649, 450);
dataGridView.TabIndex = 3;
//
// FormPetrolStations
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450);
Controls.Add(dataGridView);
Controls.Add(panel1);
Name = "FormPetrolStations";
StartPosition = FormStartPosition.CenterParent;
Text = "Виды топлива";
Load += FormPetrolStations_Load;
panel1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false);
}
#endregion
private Panel panel1;
private Button buttonAdd;
private Button buttonUpd;
private Button buttonDel;
private DataGridView dataGridView;
}
}

View File

@ -0,0 +1,108 @@
using ProjectGSM.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 ProjectGSM.Forms
{
public partial class FormPetrolStations : Form
{
private readonly IUnityContainer _container;
private readonly IPetrolStationRepository _petrolStationRepository;
public FormPetrolStations(IUnityContainer container, IPetrolStationRepository petrolStationRepository)
{
InitializeComponent();
_container = container ??
throw new ArgumentNullException(nameof(container));
_petrolStationRepository = petrolStationRepository ??
throw new ArgumentNullException(nameof(petrolStationRepository));
}
private void LoadList() => dataGridView.DataSource = _petrolStationRepository.ReadPetrolStations();
private bool TryGetIdentifierFromSelectedRow(out int id)
{
id = 0;
if (dataGridView.SelectedRows.Count < 1)
{
MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Driver_ID"].Value);
return true;
}
private void buttonAdd_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormPetrolStation>().ShowDialog();
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonUpd_Click(object sender, EventArgs e)
{
if (!TryGetIdentifierFromSelectedRow(out var findId))
return;
try
{
var form = _container.Resolve<FormPetrolStation>();
form.Id = findId;
form.ShowDialog();
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при изменении",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonDel_Click(object sender, EventArgs e)
{
if (!TryGetIdentifierFromSelectedRow(out var findId))
return;
if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes)
return;
try
{
_petrolStationRepository.DeletePetrolStation(findId);
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void FormPetrolStations_Load(object sender, EventArgs e)
{
try
{
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}

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>

167
ProjectGSM/Forms/FormRefill.Designer.cs generated Normal file
View File

@ -0,0 +1,167 @@
namespace ProjectGSM.Forms
{
partial class FormRefill
{
/// <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()
{
label1 = new Label();
label2 = new Label();
label3 = new Label();
label4 = new Label();
comboBoxFuelID = new ComboBox();
numericUpDownQuantity = new NumericUpDown();
dateTimePickerRefillDate = new DateTimePicker();
comboBoxCarID = new ComboBox();
buttonSave = new Button();
buttonCancel = new Button();
((System.ComponentModel.ISupportInitialize)numericUpDownQuantity).BeginInit();
SuspendLayout();
//
// label1
//
label1.AutoSize = true;
label1.Location = new Point(33, 24);
label1.Name = "label1";
label1.Size = new Size(99, 20);
label1.TabIndex = 0;
label1.Text = "Тип топлива:";
//
// label2
//
label2.AutoSize = true;
label2.Location = new Point(33, 89);
label2.Name = "label2";
label2.Size = new Size(93, 20);
label2.TabIndex = 1;
label2.Text = "Количество:";
//
// label3
//
label3.AutoSize = true;
label3.Location = new Point(33, 142);
label3.Name = "label3";
label3.Size = new Size(44, 20);
label3.TabIndex = 2;
label3.Text = "Дата:";
//
// label4
//
label4.AutoSize = true;
label4.Location = new Point(33, 198);
label4.Name = "label4";
label4.Size = new Size(71, 20);
label4.TabIndex = 3;
label4.Text = "Машина:";
//
// comboBoxFuelID
//
comboBoxFuelID.FormattingEnabled = true;
comboBoxFuelID.Location = new Point(162, 24);
comboBoxFuelID.Name = "comboBoxFuelID";
comboBoxFuelID.Size = new Size(250, 28);
comboBoxFuelID.TabIndex = 4;
//
// numericUpDownQuantity
//
numericUpDownQuantity.DecimalPlaces = 2;
numericUpDownQuantity.Location = new Point(162, 89);
numericUpDownQuantity.Name = "numericUpDownQuantity";
numericUpDownQuantity.Size = new Size(250, 27);
numericUpDownQuantity.TabIndex = 5;
//
// dateTimePickerRefillDate
//
dateTimePickerRefillDate.Location = new Point(162, 142);
dateTimePickerRefillDate.Name = "dateTimePickerRefillDate";
dateTimePickerRefillDate.Size = new Size(250, 27);
dateTimePickerRefillDate.TabIndex = 6;
//
// comboBoxCarID
//
comboBoxCarID.FormattingEnabled = true;
comboBoxCarID.Location = new Point(162, 198);
comboBoxCarID.Name = "comboBoxCarID";
comboBoxCarID.Size = new Size(250, 28);
comboBoxCarID.TabIndex = 7;
//
// buttonSave
//
buttonSave.Location = new Point(48, 263);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(94, 29);
buttonSave.TabIndex = 8;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += buttonSave_Click;
//
// buttonCancel
//
buttonCancel.Location = new Point(237, 263);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(94, 29);
buttonCancel.TabIndex = 9;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += buttonCancel_Click;
//
// FormRefill
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(447, 348);
Controls.Add(buttonCancel);
Controls.Add(buttonSave);
Controls.Add(comboBoxCarID);
Controls.Add(dateTimePickerRefillDate);
Controls.Add(numericUpDownQuantity);
Controls.Add(comboBoxFuelID);
Controls.Add(label4);
Controls.Add(label3);
Controls.Add(label2);
Controls.Add(label1);
Name = "FormRefill";
StartPosition = FormStartPosition.CenterParent;
Text = "Заправка";
((System.ComponentModel.ISupportInitialize)numericUpDownQuantity).EndInit();
ResumeLayout(false);
PerformLayout();
}
#endregion
private Label label1;
private Label label2;
private Label label3;
private Label label4;
private ComboBox comboBoxFuelID;
private NumericUpDown numericUpDownQuantity;
private DateTimePicker dateTimePickerRefillDate;
private ComboBox comboBoxCarID;
private Button buttonSave;
private Button buttonCancel;
}
}

View File

@ -0,0 +1,54 @@
using ProjectGSM.Entities;
using ProjectGSM.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 ProjectGSM.Forms
{
public partial class FormRefill : Form
{
private readonly IRefillRepository _refillRepository;
public FormRefill(IRefillRepository refillRepository, IPetrolStationRepository petrolStationRepository, ICarRepository carRepository)
{
InitializeComponent();
_refillRepository = refillRepository ??
throw new ArgumentNullException(nameof(refillRepository));
comboBoxFuelID.DataSource = petrolStationRepository.ReadPetrolStations();
comboBoxFuelID.DisplayMember = "Fuel_Type";
comboBoxFuelID.ValueMember = "Fuel_ID";
comboBoxCarID.DataSource = carRepository.ReadCars();
comboBoxCarID.DisplayMember = "Car_Mark";
comboBoxCarID.ValueMember = "Car_ID";
}
private void buttonSave_Click(object sender, EventArgs e)
{
try
{
if (comboBoxFuelID.SelectedIndex < 0 || comboBoxCarID.SelectedIndex < 0)
throw new Exception("Имеются незаполненные поля");
_refillRepository.CreateRefill(Refill.CreateOperation(0, dateTimePickerRefillDate.Value, (float)numericUpDownQuantity.Value, (int)comboBoxFuelID.SelectedValue!, (int)comboBoxCarID.SelectedValue!));
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при сохранении",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonCancel_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>

99
ProjectGSM/Forms/FormRefills.Designer.cs generated Normal file
View File

@ -0,0 +1,99 @@
namespace ProjectGSM.Forms
{
partial class FormRefills
{
/// <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()
{
panel1 = new Panel();
buttonAdd = new Button();
dataGridView = new DataGridView();
panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
SuspendLayout();
//
// panel1
//
panel1.Controls.Add(buttonAdd);
panel1.Dock = DockStyle.Right;
panel1.Location = new Point(646, 0);
panel1.Name = "panel1";
panel1.Size = new Size(154, 450);
panel1.TabIndex = 0;
//
// buttonAdd
//
buttonAdd.BackgroundImage = Properties.Resources.Плюс;
buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
buttonAdd.Location = new Point(32, 50);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(79, 82);
buttonAdd.TabIndex = 2;
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += buttonAdd_Click;
//
// dataGridView
//
dataGridView.AllowUserToAddRows = false;
dataGridView.AllowUserToDeleteRows = false;
dataGridView.AllowUserToResizeColumns = false;
dataGridView.AllowUserToResizeRows = false;
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Dock = DockStyle.Fill;
dataGridView.Location = new Point(0, 0);
dataGridView.MultiSelect = false;
dataGridView.Name = "dataGridView";
dataGridView.ReadOnly = true;
dataGridView.RowHeadersVisible = false;
dataGridView.RowHeadersWidth = 51;
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridView.Size = new Size(646, 450);
dataGridView.TabIndex = 3;
//
// FormRefills
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450);
Controls.Add(dataGridView);
Controls.Add(panel1);
Name = "FormRefills";
StartPosition = FormStartPosition.CenterParent;
Text = "Заправки";
Load += FormRefills_Load;
panel1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false);
}
#endregion
private Panel panel1;
private Button buttonAdd;
private DataGridView dataGridView;
}
}

View File

@ -0,0 +1,62 @@
using ProjectGSM.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 ProjectGSM.Forms
{
public partial class FormRefills : Form
{
private readonly IUnityContainer _container;
private readonly IRefillRepository _refillRepository;
public FormRefills(IUnityContainer container, IRefillRepository refillRepository)
{
InitializeComponent();
_container = container ??
throw new ArgumentNullException(nameof(container));
_refillRepository = refillRepository ??
throw new ArgumentNullException(nameof(refillRepository));
}
private void LoadList() => dataGridView.DataSource = _refillRepository.ReadRefills();
private void buttonAdd_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormRefill>().ShowDialog();
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при добавлении",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void FormRefills_Load(object sender, EventArgs e)
{
try
{
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при загрузке",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}

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
ProjectGSM/Forms/FormRoute.Designer.cs generated Normal file
View File

@ -0,0 +1,143 @@
namespace ProjectGSM.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()
{
label1 = new Label();
label2 = new Label();
label3 = new Label();
numericUpDownLength = new NumericUpDown();
textBoxEndPoint = new TextBox();
textBoxStartPoint = new TextBox();
buttonSave = new Button();
buttonCancel = new Button();
((System.ComponentModel.ISupportInitialize)numericUpDownLength).BeginInit();
SuspendLayout();
//
// label1
//
label1.AutoSize = true;
label1.Location = new Point(24, 24);
label1.Name = "label1";
label1.Size = new Size(64, 20);
label1.TabIndex = 0;
label1.Text = "Начало:";
//
// label2
//
label2.AutoSize = true;
label2.Location = new Point(24, 73);
label2.Name = "label2";
label2.Size = new Size(56, 20);
label2.TabIndex = 1;
label2.Text = "Конец:";
//
// label3
//
label3.AutoSize = true;
label3.Location = new Point(24, 132);
label3.Name = "label3";
label3.Size = new Size(139, 20);
label3.TabIndex = 2;
label3.Text = "Длинна маршрута:";
//
// numericUpDownLength
//
numericUpDownLength.DecimalPlaces = 2;
numericUpDownLength.Location = new Point(171, 132);
numericUpDownLength.Name = "numericUpDownLength";
numericUpDownLength.Size = new Size(150, 27);
numericUpDownLength.TabIndex = 3;
//
// textBoxEndPoint
//
textBoxEndPoint.Location = new Point(171, 73);
textBoxEndPoint.Name = "textBoxEndPoint";
textBoxEndPoint.Size = new Size(150, 27);
textBoxEndPoint.TabIndex = 4;
//
// textBoxStartPoint
//
textBoxStartPoint.Location = new Point(171, 24);
textBoxStartPoint.Name = "textBoxStartPoint";
textBoxStartPoint.Size = new Size(150, 27);
textBoxStartPoint.TabIndex = 5;
//
// buttonSave
//
buttonSave.Location = new Point(24, 221);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(94, 29);
buttonSave.TabIndex = 6;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += buttonSave_Click;
//
// buttonCancel
//
buttonCancel.Location = new Point(158, 221);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(94, 29);
buttonCancel.TabIndex = 7;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += buttonCancel_Click;
//
// FormRoute
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(368, 305);
Controls.Add(buttonCancel);
Controls.Add(buttonSave);
Controls.Add(textBoxStartPoint);
Controls.Add(textBoxEndPoint);
Controls.Add(numericUpDownLength);
Controls.Add(label3);
Controls.Add(label2);
Controls.Add(label1);
Name = "FormRoute";
StartPosition = FormStartPosition.CenterParent;
Text = "Маршрут";
((System.ComponentModel.ISupportInitialize)numericUpDownLength).EndInit();
ResumeLayout(false);
PerformLayout();
}
#endregion
private Label label1;
private Label label2;
private Label label3;
private NumericUpDown numericUpDownLength;
private TextBox textBoxEndPoint;
private TextBox textBoxStartPoint;
private Button buttonSave;
private Button buttonCancel;
}
}

View File

@ -0,0 +1,79 @@
using ProjectGSM.Entities;
using ProjectGSM.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 ProjectGSM.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 InvalidOperationException(nameof(route));
textBoxStartPoint.Text = route.Start_Point;
textBoxEndPoint.Text = route.End_Point;
numericUpDownLength.Value = (decimal)route.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 Route CreateRoute(int id)
{
return Route.CreateEntity(id, textBoxStartPoint.Text, textBoxEndPoint.Text, (float)numericUpDownLength.Value);
}
private void buttonSave_Click(object sender, EventArgs e)
{
try
{
if (string.IsNullOrWhiteSpace(textBoxStartPoint.Text) || string.IsNullOrWhiteSpace(textBoxEndPoint.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 buttonCancel_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,238 @@
namespace ProjectGSM.Forms
{
partial class FormRouteSheet
{
/// <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()
{
label1 = new Label();
label2 = new Label();
label3 = new Label();
label4 = new Label();
label5 = new Label();
buttonSave = new Button();
buttonCancel = new Button();
dateTimePickerStartDate = new DateTimePicker();
dateTimePickerEndDate = new DateTimePicker();
numericUpDownConsumptionRate = new NumericUpDown();
comboBoxDriverID = new ComboBox();
comboBoxCarID = new ComboBox();
groupBox1 = new GroupBox();
dataGridViewRoutes = new DataGridView();
ColumnRoute = new DataGridViewComboBoxColumn();
ColumnEndPoint = new DataGridViewTextBoxColumn();
((System.ComponentModel.ISupportInitialize)numericUpDownConsumptionRate).BeginInit();
groupBox1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridViewRoutes).BeginInit();
SuspendLayout();
//
// label1
//
label1.AutoSize = true;
label1.Location = new Point(24, 22);
label1.Name = "label1";
label1.Size = new Size(125, 20);
label1.TabIndex = 0;
label1.Text = "Начало поездки:";
//
// label2
//
label2.AutoSize = true;
label2.Location = new Point(24, 66);
label2.Name = "label2";
label2.Size = new Size(117, 20);
label2.TabIndex = 1;
label2.Text = "Конец поездки:";
//
// label3
//
label3.AutoSize = true;
label3.Location = new Point(24, 116);
label3.Name = "label3";
label3.Size = new Size(120, 20);
label3.TabIndex = 2;
label3.Text = "Расход топлива:";
//
// label4
//
label4.AutoSize = true;
label4.Location = new Point(24, 169);
label4.Name = "label4";
label4.Size = new Size(77, 20);
label4.TabIndex = 3;
label4.Text = "Водитель:";
//
// label5
//
label5.AutoSize = true;
label5.Location = new Point(24, 219);
label5.Name = "label5";
label5.Size = new Size(71, 20);
label5.TabIndex = 4;
label5.Text = "Машина:";
//
// buttonSave
//
buttonSave.Location = new Point(73, 426);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(94, 29);
buttonSave.TabIndex = 5;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += buttonSave_Click;
//
// buttonCancel
//
buttonCancel.Location = new Point(236, 426);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(94, 29);
buttonCancel.TabIndex = 6;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += buttonCancel_Click;
//
// dateTimePickerStartDate
//
dateTimePickerStartDate.Location = new Point(181, 22);
dateTimePickerStartDate.Name = "dateTimePickerStartDate";
dateTimePickerStartDate.Size = new Size(250, 27);
dateTimePickerStartDate.TabIndex = 7;
//
// dateTimePickerEndDate
//
dateTimePickerEndDate.Location = new Point(181, 66);
dateTimePickerEndDate.Name = "dateTimePickerEndDate";
dateTimePickerEndDate.Size = new Size(250, 27);
dateTimePickerEndDate.TabIndex = 8;
//
// numericUpDownConsumptionRate
//
numericUpDownConsumptionRate.DecimalPlaces = 2;
numericUpDownConsumptionRate.Location = new Point(181, 109);
numericUpDownConsumptionRate.Name = "numericUpDownConsumptionRate";
numericUpDownConsumptionRate.Size = new Size(250, 27);
numericUpDownConsumptionRate.TabIndex = 9;
//
// comboBoxDriverID
//
comboBoxDriverID.FormattingEnabled = true;
comboBoxDriverID.Location = new Point(181, 161);
comboBoxDriverID.Name = "comboBoxDriverID";
comboBoxDriverID.Size = new Size(250, 28);
comboBoxDriverID.TabIndex = 10;
//
// comboBoxCarID
//
comboBoxCarID.FormattingEnabled = true;
comboBoxCarID.Location = new Point(181, 211);
comboBoxCarID.Name = "comboBoxCarID";
comboBoxCarID.Size = new Size(250, 28);
comboBoxCarID.TabIndex = 11;
//
// groupBox1
//
groupBox1.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
groupBox1.Controls.Add(dataGridViewRoutes);
groupBox1.Location = new Point(80, 245);
groupBox1.Name = "groupBox1";
groupBox1.Size = new Size(310, 160);
groupBox1.TabIndex = 12;
groupBox1.TabStop = false;
groupBox1.Text = "Маршрут";
//
// dataGridViewRoutes
//
dataGridViewRoutes.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridViewRoutes.Columns.AddRange(new DataGridViewColumn[] { ColumnRoute, ColumnEndPoint });
dataGridViewRoutes.Dock = DockStyle.Fill;
dataGridViewRoutes.Location = new Point(3, 23);
dataGridViewRoutes.Name = "dataGridViewRoutes";
dataGridViewRoutes.RowHeadersWidth = 51;
dataGridViewRoutes.Size = new Size(304, 134);
dataGridViewRoutes.TabIndex = 13;
//
// ColumnRoute
//
ColumnRoute.HeaderText = "Начало маршрута";
ColumnRoute.MinimumWidth = 6;
ColumnRoute.Name = "ColumnRoute";
ColumnRoute.Width = 125;
//
// ColumnEndPoint
//
ColumnEndPoint.HeaderText = "Конечная точка";
ColumnEndPoint.MinimumWidth = 6;
ColumnEndPoint.Name = "ColumnEndPoint";
ColumnEndPoint.Width = 125;
//
// FormRouteSheet
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(467, 487);
Controls.Add(groupBox1);
Controls.Add(comboBoxCarID);
Controls.Add(comboBoxDriverID);
Controls.Add(numericUpDownConsumptionRate);
Controls.Add(dateTimePickerEndDate);
Controls.Add(dateTimePickerStartDate);
Controls.Add(buttonCancel);
Controls.Add(buttonSave);
Controls.Add(label5);
Controls.Add(label4);
Controls.Add(label3);
Controls.Add(label2);
Controls.Add(label1);
Name = "FormRouteSheet";
StartPosition = FormStartPosition.CenterParent;
Text = "Маршрутный лист";
((System.ComponentModel.ISupportInitialize)numericUpDownConsumptionRate).EndInit();
groupBox1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)dataGridViewRoutes).EndInit();
ResumeLayout(false);
PerformLayout();
}
#endregion
private Label label1;
private Label label2;
private Label label3;
private Label label4;
private Label label5;
private Button buttonSave;
private Button buttonCancel;
private DateTimePicker dateTimePickerStartDate;
private DateTimePicker dateTimePickerEndDate;
private NumericUpDown numericUpDownConsumptionRate;
private ComboBox comboBoxDriverID;
private ComboBox comboBoxCarID;
private GroupBox groupBox1;
private DataGridView dataGridViewRoutes;
private DataGridViewComboBoxColumn ColumnRoute;
private DataGridViewTextBoxColumn ColumnEndPoint;
}
}

View File

@ -0,0 +1,71 @@
using ProjectGSM.Entities;
using ProjectGSM.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 ProjectGSM.Forms
{
public partial class FormRouteSheet : Form
{
private readonly IRouteSheetRepository _routeSheetRepository;
public FormRouteSheet(IRouteSheetRepository routeSheetRepository, ICarRepository carRepository, IDriverRepository driverRepository, IRouteRepository routeRepository)
{
InitializeComponent();
_routeSheetRepository = routeSheetRepository ??
throw new ArgumentNullException(nameof(routeSheetRepository));
comboBoxCarID.DataSource = routeSheetRepository.ReadTrips();
comboBoxCarID.DisplayMember = "Car_Mark";
comboBoxCarID.ValueMember = "Car_ID";
comboBoxDriverID.DataSource = routeSheetRepository.ReadTrips();
comboBoxDriverID.DisplayMember = "Firstname";
comboBoxDriverID.ValueMember = "Driver_ID";
ColumnRoute.DataSource = routeRepository.ReadRoutes();
ColumnRoute.DisplayMember = "Start_Point";
ColumnRoute.ValueMember = "Route_ID";
}
private List<Route> CreateListDriversFromDataGrid()
{
var list = new List<Route>();
foreach (DataGridViewRow row in dataGridViewRoutes.Rows)
{
if (row.Cells["ColumnRoute"].Value == null || row.Cells["ColumnEndPoint"].Value == null)
continue;
list.Add(Route.CreateEntity(0, (string)row.Cells["ColumnRoute"].Value, (string)row.Cells["ColumnEndPoint"].Value, 0));
}
return list;
}
private void buttonSave_Click(object sender, EventArgs e)
{
try
{
if (comboBoxCarID.SelectedIndex < 0 || comboBoxDriverID.SelectedIndex < 0 || dataGridViewRoutes.RowCount < 0)
throw new Exception("Имеются незаполненные поля");
_routeSheetRepository.CreateTrip(RouteSheet.CreateOperation(0, dateTimePickerStartDate.Value, dateTimePickerEndDate.Value, (float)numericUpDownConsumptionRate.Value, (int)comboBoxCarID.SelectedValue!, (int)comboBoxDriverID.SelectedValue!, CreateListDriversFromDataGrid()));
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при сохранении",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonCancel_Click(object sender, EventArgs e) => Close();
}
}

View File

@ -0,0 +1,126 @@
<?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="ColumnRoute.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="ColumnEndPoint.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root>

View File

@ -0,0 +1,99 @@
namespace ProjectGSM.Forms
{
partial class FormRouteSheets
{
/// <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()
{
panel1 = new Panel();
buttonAdd = new Button();
dataGridView = new DataGridView();
panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
SuspendLayout();
//
// panel1
//
panel1.Controls.Add(buttonAdd);
panel1.Dock = DockStyle.Right;
panel1.Location = new Point(641, 0);
panel1.Name = "panel1";
panel1.Size = new Size(159, 450);
panel1.TabIndex = 0;
//
// buttonAdd
//
buttonAdd.BackgroundImage = Properties.Resources.Плюс;
buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
buttonAdd.Location = new Point(38, 64);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(79, 82);
buttonAdd.TabIndex = 2;
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += buttonAdd_Click;
//
// dataGridView
//
dataGridView.AllowUserToAddRows = false;
dataGridView.AllowUserToDeleteRows = false;
dataGridView.AllowUserToResizeColumns = false;
dataGridView.AllowUserToResizeRows = false;
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Dock = DockStyle.Fill;
dataGridView.Location = new Point(0, 0);
dataGridView.MultiSelect = false;
dataGridView.Name = "dataGridView";
dataGridView.ReadOnly = true;
dataGridView.RowHeadersVisible = false;
dataGridView.RowHeadersWidth = 51;
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridView.Size = new Size(641, 450);
dataGridView.TabIndex = 3;
//
// FormRouteSheets
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450);
Controls.Add(dataGridView);
Controls.Add(panel1);
Name = "FormRouteSheets";
StartPosition = FormStartPosition.CenterParent;
Text = "Маршрутные листы";
Load += FormRouteSheets_Load;
panel1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false);
}
#endregion
private Panel panel1;
private Button buttonAdd;
private DataGridView dataGridView;
}
}

View File

@ -0,0 +1,61 @@
using ProjectGSM.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 ProjectGSM.Forms
{
public partial class FormRouteSheets : Form
{
private readonly IUnityContainer _container;
private readonly IRouteSheetRepository _routeSheetRepository;
public FormRouteSheets(IUnityContainer container, IRouteSheetRepository routeSheetRepository)
{
InitializeComponent();
_container = container ??
throw new ArgumentNullException(nameof(container));
_routeSheetRepository = routeSheetRepository ??
throw new ArgumentNullException(nameof(routeSheetRepository));
}
private void LoadList() => dataGridView.DataSource = _routeSheetRepository.ReadTrips();
private void buttonAdd_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormRouteSheet>().ShowDialog();
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при добавлении",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void FormRouteSheets_Load(object sender, EventArgs e)
{
try
{
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при загрузке",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}

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>

127
ProjectGSM/Forms/FormRoutes.Designer.cs generated Normal file
View File

@ -0,0 +1,127 @@
namespace ProjectGSM.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()
{
panel1 = new Panel();
buttonDel = new Button();
buttonUpd = new Button();
buttonAdd = new Button();
dataGridView = new DataGridView();
panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
SuspendLayout();
//
// panel1
//
panel1.Controls.Add(buttonDel);
panel1.Controls.Add(buttonUpd);
panel1.Controls.Add(buttonAdd);
panel1.Dock = DockStyle.Right;
panel1.Location = new Point(634, 0);
panel1.Name = "panel1";
panel1.Size = new Size(166, 450);
panel1.TabIndex = 0;
//
// buttonDel
//
buttonDel.BackgroundImage = Properties.Resources.минус;
buttonDel.BackgroundImageLayout = ImageLayout.Stretch;
buttonDel.Location = new Point(45, 291);
buttonDel.Name = "buttonDel";
buttonDel.Size = new Size(79, 82);
buttonDel.TabIndex = 4;
buttonDel.UseVisualStyleBackColor = true;
buttonDel.Click += buttonDel_Click;
//
// buttonUpd
//
buttonUpd.BackgroundImage = Properties.Resources.кисть;
buttonUpd.BackgroundImageLayout = ImageLayout.Stretch;
buttonUpd.Location = new Point(45, 171);
buttonUpd.Name = "buttonUpd";
buttonUpd.Size = new Size(79, 82);
buttonUpd.TabIndex = 3;
buttonUpd.UseVisualStyleBackColor = true;
buttonUpd.Click += buttonUpd_Click;
//
// buttonAdd
//
buttonAdd.BackgroundImage = Properties.Resources.Плюс;
buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
buttonAdd.Location = new Point(45, 52);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(79, 82);
buttonAdd.TabIndex = 2;
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += buttonAdd_Click;
//
// dataGridView
//
dataGridView.AllowUserToAddRows = false;
dataGridView.AllowUserToDeleteRows = false;
dataGridView.AllowUserToResizeColumns = false;
dataGridView.AllowUserToResizeRows = false;
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Dock = DockStyle.Fill;
dataGridView.Location = new Point(0, 0);
dataGridView.MultiSelect = false;
dataGridView.Name = "dataGridView";
dataGridView.ReadOnly = true;
dataGridView.RowHeadersVisible = false;
dataGridView.RowHeadersWidth = 51;
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridView.Size = new Size(634, 450);
dataGridView.TabIndex = 3;
//
// FormRoutes
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450);
Controls.Add(dataGridView);
Controls.Add(panel1);
Name = "FormRoutes";
StartPosition = FormStartPosition.CenterParent;
Text = "Маршруты";
Load += FormRoutes_Load;
panel1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false);
}
#endregion
private Panel panel1;
private Button buttonAdd;
private Button buttonUpd;
private Button buttonDel;
private DataGridView dataGridView;
}
}

View File

@ -0,0 +1,106 @@
using ProjectGSM.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 ProjectGSM.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 LoadList() => dataGridView.DataSource = _routeRepository.ReadRoutes();
private bool TryGetIdentifierFromSelectedRow(out int id)
{
id = 0;
if (dataGridView.SelectedRows.Count < 1)
{
MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Route_ID"].Value);
return true;
}
private void buttonAdd_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormRoute>().ShowDialog();
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonUpd_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 buttonDel_Click(object sender, EventArgs e)
{
if (!TryGetIdentifierFromSelectedRow(out var findId))
return;
if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes)
return;
try
{
_routeRepository.DeleteRoute(findId);
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void FormRoutes_Load(object sender, EventArgs e)
{
try
{
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}

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 ProjectGSM.Repositories;
using ProjectGSM.Repositories.Implementations;
using Unity;
namespace ProjectGSM
{
internal static class Program
@ -11,7 +15,19 @@ namespace ProjectGSM
// 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<FormGSM>());
}
private static IUnityContainer CreateContainer()
{
var container = new UnityContainer();
container.RegisterType<ICarRepository, CarRepository>();
container.RegisterType<IDriverRepository, DriverRepository>();
container.RegisterType<IPetrolStationRepository, PetrolStationRepository>();
container.RegisterType<IRefillRepository, RefillRepository>();
container.RegisterType<IRouteRepository, RouteRepository>();
container.RegisterType<IRouteSheetRepository, RouteSheetRepository>();
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,134 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Этот код создан программой.
// Исполняемая версия:4.0.30319.42000
//
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
// повторной генерации кода.
// </auto-generated>
//------------------------------------------------------------------------------
namespace ProjectGSM.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("ProjectGSM.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 _5332808188908660305 {
get {
object obj = ResourceManager.GetObject("5332808188908660305", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap b92558ff3f28ceedac1c70e9435a9483 {
get {
object obj = ResourceManager.GetObject("b92558ff3f28ceedac1c70e9435a9483", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap b92558ff3f28ceedac1c70e9435a94831 {
get {
object obj = ResourceManager.GetObject("b92558ff3f28ceedac1c70e9435a94831", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap kisspng_computer_icons_meno_plus_and_minus_signs_symbol_5b1084ada4b796_8808036715278091976747 {
get {
object obj = ResourceManager.GetObject("kisspng-computer-icons-meno-plus-and-minus-signs-symbol-5b1084ada4b796.8808036715" +
"278091976747", 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));
}
}
/// <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,142 @@
<?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="5332808188908660305" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\5332808188908660305.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="b92558ff3f28ceedac1c70e9435a9483" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\b92558ff3f28ceedac1c70e9435a9483.png;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="kisspng-computer-icons-meno-plus-and-minus-signs-symbol-5b1084ada4b796.8808036715278091976747" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\kisspng-computer-icons-meno-plus-and-minus-signs-symbol-5b1084ada4b796.8808036715278091976747.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="b92558ff3f28ceedac1c70e9435a94831" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\b92558ff3f28ceedac1c70e9435a94831.png;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\Плюс.png;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 ProjectGSM.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectGSM.Repositories;
public interface ICarRepository
{
IEnumerable<Car> ReadCars();
Car ReadCarByID(int id);
void CreateCar(Car car);
void UpdateCar(Car car);
void DeleteCar(int id);
}

View File

@ -0,0 +1,21 @@
using ProjectGSM.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectGSM.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 ProjectGSM.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectGSM.Repositories;
public interface IPetrolStationRepository
{
IEnumerable<PetrolStation> ReadPetrolStations();
PetrolStation ReadPetrolStationByID(int id);
void CreatePetrolStation(PetrolStation petrolStations);
void UpdatePetrolStation(PetrolStation petrolStations);
void DeletePetrolStation(int id);
}

View File

@ -0,0 +1,15 @@
using ProjectGSM.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectGSM.Repositories;
public interface IRefillRepository
{
IEnumerable<Refill> ReadRefills(DateTime? dateFrom = null, DateTime? dateTo = null, int? fuelId = null, int? carId = null);
void CreateRefill(Refill refill);
}

View File

@ -0,0 +1,21 @@
using ProjectGSM.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectGSM.Repositories;
public interface IRouteRepository
{
IEnumerable<Route> ReadRoutes();
Route ReadRouteByID(int id);
void CreateRoute(Route route);
void UpdateRoute(Route route);
void DeleteRoute(int id);
}

View File

@ -0,0 +1,15 @@
using ProjectGSM.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectGSM.Repositories;
public interface IRouteSheetRepository
{
IEnumerable<RouteSheet> ReadTrips(DateTime? dateFrom = null, DateTime? dateTo = null, int? carId = null, int? driverId = null, int? routeId = null);
void CreateTrip(RouteSheet trip);
}

View File

@ -0,0 +1,34 @@
using ProjectGSM.Entities;
using ProjectGSM.Repositories;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectGSM.Repositories.Implementations;
public class CarRepository : ICarRepository
{
public void CreateCar(Car car)
{
}
public void DeleteCar(int id)
{
}
public Car ReadCarByID(int id)
{
return Car.CreateEntity(0, string.Empty, string.Empty, 0, 0, 0);
}
public IEnumerable<Car> ReadCars()
{
return [];
}
public void UpdateCar(Car car)
{
}
}

View File

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

View File

@ -0,0 +1,34 @@
using ProjectGSM.Entities;
using ProjectGSM.Repositories;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectGSM.Repositories.Implementations;
public class PetrolStationRepository : IPetrolStationRepository
{
public void CreatePetrolStation(PetrolStation fuel)
{
}
public void DeletePetrolStation(int id)
{
}
public PetrolStation ReadPetrolStationByID(int id)
{
return PetrolStation.CreateEntity(0, 0, 0, 0);
}
public IEnumerable<PetrolStation> ReadPetrolStations()
{
return [];
}
public void UpdatePetrolStation(PetrolStation PetrolStation)
{
}
}

View File

@ -0,0 +1,21 @@
using ProjectGSM.Entities;
using ProjectGSM.Repositories;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectGSM.Repositories.Implementations;
public class RefillRepository : IRefillRepository
{
public void CreateRefill(Refill refill)
{
}
public IEnumerable<Refill> ReadRefills(DateTime? dateFrom = null, DateTime? dateTo = null, int? fuelId = null, int? carId = null)
{
return [];
}
}

View File

@ -0,0 +1,34 @@
using ProjectGSM.Entities;
using ProjectGSM.Repositories;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectGSM.Repositories.Implementations;
public class RouteRepository : IRouteRepository
{
public void CreateRoute(Route route)
{
}
public void DeleteRoute(int id)
{
}
public Route ReadRouteByID(int id)
{
return Route.CreateEntity(0, string.Empty, string.Empty, 0);
}
public IEnumerable<Route> ReadRoutes()
{
return [];
}
public void UpdateRoute(Route route)
{
}
}

View File

@ -0,0 +1,21 @@
using ProjectGSM.Entities;
using ProjectGSM.Repositories;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectGSM.Repositories.Implementations;
public class RouteSheetRepository : IRouteSheetRepository
{
public void CreateTrip(RouteSheet routeSheet)
{
}
public IEnumerable<RouteSheet> ReadTrips(DateTime? dateFrom = null, DateTime? dateTo = null, int? carId = null, int? driverId = null, int? routeId = null)
{
return [];
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 154 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 100 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 100 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 100 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB