ПИбд-23 Ладягин П.Д. Первая л.р. #1

Open
F1rsTTeaM wants to merge 20 commits from LabWork01 into main
3 changed files with 409 additions and 0 deletions
Showing only changes of commit c1d186328c - Show all commits

View File

@ -0,0 +1,241 @@
namespace FuelAndLubricants.Forms
{
partial class FormTrip
{
/// <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()
{
label5 = new Label();
numericUpDownConsumptionRate = new NumericUpDown();
label4 = new Label();
comboBoxShift = new ComboBox();
buttonCancel = new Button();
buttonTripSave = new Button();
label6 = new Label();
dateTimePickerStartDate = new DateTimePicker();
label1 = new Label();
dateTimePickerEndDate = new DateTimePicker();
label3 = new Label();
comboBoxCarID = new ComboBox();
comboBoxDriverID = new ComboBox();
label2 = new Label();
comboBoxRouteID = new ComboBox();
label7 = new Label();
((System.ComponentModel.ISupportInitialize)numericUpDownConsumptionRate).BeginInit();
SuspendLayout();
//
// label5
//
label5.AutoSize = true;
label5.Location = new Point(9, 100);
label5.Name = "label5";
label5.Size = new Size(93, 15);
label5.TabIndex = 33;
label5.Text = "Расход топлива";
//
// numericUpDownConsumptionRate
//
numericUpDownConsumptionRate.DecimalPlaces = 2;
numericUpDownConsumptionRate.Location = new Point(107, 98);
numericUpDownConsumptionRate.Maximum = new decimal(new int[] { 10000, 0, 0, 0 });
numericUpDownConsumptionRate.Minimum = new decimal(new int[] { 1, 0, 0, 131072 });
numericUpDownConsumptionRate.Name = "numericUpDownConsumptionRate";
numericUpDownConsumptionRate.Size = new Size(140, 23);
numericUpDownConsumptionRate.TabIndex = 32;
numericUpDownConsumptionRate.Value = new decimal(new int[] { 1, 0, 0, 131072 });
//
// label4
//
label4.AutoSize = true;
label4.Location = new Point(9, 73);
label4.Name = "label4";
label4.Size = new Size(43, 15);
label4.TabIndex = 31;
label4.Text = "Смена";
//
// comboBoxShift
//
comboBoxShift.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxShift.FormattingEnabled = true;
comboBoxShift.Location = new Point(107, 70);
comboBoxShift.Name = "comboBoxShift";
comboBoxShift.Size = new Size(140, 23);
comboBoxShift.TabIndex = 30;
//
// buttonCancel
//
buttonCancel.Location = new Point(172, 226);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(75, 23);
buttonCancel.TabIndex = 28;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += ButtonCancel_Click;
//
// buttonTripSave
//
buttonTripSave.Location = new Point(9, 226);
buttonTripSave.Name = "buttonTripSave";
buttonTripSave.Size = new Size(75, 23);
buttonTripSave.TabIndex = 27;
buttonTripSave.Text = "Сохранить";
buttonTripSave.UseVisualStyleBackColor = true;
buttonTripSave.Click += ButtonSave_Click;
//
// label6
//
label6.AutoSize = true;
label6.Location = new Point(9, 18);
label6.Name = "label6";
label6.Size = new Size(74, 15);
label6.TabIndex = 37;
label6.Text = "Дата начала";
//
// dateTimePickerStartDate
//
dateTimePickerStartDate.Location = new Point(107, 12);
dateTimePickerStartDate.Name = "dateTimePickerStartDate";
dateTimePickerStartDate.Size = new Size(140, 23);
dateTimePickerStartDate.TabIndex = 36;
//
// label1
//
label1.AutoSize = true;
label1.Location = new Point(9, 47);
label1.Name = "label1";
label1.Size = new Size(68, 15);
label1.TabIndex = 39;
label1.Text = "Дата конца";
//
// dateTimePickerEndDate
//
dateTimePickerEndDate.Location = new Point(107, 41);
dateTimePickerEndDate.Name = "dateTimePickerEndDate";
dateTimePickerEndDate.Size = new Size(140, 23);
dateTimePickerEndDate.TabIndex = 38;
//
// label3
//
label3.AutoSize = true;
label3.Location = new Point(9, 130);
label3.Name = "label3";
label3.Size = new Size(55, 15);
label3.TabIndex = 42;
label3.Text = "Машина";
//
// comboBoxCarID
//
comboBoxCarID.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxCarID.FormattingEnabled = true;
comboBoxCarID.Location = new Point(107, 127);
comboBoxCarID.Name = "comboBoxCarID";
comboBoxCarID.Size = new Size(140, 23);
comboBoxCarID.TabIndex = 41;
//
// comboBoxDriverID
//
comboBoxDriverID.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxDriverID.FormattingEnabled = true;
comboBoxDriverID.Location = new Point(107, 157);
comboBoxDriverID.Name = "comboBoxDriverID";
comboBoxDriverID.Size = new Size(140, 23);
comboBoxDriverID.TabIndex = 46;
//
// label2
//
label2.AutoSize = true;
label2.Location = new Point(9, 189);
label2.Name = "label2";
label2.Size = new Size(60, 15);
label2.TabIndex = 45;
label2.Text = "Маршрут";
//
// comboBoxRouteID
//
comboBoxRouteID.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxRouteID.FormattingEnabled = true;
comboBoxRouteID.Location = new Point(107, 186);
comboBoxRouteID.Name = "comboBoxRouteID";
comboBoxRouteID.Size = new Size(140, 23);
comboBoxRouteID.TabIndex = 44;
//
// label7
//
label7.AutoSize = true;
label7.Location = new Point(9, 160);
label7.Name = "label7";
label7.Size = new Size(58, 15);
label7.TabIndex = 43;
label7.Text = "Водитель";
//
// FormTrip
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(259, 266);
Controls.Add(comboBoxDriverID);
Controls.Add(label2);
Controls.Add(comboBoxRouteID);
Controls.Add(label7);
Controls.Add(label3);
Controls.Add(comboBoxCarID);
Controls.Add(label1);
Controls.Add(dateTimePickerEndDate);
Controls.Add(label6);
Controls.Add(dateTimePickerStartDate);
Controls.Add(label5);
Controls.Add(numericUpDownConsumptionRate);
Controls.Add(label4);
Controls.Add(comboBoxShift);
Controls.Add(buttonCancel);
Controls.Add(buttonTripSave);
Name = "FormTrip";
Text = "FormTrip";
((System.ComponentModel.ISupportInitialize)numericUpDownConsumptionRate).EndInit();
ResumeLayout(false);
PerformLayout();
}
#endregion
private Label label5;
private NumericUpDown numericUpDownConsumptionRate;
private Label label4;
private ComboBox comboBoxShift;
private Button buttonCancel;
private Button buttonTripSave;
private Label label6;
private DateTimePicker dateTimePickerStartDate;
private Label label1;
private DateTimePicker dateTimePickerEndDate;
private Label label3;
private ComboBox comboBoxCarID;
private ComboBox comboBoxDriverID;
private Label label2;
private ComboBox comboBoxRouteID;
private Label label7;
}
}

