diff --git a/FuelAndLubricants/FuelAndLubricants/Entities/Car.cs b/FuelAndLubricants/FuelAndLubricants/Entities/Car.cs new file mode 100644 index 0000000..5257fab --- /dev/null +++ b/FuelAndLubricants/FuelAndLubricants/Entities/Car.cs @@ -0,0 +1,26 @@ +using FuelAndLubricants.Entities.Enums; + +namespace FuelAndLubricants.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 Driver_License 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, Driver_License 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 + }; + } +} diff --git a/FuelAndLubricants/FuelAndLubricants/Entities/Driver.cs b/FuelAndLubricants/FuelAndLubricants/Entities/Driver.cs new file mode 100644 index 0000000..7899494 --- /dev/null +++ b/FuelAndLubricants/FuelAndLubricants/Entities/Driver.cs @@ -0,0 +1,22 @@ +using FuelAndLubricants.Entities.Enums; + +namespace FuelAndLubricants.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 Driver_License Driver_License { get; private set; } + + public static Driver CreateEntity (int driver_ID, string firstname, string secondname, Driver_License license) + { + return new Driver + { + Driver_ID = driver_ID, + Firstname = firstname ?? string.Empty, + Secondname = secondname ?? string.Empty, + Driver_License = license + }; + } +} diff --git a/FuelAndLubricants/FuelAndLubricants/Entities/Enums/Car_Type.cs b/FuelAndLubricants/FuelAndLubricants/Entities/Enums/Car_Type.cs new file mode 100644 index 0000000..a700a41 --- /dev/null +++ b/FuelAndLubricants/FuelAndLubricants/Entities/Enums/Car_Type.cs @@ -0,0 +1,9 @@ +namespace FuelAndLubricants.Entities.Enums; + +public enum Car_Type +{ + None = 0, + Passenger = 1, + Cargo = 2, + Bus = 3 +} diff --git a/FuelAndLubricants/FuelAndLubricants/Entities/Enums/Driver_License.cs b/FuelAndLubricants/FuelAndLubricants/Entities/Enums/Driver_License.cs new file mode 100644 index 0000000..ae865a1 --- /dev/null +++ b/FuelAndLubricants/FuelAndLubricants/Entities/Enums/Driver_License.cs @@ -0,0 +1,13 @@ +namespace FuelAndLubricants.Entities.Enums; + +[Flags] +public enum Driver_License +{ + None = 0, + A = 1, + B = 2, + C = 4, + D = 8, + BE = 16, + CE = 32 +} diff --git a/FuelAndLubricants/FuelAndLubricants/Entities/Enums/Fuel_Type.cs b/FuelAndLubricants/FuelAndLubricants/Entities/Enums/Fuel_Type.cs new file mode 100644 index 0000000..b408283 --- /dev/null +++ b/FuelAndLubricants/FuelAndLubricants/Entities/Enums/Fuel_Type.cs @@ -0,0 +1,10 @@ +namespace FuelAndLubricants.Entities.Enums; + +public enum Fuel_Type +{ + None = 0, + + Petrol = 1, + + Diesel = 2 +} diff --git a/FuelAndLubricants/FuelAndLubricants/Entities/Enums/Shift.cs b/FuelAndLubricants/FuelAndLubricants/Entities/Enums/Shift.cs new file mode 100644 index 0000000..a05e003 --- /dev/null +++ b/FuelAndLubricants/FuelAndLubricants/Entities/Enums/Shift.cs @@ -0,0 +1,8 @@ +namespace FuelAndLubricants.Entities.Enums; + +public enum Shift +{ + None = 0, + Day = 1, + Night = 2 +} diff --git a/FuelAndLubricants/FuelAndLubricants/Entities/Fuel_And_Lubricants.cs b/FuelAndLubricants/FuelAndLubricants/Entities/Fuel_And_Lubricants.cs new file mode 100644 index 0000000..5928429 --- /dev/null +++ b/FuelAndLubricants/FuelAndLubricants/Entities/Fuel_And_Lubricants.cs @@ -0,0 +1,22 @@ +using FuelAndLubricants.Entities.Enums; + +namespace FuelAndLubricants.Entities; + +public class Fuel_And_Lubricants +{ + public int Fuel_ID { get; private set; } + public Fuel_Type Fuel_Type { get; private set; } + public float Price_Per_Liter { get; private set; } + public float Amount { get; private set; } + + public static Fuel_And_Lubricants CreateEntity(int fuel_id, Fuel_Type type, float price, float amount) + { + return new Fuel_And_Lubricants + { + Fuel_ID = fuel_id, + Fuel_Type = type, + Price_Per_Liter = price, + Amount = amount + }; + } +} diff --git a/FuelAndLubricants/FuelAndLubricants/Entities/Refill.cs b/FuelAndLubricants/FuelAndLubricants/Entities/Refill.cs new file mode 100644 index 0000000..a67ff0b --- /dev/null +++ b/FuelAndLubricants/FuelAndLubricants/Entities/Refill.cs @@ -0,0 +1,22 @@ +namespace FuelAndLubricants.Entities; + +public class Refill +{ + public int Refill_ID { get; private set; } + public DateTime Refill_Date { get; private set; } + public float Refill_Amount { 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 refill_amount, int fuel_id, int car_id) + { + return new Refill + { + Refill_ID = refill_ID, + Refill_Date = refill_date, + Refill_Amount = refill_amount, + Fuel_ID = fuel_id, + Car_ID = car_id + }; + } +} diff --git a/FuelAndLubricants/FuelAndLubricants/Entities/Route.cs b/FuelAndLubricants/FuelAndLubricants/Entities/Route.cs new file mode 100644 index 0000000..3087552 --- /dev/null +++ b/FuelAndLubricants/FuelAndLubricants/Entities/Route.cs @@ -0,0 +1,20 @@ +namespace FuelAndLubricants.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 + }; + } +} diff --git a/FuelAndLubricants/FuelAndLubricants/Entities/Trip.cs b/FuelAndLubricants/FuelAndLubricants/Entities/Trip.cs new file mode 100644 index 0000000..83e9614 --- /dev/null +++ b/FuelAndLubricants/FuelAndLubricants/Entities/Trip.cs @@ -0,0 +1,30 @@ +using FuelAndLubricants.Entities.Enums; + +namespace FuelAndLubricants.Entities; + +public class Trip +{ + public int Trip_ID { get; private set; } + public DateTime Start_Date { get; private set; } + public DateTime End_Date { get; private set; } + public Shift Shift { 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 Routes { get; private set; } = []; + + public static Trip CreateOperation(int trip_id, DateTime start_date, DateTime end_date, Shift shift, float consumption, int car_id, int driver_id, IEnumerable routes) + { + return new Trip + { + Trip_ID = trip_id, + Start_Date = start_date, + End_Date = end_date, + Shift = shift, + Fuel_Consumption = consumption, + Car_ID = car_id, + Driver_ID = driver_id, + Routes = routes + }; + } +} diff --git a/FuelAndLubricants/FuelAndLubricants/Form1.Designer.cs b/FuelAndLubricants/FuelAndLubricants/Form1.Designer.cs deleted file mode 100644 index 2978835..0000000 --- a/FuelAndLubricants/FuelAndLubricants/Form1.Designer.cs +++ /dev/null @@ -1,39 +0,0 @@ -namespace FuelAndLubricants -{ - partial class Form1 - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - 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 - } -} diff --git a/FuelAndLubricants/FuelAndLubricants/Form1.cs b/FuelAndLubricants/FuelAndLubricants/Form1.cs deleted file mode 100644 index 9d5b795..0000000 --- a/FuelAndLubricants/FuelAndLubricants/Form1.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace FuelAndLubricants -{ - public partial class Form1 : Form - { - public Form1() - { - InitializeComponent(); - } - } -} diff --git a/FuelAndLubricants/FuelAndLubricants/FormFuelAndLubricants.Designer.cs b/FuelAndLubricants/FuelAndLubricants/FormFuelAndLubricants.Designer.cs new file mode 100644 index 0000000..2e506cc --- /dev/null +++ b/FuelAndLubricants/FuelAndLubricants/FormFuelAndLubricants.Designer.cs @@ -0,0 +1,146 @@ +namespace FuelAndLubricants +{ + partial class FormFuelAndLubricants + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + 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.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, операцииToolStripMenuItem, отчетыToolStripMenuItem }); + menuStrip.Location = new Point(0, 0); + menuStrip.Name = "menuStrip"; + menuStrip.Size = new Size(784, 24); + menuStrip.TabIndex = 0; + menuStrip.Text = "menuStrip1"; + // + // справочникиToolStripMenuItem + // + справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { CarsToolStripMenuItem, DriversToolStripMenuItem, FuelToolStripMenuItem, RoutesToolStripMenuItem }); + справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem"; + справочникиToolStripMenuItem.Size = new Size(94, 20); + справочникиToolStripMenuItem.Text = "Справочники"; + // + // CarsToolStripMenuItem + // + CarsToolStripMenuItem.Name = "CarsToolStripMenuItem"; + CarsToolStripMenuItem.Size = new Size(180, 22); + CarsToolStripMenuItem.Text = "Машины"; + CarsToolStripMenuItem.Click += CarsToolStripMenuItem_Click; + // + // DriversToolStripMenuItem + // + DriversToolStripMenuItem.Name = "DriversToolStripMenuItem"; + DriversToolStripMenuItem.Size = new Size(180, 22); + DriversToolStripMenuItem.Text = "Водители"; + DriversToolStripMenuItem.Click += DriversToolStripMenuItem_Click; + // + // FuelToolStripMenuItem + // + FuelToolStripMenuItem.Name = "FuelToolStripMenuItem"; + FuelToolStripMenuItem.Size = new Size(180, 22); + FuelToolStripMenuItem.Text = "Топливо"; + FuelToolStripMenuItem.Click += FuelToolStripMenuItem_Click; + // + // RoutesToolStripMenuItem + // + RoutesToolStripMenuItem.Name = "RoutesToolStripMenuItem"; + RoutesToolStripMenuItem.Size = new Size(180, 22); + RoutesToolStripMenuItem.Text = "Маршруты"; + RoutesToolStripMenuItem.Click += RoutesToolStripMenuItem_Click; + // + // операцииToolStripMenuItem + // + операцииToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { RefillToolStripMenuItem, TripToolStripMenuItem }); + операцииToolStripMenuItem.Name = "операцииToolStripMenuItem"; + операцииToolStripMenuItem.Size = new Size(75, 20); + операцииToolStripMenuItem.Text = "Операции"; + // + // RefillToolStripMenuItem + // + RefillToolStripMenuItem.Name = "RefillToolStripMenuItem"; + RefillToolStripMenuItem.Size = new Size(180, 22); + RefillToolStripMenuItem.Text = "Заправка"; + RefillToolStripMenuItem.Click += RefillToolStripMenuItem_Click; + // + // TripToolStripMenuItem + // + TripToolStripMenuItem.Name = "TripToolStripMenuItem"; + TripToolStripMenuItem.Size = new Size(180, 22); + TripToolStripMenuItem.Text = "Поездка"; + TripToolStripMenuItem.Click += TripToolStripMenuItem_Click; + // + // отчетыToolStripMenuItem + // + отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem"; + отчетыToolStripMenuItem.Size = new Size(60, 20); + отчетыToolStripMenuItem.Text = "Отчеты"; + // + // FormFuelAndLubricants + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + BackgroundImage = Properties.Resources.ГСМ; + BackgroundImageLayout = ImageLayout.Stretch; + ClientSize = new Size(784, 411); + Controls.Add(menuStrip); + MainMenuStrip = menuStrip; + Name = "FormFuelAndLubricants"; + 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 RoutesToolStripMenuItem; + private ToolStripMenuItem операцииToolStripMenuItem; + private ToolStripMenuItem RefillToolStripMenuItem; + private ToolStripMenuItem TripToolStripMenuItem; + private ToolStripMenuItem отчетыToolStripMenuItem; + } +} diff --git a/FuelAndLubricants/FuelAndLubricants/FormFuelAndLubricants.cs b/FuelAndLubricants/FuelAndLubricants/FormFuelAndLubricants.cs new file mode 100644 index 0000000..5ec2c97 --- /dev/null +++ b/FuelAndLubricants/FuelAndLubricants/FormFuelAndLubricants.cs @@ -0,0 +1,102 @@ +using FuelAndLubricants.Forms; +using Unity; + +namespace FuelAndLubricants +{ + public partial class FormFuelAndLubricants : Form + { + private readonly IUnityContainer _container; + + public FormFuelAndLubricants(IUnityContainer container) + { + InitializeComponent(); + _container = container ?? + throw new ArgumentNullException(nameof(container)); + + } + + private void CarsToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + } + + private void DriversToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + } + + private void FuelToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + } + + private void RoutesToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + } + + private void RefillToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + } + + private void TripToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + } + } +} diff --git a/FuelAndLubricants/FuelAndLubricants/FormFuelAndLubricants.resx b/FuelAndLubricants/FuelAndLubricants/FormFuelAndLubricants.resx new file mode 100644 index 0000000..31084d5 --- /dev/null +++ b/FuelAndLubricants/FuelAndLubricants/FormFuelAndLubricants.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + \ No newline at end of file diff --git a/FuelAndLubricants/FuelAndLubricants/Forms/FormCar.Designer.cs b/FuelAndLubricants/FuelAndLubricants/Forms/FormCar.Designer.cs new file mode 100644 index 0000000..a17b551 --- /dev/null +++ b/FuelAndLubricants/FuelAndLubricants/Forms/FormCar.Designer.cs @@ -0,0 +1,207 @@ +namespace FuelAndLubricants.Forms +{ + partial class FormCar + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + checkedListBoxDriverLicense = new CheckedListBox(); + buttonCancel = new Button(); + buttonCarSave = new Button(); + label3 = new Label(); + textBoxCarModel = new TextBox(); + label2 = new Label(); + textBoxCarMark = new TextBox(); + label1 = new Label(); + comboBoxCarType = new ComboBox(); + label4 = new Label(); + numericUpDownConsumptionRate = new NumericUpDown(); + label5 = new Label(); + ((System.ComponentModel.ISupportInitialize)numericUpDownConsumptionRate).BeginInit(); + SuspendLayout(); + // + // checkedListBoxDriverLicense + // + checkedListBoxDriverLicense.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + checkedListBoxDriverLicense.FormattingEnabled = true; + checkedListBoxDriverLicense.Location = new Point(122, 129); + checkedListBoxDriverLicense.Margin = new Padding(3, 4, 3, 4); + checkedListBoxDriverLicense.Name = "checkedListBoxDriverLicense"; + checkedListBoxDriverLicense.Size = new Size(159, 114); + checkedListBoxDriverLicense.TabIndex = 17; + // + // buttonCancel + // + buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonCancel.Location = new Point(197, 309); + buttonCancel.Margin = new Padding(3, 4, 3, 4); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(86, 31); + buttonCancel.TabIndex = 16; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += ButtonCancel_Click; + // + // buttonCarSave + // + buttonCarSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; + buttonCarSave.Location = new Point(10, 309); + buttonCarSave.Margin = new Padding(3, 4, 3, 4); + buttonCarSave.Name = "buttonCarSave"; + buttonCarSave.Size = new Size(86, 31); + buttonCarSave.TabIndex = 15; + buttonCarSave.Text = "Сохранить"; + buttonCarSave.UseVisualStyleBackColor = true; + buttonCarSave.Click += ButtonCarSave_Click; + // + // label3 + // + label3.AutoSize = true; + label3.Location = new Point(10, 129); + label3.Name = "label3"; + label3.Size = new Size(119, 20); + label3.TabIndex = 14; + label3.Text = "Категория прав"; + // + // textBoxCarModel + // + textBoxCarModel.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + textBoxCarModel.Location = new Point(122, 52); + textBoxCarModel.Margin = new Padding(3, 4, 3, 4); + textBoxCarModel.Name = "textBoxCarModel"; + textBoxCarModel.Size = new Size(159, 27); + textBoxCarModel.TabIndex = 13; + // + // label2 + // + label2.AutoSize = true; + label2.Location = new Point(10, 56); + label2.Name = "label2"; + label2.Size = new Size(63, 20); + label2.TabIndex = 12; + label2.Text = "Модель"; + // + // textBoxCarMark + // + textBoxCarMark.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + textBoxCarMark.Location = new Point(122, 13); + textBoxCarMark.Margin = new Padding(3, 4, 3, 4); + textBoxCarMark.Name = "textBoxCarMark"; + textBoxCarMark.Size = new Size(159, 27); + textBoxCarMark.TabIndex = 11; + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(10, 17); + label1.Name = "label1"; + label1.Size = new Size(54, 20); + label1.TabIndex = 10; + label1.Text = "Марка"; + // + // comboBoxCarType + // + comboBoxCarType.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + comboBoxCarType.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxCarType.FormattingEnabled = true; + comboBoxCarType.Location = new Point(122, 91); + comboBoxCarType.Margin = new Padding(3, 4, 3, 4); + comboBoxCarType.Name = "comboBoxCarType"; + comboBoxCarType.Size = new Size(159, 28); + comboBoxCarType.TabIndex = 18; + // + // label4 + // + label4.AutoSize = true; + label4.Location = new Point(10, 95); + label4.Name = "label4"; + label4.Size = new Size(99, 20); + label4.TabIndex = 19; + label4.Text = "Тип машины"; + // + // numericUpDownConsumptionRate + // + numericUpDownConsumptionRate.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + numericUpDownConsumptionRate.DecimalPlaces = 2; + numericUpDownConsumptionRate.Location = new Point(122, 263); + numericUpDownConsumptionRate.Margin = new Padding(3, 4, 3, 4); + numericUpDownConsumptionRate.Minimum = new decimal(new int[] { 1, 0, 0, 131072 }); + numericUpDownConsumptionRate.Name = "numericUpDownConsumptionRate"; + numericUpDownConsumptionRate.Size = new Size(160, 27); + numericUpDownConsumptionRate.TabIndex = 20; + numericUpDownConsumptionRate.Value = new decimal(new int[] { 1, 0, 0, 131072 }); + // + // label5 + // + label5.AutoSize = true; + label5.Location = new Point(10, 265); + label5.Name = "label5"; + label5.Size = new Size(117, 20); + label5.TabIndex = 21; + label5.Text = "Расход топлива"; + // + // FormCar + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(299, 355); + Controls.Add(label5); + Controls.Add(numericUpDownConsumptionRate); + Controls.Add(label4); + Controls.Add(comboBoxCarType); + Controls.Add(checkedListBoxDriverLicense); + Controls.Add(buttonCancel); + Controls.Add(buttonCarSave); + Controls.Add(label3); + Controls.Add(textBoxCarModel); + Controls.Add(label2); + Controls.Add(textBoxCarMark); + Controls.Add(label1); + Margin = new Padding(3, 4, 3, 4); + Name = "FormCar"; + StartPosition = FormStartPosition.CenterParent; + Text = "FormCar"; + ((System.ComponentModel.ISupportInitialize)numericUpDownConsumptionRate).EndInit(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private CheckedListBox checkedListBoxDriverLicense; + private Button buttonCancel; + private Button buttonCarSave; + private Label label3; + private TextBox textBoxCarModel; + private Label label2; + private TextBox textBoxCarMark; + private Label label1; + private ComboBox comboBoxCarType; + private Label label4; + private NumericUpDown numericUpDownConsumptionRate; + private Label label5; + } +} \ No newline at end of file diff --git a/FuelAndLubricants/FuelAndLubricants/Forms/FormCar.cs b/FuelAndLubricants/FuelAndLubricants/Forms/FormCar.cs new file mode 100644 index 0000000..9529bdc --- /dev/null +++ b/FuelAndLubricants/FuelAndLubricants/Forms/FormCar.cs @@ -0,0 +1,91 @@ +using FuelAndLubricants.Entities; +using FuelAndLubricants.Entities.Enums; +using FuelAndLubricants.Repositories; + +namespace FuelAndLubricants.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 (Driver_License elem in Enum.GetValues(typeof(Driver_License))) + { + if ((elem & car.License) != 0) + { + checkedListBoxDriverLicense.SetItemChecked(checkedListBoxDriverLicense.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(Driver_License))) + checkedListBoxDriverLicense.Items.Add(elem); + + comboBoxCarType.DataSource = Enum.GetValues(typeof(Car_Type)); + } + + private void ButtonCarSave_Click(object sender, EventArgs e) + { + try + { + if (string.IsNullOrWhiteSpace(textBoxCarMark.Text) || string.IsNullOrWhiteSpace(textBoxCarModel.Text) || comboBoxCarType.SelectedIndex < 1 || checkedListBoxDriverLicense.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); + } + } + + private void ButtonCancel_Click(object sender, EventArgs e) => Close(); + + private Car CreateCar(int id) + { + Driver_License driver_License = Driver_License.None; + foreach (var elem in checkedListBoxDriverLicense.CheckedItems) + { + driver_License |= (Driver_License)elem; + } + + return Car.CreateEntity(id, textBoxCarMark.Text, textBoxCarModel.Text, (Car_Type)comboBoxCarType.SelectedItem!, driver_License, (float)numericUpDownConsumptionRate.Value); + } + } +} diff --git a/FuelAndLubricants/FuelAndLubricants/Form1.resx b/FuelAndLubricants/FuelAndLubricants/Forms/FormCar.resx similarity index 93% rename from FuelAndLubricants/FuelAndLubricants/Form1.resx rename to FuelAndLubricants/FuelAndLubricants/Forms/FormCar.resx index 1af7de1..af32865 100644 --- a/FuelAndLubricants/FuelAndLubricants/Form1.resx +++ b/FuelAndLubricants/FuelAndLubricants/Forms/FormCar.resx @@ -1,17 +1,17 @@  - diff --git a/FuelAndLubricants/FuelAndLubricants/Forms/FormCars.Designer.cs b/FuelAndLubricants/FuelAndLubricants/Forms/FormCars.Designer.cs new file mode 100644 index 0000000..1fd663b --- /dev/null +++ b/FuelAndLubricants/FuelAndLubricants/Forms/FormCars.Designer.cs @@ -0,0 +1,133 @@ +namespace FuelAndLubricants.Forms +{ + partial class FormCars + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + 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(778, 0); + panel1.Margin = new Padding(3, 4, 3, 4); + panel1.Name = "panel1"; + panel1.Size = new Size(113, 345); + panel1.TabIndex = 0; + // + // buttonDel + // + buttonDel.BackgroundImage = Properties.Resources.Удалить; + buttonDel.BackgroundImageLayout = ImageLayout.Stretch; + buttonDel.Location = new Point(14, 232); + buttonDel.Margin = new Padding(3, 4, 3, 4); + buttonDel.Name = "buttonDel"; + buttonDel.Size = new Size(86, 100); + buttonDel.TabIndex = 5; + buttonDel.UseVisualStyleBackColor = true; + buttonDel.Click += ButtonDel_Click; + // + // buttonUpd + // + buttonUpd.BackgroundImage = Properties.Resources.Редактировать; + buttonUpd.BackgroundImageLayout = ImageLayout.Stretch; + buttonUpd.Location = new Point(14, 124); + buttonUpd.Margin = new Padding(3, 4, 3, 4); + buttonUpd.Name = "buttonUpd"; + buttonUpd.Size = new Size(86, 100); + buttonUpd.TabIndex = 4; + buttonUpd.UseVisualStyleBackColor = true; + buttonUpd.Click += ButtonUpd_Click; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.Добавить; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(14, 16); + buttonAdd.Margin = new Padding(3, 4, 3, 4); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(86, 100); + buttonAdd.TabIndex = 3; + 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.Margin = new Padding(3, 4, 3, 4); + dataGridView.MultiSelect = false; + dataGridView.Name = "dataGridView"; + dataGridView.ReadOnly = true; + dataGridView.RowHeadersVisible = false; + dataGridView.RowHeadersWidth = 51; + dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridView.Size = new Size(778, 345); + dataGridView.TabIndex = 2; + // + // FormCars + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(891, 345); + Controls.Add(dataGridView); + Controls.Add(panel1); + Margin = new Padding(3, 4, 3, 4); + 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 buttonDel; + private Button buttonUpd; + private Button buttonAdd; + private DataGridView dataGridView; + } +} \ No newline at end of file diff --git a/FuelAndLubricants/FuelAndLubricants/Forms/FormCars.cs b/FuelAndLubricants/FuelAndLubricants/Forms/FormCars.cs new file mode 100644 index 0000000..797ff16 --- /dev/null +++ b/FuelAndLubricants/FuelAndLubricants/Forms/FormCars.cs @@ -0,0 +1,100 @@ +using FuelAndLubricants.Repositories; +using Unity; + +namespace FuelAndLubricants.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 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().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(); + 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 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; + } + } +} diff --git a/FuelAndLubricants/FuelAndLubricants/Forms/FormCars.resx b/FuelAndLubricants/FuelAndLubricants/Forms/FormCars.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/FuelAndLubricants/FuelAndLubricants/Forms/FormCars.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/FuelAndLubricants/FuelAndLubricants/Forms/FormDriver.Designer.cs b/FuelAndLubricants/FuelAndLubricants/Forms/FormDriver.Designer.cs new file mode 100644 index 0000000..0876acd --- /dev/null +++ b/FuelAndLubricants/FuelAndLubricants/Forms/FormDriver.Designer.cs @@ -0,0 +1,152 @@ +namespace FuelAndLubricants.Forms +{ + partial class FormDriver + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + label1 = new Label(); + textBoxDriverFirstname = new TextBox(); + textBoxDriverSecondname = new TextBox(); + label2 = new Label(); + label3 = new Label(); + buttonDriverSave = new Button(); + buttonDriverCancel = new Button(); + checkedListBoxDriverLicense = new CheckedListBox(); + SuspendLayout(); + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(15, 24); + label1.Name = "label1"; + label1.Size = new Size(39, 20); + label1.TabIndex = 0; + label1.Text = "Имя"; + // + // textBoxDriverFirstname + // + textBoxDriverFirstname.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + textBoxDriverFirstname.Location = new Point(127, 20); + textBoxDriverFirstname.Margin = new Padding(3, 4, 3, 4); + textBoxDriverFirstname.Name = "textBoxDriverFirstname"; + textBoxDriverFirstname.Size = new Size(159, 27); + textBoxDriverFirstname.TabIndex = 1; + // + // textBoxDriverSecondname + // + textBoxDriverSecondname.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + textBoxDriverSecondname.Location = new Point(127, 59); + textBoxDriverSecondname.Margin = new Padding(3, 4, 3, 4); + textBoxDriverSecondname.Name = "textBoxDriverSecondname"; + textBoxDriverSecondname.Size = new Size(159, 27); + textBoxDriverSecondname.TabIndex = 3; + // + // label2 + // + label2.AutoSize = true; + label2.Location = new Point(15, 63); + label2.Name = "label2"; + label2.Size = new Size(73, 20); + label2.TabIndex = 2; + label2.Text = "Фамилия"; + // + // label3 + // + label3.AutoSize = true; + label3.Location = new Point(15, 101); + label3.Name = "label3"; + label3.Size = new Size(119, 20); + label3.TabIndex = 4; + label3.Text = "Категория прав"; + // + // buttonDriverSave + // + buttonDriverSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; + buttonDriverSave.Location = new Point(15, 235); + buttonDriverSave.Margin = new Padding(3, 4, 3, 4); + buttonDriverSave.Name = "buttonDriverSave"; + buttonDriverSave.Size = new Size(86, 31); + buttonDriverSave.TabIndex = 6; + buttonDriverSave.Text = "Сохранить"; + buttonDriverSave.UseVisualStyleBackColor = true; + buttonDriverSave.Click += ButtonDriverSave_Click; + // + // buttonDriverCancel + // + buttonDriverCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonDriverCancel.Location = new Point(201, 235); + buttonDriverCancel.Margin = new Padding(3, 4, 3, 4); + buttonDriverCancel.Name = "buttonDriverCancel"; + buttonDriverCancel.Size = new Size(86, 31); + buttonDriverCancel.TabIndex = 7; + buttonDriverCancel.Text = "Отмена"; + buttonDriverCancel.UseVisualStyleBackColor = true; + buttonDriverCancel.Click += ButtonDriverCancel_Click; + // + // checkedListBoxDriverLicense + // + checkedListBoxDriverLicense.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + checkedListBoxDriverLicense.FormattingEnabled = true; + checkedListBoxDriverLicense.Location = new Point(127, 101); + checkedListBoxDriverLicense.Margin = new Padding(3, 4, 3, 4); + checkedListBoxDriverLicense.Name = "checkedListBoxDriverLicense"; + checkedListBoxDriverLicense.Size = new Size(159, 114); + checkedListBoxDriverLicense.TabIndex = 9; + // + // FormDriver + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(302, 281); + Controls.Add(checkedListBoxDriverLicense); + Controls.Add(buttonDriverCancel); + Controls.Add(buttonDriverSave); + Controls.Add(label3); + Controls.Add(textBoxDriverSecondname); + Controls.Add(label2); + Controls.Add(textBoxDriverFirstname); + Controls.Add(label1); + Margin = new Padding(3, 4, 3, 4); + Name = "FormDriver"; + StartPosition = FormStartPosition.CenterParent; + Text = "Водитель"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label label1; + private TextBox textBoxDriverFirstname; + private TextBox textBoxDriverSecondname; + private Label label2; + private Label label3; + private Button buttonDriverSave; + private Button buttonDriverCancel; + private CheckedListBox checkedListBoxDriverLicense; + } +} \ No newline at end of file diff --git a/FuelAndLubricants/FuelAndLubricants/Forms/FormDriver.cs b/FuelAndLubricants/FuelAndLubricants/Forms/FormDriver.cs new file mode 100644 index 0000000..b67eb43 --- /dev/null +++ b/FuelAndLubricants/FuelAndLubricants/Forms/FormDriver.cs @@ -0,0 +1,87 @@ +using FuelAndLubricants.Entities; +using FuelAndLubricants.Entities.Enums; +using FuelAndLubricants.Repositories; + +namespace FuelAndLubricants.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 (Driver_License elem in Enum.GetValues(typeof(Driver_License))) + { + if ((elem & driver.Driver_License) != 0) + { + checkedListBoxDriverLicense.SetItemChecked(checkedListBoxDriverLicense.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(Driver_License))) + checkedListBoxDriverLicense.Items.Add(elem); + } + + private void ButtonDriverSave_Click(object sender, EventArgs e) + { + try + { + if (string.IsNullOrWhiteSpace(textBoxDriverFirstname.Text) || string.IsNullOrWhiteSpace(textBoxDriverSecondname.Text) || checkedListBoxDriverLicense.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 ButtonDriverCancel_Click(object sender, EventArgs e) => Close(); + + private Driver CreateDriver(int id) + { + Driver_License driver_License = Driver_License.None; + foreach (var elem in checkedListBoxDriverLicense.CheckedItems) + { + driver_License |= (Driver_License)elem; + } + + return Driver.CreateEntity(id, textBoxDriverFirstname.Text, textBoxDriverSecondname.Text, driver_License); + } + } +} diff --git a/FuelAndLubricants/FuelAndLubricants/Forms/FormDriver.resx b/FuelAndLubricants/FuelAndLubricants/Forms/FormDriver.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/FuelAndLubricants/FuelAndLubricants/Forms/FormDriver.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/FuelAndLubricants/FuelAndLubricants/Forms/FormDrivers.Designer.cs b/FuelAndLubricants/FuelAndLubricants/Forms/FormDrivers.Designer.cs new file mode 100644 index 0000000..91aa935 --- /dev/null +++ b/FuelAndLubricants/FuelAndLubricants/Forms/FormDrivers.Designer.cs @@ -0,0 +1,127 @@ +namespace FuelAndLubricants.Forms +{ + partial class FormDrivers + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + 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.ImeMode = ImeMode.NoControl; + panel1.Location = new Point(660, 0); + panel1.Name = "panel1"; + panel1.Size = new Size(89, 264); + panel1.TabIndex = 0; + // + // buttonDel + // + buttonDel.BackgroundImage = Properties.Resources.Удалить; + buttonDel.BackgroundImageLayout = ImageLayout.Stretch; + buttonDel.Location = new Point(6, 174); + buttonDel.Name = "buttonDel"; + buttonDel.Size = new Size(75, 75); + buttonDel.TabIndex = 2; + buttonDel.UseVisualStyleBackColor = true; + buttonDel.Click += ButtonDel_Click; + // + // buttonUpd + // + buttonUpd.BackgroundImage = Properties.Resources.Редактировать; + buttonUpd.BackgroundImageLayout = ImageLayout.Stretch; + buttonUpd.Location = new Point(6, 93); + buttonUpd.Name = "buttonUpd"; + buttonUpd.Size = new Size(75, 75); + buttonUpd.TabIndex = 1; + buttonUpd.UseVisualStyleBackColor = true; + buttonUpd.Click += ButtonUpd_Click; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.Добавить; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(6, 12); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(75, 75); + 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.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridView.Size = new Size(660, 264); + dataGridView.TabIndex = 1; + // + // FormDrivers + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(749, 264); + 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 buttonDel; + private Button buttonUpd; + private Button buttonAdd; + private DataGridView dataGridView; + } +} \ No newline at end of file diff --git a/FuelAndLubricants/FuelAndLubricants/Forms/FormDrivers.cs b/FuelAndLubricants/FuelAndLubricants/Forms/FormDrivers.cs new file mode 100644 index 0000000..4d773e5 --- /dev/null +++ b/FuelAndLubricants/FuelAndLubricants/Forms/FormDrivers.cs @@ -0,0 +1,103 @@ +using FuelAndLubricants.Repositories; +using Unity; + +namespace FuelAndLubricants.Forms +{ + public partial class FormDrivers : Form + { + private readonly IUnityContainer _container; + + private readonly IDriverRepository _driverRepository; + + public FormDrivers(IUnityContainer container, IDriverRepository driverRepository) + { + InitializeComponent(); + _container = container ?? + throw new ArgumentNullException(nameof(container)); + _driverRepository = driverRepository ?? + throw new ArgumentNullException(nameof(driverRepository)); + + } + + private void FormDrivers_Load(object sender, EventArgs e) + { + try + { + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonAdd_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().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(); + 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 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; + } + + } +} diff --git a/FuelAndLubricants/FuelAndLubricants/Forms/FormDrivers.resx b/FuelAndLubricants/FuelAndLubricants/Forms/FormDrivers.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/FuelAndLubricants/FuelAndLubricants/Forms/FormDrivers.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/FuelAndLubricants/FuelAndLubricants/Forms/FormFuel.Designer.cs b/FuelAndLubricants/FuelAndLubricants/Forms/FormFuel.Designer.cs new file mode 100644 index 0000000..607abe8 --- /dev/null +++ b/FuelAndLubricants/FuelAndLubricants/Forms/FormFuel.Designer.cs @@ -0,0 +1,163 @@ +namespace FuelAndLubricants.Forms +{ + partial class FormFuel + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + label5 = new Label(); + numericUpDownPrice = new NumericUpDown(); + buttonCancel = new Button(); + buttonFuelSave = new Button(); + label1 = new Label(); + comboBoxFuelType = new ComboBox(); + label2 = new Label(); + numericUpDownAmount = new NumericUpDown(); + ((System.ComponentModel.ISupportInitialize)numericUpDownPrice).BeginInit(); + ((System.ComponentModel.ISupportInitialize)numericUpDownAmount).BeginInit(); + SuspendLayout(); + // + // label5 + // + label5.AutoSize = true; + label5.Location = new Point(8, 53); + label5.Name = "label5"; + label5.Size = new Size(100, 20); + label5.TabIndex = 33; + label5.Text = "Цена за литр"; + // + // numericUpDownPrice + // + numericUpDownPrice.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + numericUpDownPrice.DecimalPlaces = 2; + numericUpDownPrice.Location = new Point(120, 51); + numericUpDownPrice.Margin = new Padding(3, 4, 3, 4); + numericUpDownPrice.Minimum = new decimal(new int[] { 1, 0, 0, 131072 }); + numericUpDownPrice.Name = "numericUpDownPrice"; + numericUpDownPrice.Size = new Size(160, 27); + numericUpDownPrice.TabIndex = 32; + numericUpDownPrice.Value = new decimal(new int[] { 1, 0, 0, 131072 }); + // + // buttonCancel + // + buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonCancel.Location = new Point(194, 141); + buttonCancel.Margin = new Padding(3, 4, 3, 4); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(86, 31); + buttonCancel.TabIndex = 28; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += ButtonCancel_Click; + // + // buttonFuelSave + // + buttonFuelSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; + buttonFuelSave.Location = new Point(8, 141); + buttonFuelSave.Margin = new Padding(3, 4, 3, 4); + buttonFuelSave.Name = "buttonFuelSave"; + buttonFuelSave.Size = new Size(86, 31); + buttonFuelSave.TabIndex = 27; + buttonFuelSave.Text = "Сохранить"; + buttonFuelSave.UseVisualStyleBackColor = true; + buttonFuelSave.Click += ButtonFuelSave_Click; + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(8, 16); + label1.Name = "label1"; + label1.Size = new Size(96, 20); + label1.TabIndex = 35; + label1.Text = "Тип топлива"; + // + // comboBoxFuelType + // + comboBoxFuelType.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + comboBoxFuelType.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxFuelType.FormattingEnabled = true; + comboBoxFuelType.Location = new Point(120, 12); + comboBoxFuelType.Margin = new Padding(3, 4, 3, 4); + comboBoxFuelType.Name = "comboBoxFuelType"; + comboBoxFuelType.Size = new Size(159, 28); + comboBoxFuelType.TabIndex = 34; + // + // label2 + // + label2.AutoSize = true; + label2.Location = new Point(8, 92); + label2.Name = "label2"; + label2.Size = new Size(90, 20); + label2.TabIndex = 37; + label2.Text = "Количество"; + // + // numericUpDownAmount + // + numericUpDownAmount.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + numericUpDownAmount.DecimalPlaces = 2; + numericUpDownAmount.Location = new Point(120, 89); + numericUpDownAmount.Margin = new Padding(3, 4, 3, 4); + numericUpDownAmount.Minimum = new decimal(new int[] { 1, 0, 0, 131072 }); + numericUpDownAmount.Name = "numericUpDownAmount"; + numericUpDownAmount.Size = new Size(160, 27); + numericUpDownAmount.TabIndex = 36; + numericUpDownAmount.Value = new decimal(new int[] { 1, 0, 0, 131072 }); + // + // FormFuel + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(293, 181); + Controls.Add(label2); + Controls.Add(numericUpDownAmount); + Controls.Add(label1); + Controls.Add(comboBoxFuelType); + Controls.Add(label5); + Controls.Add(numericUpDownPrice); + Controls.Add(buttonCancel); + Controls.Add(buttonFuelSave); + Margin = new Padding(3, 4, 3, 4); + Name = "FormFuel"; + StartPosition = FormStartPosition.CenterParent; + Text = "FormFuel"; + ((System.ComponentModel.ISupportInitialize)numericUpDownPrice).EndInit(); + ((System.ComponentModel.ISupportInitialize)numericUpDownAmount).EndInit(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label label5; + private NumericUpDown numericUpDownPrice; + private Button buttonCancel; + private Button buttonFuelSave; + private Label label1; + private ComboBox comboBoxFuelType; + private Label label2; + private NumericUpDown numericUpDownAmount; + } +} \ No newline at end of file diff --git a/FuelAndLubricants/FuelAndLubricants/Forms/FormFuel.cs b/FuelAndLubricants/FuelAndLubricants/Forms/FormFuel.cs new file mode 100644 index 0000000..ae8ee7e --- /dev/null +++ b/FuelAndLubricants/FuelAndLubricants/Forms/FormFuel.cs @@ -0,0 +1,72 @@ +using FuelAndLubricants.Entities; +using FuelAndLubricants.Entities.Enums; +using FuelAndLubricants.Repositories; + +namespace FuelAndLubricants.Forms +{ + public partial class FormFuel : Form + { + private readonly IFuelRepository _fuelRepository; + + private int? _fuelId; + + public int Id + { + set + { + try + { + var fuel = _fuelRepository.ReadFuelByID(value); + if (fuel == null) + throw new InvalidOperationException(nameof(fuel)); + + comboBoxFuelType.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 FormFuel(IFuelRepository fuelRepository) + { + InitializeComponent(); + _fuelRepository = fuelRepository ?? + throw new ArgumentNullException(nameof(fuelRepository)); + + comboBoxFuelType.DataSource = Enum.GetValues(typeof(Fuel_Type)); + } + + private void ButtonFuelSave_Click(object sender, EventArgs e) + { + try + { + if (comboBoxFuelType.SelectedIndex < 1) + throw new Exception("Имеются незаполненные поля"); + + if (_fuelId.HasValue) + _fuelRepository.UpdateFuel(CreateFuel(_fuelId.Value)); + else + _fuelRepository.CreateFuel(CreateFuel(0)); + + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonCancel_Click(object sender, EventArgs e) => Close(); + + private Fuel_And_Lubricants CreateFuel(int id) + { + return Fuel_And_Lubricants.CreateEntity(id, (Fuel_Type)comboBoxFuelType.SelectedItem!, (float)numericUpDownPrice.Value, (float)numericUpDownAmount.Value); + } + } +} diff --git a/FuelAndLubricants/FuelAndLubricants/Forms/FormFuel.resx b/FuelAndLubricants/FuelAndLubricants/Forms/FormFuel.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/FuelAndLubricants/FuelAndLubricants/Forms/FormFuel.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/FuelAndLubricants/FuelAndLubricants/Forms/FormFuels.Designer.cs b/FuelAndLubricants/FuelAndLubricants/Forms/FormFuels.Designer.cs new file mode 100644 index 0000000..30fe064 --- /dev/null +++ b/FuelAndLubricants/FuelAndLubricants/Forms/FormFuels.Designer.cs @@ -0,0 +1,133 @@ +namespace FuelAndLubricants.Forms +{ + partial class FormFuels + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + 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(607, 0); + panel1.Margin = new Padding(3, 4, 3, 4); + panel1.Name = "panel1"; + panel1.Size = new Size(115, 348); + panel1.TabIndex = 0; + // + // buttonDel + // + buttonDel.BackgroundImage = Properties.Resources.Удалить; + buttonDel.BackgroundImageLayout = ImageLayout.Stretch; + buttonDel.Location = new Point(15, 232); + buttonDel.Margin = new Padding(3, 4, 3, 4); + buttonDel.Name = "buttonDel"; + buttonDel.Size = new Size(86, 100); + buttonDel.TabIndex = 8; + buttonDel.UseVisualStyleBackColor = true; + buttonDel.Click += ButtonDel_Click; + // + // buttonUpd + // + buttonUpd.BackgroundImage = Properties.Resources.Редактировать; + buttonUpd.BackgroundImageLayout = ImageLayout.Stretch; + buttonUpd.Location = new Point(15, 124); + buttonUpd.Margin = new Padding(3, 4, 3, 4); + buttonUpd.Name = "buttonUpd"; + buttonUpd.Size = new Size(86, 100); + buttonUpd.TabIndex = 7; + buttonUpd.UseVisualStyleBackColor = true; + buttonUpd.Click += ButtonUpd_Click; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.Добавить; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(15, 16); + buttonAdd.Margin = new Padding(3, 4, 3, 4); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(86, 100); + buttonAdd.TabIndex = 6; + 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.Margin = new Padding(3, 4, 3, 4); + dataGridView.MultiSelect = false; + dataGridView.Name = "dataGridView"; + dataGridView.ReadOnly = true; + dataGridView.RowHeadersVisible = false; + dataGridView.RowHeadersWidth = 51; + dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridView.Size = new Size(607, 348); + dataGridView.TabIndex = 3; + // + // FormFuels + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(722, 348); + Controls.Add(dataGridView); + Controls.Add(panel1); + Margin = new Padding(3, 4, 3, 4); + Name = "FormFuels"; + StartPosition = FormStartPosition.CenterParent; + Text = "Топлива"; + Load += FormFuels_Load; + panel1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + } + + #endregion + + private Panel panel1; + private Button buttonDel; + private Button buttonUpd; + private Button buttonAdd; + private DataGridView dataGridView; + } +} \ No newline at end of file diff --git a/FuelAndLubricants/FuelAndLubricants/Forms/FormFuels.cs b/FuelAndLubricants/FuelAndLubricants/Forms/FormFuels.cs new file mode 100644 index 0000000..31bd21e --- /dev/null +++ b/FuelAndLubricants/FuelAndLubricants/Forms/FormFuels.cs @@ -0,0 +1,100 @@ +using FuelAndLubricants.Repositories; +using Unity; + +namespace FuelAndLubricants.Forms +{ + public partial class FormFuels : Form + { + private readonly IUnityContainer _container; + + private readonly IFuelRepository _fuelRepository; + + public FormFuels(IUnityContainer container, IFuelRepository fuelRepository) + { + InitializeComponent(); + _container = container ?? + throw new ArgumentNullException(nameof(container)); + _fuelRepository = fuelRepository ?? + throw new ArgumentNullException(nameof(fuelRepository)); + } + + private void FormFuels_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().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(); + 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 + { + _fuelRepository.DeleteFuel(findId); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void LoadList() => dataGridView.DataSource = _fuelRepository.ReadFuels(); + + 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["Fuel_ID"].Value); + return true; + } + } +} diff --git a/FuelAndLubricants/FuelAndLubricants/Forms/FormFuels.resx b/FuelAndLubricants/FuelAndLubricants/Forms/FormFuels.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/FuelAndLubricants/FuelAndLubricants/Forms/FormFuels.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/FuelAndLubricants/FuelAndLubricants/Forms/FormRefill.Designer.cs b/FuelAndLubricants/FuelAndLubricants/Forms/FormRefill.Designer.cs new file mode 100644 index 0000000..2ba153e --- /dev/null +++ b/FuelAndLubricants/FuelAndLubricants/Forms/FormRefill.Designer.cs @@ -0,0 +1,188 @@ +namespace FuelAndLubricants.Forms +{ + partial class FormRefill + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + label4 = new Label(); + buttonCancel = new Button(); + buttonRefillSave = new Button(); + label2 = new Label(); + dateTimePickerRefillDate = new DateTimePicker(); + label1 = new Label(); + numericUpDownRefillAmount = new NumericUpDown(); + label3 = new Label(); + comboBoxCarID = new ComboBox(); + comboBoxFuelID = new ComboBox(); + ((System.ComponentModel.ISupportInitialize)numericUpDownRefillAmount).BeginInit(); + SuspendLayout(); + // + // label4 + // + label4.AutoSize = true; + label4.Location = new Point(13, 93); + label4.Name = "label4"; + label4.Size = new Size(69, 20); + label4.TabIndex = 31; + label4.Text = "Топливо"; + // + // buttonCancel + // + buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonCancel.Location = new Point(199, 180); + buttonCancel.Margin = new Padding(3, 4, 3, 4); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(86, 31); + buttonCancel.TabIndex = 28; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += ButtonCancel_Click; + // + // buttonRefillSave + // + buttonRefillSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; + buttonRefillSave.Location = new Point(13, 180); + buttonRefillSave.Margin = new Padding(3, 4, 3, 4); + buttonRefillSave.Name = "buttonRefillSave"; + buttonRefillSave.Size = new Size(86, 31); + buttonRefillSave.TabIndex = 27; + buttonRefillSave.Text = "Сохранить"; + buttonRefillSave.UseVisualStyleBackColor = true; + buttonRefillSave.Click += ButtonSave_Click; + // + // label2 + // + label2.AutoSize = true; + label2.Location = new Point(13, 55); + label2.Name = "label2"; + label2.Size = new Size(90, 20); + label2.TabIndex = 24; + label2.Text = "Количество"; + // + // dateTimePickerRefillDate + // + dateTimePickerRefillDate.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + dateTimePickerRefillDate.Location = new Point(125, 12); + dateTimePickerRefillDate.Margin = new Padding(3, 4, 3, 4); + dateTimePickerRefillDate.Name = "dateTimePickerRefillDate"; + dateTimePickerRefillDate.Size = new Size(159, 27); + dateTimePickerRefillDate.TabIndex = 34; + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(13, 20); + label1.Name = "label1"; + label1.Size = new Size(110, 20); + label1.TabIndex = 35; + label1.Text = "Дата заправки"; + // + // numericUpDownRefillAmount + // + numericUpDownRefillAmount.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + numericUpDownRefillAmount.DecimalPlaces = 2; + numericUpDownRefillAmount.Location = new Point(125, 52); + numericUpDownRefillAmount.Margin = new Padding(3, 4, 3, 4); + numericUpDownRefillAmount.Minimum = new decimal(new int[] { 1, 0, 0, 131072 }); + numericUpDownRefillAmount.Name = "numericUpDownRefillAmount"; + numericUpDownRefillAmount.Size = new Size(160, 27); + numericUpDownRefillAmount.TabIndex = 36; + numericUpDownRefillAmount.Value = new decimal(new int[] { 1, 0, 0, 131072 }); + // + // label3 + // + label3.AutoSize = true; + label3.Location = new Point(13, 132); + label3.Name = "label3"; + label3.Size = new Size(68, 20); + label3.TabIndex = 38; + label3.Text = "Машина"; + // + // comboBoxCarID + // + comboBoxCarID.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + comboBoxCarID.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxCarID.FormattingEnabled = true; + comboBoxCarID.Location = new Point(125, 128); + comboBoxCarID.Margin = new Padding(3, 4, 3, 4); + comboBoxCarID.Name = "comboBoxCarID"; + comboBoxCarID.Size = new Size(159, 28); + comboBoxCarID.TabIndex = 37; + // + // comboBoxFuelID + // + comboBoxFuelID.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + comboBoxFuelID.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxFuelID.FormattingEnabled = true; + comboBoxFuelID.Location = new Point(125, 89); + comboBoxFuelID.Margin = new Padding(3, 4, 3, 4); + comboBoxFuelID.Name = "comboBoxFuelID"; + comboBoxFuelID.Size = new Size(159, 28); + comboBoxFuelID.TabIndex = 39; + // + // FormRefill + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(294, 220); + Controls.Add(comboBoxFuelID); + Controls.Add(label3); + Controls.Add(comboBoxCarID); + Controls.Add(numericUpDownRefillAmount); + Controls.Add(label1); + Controls.Add(dateTimePickerRefillDate); + Controls.Add(label4); + Controls.Add(buttonCancel); + Controls.Add(buttonRefillSave); + Controls.Add(label2); + Margin = new Padding(3, 4, 3, 4); + Name = "FormRefill"; + StartPosition = FormStartPosition.CenterParent; + Text = "FormRefill"; + ((System.ComponentModel.ISupportInitialize)numericUpDownRefillAmount).EndInit(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label label5; + private NumericUpDown numericUpDownConsumptionRate; + private Label label4; + private ComboBox comboBoxCarType; + private CheckedListBox checkedListBoxDriverLicense; + private Button buttonCancel; + private Button buttonRefillSave; + private Label label2; + private DateTimePicker dateTimePickerRefillDate; + private Label label1; + private NumericUpDown numericUpDownRefillAmount; + private Label label3; + private ComboBox comboBoxCarID; + private ComboBox comboBoxFuelID; + } +} \ No newline at end of file diff --git a/FuelAndLubricants/FuelAndLubricants/Forms/FormRefill.cs b/FuelAndLubricants/FuelAndLubricants/Forms/FormRefill.cs new file mode 100644 index 0000000..61140f4 --- /dev/null +++ b/FuelAndLubricants/FuelAndLubricants/Forms/FormRefill.cs @@ -0,0 +1,43 @@ +using FuelAndLubricants.Entities; +using FuelAndLubricants.Repositories; + +namespace FuelAndLubricants.Forms +{ + public partial class FormRefill : Form + { + private readonly IRefillRepository _refillRepository; + + public FormRefill(IRefillRepository refillRepository, IFuelRepository fuelRepository, ICarRepository carRepository) + { + InitializeComponent(); + + _refillRepository = refillRepository ?? + throw new ArgumentNullException(nameof(refillRepository)); + + comboBoxFuelID.DataSource = fuelRepository.ReadFuels(); + 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)numericUpDownRefillAmount.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(); + } +} diff --git a/FuelAndLubricants/FuelAndLubricants/Forms/FormRefill.resx b/FuelAndLubricants/FuelAndLubricants/Forms/FormRefill.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/FuelAndLubricants/FuelAndLubricants/Forms/FormRefill.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/FuelAndLubricants/FuelAndLubricants/Forms/FormRefills.Designer.cs b/FuelAndLubricants/FuelAndLubricants/Forms/FormRefills.Designer.cs new file mode 100644 index 0000000..0bfb237 --- /dev/null +++ b/FuelAndLubricants/FuelAndLubricants/Forms/FormRefills.Designer.cs @@ -0,0 +1,103 @@ +namespace FuelAndLubricants.Forms +{ + partial class FormRefills + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + 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(791, 0); + panel1.Margin = new Padding(3, 4, 3, 4); + panel1.Name = "panel1"; + panel1.Size = new Size(112, 372); + panel1.TabIndex = 0; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.Добавить; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(15, 16); + buttonAdd.Margin = new Padding(3, 4, 3, 4); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(86, 100); + buttonAdd.TabIndex = 4; + 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.Margin = new Padding(3, 4, 3, 4); + dataGridView.MultiSelect = false; + dataGridView.Name = "dataGridView"; + dataGridView.ReadOnly = true; + dataGridView.RowHeadersVisible = false; + dataGridView.RowHeadersWidth = 51; + dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridView.Size = new Size(791, 372); + dataGridView.TabIndex = 3; + // + // FormRefills + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(903, 372); + Controls.Add(dataGridView); + Controls.Add(panel1); + Margin = new Padding(3, 4, 3, 4); + 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; + } +} \ No newline at end of file diff --git a/FuelAndLubricants/FuelAndLubricants/Forms/FormRefills.cs b/FuelAndLubricants/FuelAndLubricants/Forms/FormRefills.cs new file mode 100644 index 0000000..f2c7f72 --- /dev/null +++ b/FuelAndLubricants/FuelAndLubricants/Forms/FormRefills.cs @@ -0,0 +1,51 @@ +using FuelAndLubricants.Repositories; +using Unity; + +namespace FuelAndLubricants.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 FormRefills_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().ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при добавлении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void LoadList() => dataGridView.DataSource = _refillRepository.ReadRefills(); + } +} diff --git a/FuelAndLubricants/FuelAndLubricants/Forms/FormRefills.resx b/FuelAndLubricants/FuelAndLubricants/Forms/FormRefills.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/FuelAndLubricants/FuelAndLubricants/Forms/FormRefills.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/FuelAndLubricants/FuelAndLubricants/Forms/FormRoute.Designer.cs b/FuelAndLubricants/FuelAndLubricants/Forms/FormRoute.Designer.cs new file mode 100644 index 0000000..ac63bb4 --- /dev/null +++ b/FuelAndLubricants/FuelAndLubricants/Forms/FormRoute.Designer.cs @@ -0,0 +1,156 @@ +namespace FuelAndLubricants.Forms +{ + partial class FormRoute + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + label5 = new Label(); + numericUpDownLength = new NumericUpDown(); + buttonCancel = new Button(); + buttonRouteSave = new Button(); + textBoxEndPoint = new TextBox(); + label2 = new Label(); + textBoxStartPoint = new TextBox(); + label1 = new Label(); + ((System.ComponentModel.ISupportInitialize)numericUpDownLength).BeginInit(); + SuspendLayout(); + // + // label5 + // + label5.AutoSize = true; + label5.Location = new Point(11, 93); + label5.Name = "label5"; + label5.Size = new Size(127, 20); + label5.TabIndex = 33; + label5.Text = "Длина маршрута"; + // + // numericUpDownLength + // + numericUpDownLength.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + numericUpDownLength.DecimalPlaces = 2; + numericUpDownLength.Location = new Point(134, 91); + numericUpDownLength.Margin = new Padding(3, 4, 3, 4); + numericUpDownLength.Minimum = new decimal(new int[] { 1, 0, 0, 131072 }); + numericUpDownLength.Name = "numericUpDownLength"; + numericUpDownLength.Size = new Size(160, 27); + numericUpDownLength.TabIndex = 32; + numericUpDownLength.Value = new decimal(new int[] { 1, 0, 0, 131072 }); + // + // buttonCancel + // + buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonCancel.Location = new Point(208, 136); + buttonCancel.Margin = new Padding(3, 4, 3, 4); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(86, 31); + buttonCancel.TabIndex = 28; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += ButtonCancel_Click; + // + // buttonRouteSave + // + buttonRouteSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; + buttonRouteSave.Location = new Point(11, 136); + buttonRouteSave.Margin = new Padding(3, 4, 3, 4); + buttonRouteSave.Name = "buttonRouteSave"; + buttonRouteSave.Size = new Size(86, 31); + buttonRouteSave.TabIndex = 27; + buttonRouteSave.Text = "Сохранить"; + buttonRouteSave.UseVisualStyleBackColor = true; + buttonRouteSave.Click += ButtonRouteSave_Click; + // + // textBoxEndPoint + // + textBoxEndPoint.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + textBoxEndPoint.Location = new Point(134, 52); + textBoxEndPoint.Margin = new Padding(3, 4, 3, 4); + textBoxEndPoint.Name = "textBoxEndPoint"; + textBoxEndPoint.Size = new Size(159, 27); + textBoxEndPoint.TabIndex = 25; + // + // label2 + // + label2.AutoSize = true; + label2.Location = new Point(11, 56); + label2.Name = "label2"; + label2.Size = new Size(119, 20); + label2.TabIndex = 24; + label2.Text = "Конечная точка"; + // + // textBoxStartPoint + // + textBoxStartPoint.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + textBoxStartPoint.Location = new Point(134, 13); + textBoxStartPoint.Margin = new Padding(3, 4, 3, 4); + textBoxStartPoint.Name = "textBoxStartPoint"; + textBoxStartPoint.Size = new Size(159, 27); + textBoxStartPoint.TabIndex = 23; + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(11, 17); + label1.Name = "label1"; + label1.Size = new Size(127, 20); + label1.TabIndex = 22; + label1.Text = "Начальная точка"; + // + // FormRoute + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(305, 179); + Controls.Add(label5); + Controls.Add(numericUpDownLength); + Controls.Add(buttonCancel); + Controls.Add(buttonRouteSave); + Controls.Add(textBoxEndPoint); + Controls.Add(label2); + Controls.Add(textBoxStartPoint); + Controls.Add(label1); + Margin = new Padding(3, 4, 3, 4); + Name = "FormRoute"; + StartPosition = FormStartPosition.CenterParent; + Text = "FormRoute"; + ((System.ComponentModel.ISupportInitialize)numericUpDownLength).EndInit(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label label5; + private NumericUpDown numericUpDownLength; + private Button buttonCancel; + private Button buttonRouteSave; + private TextBox textBoxEndPoint; + private Label label2; + private TextBox textBoxStartPoint; + private Label label1; + } +} \ No newline at end of file diff --git a/FuelAndLubricants/FuelAndLubricants/Forms/FormRoute.cs b/FuelAndLubricants/FuelAndLubricants/Forms/FormRoute.cs new file mode 100644 index 0000000..3e7b40e --- /dev/null +++ b/FuelAndLubricants/FuelAndLubricants/Forms/FormRoute.cs @@ -0,0 +1,70 @@ +using FuelAndLubricants.Entities; +using FuelAndLubricants.Repositories; + +namespace FuelAndLubricants.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 void ButtonRouteSave_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(); + + private Route CreateRoute(int id) + { + return Route.CreateEntity(id, textBoxStartPoint.Text, textBoxEndPoint.Text, (float)numericUpDownLength.Value); + } + } +} diff --git a/FuelAndLubricants/FuelAndLubricants/Forms/FormRoute.resx b/FuelAndLubricants/FuelAndLubricants/Forms/FormRoute.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/FuelAndLubricants/FuelAndLubricants/Forms/FormRoute.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/FuelAndLubricants/FuelAndLubricants/Forms/FormRoutes.Designer.cs b/FuelAndLubricants/FuelAndLubricants/Forms/FormRoutes.Designer.cs new file mode 100644 index 0000000..1a91e18 --- /dev/null +++ b/FuelAndLubricants/FuelAndLubricants/Forms/FormRoutes.Designer.cs @@ -0,0 +1,133 @@ +namespace FuelAndLubricants.Forms +{ + partial class FormRoutes + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + 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(778, 0); + panel1.Margin = new Padding(3, 4, 3, 4); + panel1.Name = "panel1"; + panel1.Size = new Size(113, 347); + panel1.TabIndex = 0; + // + // buttonDel + // + buttonDel.BackgroundImage = Properties.Resources.Удалить; + buttonDel.BackgroundImageLayout = ImageLayout.Stretch; + buttonDel.Location = new Point(14, 232); + buttonDel.Margin = new Padding(3, 4, 3, 4); + buttonDel.Name = "buttonDel"; + buttonDel.Size = new Size(86, 100); + buttonDel.TabIndex = 8; + buttonDel.UseVisualStyleBackColor = true; + buttonDel.Click += ButtonDel_Click; + // + // buttonUpd + // + buttonUpd.BackgroundImage = Properties.Resources.Редактировать; + buttonUpd.BackgroundImageLayout = ImageLayout.Stretch; + buttonUpd.Location = new Point(14, 124); + buttonUpd.Margin = new Padding(3, 4, 3, 4); + buttonUpd.Name = "buttonUpd"; + buttonUpd.Size = new Size(86, 100); + buttonUpd.TabIndex = 7; + buttonUpd.UseVisualStyleBackColor = true; + buttonUpd.Click += ButtonUpd_Click; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.Добавить; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(14, 16); + buttonAdd.Margin = new Padding(3, 4, 3, 4); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(86, 100); + buttonAdd.TabIndex = 6; + 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.Margin = new Padding(3, 4, 3, 4); + dataGridView.MultiSelect = false; + dataGridView.Name = "dataGridView"; + dataGridView.ReadOnly = true; + dataGridView.RowHeadersVisible = false; + dataGridView.RowHeadersWidth = 51; + dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridView.Size = new Size(778, 347); + dataGridView.TabIndex = 3; + // + // FormRoutes + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(891, 347); + Controls.Add(dataGridView); + Controls.Add(panel1); + Margin = new Padding(3, 4, 3, 4); + Name = "FormRoutes"; + StartPosition = FormStartPosition.CenterParent; + Text = "FormRoutes"; + Load += FormRoutes_Load; + panel1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + } + + #endregion + + private Panel panel1; + private Button buttonDel; + private Button buttonUpd; + private Button buttonAdd; + private DataGridView dataGridView; + } +} \ No newline at end of file diff --git a/FuelAndLubricants/FuelAndLubricants/Forms/FormRoutes.cs b/FuelAndLubricants/FuelAndLubricants/Forms/FormRoutes.cs new file mode 100644 index 0000000..312d332 --- /dev/null +++ b/FuelAndLubricants/FuelAndLubricants/Forms/FormRoutes.cs @@ -0,0 +1,109 @@ +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 FuelAndLubricants.Repositories; +using FuelAndLubricants.Repositories.Implementations; +using Unity; + +namespace FuelAndLubricants.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 FormRoutes_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().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(); + 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 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; + } + } +} diff --git a/FuelAndLubricants/FuelAndLubricants/Forms/FormRoutes.resx b/FuelAndLubricants/FuelAndLubricants/Forms/FormRoutes.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/FuelAndLubricants/FuelAndLubricants/Forms/FormRoutes.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/FuelAndLubricants/FuelAndLubricants/Forms/FormTrip.Designer.cs b/FuelAndLubricants/FuelAndLubricants/Forms/FormTrip.Designer.cs new file mode 100644 index 0000000..c51394e --- /dev/null +++ b/FuelAndLubricants/FuelAndLubricants/Forms/FormTrip.Designer.cs @@ -0,0 +1,289 @@ +namespace FuelAndLubricants.Forms +{ + partial class FormTrip + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + 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(); + label7 = new Label(); + groupBox = new GroupBox(); + dataGridViewRoutes = new DataGridView(); + ColumnRoute = new DataGridViewComboBoxColumn(); + ColumnEndPoint = new DataGridViewTextBoxColumn(); + ((System.ComponentModel.ISupportInitialize)numericUpDownConsumptionRate).BeginInit(); + groupBox.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridViewRoutes).BeginInit(); + SuspendLayout(); + // + // label5 + // + label5.AutoSize = true; + label5.Location = new Point(10, 133); + label5.Name = "label5"; + label5.Size = new Size(117, 20); + label5.TabIndex = 33; + label5.Text = "Расход топлива"; + // + // numericUpDownConsumptionRate + // + numericUpDownConsumptionRate.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + numericUpDownConsumptionRate.DecimalPlaces = 2; + numericUpDownConsumptionRate.Location = new Point(122, 131); + numericUpDownConsumptionRate.Margin = new Padding(3, 4, 3, 4); + 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(160, 27); + numericUpDownConsumptionRate.TabIndex = 32; + numericUpDownConsumptionRate.Value = new decimal(new int[] { 1, 0, 0, 131072 }); + // + // label4 + // + label4.AutoSize = true; + label4.Location = new Point(10, 97); + label4.Name = "label4"; + label4.Size = new Size(54, 20); + label4.TabIndex = 31; + label4.Text = "Смена"; + // + // comboBoxShift + // + comboBoxShift.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + comboBoxShift.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxShift.FormattingEnabled = true; + comboBoxShift.Location = new Point(122, 93); + comboBoxShift.Margin = new Padding(3, 4, 3, 4); + comboBoxShift.Name = "comboBoxShift"; + comboBoxShift.Size = new Size(159, 28); + comboBoxShift.TabIndex = 30; + // + // buttonCancel + // + buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonCancel.Location = new Point(196, 427); + buttonCancel.Margin = new Padding(3, 4, 3, 4); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(86, 31); + buttonCancel.TabIndex = 28; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += ButtonCancel_Click; + // + // buttonTripSave + // + buttonTripSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; + buttonTripSave.Location = new Point(9, 427); + buttonTripSave.Margin = new Padding(3, 4, 3, 4); + buttonTripSave.Name = "buttonTripSave"; + buttonTripSave.Size = new Size(86, 31); + buttonTripSave.TabIndex = 27; + buttonTripSave.Text = "Сохранить"; + buttonTripSave.UseVisualStyleBackColor = true; + buttonTripSave.Click += ButtonSave_Click; + // + // label6 + // + label6.AutoSize = true; + label6.Location = new Point(10, 24); + label6.Name = "label6"; + label6.Size = new Size(94, 20); + label6.TabIndex = 37; + label6.Text = "Дата начала"; + // + // dateTimePickerStartDate + // + dateTimePickerStartDate.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + dateTimePickerStartDate.Location = new Point(122, 16); + dateTimePickerStartDate.Margin = new Padding(3, 4, 3, 4); + dateTimePickerStartDate.Name = "dateTimePickerStartDate"; + dateTimePickerStartDate.Size = new Size(159, 27); + dateTimePickerStartDate.TabIndex = 36; + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(10, 63); + label1.Name = "label1"; + label1.Size = new Size(87, 20); + label1.TabIndex = 39; + label1.Text = "Дата конца"; + // + // dateTimePickerEndDate + // + dateTimePickerEndDate.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + dateTimePickerEndDate.Location = new Point(122, 55); + dateTimePickerEndDate.Margin = new Padding(3, 4, 3, 4); + dateTimePickerEndDate.Name = "dateTimePickerEndDate"; + dateTimePickerEndDate.Size = new Size(159, 27); + dateTimePickerEndDate.TabIndex = 38; + // + // label3 + // + label3.AutoSize = true; + label3.Location = new Point(10, 173); + label3.Name = "label3"; + label3.Size = new Size(68, 20); + label3.TabIndex = 42; + label3.Text = "Машина"; + // + // comboBoxCarID + // + comboBoxCarID.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + comboBoxCarID.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxCarID.FormattingEnabled = true; + comboBoxCarID.Location = new Point(122, 169); + comboBoxCarID.Margin = new Padding(3, 4, 3, 4); + comboBoxCarID.Name = "comboBoxCarID"; + comboBoxCarID.Size = new Size(159, 28); + comboBoxCarID.TabIndex = 41; + // + // comboBoxDriverID + // + comboBoxDriverID.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + comboBoxDriverID.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxDriverID.FormattingEnabled = true; + comboBoxDriverID.Location = new Point(122, 209); + comboBoxDriverID.Margin = new Padding(3, 4, 3, 4); + comboBoxDriverID.Name = "comboBoxDriverID"; + comboBoxDriverID.Size = new Size(159, 28); + comboBoxDriverID.TabIndex = 46; + // + // label7 + // + label7.AutoSize = true; + label7.Location = new Point(10, 213); + label7.Name = "label7"; + label7.Size = new Size(74, 20); + label7.TabIndex = 43; + label7.Text = "Водитель"; + // + // groupBox + // + groupBox.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + groupBox.Controls.Add(dataGridViewRoutes); + groupBox.Location = new Point(10, 254); + groupBox.Name = "groupBox"; + groupBox.Size = new Size(272, 166); + groupBox.TabIndex = 47; + groupBox.TabStop = false; + groupBox.Text = "Маршруты"; + // + // dataGridViewRoutes + // + dataGridViewRoutes.AllowUserToResizeColumns = false; + dataGridViewRoutes.AllowUserToResizeRows = false; + dataGridViewRoutes.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewRoutes.Columns.AddRange(new DataGridViewColumn[] { ColumnRoute, ColumnEndPoint }); + dataGridViewRoutes.Dock = DockStyle.Fill; + dataGridViewRoutes.Location = new Point(3, 23); + dataGridViewRoutes.MultiSelect = false; + dataGridViewRoutes.Name = "dataGridViewRoutes"; + dataGridViewRoutes.RowHeadersVisible = false; + dataGridViewRoutes.RowHeadersWidth = 51; + dataGridViewRoutes.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridViewRoutes.Size = new Size(266, 140); + dataGridViewRoutes.TabIndex = 0; + // + // ColumnRoute + // + ColumnRoute.HeaderText = "Маршрут"; + ColumnRoute.MinimumWidth = 6; + ColumnRoute.Name = "ColumnRoute"; + ColumnRoute.Width = 125; + // + // ColumnEndPoint + // + ColumnEndPoint.HeaderText = "Конечная точка"; + ColumnEndPoint.MinimumWidth = 6; + ColumnEndPoint.Name = "ColumnEndPoint"; + ColumnEndPoint.Width = 125; + // + // FormTrip + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(289, 468); + Controls.Add(groupBox); + Controls.Add(comboBoxDriverID); + 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); + Margin = new Padding(3, 4, 3, 4); + Name = "FormTrip"; + StartPosition = FormStartPosition.CenterParent; + Text = "FormTrip"; + ((System.ComponentModel.ISupportInitialize)numericUpDownConsumptionRate).EndInit(); + groupBox.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridViewRoutes).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 label7; + private GroupBox groupBox; + private DataGridView dataGridViewRoutes; + private DataGridViewComboBoxColumn ColumnRoute; + private DataGridViewTextBoxColumn ColumnEndPoint; + } +} \ No newline at end of file diff --git a/FuelAndLubricants/FuelAndLubricants/Forms/FormTrip.cs b/FuelAndLubricants/FuelAndLubricants/Forms/FormTrip.cs new file mode 100644 index 0000000..62913dc --- /dev/null +++ b/FuelAndLubricants/FuelAndLubricants/Forms/FormTrip.cs @@ -0,0 +1,62 @@ +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"; + + ColumnRoute.DataSource = routeRepository.ReadRoutes(); + ColumnRoute.DisplayMember = "Start_Point"; + ColumnRoute.ValueMember = "Route_ID"; + } + private void ButtonSave_Click(object sender, EventArgs e) + { + try + { + if (comboBoxCarID.SelectedIndex < 0 || comboBoxDriverID.SelectedIndex < 0 || dataGridViewRoutes.RowCount < 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!, CreateListDriversFromDataGrid())); + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void ButtonCancel_Click(object sender, EventArgs e) => Close(); + + private List CreateListDriversFromDataGrid() + { + var list = new List(); + 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; + } + + } +} diff --git a/FuelAndLubricants/FuelAndLubricants/Forms/FormTrip.resx b/FuelAndLubricants/FuelAndLubricants/Forms/FormTrip.resx new file mode 100644 index 0000000..f557e1d --- /dev/null +++ b/FuelAndLubricants/FuelAndLubricants/Forms/FormTrip.resx @@ -0,0 +1,132 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + True + + + True + + + True + + + True + + \ No newline at end of file diff --git a/FuelAndLubricants/FuelAndLubricants/Forms/FormTrips.Designer.cs b/FuelAndLubricants/FuelAndLubricants/Forms/FormTrips.Designer.cs new file mode 100644 index 0000000..3e2785d --- /dev/null +++ b/FuelAndLubricants/FuelAndLubricants/Forms/FormTrips.Designer.cs @@ -0,0 +1,103 @@ +namespace FuelAndLubricants.Forms +{ + partial class FormTrips + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + 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(787, 0); + panel1.Margin = new Padding(3, 4, 3, 4); + panel1.Name = "panel1"; + panel1.Size = new Size(112, 388); + panel1.TabIndex = 0; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.Добавить; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(13, 16); + buttonAdd.Margin = new Padding(3, 4, 3, 4); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(86, 100); + buttonAdd.TabIndex = 5; + 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.Margin = new Padding(3, 4, 3, 4); + dataGridView.MultiSelect = false; + dataGridView.Name = "dataGridView"; + dataGridView.ReadOnly = true; + dataGridView.RowHeadersVisible = false; + dataGridView.RowHeadersWidth = 51; + dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridView.Size = new Size(787, 388); + dataGridView.TabIndex = 4; + // + // FormTrips + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(899, 388); + Controls.Add(dataGridView); + Controls.Add(panel1); + Margin = new Padding(3, 4, 3, 4); + Name = "FormTrips"; + StartPosition = FormStartPosition.CenterParent; + Text = "Поездки"; + Load += FormTrips_Load; + panel1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + } + + #endregion + + private Panel panel1; + private Button buttonAdd; + private DataGridView dataGridView; + } +} \ No newline at end of file diff --git a/FuelAndLubricants/FuelAndLubricants/Forms/FormTrips.cs b/FuelAndLubricants/FuelAndLubricants/Forms/FormTrips.cs new file mode 100644 index 0000000..186da3b --- /dev/null +++ b/FuelAndLubricants/FuelAndLubricants/Forms/FormTrips.cs @@ -0,0 +1,62 @@ +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 FuelAndLubricants.Repositories; +using FuelAndLubricants.Repositories.Implementations; +using Unity; + +namespace FuelAndLubricants.Forms +{ + public partial class FormTrips : Form + { + private readonly IUnityContainer _container; + + private readonly ITripRepository _tripRepository; + + public FormTrips(IUnityContainer container, ITripRepository tripRepository) + { + InitializeComponent(); + + _container = container ?? + throw new ArgumentNullException(nameof(container)); + + _tripRepository = tripRepository ?? + throw new ArgumentNullException(nameof(tripRepository)); + } + + private void FormTrips_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().ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при добавлении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void LoadList() => dataGridView.DataSource = _tripRepository.ReadTrips(); + } +} diff --git a/FuelAndLubricants/FuelAndLubricants/Forms/FormTrips.resx b/FuelAndLubricants/FuelAndLubricants/Forms/FormTrips.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/FuelAndLubricants/FuelAndLubricants/Forms/FormTrips.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/FuelAndLubricants/FuelAndLubricants/FuelAndLubricants.csproj b/FuelAndLubricants/FuelAndLubricants/FuelAndLubricants.csproj index 663fdb8..accbdf0 100644 --- a/FuelAndLubricants/FuelAndLubricants/FuelAndLubricants.csproj +++ b/FuelAndLubricants/FuelAndLubricants/FuelAndLubricants.csproj @@ -8,4 +8,23 @@ enable + + + + + + + True + True + Resources.resx + + + + + + ResXFileCodeGenerator + Resources.Designer.cs + + + \ No newline at end of file diff --git a/FuelAndLubricants/FuelAndLubricants/Program.cs b/FuelAndLubricants/FuelAndLubricants/Program.cs index 9b4d241..5ab9ffd 100644 --- a/FuelAndLubricants/FuelAndLubricants/Program.cs +++ b/FuelAndLubricants/FuelAndLubricants/Program.cs @@ -1,3 +1,7 @@ +using FuelAndLubricants.Repositories; +using FuelAndLubricants.Repositories.Implementations; +using Unity; + namespace FuelAndLubricants { internal static class Program @@ -11,7 +15,21 @@ namespace FuelAndLubricants // 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()); + } + + private static UnityContainer CreateContainer() + { + var container = new UnityContainer(); + + container.RegisterType(); + container.RegisterType(); + container.RegisterType(); + container.RegisterType(); + container.RegisterType(); + container.RegisterType(); + + return container; } } } \ No newline at end of file diff --git a/FuelAndLubricants/FuelAndLubricants/Properties/Resources.Designer.cs b/FuelAndLubricants/FuelAndLubricants/Properties/Resources.Designer.cs new file mode 100644 index 0000000..9d3b463 --- /dev/null +++ b/FuelAndLubricants/FuelAndLubricants/Properties/Resources.Designer.cs @@ -0,0 +1,103 @@ +//------------------------------------------------------------------------------ +// +// Этот код создан программой. +// Исполняемая версия:4.0.30319.42000 +// +// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае +// повторной генерации кода. +// +//------------------------------------------------------------------------------ + +namespace FuelAndLubricants.Properties { + using System; + + + /// + /// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д. + /// + // Этот класс создан автоматически классом 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() { + } + + /// + /// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом. + /// + [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("FuelAndLubricants.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Перезаписывает свойство CurrentUICulture текущего потока для всех + /// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap ГСМ { + get { + object obj = ResourceManager.GetObject("ГСМ", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap Добавить { + get { + object obj = ResourceManager.GetObject("Добавить", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap Редактировать { + get { + object obj = ResourceManager.GetObject("Редактировать", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap Удалить { + get { + object obj = ResourceManager.GetObject("Удалить", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + } +} diff --git a/FuelAndLubricants/FuelAndLubricants/Properties/Resources.resx b/FuelAndLubricants/FuelAndLubricants/Properties/Resources.resx new file mode 100644 index 0000000..f20a0d8 --- /dev/null +++ b/FuelAndLubricants/FuelAndLubricants/Properties/Resources.resx @@ -0,0 +1,133 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + ..\Resources\ГСМ.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\Добавить.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\Редактировать.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\Удалить.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + \ No newline at end of file diff --git a/FuelAndLubricants/FuelAndLubricants/Repositories/ICarRepository.cs b/FuelAndLubricants/FuelAndLubricants/Repositories/ICarRepository.cs new file mode 100644 index 0000000..a4d9d34 --- /dev/null +++ b/FuelAndLubricants/FuelAndLubricants/Repositories/ICarRepository.cs @@ -0,0 +1,16 @@ +using FuelAndLubricants.Entities; + +namespace FuelAndLubricants.Repositories; + +public interface ICarRepository +{ + IEnumerable ReadCars(); + + Car ReadCarByID(int id); + + void CreateCar(Car car); + + void UpdateCar(Car car); + + void DeleteCar(int id); +} diff --git a/FuelAndLubricants/FuelAndLubricants/Repositories/IDriverRepository.cs b/FuelAndLubricants/FuelAndLubricants/Repositories/IDriverRepository.cs new file mode 100644 index 0000000..f0ee896 --- /dev/null +++ b/FuelAndLubricants/FuelAndLubricants/Repositories/IDriverRepository.cs @@ -0,0 +1,16 @@ +using FuelAndLubricants.Entities; + +namespace FuelAndLubricants.Repositories; + +public interface IDriverRepository +{ + IEnumerable ReadDrivers(); + + Driver ReadDriverByID(int id); + + void CreateDriver(Driver driver); + + void UpdateDriver(Driver driver); + + void DeleteDriver(int id); +} diff --git a/FuelAndLubricants/FuelAndLubricants/Repositories/IFuelRepository.cs b/FuelAndLubricants/FuelAndLubricants/Repositories/IFuelRepository.cs new file mode 100644 index 0000000..f02721c --- /dev/null +++ b/FuelAndLubricants/FuelAndLubricants/Repositories/IFuelRepository.cs @@ -0,0 +1,16 @@ +using FuelAndLubricants.Entities; + +namespace FuelAndLubricants.Repositories; + +public interface IFuelRepository +{ + IEnumerable ReadFuels(); + + Fuel_And_Lubricants ReadFuelByID(int id); + + void CreateFuel(Fuel_And_Lubricants fuel); + + void UpdateFuel(Fuel_And_Lubricants fuel); + + void DeleteFuel(int id); +} diff --git a/FuelAndLubricants/FuelAndLubricants/Repositories/IRefillRepository.cs b/FuelAndLubricants/FuelAndLubricants/Repositories/IRefillRepository.cs new file mode 100644 index 0000000..0160072 --- /dev/null +++ b/FuelAndLubricants/FuelAndLubricants/Repositories/IRefillRepository.cs @@ -0,0 +1,10 @@ +using FuelAndLubricants.Entities; + +namespace FuelAndLubricants.Repositories; + +public interface IRefillRepository +{ + IEnumerable ReadRefills(DateTime? dateFrom = null, DateTime? dateTo = null, int? fuelId = null, int? carId = null); + + void CreateRefill(Refill refill); +} diff --git a/FuelAndLubricants/FuelAndLubricants/Repositories/IRouteRepository.cs b/FuelAndLubricants/FuelAndLubricants/Repositories/IRouteRepository.cs new file mode 100644 index 0000000..7a5ee9b --- /dev/null +++ b/FuelAndLubricants/FuelAndLubricants/Repositories/IRouteRepository.cs @@ -0,0 +1,16 @@ +using FuelAndLubricants.Entities; + +namespace FuelAndLubricants.Repositories; + +public interface IRouteRepository +{ + IEnumerable ReadRoutes(); + + Route ReadRouteByID(int id); + + void CreateRoute(Route route); + + void UpdateRoute(Route route); + + void DeleteRoute(int id); +} diff --git a/FuelAndLubricants/FuelAndLubricants/Repositories/ITripRepository.cs b/FuelAndLubricants/FuelAndLubricants/Repositories/ITripRepository.cs new file mode 100644 index 0000000..6ceb297 --- /dev/null +++ b/FuelAndLubricants/FuelAndLubricants/Repositories/ITripRepository.cs @@ -0,0 +1,10 @@ +using FuelAndLubricants.Entities; + +namespace FuelAndLubricants.Repositories; + +public interface ITripRepository +{ + IEnumerable ReadTrips(DateTime? dateFrom = null, DateTime? dateTo = null, int? carId = null, int? driverId = null, int? routeId = null); + + void CreateTrip(Trip trip); +} diff --git a/FuelAndLubricants/FuelAndLubricants/Repositories/Implementations/CarRepository.cs b/FuelAndLubricants/FuelAndLubricants/Repositories/Implementations/CarRepository.cs new file mode 100644 index 0000000..5759289 --- /dev/null +++ b/FuelAndLubricants/FuelAndLubricants/Repositories/Implementations/CarRepository.cs @@ -0,0 +1,28 @@ +using FuelAndLubricants.Entities; + +namespace FuelAndLubricants.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 ReadCars() + { + return []; + } + + public void UpdateCar(Car car) + { + } +} diff --git a/FuelAndLubricants/FuelAndLubricants/Repositories/Implementations/DriverRepository.cs b/FuelAndLubricants/FuelAndLubricants/Repositories/Implementations/DriverRepository.cs new file mode 100644 index 0000000..7194bc2 --- /dev/null +++ b/FuelAndLubricants/FuelAndLubricants/Repositories/Implementations/DriverRepository.cs @@ -0,0 +1,28 @@ +using FuelAndLubricants.Entities; + +namespace FuelAndLubricants.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 ReadDrivers() + { + return []; + } + + public void UpdateDriver(Driver driver) + { + } +} diff --git a/FuelAndLubricants/FuelAndLubricants/Repositories/Implementations/FuelRepository.cs b/FuelAndLubricants/FuelAndLubricants/Repositories/Implementations/FuelRepository.cs new file mode 100644 index 0000000..54b793b --- /dev/null +++ b/FuelAndLubricants/FuelAndLubricants/Repositories/Implementations/FuelRepository.cs @@ -0,0 +1,28 @@ +using FuelAndLubricants.Entities; + +namespace FuelAndLubricants.Repositories.Implementations; + +public class FuelRepository : IFuelRepository +{ + public void CreateFuel(Fuel_And_Lubricants fuel) + { + } + + public void DeleteFuel(int id) + { + } + + public Fuel_And_Lubricants ReadFuelByID(int id) + { + return Fuel_And_Lubricants.CreateEntity(0, 0, 0, 0); + } + + public IEnumerable ReadFuels() + { + return []; + } + + public void UpdateFuel(Fuel_And_Lubricants fuel) + { + } +} diff --git a/FuelAndLubricants/FuelAndLubricants/Repositories/Implementations/RefillRepository.cs b/FuelAndLubricants/FuelAndLubricants/Repositories/Implementations/RefillRepository.cs new file mode 100644 index 0000000..719e34c --- /dev/null +++ b/FuelAndLubricants/FuelAndLubricants/Repositories/Implementations/RefillRepository.cs @@ -0,0 +1,15 @@ +using FuelAndLubricants.Entities; + +namespace FuelAndLubricants.Repositories.Implementations; + +public class RefillRepository : IRefillRepository +{ + public void CreateRefill(Refill refill) + { + } + + public IEnumerable ReadRefills(DateTime? dateFrom = null, DateTime? dateTo = null, int? fuelId = null, int? carId = null) + { + return []; + } +} diff --git a/FuelAndLubricants/FuelAndLubricants/Repositories/Implementations/RouteRepository.cs b/FuelAndLubricants/FuelAndLubricants/Repositories/Implementations/RouteRepository.cs new file mode 100644 index 0000000..cc9e08e --- /dev/null +++ b/FuelAndLubricants/FuelAndLubricants/Repositories/Implementations/RouteRepository.cs @@ -0,0 +1,28 @@ +using FuelAndLubricants.Entities; + +namespace FuelAndLubricants.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 ReadRoutes() + { + return []; + } + + public void UpdateRoute(Route route) + { + } +} diff --git a/FuelAndLubricants/FuelAndLubricants/Repositories/Implementations/TripRepository.cs b/FuelAndLubricants/FuelAndLubricants/Repositories/Implementations/TripRepository.cs new file mode 100644 index 0000000..9cd8e6f --- /dev/null +++ b/FuelAndLubricants/FuelAndLubricants/Repositories/Implementations/TripRepository.cs @@ -0,0 +1,15 @@ +using FuelAndLubricants.Entities; + +namespace FuelAndLubricants.Repositories.Implementations; + +public class TripRepository : ITripRepository +{ + public void CreateTrip(Trip trip) + { + } + + public IEnumerable ReadTrips(DateTime? dateFrom = null, DateTime? dateTo = null, int? carId = null, int? driverId = null, int? routeId = null) + { + return []; + } +} diff --git a/FuelAndLubricants/FuelAndLubricants/Resources/ГСМ.jpg b/FuelAndLubricants/FuelAndLubricants/Resources/ГСМ.jpg new file mode 100644 index 0000000..5fcd8ee Binary files /dev/null and b/FuelAndLubricants/FuelAndLubricants/Resources/ГСМ.jpg differ diff --git a/FuelAndLubricants/FuelAndLubricants/Resources/Добавить.png b/FuelAndLubricants/FuelAndLubricants/Resources/Добавить.png new file mode 100644 index 0000000..ecc20e3 Binary files /dev/null and b/FuelAndLubricants/FuelAndLubricants/Resources/Добавить.png differ diff --git a/FuelAndLubricants/FuelAndLubricants/Resources/Редактировать.png b/FuelAndLubricants/FuelAndLubricants/Resources/Редактировать.png new file mode 100644 index 0000000..53c3cf6 Binary files /dev/null and b/FuelAndLubricants/FuelAndLubricants/Resources/Редактировать.png differ diff --git a/FuelAndLubricants/FuelAndLubricants/Resources/Удалить.png b/FuelAndLubricants/FuelAndLubricants/Resources/Удалить.png new file mode 100644 index 0000000..ab02768 Binary files /dev/null and b/FuelAndLubricants/FuelAndLubricants/Resources/Удалить.png differ