View File

@ -0,0 +1,48 @@
using FuelAndLubricants.Entities;
using FuelAndLubricants.Entities.Enums;
using FuelAndLubricants.Repositories;
namespace FuelAndLubricants.Forms
{
public partial class FormTrip : Form
{
private readonly ITripRepository _tripRepository;
public FormTrip(ITripRepository tripRepository, ICarRepository carRepository, IDriverRepository driverRepository, IRouteRepository routeRepository)
{
InitializeComponent();
_tripRepository = tripRepository ??
throw new ArgumentNullException(nameof(tripRepository));
comboBoxCarID.DataSource = tripRepository.ReadTrips();
comboBoxCarID.DisplayMember = "Car_Mark";
comboBoxCarID.ValueMember = "Car_ID";
comboBoxDriverID.DataSource = tripRepository.ReadTrips();
comboBoxDriverID.DisplayMember = "Firstname";
comboBoxDriverID.ValueMember = "Driver_ID";
comboBoxRouteID.DataSource = tripRepository.ReadTrips();
comboBoxRouteID.DisplayMember = "Route_Length";
comboBoxRouteID.ValueMember = "Route_ID";
}
private void ButtonSave_Click(object sender, EventArgs e)
{
try
{
if (comboBoxCarID.SelectedIndex < 0 || comboBoxDriverID.SelectedIndex < 0 || comboBoxRouteID.SelectedIndex < 0)
throw new Exception("Имеются незаполненные поля");
_tripRepository.CreateTrip(Trip.CreateOperation(0, dateTimePickerStartDate.Value, dateTimePickerEndDate.Value, (Shift)comboBoxShift.SelectedItem!, (float)numericUpDownConsumptionRate.Value, (int)comboBoxCarID.SelectedValue!, (int)comboBoxDriverID.SelectedValue!, (int)comboBoxRouteID.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>