diff --git a/ProjectGSM/Entities/Car.cs b/ProjectGSM/Entities/Car.cs new file mode 100644 index 0000000..d345d59 --- /dev/null +++ b/ProjectGSM/Entities/Car.cs @@ -0,0 +1,32 @@ +using ProjectGSM.Entities.Enums; +using Microsoft.VisualBasic; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectGSM.Entities; + +public class Car +{ + public int Car_ID { get; private set; } + public string Car_Mark { get; private set; } = string.Empty; + public string Car_Model { get; private set; } = string.Empty; + public Car_Type Car_Type { get; private set; } + public СategoryRights License { get; private set; } + public float Consumption_Rate { get; private set; } + + public static Car CreateEntity(int car_ID, string car_mark, string car_model, Car_Type car_type, СategoryRights license, float consumption) + { + return new Car + { + Car_ID = car_ID, + Car_Mark = car_mark ?? string.Empty, + Car_Model = car_model ?? string.Empty, + Car_Type = car_type, + License = license, + Consumption_Rate = consumption + }; + } +} diff --git a/ProjectGSM/Entities/Driver.cs b/ProjectGSM/Entities/Driver.cs new file mode 100644 index 0000000..07e9e3b --- /dev/null +++ b/ProjectGSM/Entities/Driver.cs @@ -0,0 +1,27 @@ +using ProjectGSM.Entities.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectGSM.Entities; + +public class Driver +{ + public int Driver_ID { get; private set; } + public string Firstname { get; private set; } = string.Empty; + public string Secondname { get; private set; } = string.Empty; + public СategoryRights Driver_License { get; private set; } + + public static Driver CreateEntity(int driver_ID, string firstname, string secondname, СategoryRights license) + { + return new Driver + { + Driver_ID = driver_ID, + Firstname = firstname ?? string.Empty, + Secondname = secondname ?? string.Empty, + Driver_License = license + }; + } +} diff --git a/ProjectGSM/Entities/Enums/Car_Type.cs b/ProjectGSM/Entities/Enums/Car_Type.cs new file mode 100644 index 0000000..0f3bfb1 --- /dev/null +++ b/ProjectGSM/Entities/Enums/Car_Type.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectGSM.Entities.Enums; + +public enum Car_Type +{ + None = 0, + + Passender_car = 1, + + Truck = 2, + + Bus = 3 +} \ No newline at end of file diff --git a/ProjectGSM/Entities/Enums/FuelType.cs b/ProjectGSM/Entities/Enums/FuelType.cs new file mode 100644 index 0000000..23ca081 --- /dev/null +++ b/ProjectGSM/Entities/Enums/FuelType.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectGSM.Entities.Enums; + +public enum FuelType +{ + None = 0, + + Petrol = 1, + + Diesel = 2 +} diff --git a/ProjectGSM/Entities/Enums/СategoryRights.cs b/ProjectGSM/Entities/Enums/СategoryRights.cs new file mode 100644 index 0000000..721286a --- /dev/null +++ b/ProjectGSM/Entities/Enums/СategoryRights.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectGSM.Entities.Enums; + +[Flags] +public enum СategoryRights +{ + None = 0, + + A = 1, + + B = 2, + + C = 4, + + D = 8 +} diff --git a/ProjectGSM/Entities/PetrolStation.cs b/ProjectGSM/Entities/PetrolStation.cs new file mode 100644 index 0000000..f179590 --- /dev/null +++ b/ProjectGSM/Entities/PetrolStation.cs @@ -0,0 +1,29 @@ +using Microsoft.VisualBasic.FileIO; +using ProjectGSM.Entities.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms.VisualStyles; + +namespace ProjectGSM.Entities; + +public class PetrolStation +{ + public int Fuel_ID { get; private set; } + public FuelType Fuel_Type { get; private set; } + public float Price_Per_Liter { get; private set; } + public float Amount { get; private set; } + + public static PetrolStation CreateEntity(int fuel_id, FuelType type, float price, float amount) + { + return new PetrolStation + { + Fuel_ID = fuel_id, + Fuel_Type = type, + Price_Per_Liter = price, + Amount = amount + }; + } +} diff --git a/ProjectGSM/Entities/Refill.cs b/ProjectGSM/Entities/Refill.cs new file mode 100644 index 0000000..c6a35cd --- /dev/null +++ b/ProjectGSM/Entities/Refill.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectGSM.Entities; + +public class Refill +{ + public int Refill_ID { get; private set; } + public DateTime Refill_Date { get; private set; } + public float Quantity { get; private set; } + public int Fuel_ID { get; private set; } + public int Car_ID { get; private set; } + + public static Refill CreateOperation(int refill_ID, DateTime refill_date, float quantity, int fuel_id, int car_id) + { + return new Refill + { + Refill_ID = refill_ID, + Refill_Date = refill_date, + Quantity = quantity, + Fuel_ID = fuel_id, + Car_ID = car_id + }; + } +} diff --git a/ProjectGSM/Entities/Route.cs b/ProjectGSM/Entities/Route.cs new file mode 100644 index 0000000..c241f92 --- /dev/null +++ b/ProjectGSM/Entities/Route.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectGSM.Entities; + +public class Route +{ + public int Route_ID { get; private set; } + public string Start_Point { get; private set; } = string.Empty; + public string End_Point { get; private set; } = string.Empty; + public float Route_Length { get; private set; } + + public static Route CreateEntity(int route_id, string start_point, string end_point, float length) + { + return new Route + { + Route_ID = route_id, + Start_Point = start_point ?? string.Empty, + End_Point = end_point ?? string.Empty, + Route_Length = length + }; + } +} \ No newline at end of file diff --git a/ProjectGSM/Entities/RouteSheet.cs b/ProjectGSM/Entities/RouteSheet.cs new file mode 100644 index 0000000..ab757c5 --- /dev/null +++ b/ProjectGSM/Entities/RouteSheet.cs @@ -0,0 +1,33 @@ +using ProjectGSM.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectGSM.Entities; + +public class RouteSheet +{ + public int Trip_ID { get; private set; } + public DateTime Start_Date { get; private set; } + public DateTime End_Date { get; private set; } + public float Fuel_Consumption { get; private set; } + public int Car_ID { get; private set; } + public int Driver_ID { get; private set; } + public IEnumerable Routes { get; private set; } = []; + + public static RouteSheet CreateOperation(int trip_id, DateTime start_date, DateTime end_date, float consumption, int car_id, int driver_id, IEnumerable routes) + { + return new RouteSheet + { + Trip_ID = trip_id, + Start_Date = start_date, + End_Date = end_date, + Fuel_Consumption = consumption, + Car_ID = car_id, + Driver_ID = driver_id, + Routes = routes + }; + } +} diff --git a/ProjectGSM/Form1.Designer.cs b/ProjectGSM/Form1.Designer.cs deleted file mode 100644 index 78f42e6..0000000 --- a/ProjectGSM/Form1.Designer.cs +++ /dev/null @@ -1,39 +0,0 @@ -namespace ProjectGSM -{ - 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/ProjectGSM/Form1.cs b/ProjectGSM/Form1.cs deleted file mode 100644 index 07e9ed7..0000000 --- a/ProjectGSM/Form1.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace ProjectGSM -{ - public partial class Form1 : Form - { - public Form1() - { - InitializeComponent(); - } - } -} diff --git a/ProjectGSM/FormGSM.Designer.cs b/ProjectGSM/FormGSM.Designer.cs new file mode 100644 index 0000000..3d6ffab --- /dev/null +++ b/ProjectGSM/FormGSM.Designer.cs @@ -0,0 +1,147 @@ +namespace ProjectGSM +{ + partial class FormGSM + { + /// + /// 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.ImageScalingSize = new Size(20, 20); + menuStrip.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, операцииToolStripMenuItem, отчётыToolStripMenuItem }); + menuStrip.Location = new Point(0, 0); + menuStrip.Name = "menuStrip"; + menuStrip.Size = new Size(782, 28); + menuStrip.TabIndex = 0; + menuStrip.Text = "menuStrip1"; + // + // справочникиToolStripMenuItem + // + справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { CarsToolStripMenuItem, DriversToolStripMenuItem, FuelToolStripMenuItem, RoutesToolStripMenuItem }); + справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem"; + справочникиToolStripMenuItem.Size = new Size(120, 24); + справочникиToolStripMenuItem.Text = "Справочники:"; + // + // CarsToolStripMenuItem + // + CarsToolStripMenuItem.Name = "CarsToolStripMenuItem"; + CarsToolStripMenuItem.Size = new Size(224, 26); + CarsToolStripMenuItem.Text = "Машина"; + CarsToolStripMenuItem.Click += CarsToolStripMenuItem_Click; + // + // DriversToolStripMenuItem + // + DriversToolStripMenuItem.Name = "DriversToolStripMenuItem"; + DriversToolStripMenuItem.Size = new Size(224, 26); + DriversToolStripMenuItem.Text = "Водитель"; + DriversToolStripMenuItem.Click += DriversToolStripMenuItem_Click; + // + // FuelToolStripMenuItem + // + FuelToolStripMenuItem.Name = "FuelToolStripMenuItem"; + FuelToolStripMenuItem.Size = new Size(224, 26); + FuelToolStripMenuItem.Text = "Заправка"; + FuelToolStripMenuItem.Click += FuelToolStripMenuItem_Click; + // + // RoutesToolStripMenuItem + // + RoutesToolStripMenuItem.Name = "RoutesToolStripMenuItem"; + RoutesToolStripMenuItem.Size = new Size(224, 26); + RoutesToolStripMenuItem.Text = "Маршрут"; + RoutesToolStripMenuItem.Click += RoutesToolStripMenuItem_Click; + // + // операцииToolStripMenuItem + // + операцииToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { RefillToolStripMenuItem, TripToolStripMenuItem }); + операцииToolStripMenuItem.Name = "операцииToolStripMenuItem"; + операцииToolStripMenuItem.Size = new Size(98, 24); + операцииToolStripMenuItem.Text = "Операции:"; + // + // RefillToolStripMenuItem + // + RefillToolStripMenuItem.Name = "RefillToolStripMenuItem"; + RefillToolStripMenuItem.Size = new Size(224, 26); + RefillToolStripMenuItem.Text = "Пополнение"; + RefillToolStripMenuItem.Click += RefillToolStripMenuItem_Click; + // + // TripToolStripMenuItem + // + TripToolStripMenuItem.Name = "TripToolStripMenuItem"; + TripToolStripMenuItem.Size = new Size(224, 26); + TripToolStripMenuItem.Text = "Выбор поездки"; + TripToolStripMenuItem.Click += TripToolStripMenuItem_Click; + // + // отчётыToolStripMenuItem + // + отчётыToolStripMenuItem.Name = "отчётыToolStripMenuItem"; + отчётыToolStripMenuItem.Size = new Size(73, 24); + отчётыToolStripMenuItem.Text = "Отчёты"; + // + // FormGSM + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + BackgroundImage = Properties.Resources._5332808188908660305; + BackgroundImageLayout = ImageLayout.Stretch; + ClientSize = new Size(782, 403); + Controls.Add(menuStrip); + MainMenuStrip = menuStrip; + Name = "FormGSM"; + StartPosition = FormStartPosition.CenterScreen; + Text = "Отчёт ГСМ"; + menuStrip.ResumeLayout(false); + menuStrip.PerformLayout(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private MenuStrip menuStrip; + private ToolStripMenuItem справочникиToolStripMenuItem; + private ToolStripMenuItem CarsToolStripMenuItem; + private ToolStripMenuItem DriversToolStripMenuItem; + private ToolStripMenuItem FuelToolStripMenuItem; + private ToolStripMenuItem операцииToolStripMenuItem; + private ToolStripMenuItem RefillToolStripMenuItem; + private ToolStripMenuItem TripToolStripMenuItem; + private ToolStripMenuItem отчётыToolStripMenuItem; + private ToolStripMenuItem RoutesToolStripMenuItem; + } +} diff --git a/ProjectGSM/FormGSM.cs b/ProjectGSM/FormGSM.cs new file mode 100644 index 0000000..c4756c0 --- /dev/null +++ b/ProjectGSM/FormGSM.cs @@ -0,0 +1,96 @@ +using ProjectGSM.Forms; +using Unity; + +namespace ProjectGSM +{ + public partial class FormGSM : Form + { + private readonly IUnityContainer _container; + + public FormGSM(IUnityContainer container) + { + InitializeComponent(); + _container = container ?? + throw new ArgumentNullException(nameof(container)); + + } + + private void CarsToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().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); + } + } + } +} \ No newline at end of file diff --git a/ProjectGSM/FormGSM.resx b/ProjectGSM/FormGSM.resx new file mode 100644 index 0000000..31084d5 --- /dev/null +++ b/ProjectGSM/FormGSM.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/ProjectGSM/Forms/FormCar.Designer.cs b/ProjectGSM/Forms/FormCar.Designer.cs new file mode 100644 index 0000000..95fe80b --- /dev/null +++ b/ProjectGSM/Forms/FormCar.Designer.cs @@ -0,0 +1,189 @@ +namespace ProjectGSM.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() + { + Car_Mark = new Label(); + Car_Model = new Label(); + Car_Type = new Label(); + labelСategoryRights = new Label(); + Consumption_Rate = new Label(); + textBoxCarModel = new TextBox(); + textBoxCarMark = new TextBox(); + comboBoxCarType = new ComboBox(); + checkedListBoxСategoryRights = new CheckedListBox(); + numericUpDownConsumptionRate = new NumericUpDown(); + CarSave = new Button(); + buttonCancel = new Button(); + ((System.ComponentModel.ISupportInitialize)numericUpDownConsumptionRate).BeginInit(); + SuspendLayout(); + // + // Car_Mark + // + Car_Mark.AutoSize = true; + Car_Mark.Location = new Point(24, 21); + Car_Mark.Name = "Car_Mark"; + Car_Mark.Size = new Size(121, 20); + Car_Mark.TabIndex = 0; + Car_Mark.Text = "Марка машины:"; + // + // Car_Model + // + Car_Model.AutoSize = true; + Car_Model.Location = new Point(24, 57); + Car_Model.Name = "Car_Model"; + Car_Model.Size = new Size(130, 20); + Car_Model.TabIndex = 1; + Car_Model.Text = "Модель машины:"; + // + // Car_Type + // + Car_Type.AutoSize = true; + Car_Type.Location = new Point(24, 93); + Car_Type.Name = "Car_Type"; + Car_Type.Size = new Size(102, 20); + Car_Type.TabIndex = 2; + Car_Type.Text = "Тип машины:"; + // + // labelСategoryRights + // + labelСategoryRights.AutoSize = true; + labelСategoryRights.Location = new Point(24, 130); + labelСategoryRights.Name = "labelСategoryRights"; + labelСategoryRights.Size = new Size(84, 20); + labelСategoryRights.TabIndex = 3; + labelСategoryRights.Text = "Категория:"; + // + // Consumption_Rate + // + Consumption_Rate.AutoSize = true; + Consumption_Rate.Location = new Point(24, 259); + Consumption_Rate.Name = "Consumption_Rate"; + Consumption_Rate.Size = new Size(120, 20); + Consumption_Rate.TabIndex = 4; + Consumption_Rate.Text = "Расход топлива:"; + // + // textBoxCarModel + // + textBoxCarModel.Location = new Point(172, 57); + textBoxCarModel.Name = "textBoxCarModel"; + textBoxCarModel.Size = new Size(151, 27); + textBoxCarModel.TabIndex = 5; + // + // textBoxCarMark + // + textBoxCarMark.Location = new Point(172, 21); + textBoxCarMark.Name = "textBoxCarMark"; + textBoxCarMark.Size = new Size(151, 27); + textBoxCarMark.TabIndex = 6; + // + // comboBoxCarType + // + comboBoxCarType.FormattingEnabled = true; + comboBoxCarType.Location = new Point(172, 93); + comboBoxCarType.Name = "comboBoxCarType"; + comboBoxCarType.Size = new Size(151, 28); + comboBoxCarType.TabIndex = 7; + // + // checkedListBoxСategoryRights + // + checkedListBoxСategoryRights.FormattingEnabled = true; + checkedListBoxСategoryRights.Location = new Point(172, 127); + checkedListBoxСategoryRights.Name = "checkedListBoxСategoryRights"; + checkedListBoxСategoryRights.Size = new Size(150, 114); + checkedListBoxСategoryRights.TabIndex = 8; + // + // numericUpDownConsumptionRate + // + numericUpDownConsumptionRate.DecimalPlaces = 2; + numericUpDownConsumptionRate.Location = new Point(173, 257); + numericUpDownConsumptionRate.Name = "numericUpDownConsumptionRate"; + numericUpDownConsumptionRate.Size = new Size(150, 27); + numericUpDownConsumptionRate.TabIndex = 9; + // + // CarSave + // + CarSave.Location = new Point(50, 321); + CarSave.Name = "CarSave"; + CarSave.Size = new Size(94, 29); + CarSave.TabIndex = 10; + CarSave.Text = "Сохранить"; + CarSave.UseVisualStyleBackColor = true; + CarSave.Click += CarSave_Click; + // + // buttonCancel + // + buttonCancel.Location = new Point(199, 321); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(94, 29); + buttonCancel.TabIndex = 11; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += buttonCancel_Click; + // + // FormCar + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(409, 380); + Controls.Add(buttonCancel); + Controls.Add(CarSave); + Controls.Add(numericUpDownConsumptionRate); + Controls.Add(checkedListBoxСategoryRights); + Controls.Add(comboBoxCarType); + Controls.Add(textBoxCarMark); + Controls.Add(textBoxCarModel); + Controls.Add(Consumption_Rate); + Controls.Add(labelСategoryRights); + Controls.Add(Car_Type); + Controls.Add(Car_Model); + Controls.Add(Car_Mark); + Name = "FormCar"; + StartPosition = FormStartPosition.CenterParent; + Text = "Машина"; + ((System.ComponentModel.ISupportInitialize)numericUpDownConsumptionRate).EndInit(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label Car_Mark; + private Label Car_Model; + private Label Car_Type; + private Label labelСategoryRights; + private Label Consumption_Rate; + private TextBox textBoxCarModel; + private TextBox textBoxCarMark; + private ComboBox comboBoxCarType; + private CheckedListBox checkedListBoxСategoryRights; + private NumericUpDown numericUpDownConsumptionRate; + private Button CarSave; + private Button buttonCancel; + } +} \ No newline at end of file diff --git a/ProjectGSM/Forms/FormCar.cs b/ProjectGSM/Forms/FormCar.cs new file mode 100644 index 0000000..035e8b5 --- /dev/null +++ b/ProjectGSM/Forms/FormCar.cs @@ -0,0 +1,100 @@ +using ProjectGSM.Entities.Enums; +using ProjectGSM.Entities; +using ProjectGSM.Repositories; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace ProjectGSM.Forms +{ + public partial class FormCar : Form + { + private readonly ICarRepository _carRepository; + + private int? _carId; + + public int Id + { + set + { + try + { + var car = _carRepository.ReadCarByID(value); + if (car == null) + throw new InvalidOperationException(nameof(car)); + + foreach (СategoryRights elem in Enum.GetValues(typeof(СategoryRights))) + { + if ((elem & car.License) != 0) + { + checkedListBoxСategoryRights.SetItemChecked(checkedListBoxСategoryRights.Items.IndexOf(elem), true); + } + } + + + textBoxCarMark.Text = car.Car_Mark; + textBoxCarModel.Text = car.Car_Model; + comboBoxCarType.SelectedItem = car.Car_Type; + numericUpDownConsumptionRate.Value = (decimal)car.Consumption_Rate; + + _carId = value; + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + } + } + public FormCar(ICarRepository carRepository) + { + InitializeComponent(); + _carRepository = carRepository ?? + throw new ArgumentNullException(nameof(carRepository)); + + foreach (var elem in Enum.GetValues(typeof(СategoryRights))) + checkedListBoxСategoryRights.Items.Add(elem); + + comboBoxCarType.DataSource = Enum.GetValues(typeof(Car_Type)); + } + + private Car CreateCar(int id) + { + СategoryRights categoryRights = СategoryRights.None; + foreach (var elem in checkedListBoxСategoryRights.CheckedItems) + { + categoryRights |= (СategoryRights)elem; + } + + return Car.CreateEntity(id, textBoxCarMark.Text, textBoxCarModel.Text, (Car_Type)comboBoxCarType.SelectedItem!, categoryRights, (float)numericUpDownConsumptionRate.Value); + } + + private void buttonCancel_Click(object sender, EventArgs e) => Close(); + + private void CarSave_Click(object sender, EventArgs e) + { + try + { + if (string.IsNullOrWhiteSpace(textBoxCarMark.Text) || string.IsNullOrWhiteSpace(textBoxCarModel.Text) || comboBoxCarType.SelectedIndex < 1 || checkedListBoxСategoryRights.CheckedItems.Count == 0) + throw new Exception("Имеются незаполненные поля"); + + if (_carId.HasValue) + _carRepository.UpdateCar(CreateCar(_carId.Value)); + else + _carRepository.CreateCar(CreateCar(0)); + + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } +} \ No newline at end of file diff --git a/ProjectGSM/Form1.resx b/ProjectGSM/Forms/FormCar.resx similarity index 92% rename from ProjectGSM/Form1.resx rename to ProjectGSM/Forms/FormCar.resx index 1af7de1..8b2ff64 100644 --- a/ProjectGSM/Form1.resx +++ b/ProjectGSM/Forms/FormCar.resx @@ -1,17 +1,17 @@  - diff --git a/ProjectGSM/Forms/FormCars.Designer.cs b/ProjectGSM/Forms/FormCars.Designer.cs new file mode 100644 index 0000000..5ff3f97 --- /dev/null +++ b/ProjectGSM/Forms/FormCars.Designer.cs @@ -0,0 +1,127 @@ +namespace ProjectGSM.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(641, 0); + panel1.Name = "panel1"; + panel1.Size = new Size(159, 450); + panel1.TabIndex = 0; + // + // buttonDel + // + buttonDel.BackgroundImage = Properties.Resources.минус; + buttonDel.BackgroundImageLayout = ImageLayout.Stretch; + buttonDel.Location = new Point(46, 257); + buttonDel.Name = "buttonDel"; + buttonDel.Size = new Size(79, 82); + buttonDel.TabIndex = 2; + buttonDel.UseVisualStyleBackColor = true; + buttonDel.Click += buttonDel_Click; + // + // buttonUpd + // + buttonUpd.BackgroundImage = Properties.Resources.кисть; + buttonUpd.BackgroundImageLayout = ImageLayout.Stretch; + buttonUpd.Location = new Point(46, 152); + buttonUpd.Name = "buttonUpd"; + buttonUpd.Size = new Size(79, 82); + buttonUpd.TabIndex = 1; + buttonUpd.UseVisualStyleBackColor = true; + buttonUpd.Click += buttonUpd_Click; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.Плюс; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(46, 45); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(79, 82); + buttonAdd.TabIndex = 0; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += buttonAdd_Click; + // + // dataGridView + // + dataGridView.AllowUserToAddRows = false; + dataGridView.AllowUserToDeleteRows = false; + dataGridView.AllowUserToResizeColumns = false; + dataGridView.AllowUserToResizeRows = false; + dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Dock = DockStyle.Fill; + dataGridView.Location = new Point(0, 0); + dataGridView.MultiSelect = false; + dataGridView.Name = "dataGridView"; + dataGridView.ReadOnly = true; + dataGridView.RowHeadersVisible = false; + dataGridView.RowHeadersWidth = 51; + dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridView.Size = new Size(641, 450); + dataGridView.TabIndex = 1; + // + // FormCars + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(800, 450); + Controls.Add(dataGridView); + Controls.Add(panel1); + Name = "FormCars"; + StartPosition = FormStartPosition.CenterParent; + Text = "Машины"; + Load += FormCars_Load; + panel1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + } + + #endregion + + private Panel panel1; + private Button buttonAdd; + private Button buttonDel; + private Button buttonUpd; + private DataGridView dataGridView; + } +} \ No newline at end of file diff --git a/ProjectGSM/Forms/FormCars.cs b/ProjectGSM/Forms/FormCars.cs new file mode 100644 index 0000000..13274be --- /dev/null +++ b/ProjectGSM/Forms/FormCars.cs @@ -0,0 +1,111 @@ +using ProjectGSM.Repositories; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using Unity; + +namespace ProjectGSM.Forms +{ + public partial class FormCars : Form + { + private readonly IUnityContainer _container; + + private readonly ICarRepository _carRepository; + + public FormCars(IUnityContainer container, ICarRepository carRepository) + { + InitializeComponent(); + _container = container ?? + throw new ArgumentNullException(nameof(container)); + _carRepository = carRepository ?? + throw new ArgumentNullException(nameof(carRepository)); + } + + + + private void LoadList() => dataGridView.DataSource = _carRepository.ReadCars(); + + private bool TryGetIdentifierFromSelectedRow(out int id) + { + id = 0; + if (dataGridView.SelectedRows.Count < 1) + { + MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Car_ID"].Value); + return true; + } + + + + private void buttonUpd_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromSelectedRow(out var findId)) + return; + + try + { + var form = _container.Resolve(); + form.Id = findId; + form.ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при изменении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void buttonDel_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromSelectedRow(out var findId)) + return; + + if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes) + return; + + try + { + _carRepository.DeleteCar(findId); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void FormCars_Load(object sender, EventArgs e) + { + try + { + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void buttonAdd_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } +} diff --git a/ProjectGSM/Forms/FormCars.resx b/ProjectGSM/Forms/FormCars.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/ProjectGSM/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/ProjectGSM/Forms/FormDriver.Designer.cs b/ProjectGSM/Forms/FormDriver.Designer.cs new file mode 100644 index 0000000..00f25ac --- /dev/null +++ b/ProjectGSM/Forms/FormDriver.Designer.cs @@ -0,0 +1,141 @@ +namespace ProjectGSM.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(); + label2 = new Label(); + label3 = new Label(); + buttonSave = new Button(); + buttonCancel = new Button(); + textBoxDriverSecondname = new TextBox(); + textBoxDriverFirstname = new TextBox(); + checkedListBoxСategoryRights = new CheckedListBox(); + SuspendLayout(); + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(34, 26); + label1.Name = "label1"; + label1.Size = new Size(42, 20); + label1.TabIndex = 0; + label1.Text = "Имя:"; + // + // label2 + // + label2.AutoSize = true; + label2.Location = new Point(34, 68); + label2.Name = "label2"; + label2.Size = new Size(76, 20); + label2.TabIndex = 1; + label2.Text = "Фамилия:"; + // + // label3 + // + label3.AutoSize = true; + label3.Location = new Point(34, 120); + label3.Name = "label3"; + label3.Size = new Size(122, 20); + label3.TabIndex = 2; + label3.Text = "Категория прав:"; + // + // buttonSave + // + buttonSave.Location = new Point(47, 284); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(94, 29); + buttonSave.TabIndex = 3; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += buttonSave_Click; + // + // buttonCancel + // + buttonCancel.Location = new Point(185, 284); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(94, 29); + buttonCancel.TabIndex = 4; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += buttonCancel_Click; + // + // textBoxDriverSecondname + // + textBoxDriverSecondname.Location = new Point(165, 68); + textBoxDriverSecondname.Name = "textBoxDriverSecondname"; + textBoxDriverSecondname.Size = new Size(150, 27); + textBoxDriverSecondname.TabIndex = 5; + // + // textBoxDriverFirstname + // + textBoxDriverFirstname.Location = new Point(165, 23); + textBoxDriverFirstname.Name = "textBoxDriverFirstname"; + textBoxDriverFirstname.Size = new Size(150, 27); + textBoxDriverFirstname.TabIndex = 6; + // + // checkedListBoxСategoryRights + // + checkedListBoxСategoryRights.FormattingEnabled = true; + checkedListBoxСategoryRights.Location = new Point(165, 120); + checkedListBoxСategoryRights.Name = "checkedListBoxСategoryRights"; + checkedListBoxСategoryRights.Size = new Size(150, 114); + checkedListBoxСategoryRights.TabIndex = 7; + // + // FormDriver + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(383, 350); + Controls.Add(checkedListBoxСategoryRights); + Controls.Add(textBoxDriverFirstname); + Controls.Add(textBoxDriverSecondname); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(label3); + Controls.Add(label2); + Controls.Add(label1); + Name = "FormDriver"; + StartPosition = FormStartPosition.CenterParent; + Text = "Водитель"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label label1; + private Label label2; + private Label label3; + private Button buttonSave; + private Button buttonCancel; + private TextBox textBoxDriverSecondname; + private TextBox textBoxDriverFirstname; + private CheckedListBox checkedListBoxСategoryRights; + } +} \ No newline at end of file diff --git a/ProjectGSM/Forms/FormDriver.cs b/ProjectGSM/Forms/FormDriver.cs new file mode 100644 index 0000000..9d3edaf --- /dev/null +++ b/ProjectGSM/Forms/FormDriver.cs @@ -0,0 +1,97 @@ +using ProjectGSM.Entities.Enums; +using ProjectGSM.Entities; +using ProjectGSM.Repositories; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace ProjectGSM.Forms +{ + public partial class FormDriver : Form + { + private readonly IDriverRepository _driverRepository; + + private int? _driverId; + + public int Id + { + set + { + try + { + var driver = _driverRepository.ReadDriverByID(value); + if (driver == null) + throw new InvalidOperationException(nameof(driver)); + + foreach (СategoryRights elem in Enum.GetValues(typeof(СategoryRights))) + { + if ((elem & driver.Driver_License) != 0) + { + checkedListBoxСategoryRights.SetItemChecked(checkedListBoxСategoryRights.Items.IndexOf(elem), true); + } + } + + + textBoxDriverFirstname.Text = driver.Firstname; + textBoxDriverSecondname.Text = driver.Secondname; + _driverId = value; + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + } + } + + public FormDriver(IDriverRepository driverRepository) + { + InitializeComponent(); + _driverRepository = driverRepository ?? + throw new ArgumentNullException(nameof(driverRepository)); + + foreach (var elem in Enum.GetValues(typeof(СategoryRights))) + checkedListBoxСategoryRights.Items.Add(elem); + } + + + private Driver CreateDriver(int id) + { + СategoryRights categoryRights = СategoryRights.None; + foreach (var elem in checkedListBoxСategoryRights.CheckedItems) + { + categoryRights |= (СategoryRights)elem; + } + + return Driver.CreateEntity(id, textBoxDriverFirstname.Text, textBoxDriverSecondname.Text, categoryRights); + } + + private void buttonSave_Click(object sender, EventArgs e) + { + try + { + if (string.IsNullOrWhiteSpace(textBoxDriverFirstname.Text) || string.IsNullOrWhiteSpace(textBoxDriverSecondname.Text) || checkedListBoxСategoryRights.CheckedItems.Count == 0) + throw new Exception("Имеются незаполненные поля"); + + if (_driverId.HasValue) + _driverRepository.UpdateDriver(CreateDriver(_driverId.Value)); + else + _driverRepository.CreateDriver(CreateDriver(0)); + + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void buttonCancel_Click(object sender, EventArgs e) => Close(); + } +} \ No newline at end of file diff --git a/ProjectGSM/Forms/FormDriver.resx b/ProjectGSM/Forms/FormDriver.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/ProjectGSM/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/ProjectGSM/Forms/FormDrivers.Designer.cs b/ProjectGSM/Forms/FormDrivers.Designer.cs new file mode 100644 index 0000000..1870b3f --- /dev/null +++ b/ProjectGSM/Forms/FormDrivers.Designer.cs @@ -0,0 +1,127 @@ +namespace ProjectGSM.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.Location = new Point(640, 0); + panel1.Name = "panel1"; + panel1.Size = new Size(160, 450); + panel1.TabIndex = 0; + // + // buttonDel + // + buttonDel.BackgroundImage = Properties.Resources.минус; + buttonDel.BackgroundImageLayout = ImageLayout.Stretch; + buttonDel.Location = new Point(45, 268); + buttonDel.Name = "buttonDel"; + buttonDel.Size = new Size(79, 82); + buttonDel.TabIndex = 3; + buttonDel.UseVisualStyleBackColor = true; + buttonDel.Click += buttonDel_Click; + // + // buttonUpd + // + buttonUpd.BackgroundImage = Properties.Resources.кисть; + buttonUpd.BackgroundImageLayout = ImageLayout.Stretch; + buttonUpd.Location = new Point(45, 148); + buttonUpd.Name = "buttonUpd"; + buttonUpd.Size = new Size(79, 82); + buttonUpd.TabIndex = 2; + buttonUpd.UseVisualStyleBackColor = true; + buttonUpd.Click += buttonUpd_Click; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.Плюс; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(45, 37); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(79, 82); + buttonAdd.TabIndex = 1; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += buttonAdd_Click; + // + // dataGridView + // + dataGridView.AllowUserToAddRows = false; + dataGridView.AllowUserToDeleteRows = false; + dataGridView.AllowUserToResizeColumns = false; + dataGridView.AllowUserToResizeRows = false; + dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Dock = DockStyle.Fill; + dataGridView.Location = new Point(0, 0); + dataGridView.MultiSelect = false; + dataGridView.Name = "dataGridView"; + dataGridView.ReadOnly = true; + dataGridView.RowHeadersVisible = false; + dataGridView.RowHeadersWidth = 51; + dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridView.Size = new Size(640, 450); + dataGridView.TabIndex = 2; + // + // FormDrivers + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(800, 450); + Controls.Add(dataGridView); + Controls.Add(panel1); + Name = "FormDrivers"; + StartPosition = FormStartPosition.CenterParent; + Text = "Водители"; + Load += FormDrivers_Load; + panel1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + } + + #endregion + + private Panel panel1; + private Button buttonAdd; + private Button buttonUpd; + private Button buttonDel; + private DataGridView dataGridView; + } +} \ No newline at end of file diff --git a/ProjectGSM/Forms/FormDrivers.cs b/ProjectGSM/Forms/FormDrivers.cs new file mode 100644 index 0000000..43f326d --- /dev/null +++ b/ProjectGSM/Forms/FormDrivers.cs @@ -0,0 +1,108 @@ +using ProjectGSM.Repositories; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using Unity; + +namespace ProjectGSM.Forms +{ + public partial class FormDrivers : Form + { + private readonly IUnityContainer _container; + + private readonly IDriverRepository _driverRepository; + + public FormDrivers(IUnityContainer container, IDriverRepository driverRepository) + { + InitializeComponent(); + _container = container ?? + throw new ArgumentNullException(nameof(container)); + _driverRepository = driverRepository ?? + throw new ArgumentNullException(nameof(driverRepository)); + + } + + private void LoadList() => dataGridView.DataSource = _driverRepository.ReadDrivers(); + + private bool TryGetIdentifierFromSelectedRow(out int id) + { + id = 0; + if (dataGridView.SelectedRows.Count < 1) + { + MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Driver_ID"].Value); + return true; + } + + private void buttonAdd_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().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 FormDrivers_Load(object sender, EventArgs e) + { + try + { + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } +} \ No newline at end of file diff --git a/ProjectGSM/Forms/FormDrivers.resx b/ProjectGSM/Forms/FormDrivers.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/ProjectGSM/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/ProjectGSM/Forms/FormPetrolStation.Designer.cs b/ProjectGSM/Forms/FormPetrolStation.Designer.cs new file mode 100644 index 0000000..5d880be --- /dev/null +++ b/ProjectGSM/Forms/FormPetrolStation.Designer.cs @@ -0,0 +1,147 @@ +namespace ProjectGSM.Forms +{ + partial class FormPetrolStation + { + /// + /// 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(); + label2 = new Label(); + label3 = new Label(); + comboBoxType = new ComboBox(); + numericUpDownPrice = new NumericUpDown(); + numericUpDownAmount = new NumericUpDown(); + buttonSave = new Button(); + buttonCancel = new Button(); + ((System.ComponentModel.ISupportInitialize)numericUpDownPrice).BeginInit(); + ((System.ComponentModel.ISupportInitialize)numericUpDownAmount).BeginInit(); + SuspendLayout(); + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(25, 28); + label1.Name = "label1"; + label1.Size = new Size(99, 20); + label1.TabIndex = 0; + label1.Text = "Тип топлива:"; + // + // label2 + // + label2.AutoSize = true; + label2.Location = new Point(25, 83); + label2.Name = "label2"; + label2.Size = new Size(48, 20); + label2.TabIndex = 1; + label2.Text = "Цена:"; + // + // label3 + // + label3.AutoSize = true; + label3.Location = new Point(25, 146); + label3.Name = "label3"; + label3.Size = new Size(93, 20); + label3.TabIndex = 2; + label3.Text = "Количество:"; + // + // comboBoxType + // + comboBoxType.FormattingEnabled = true; + comboBoxType.Location = new Point(156, 28); + comboBoxType.Name = "comboBoxType"; + comboBoxType.Size = new Size(151, 28); + comboBoxType.TabIndex = 3; + // + // numericUpDownPrice + // + numericUpDownPrice.DecimalPlaces = 2; + numericUpDownPrice.Location = new Point(157, 83); + numericUpDownPrice.Name = "numericUpDownPrice"; + numericUpDownPrice.Size = new Size(150, 27); + numericUpDownPrice.TabIndex = 4; + // + // numericUpDownAmount + // + numericUpDownAmount.DecimalPlaces = 2; + numericUpDownAmount.Location = new Point(157, 139); + numericUpDownAmount.Name = "numericUpDownAmount"; + numericUpDownAmount.Size = new Size(150, 27); + numericUpDownAmount.TabIndex = 5; + // + // buttonSave + // + buttonSave.Location = new Point(40, 229); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(94, 29); + buttonSave.TabIndex = 6; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += buttonSave_Click; + // + // buttonCancel + // + buttonCancel.Location = new Point(170, 229); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(94, 29); + buttonCancel.TabIndex = 7; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += buttonCancel_Click; + // + // FormPetrolStation + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(353, 331); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(numericUpDownAmount); + Controls.Add(numericUpDownPrice); + Controls.Add(comboBoxType); + Controls.Add(label3); + Controls.Add(label2); + Controls.Add(label1); + Name = "FormPetrolStation"; + StartPosition = FormStartPosition.CenterParent; + Text = "Топливо"; + ((System.ComponentModel.ISupportInitialize)numericUpDownPrice).EndInit(); + ((System.ComponentModel.ISupportInitialize)numericUpDownAmount).EndInit(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label label1; + private Label label2; + private Label label3; + private ComboBox comboBoxType; + private NumericUpDown numericUpDownPrice; + private NumericUpDown numericUpDownAmount; + private Button buttonSave; + private Button buttonCancel; + } +} \ No newline at end of file diff --git a/ProjectGSM/Forms/FormPetrolStation.cs b/ProjectGSM/Forms/FormPetrolStation.cs new file mode 100644 index 0000000..ed50dda --- /dev/null +++ b/ProjectGSM/Forms/FormPetrolStation.cs @@ -0,0 +1,81 @@ +using ProjectGSM.Entities.Enums; +using ProjectGSM.Entities; +using ProjectGSM.Repositories; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace ProjectGSM.Forms +{ + public partial class FormPetrolStation : Form + { + private readonly IPetrolStationRepository _petrolStationRepository; + + private int? _fuelId; + + public int Id + { + set + { + try + { + var fuel = _petrolStationRepository.ReadPetrolStationByID(value); + if (fuel == null) + throw new InvalidOperationException(nameof(fuel)); + + comboBoxType.SelectedItem = fuel.Fuel_Type; + numericUpDownPrice.Value = (decimal)fuel.Price_Per_Liter; + numericUpDownAmount.Value = (decimal)fuel.Amount; + + _fuelId = value; + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + } + } + public FormPetrolStation(IPetrolStationRepository petrolStationRepository) + { + InitializeComponent(); + _petrolStationRepository = petrolStationRepository ?? + throw new ArgumentNullException(nameof(petrolStationRepository)); + + comboBoxType.DataSource = Enum.GetValues(typeof(FuelType)); + } + + private PetrolStation CreateFuel(int id) + { + return PetrolStation.CreateEntity(id, (FuelType)comboBoxType.SelectedItem!, (float)numericUpDownPrice.Value, (float)numericUpDownAmount.Value); + } + + private void buttonSave_Click(object sender, EventArgs e) + { + try + { + if (comboBoxType.SelectedIndex < 1) + throw new Exception("Имеются незаполненные поля"); + + if (_fuelId.HasValue) + _petrolStationRepository.UpdatePetrolStation(CreateFuel(_fuelId.Value)); + else + _petrolStationRepository.CreatePetrolStation(CreateFuel(0)); + + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void buttonCancel_Click(object sender, EventArgs e) => Close(); + } +} \ No newline at end of file diff --git a/ProjectGSM/Forms/FormPetrolStation.resx b/ProjectGSM/Forms/FormPetrolStation.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/ProjectGSM/Forms/FormPetrolStation.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/ProjectGSM/Forms/FormPetrolStations.Designer.cs b/ProjectGSM/Forms/FormPetrolStations.Designer.cs new file mode 100644 index 0000000..fbc4236 --- /dev/null +++ b/ProjectGSM/Forms/FormPetrolStations.Designer.cs @@ -0,0 +1,127 @@ +namespace ProjectGSM.Forms +{ + partial class FormPetrolStations + { + /// + /// 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(649, 0); + panel1.Name = "panel1"; + panel1.Size = new Size(151, 450); + panel1.TabIndex = 0; + // + // buttonDel + // + buttonDel.BackgroundImage = Properties.Resources.минус; + buttonDel.BackgroundImageLayout = ImageLayout.Stretch; + buttonDel.Location = new Point(35, 289); + buttonDel.Name = "buttonDel"; + buttonDel.Size = new Size(79, 82); + buttonDel.TabIndex = 4; + buttonDel.UseVisualStyleBackColor = true; + buttonDel.Click += buttonDel_Click; + // + // buttonUpd + // + buttonUpd.BackgroundImage = Properties.Resources.кисть; + buttonUpd.BackgroundImageLayout = ImageLayout.Stretch; + buttonUpd.Location = new Point(35, 168); + buttonUpd.Name = "buttonUpd"; + buttonUpd.Size = new Size(79, 82); + buttonUpd.TabIndex = 3; + buttonUpd.UseVisualStyleBackColor = true; + buttonUpd.Click += buttonUpd_Click; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.Плюс; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(35, 53); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(79, 82); + buttonAdd.TabIndex = 2; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += buttonAdd_Click; + // + // dataGridView + // + dataGridView.AllowUserToAddRows = false; + dataGridView.AllowUserToDeleteRows = false; + dataGridView.AllowUserToResizeColumns = false; + dataGridView.AllowUserToResizeRows = false; + dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Dock = DockStyle.Fill; + dataGridView.Location = new Point(0, 0); + dataGridView.MultiSelect = false; + dataGridView.Name = "dataGridView"; + dataGridView.ReadOnly = true; + dataGridView.RowHeadersVisible = false; + dataGridView.RowHeadersWidth = 51; + dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridView.Size = new Size(649, 450); + dataGridView.TabIndex = 3; + // + // FormPetrolStations + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(800, 450); + Controls.Add(dataGridView); + Controls.Add(panel1); + Name = "FormPetrolStations"; + StartPosition = FormStartPosition.CenterParent; + Text = "Виды топлива"; + Load += FormPetrolStations_Load; + panel1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + } + + #endregion + + private Panel panel1; + private Button buttonAdd; + private Button buttonUpd; + private Button buttonDel; + private DataGridView dataGridView; + } +} \ No newline at end of file diff --git a/ProjectGSM/Forms/FormPetrolStations.cs b/ProjectGSM/Forms/FormPetrolStations.cs new file mode 100644 index 0000000..635ed2e --- /dev/null +++ b/ProjectGSM/Forms/FormPetrolStations.cs @@ -0,0 +1,108 @@ +using ProjectGSM.Repositories; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using Unity; + +namespace ProjectGSM.Forms +{ + public partial class FormPetrolStations : Form + { + private readonly IUnityContainer _container; + + private readonly IPetrolStationRepository _petrolStationRepository; + + public FormPetrolStations(IUnityContainer container, IPetrolStationRepository petrolStationRepository) + { + InitializeComponent(); + _container = container ?? + throw new ArgumentNullException(nameof(container)); + _petrolStationRepository = petrolStationRepository ?? + throw new ArgumentNullException(nameof(petrolStationRepository)); + } + + + private void LoadList() => dataGridView.DataSource = _petrolStationRepository.ReadPetrolStations(); + + private bool TryGetIdentifierFromSelectedRow(out int id) + { + id = 0; + if (dataGridView.SelectedRows.Count < 1) + { + MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Driver_ID"].Value); + return true; + } + + private void buttonAdd_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().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 + { + _petrolStationRepository.DeletePetrolStation(findId); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void FormPetrolStations_Load(object sender, EventArgs e) + { + try + { + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } +} \ No newline at end of file diff --git a/ProjectGSM/Forms/FormPetrolStations.resx b/ProjectGSM/Forms/FormPetrolStations.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/ProjectGSM/Forms/FormPetrolStations.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/ProjectGSM/Forms/FormRefill.Designer.cs b/ProjectGSM/Forms/FormRefill.Designer.cs new file mode 100644 index 0000000..23c51a8 --- /dev/null +++ b/ProjectGSM/Forms/FormRefill.Designer.cs @@ -0,0 +1,167 @@ +namespace ProjectGSM.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() + { + label1 = new Label(); + label2 = new Label(); + label3 = new Label(); + label4 = new Label(); + comboBoxFuelID = new ComboBox(); + numericUpDownQuantity = new NumericUpDown(); + dateTimePickerRefillDate = new DateTimePicker(); + comboBoxCarID = new ComboBox(); + buttonSave = new Button(); + buttonCancel = new Button(); + ((System.ComponentModel.ISupportInitialize)numericUpDownQuantity).BeginInit(); + SuspendLayout(); + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(33, 24); + label1.Name = "label1"; + label1.Size = new Size(99, 20); + label1.TabIndex = 0; + label1.Text = "Тип топлива:"; + // + // label2 + // + label2.AutoSize = true; + label2.Location = new Point(33, 89); + label2.Name = "label2"; + label2.Size = new Size(93, 20); + label2.TabIndex = 1; + label2.Text = "Количество:"; + // + // label3 + // + label3.AutoSize = true; + label3.Location = new Point(33, 142); + label3.Name = "label3"; + label3.Size = new Size(44, 20); + label3.TabIndex = 2; + label3.Text = "Дата:"; + // + // label4 + // + label4.AutoSize = true; + label4.Location = new Point(33, 198); + label4.Name = "label4"; + label4.Size = new Size(71, 20); + label4.TabIndex = 3; + label4.Text = "Машина:"; + // + // comboBoxFuelID + // + comboBoxFuelID.FormattingEnabled = true; + comboBoxFuelID.Location = new Point(162, 24); + comboBoxFuelID.Name = "comboBoxFuelID"; + comboBoxFuelID.Size = new Size(250, 28); + comboBoxFuelID.TabIndex = 4; + // + // numericUpDownQuantity + // + numericUpDownQuantity.DecimalPlaces = 2; + numericUpDownQuantity.Location = new Point(162, 89); + numericUpDownQuantity.Name = "numericUpDownQuantity"; + numericUpDownQuantity.Size = new Size(250, 27); + numericUpDownQuantity.TabIndex = 5; + // + // dateTimePickerRefillDate + // + dateTimePickerRefillDate.Location = new Point(162, 142); + dateTimePickerRefillDate.Name = "dateTimePickerRefillDate"; + dateTimePickerRefillDate.Size = new Size(250, 27); + dateTimePickerRefillDate.TabIndex = 6; + // + // comboBoxCarID + // + comboBoxCarID.FormattingEnabled = true; + comboBoxCarID.Location = new Point(162, 198); + comboBoxCarID.Name = "comboBoxCarID"; + comboBoxCarID.Size = new Size(250, 28); + comboBoxCarID.TabIndex = 7; + // + // buttonSave + // + buttonSave.Location = new Point(48, 263); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(94, 29); + buttonSave.TabIndex = 8; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += buttonSave_Click; + // + // buttonCancel + // + buttonCancel.Location = new Point(237, 263); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(94, 29); + buttonCancel.TabIndex = 9; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += buttonCancel_Click; + // + // FormRefill + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(447, 348); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(comboBoxCarID); + Controls.Add(dateTimePickerRefillDate); + Controls.Add(numericUpDownQuantity); + Controls.Add(comboBoxFuelID); + Controls.Add(label4); + Controls.Add(label3); + Controls.Add(label2); + Controls.Add(label1); + Name = "FormRefill"; + StartPosition = FormStartPosition.CenterParent; + Text = "Заправка"; + ((System.ComponentModel.ISupportInitialize)numericUpDownQuantity).EndInit(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label label1; + private Label label2; + private Label label3; + private Label label4; + private ComboBox comboBoxFuelID; + private NumericUpDown numericUpDownQuantity; + private DateTimePicker dateTimePickerRefillDate; + private ComboBox comboBoxCarID; + private Button buttonSave; + private Button buttonCancel; + } +} \ No newline at end of file diff --git a/ProjectGSM/Forms/FormRefill.cs b/ProjectGSM/Forms/FormRefill.cs new file mode 100644 index 0000000..07aec2a --- /dev/null +++ b/ProjectGSM/Forms/FormRefill.cs @@ -0,0 +1,54 @@ +using ProjectGSM.Entities; +using ProjectGSM.Repositories; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace ProjectGSM.Forms +{ + public partial class FormRefill : Form + { + private readonly IRefillRepository _refillRepository; + + public FormRefill(IRefillRepository refillRepository, IPetrolStationRepository petrolStationRepository, ICarRepository carRepository) + { + InitializeComponent(); + + _refillRepository = refillRepository ?? + throw new ArgumentNullException(nameof(refillRepository)); + + comboBoxFuelID.DataSource = petrolStationRepository.ReadPetrolStations(); + comboBoxFuelID.DisplayMember = "Fuel_Type"; + comboBoxFuelID.ValueMember = "Fuel_ID"; + + comboBoxCarID.DataSource = carRepository.ReadCars(); + comboBoxCarID.DisplayMember = "Car_Mark"; + comboBoxCarID.ValueMember = "Car_ID"; + } + + private void buttonSave_Click(object sender, EventArgs e) + { + try + { + if (comboBoxFuelID.SelectedIndex < 0 || comboBoxCarID.SelectedIndex < 0) + throw new Exception("Имеются незаполненные поля"); + + _refillRepository.CreateRefill(Refill.CreateOperation(0, dateTimePickerRefillDate.Value, (float)numericUpDownQuantity.Value, (int)comboBoxFuelID.SelectedValue!, (int)comboBoxCarID.SelectedValue!)); + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void buttonCancel_Click(object sender, EventArgs e) => Close(); + } +} \ No newline at end of file diff --git a/ProjectGSM/Forms/FormRefill.resx b/ProjectGSM/Forms/FormRefill.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/ProjectGSM/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/ProjectGSM/Forms/FormRefills.Designer.cs b/ProjectGSM/Forms/FormRefills.Designer.cs new file mode 100644 index 0000000..97262d0 --- /dev/null +++ b/ProjectGSM/Forms/FormRefills.Designer.cs @@ -0,0 +1,99 @@ +namespace ProjectGSM.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(646, 0); + panel1.Name = "panel1"; + panel1.Size = new Size(154, 450); + panel1.TabIndex = 0; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.Плюс; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(32, 50); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(79, 82); + buttonAdd.TabIndex = 2; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += buttonAdd_Click; + // + // dataGridView + // + dataGridView.AllowUserToAddRows = false; + dataGridView.AllowUserToDeleteRows = false; + dataGridView.AllowUserToResizeColumns = false; + dataGridView.AllowUserToResizeRows = false; + dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Dock = DockStyle.Fill; + dataGridView.Location = new Point(0, 0); + dataGridView.MultiSelect = false; + dataGridView.Name = "dataGridView"; + dataGridView.ReadOnly = true; + dataGridView.RowHeadersVisible = false; + dataGridView.RowHeadersWidth = 51; + dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridView.Size = new Size(646, 450); + dataGridView.TabIndex = 3; + // + // FormRefills + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(800, 450); + Controls.Add(dataGridView); + Controls.Add(panel1); + Name = "FormRefills"; + StartPosition = FormStartPosition.CenterParent; + Text = "Заправки"; + Load += FormRefills_Load; + panel1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + } + + #endregion + + private Panel panel1; + private Button buttonAdd; + private DataGridView dataGridView; + } +} \ No newline at end of file diff --git a/ProjectGSM/Forms/FormRefills.cs b/ProjectGSM/Forms/FormRefills.cs new file mode 100644 index 0000000..e7a555a --- /dev/null +++ b/ProjectGSM/Forms/FormRefills.cs @@ -0,0 +1,62 @@ +using ProjectGSM.Repositories; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using Unity; + +namespace ProjectGSM.Forms +{ + public partial class FormRefills : Form + { + private readonly IUnityContainer _container; + + private readonly IRefillRepository _refillRepository; + + public FormRefills(IUnityContainer container, IRefillRepository refillRepository) + { + InitializeComponent(); + + _container = container ?? + throw new ArgumentNullException(nameof(container)); + + _refillRepository = refillRepository ?? + throw new ArgumentNullException(nameof(refillRepository)); + } + + + private void LoadList() => dataGridView.DataSource = _refillRepository.ReadRefills(); + + private void buttonAdd_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при добавлении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void FormRefills_Load(object sender, EventArgs e) + { + try + { + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при загрузке", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } +} \ No newline at end of file diff --git a/ProjectGSM/Forms/FormRefills.resx b/ProjectGSM/Forms/FormRefills.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/ProjectGSM/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/ProjectGSM/Forms/FormRoute.Designer.cs b/ProjectGSM/Forms/FormRoute.Designer.cs new file mode 100644 index 0000000..9604551 --- /dev/null +++ b/ProjectGSM/Forms/FormRoute.Designer.cs @@ -0,0 +1,143 @@ +namespace ProjectGSM.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() + { + label1 = new Label(); + label2 = new Label(); + label3 = new Label(); + numericUpDownLength = new NumericUpDown(); + textBoxEndPoint = new TextBox(); + textBoxStartPoint = new TextBox(); + buttonSave = new Button(); + buttonCancel = new Button(); + ((System.ComponentModel.ISupportInitialize)numericUpDownLength).BeginInit(); + SuspendLayout(); + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(24, 24); + label1.Name = "label1"; + label1.Size = new Size(64, 20); + label1.TabIndex = 0; + label1.Text = "Начало:"; + // + // label2 + // + label2.AutoSize = true; + label2.Location = new Point(24, 73); + label2.Name = "label2"; + label2.Size = new Size(56, 20); + label2.TabIndex = 1; + label2.Text = "Конец:"; + // + // label3 + // + label3.AutoSize = true; + label3.Location = new Point(24, 132); + label3.Name = "label3"; + label3.Size = new Size(139, 20); + label3.TabIndex = 2; + label3.Text = "Длинна маршрута:"; + // + // numericUpDownLength + // + numericUpDownLength.DecimalPlaces = 2; + numericUpDownLength.Location = new Point(171, 132); + numericUpDownLength.Name = "numericUpDownLength"; + numericUpDownLength.Size = new Size(150, 27); + numericUpDownLength.TabIndex = 3; + // + // textBoxEndPoint + // + textBoxEndPoint.Location = new Point(171, 73); + textBoxEndPoint.Name = "textBoxEndPoint"; + textBoxEndPoint.Size = new Size(150, 27); + textBoxEndPoint.TabIndex = 4; + // + // textBoxStartPoint + // + textBoxStartPoint.Location = new Point(171, 24); + textBoxStartPoint.Name = "textBoxStartPoint"; + textBoxStartPoint.Size = new Size(150, 27); + textBoxStartPoint.TabIndex = 5; + // + // buttonSave + // + buttonSave.Location = new Point(24, 221); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(94, 29); + buttonSave.TabIndex = 6; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += buttonSave_Click; + // + // buttonCancel + // + buttonCancel.Location = new Point(158, 221); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(94, 29); + buttonCancel.TabIndex = 7; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += buttonCancel_Click; + // + // FormRoute + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(368, 305); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(textBoxStartPoint); + Controls.Add(textBoxEndPoint); + Controls.Add(numericUpDownLength); + Controls.Add(label3); + Controls.Add(label2); + Controls.Add(label1); + Name = "FormRoute"; + StartPosition = FormStartPosition.CenterParent; + Text = "Маршрут"; + ((System.ComponentModel.ISupportInitialize)numericUpDownLength).EndInit(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label label1; + private Label label2; + private Label label3; + private NumericUpDown numericUpDownLength; + private TextBox textBoxEndPoint; + private TextBox textBoxStartPoint; + private Button buttonSave; + private Button buttonCancel; + } +} \ No newline at end of file diff --git a/ProjectGSM/Forms/FormRoute.cs b/ProjectGSM/Forms/FormRoute.cs new file mode 100644 index 0000000..d4cf700 --- /dev/null +++ b/ProjectGSM/Forms/FormRoute.cs @@ -0,0 +1,79 @@ +using ProjectGSM.Entities; +using ProjectGSM.Repositories; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace ProjectGSM.Forms +{ + public partial class FormRoute : Form + { + private readonly IRouteRepository _routeRepository; + + private int? _routeId; + + public int Id + { + set + { + try + { + var route = _routeRepository.ReadRouteByID(value); + if (route == null) + throw new InvalidOperationException(nameof(route)); + + textBoxStartPoint.Text = route.Start_Point; + textBoxEndPoint.Text = route.End_Point; + numericUpDownLength.Value = (decimal)route.Route_Length; + + _routeId = value; + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + } + } + + public FormRoute(IRouteRepository routeRepository) + { + InitializeComponent(); + _routeRepository = routeRepository ?? + throw new ArgumentNullException(nameof(routeRepository)); + } + + private Route CreateRoute(int id) + { + return Route.CreateEntity(id, textBoxStartPoint.Text, textBoxEndPoint.Text, (float)numericUpDownLength.Value); + } + + private void buttonSave_Click(object sender, EventArgs e) + { + try + { + if (string.IsNullOrWhiteSpace(textBoxStartPoint.Text) || string.IsNullOrWhiteSpace(textBoxEndPoint.Text)) + throw new Exception("Имеются незаполненные поля"); + + if (_routeId.HasValue) + _routeRepository.UpdateRoute(CreateRoute(_routeId.Value)); + else + _routeRepository.CreateRoute(CreateRoute(0)); + + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void buttonCancel_Click(object sender, EventArgs e) => Close(); + } +} diff --git a/ProjectGSM/Forms/FormRoute.resx b/ProjectGSM/Forms/FormRoute.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/ProjectGSM/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/ProjectGSM/Forms/FormRouteSheet.Designer.cs b/ProjectGSM/Forms/FormRouteSheet.Designer.cs new file mode 100644 index 0000000..75d494a --- /dev/null +++ b/ProjectGSM/Forms/FormRouteSheet.Designer.cs @@ -0,0 +1,238 @@ +namespace ProjectGSM.Forms +{ + partial class FormRouteSheet + { + /// + /// 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(); + label2 = new Label(); + label3 = new Label(); + label4 = new Label(); + label5 = new Label(); + buttonSave = new Button(); + buttonCancel = new Button(); + dateTimePickerStartDate = new DateTimePicker(); + dateTimePickerEndDate = new DateTimePicker(); + numericUpDownConsumptionRate = new NumericUpDown(); + comboBoxDriverID = new ComboBox(); + comboBoxCarID = new ComboBox(); + groupBox1 = new GroupBox(); + dataGridViewRoutes = new DataGridView(); + ColumnRoute = new DataGridViewComboBoxColumn(); + ColumnEndPoint = new DataGridViewTextBoxColumn(); + ((System.ComponentModel.ISupportInitialize)numericUpDownConsumptionRate).BeginInit(); + groupBox1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridViewRoutes).BeginInit(); + SuspendLayout(); + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(24, 22); + label1.Name = "label1"; + label1.Size = new Size(125, 20); + label1.TabIndex = 0; + label1.Text = "Начало поездки:"; + // + // label2 + // + label2.AutoSize = true; + label2.Location = new Point(24, 66); + label2.Name = "label2"; + label2.Size = new Size(117, 20); + label2.TabIndex = 1; + label2.Text = "Конец поездки:"; + // + // label3 + // + label3.AutoSize = true; + label3.Location = new Point(24, 116); + label3.Name = "label3"; + label3.Size = new Size(120, 20); + label3.TabIndex = 2; + label3.Text = "Расход топлива:"; + // + // label4 + // + label4.AutoSize = true; + label4.Location = new Point(24, 169); + label4.Name = "label4"; + label4.Size = new Size(77, 20); + label4.TabIndex = 3; + label4.Text = "Водитель:"; + // + // label5 + // + label5.AutoSize = true; + label5.Location = new Point(24, 219); + label5.Name = "label5"; + label5.Size = new Size(71, 20); + label5.TabIndex = 4; + label5.Text = "Машина:"; + // + // buttonSave + // + buttonSave.Location = new Point(73, 426); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(94, 29); + buttonSave.TabIndex = 5; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += buttonSave_Click; + // + // buttonCancel + // + buttonCancel.Location = new Point(236, 426); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(94, 29); + buttonCancel.TabIndex = 6; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += buttonCancel_Click; + // + // dateTimePickerStartDate + // + dateTimePickerStartDate.Location = new Point(181, 22); + dateTimePickerStartDate.Name = "dateTimePickerStartDate"; + dateTimePickerStartDate.Size = new Size(250, 27); + dateTimePickerStartDate.TabIndex = 7; + // + // dateTimePickerEndDate + // + dateTimePickerEndDate.Location = new Point(181, 66); + dateTimePickerEndDate.Name = "dateTimePickerEndDate"; + dateTimePickerEndDate.Size = new Size(250, 27); + dateTimePickerEndDate.TabIndex = 8; + // + // numericUpDownConsumptionRate + // + numericUpDownConsumptionRate.DecimalPlaces = 2; + numericUpDownConsumptionRate.Location = new Point(181, 109); + numericUpDownConsumptionRate.Name = "numericUpDownConsumptionRate"; + numericUpDownConsumptionRate.Size = new Size(250, 27); + numericUpDownConsumptionRate.TabIndex = 9; + // + // comboBoxDriverID + // + comboBoxDriverID.FormattingEnabled = true; + comboBoxDriverID.Location = new Point(181, 161); + comboBoxDriverID.Name = "comboBoxDriverID"; + comboBoxDriverID.Size = new Size(250, 28); + comboBoxDriverID.TabIndex = 10; + // + // comboBoxCarID + // + comboBoxCarID.FormattingEnabled = true; + comboBoxCarID.Location = new Point(181, 211); + comboBoxCarID.Name = "comboBoxCarID"; + comboBoxCarID.Size = new Size(250, 28); + comboBoxCarID.TabIndex = 11; + // + // groupBox1 + // + groupBox1.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; + groupBox1.Controls.Add(dataGridViewRoutes); + groupBox1.Location = new Point(80, 245); + groupBox1.Name = "groupBox1"; + groupBox1.Size = new Size(310, 160); + groupBox1.TabIndex = 12; + groupBox1.TabStop = false; + groupBox1.Text = "Маршрут"; + // + // dataGridViewRoutes + // + dataGridViewRoutes.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewRoutes.Columns.AddRange(new DataGridViewColumn[] { ColumnRoute, ColumnEndPoint }); + dataGridViewRoutes.Dock = DockStyle.Fill; + dataGridViewRoutes.Location = new Point(3, 23); + dataGridViewRoutes.Name = "dataGridViewRoutes"; + dataGridViewRoutes.RowHeadersWidth = 51; + dataGridViewRoutes.Size = new Size(304, 134); + dataGridViewRoutes.TabIndex = 13; + // + // ColumnRoute + // + ColumnRoute.HeaderText = "Начало маршрута"; + ColumnRoute.MinimumWidth = 6; + ColumnRoute.Name = "ColumnRoute"; + ColumnRoute.Width = 125; + // + // ColumnEndPoint + // + ColumnEndPoint.HeaderText = "Конечная точка"; + ColumnEndPoint.MinimumWidth = 6; + ColumnEndPoint.Name = "ColumnEndPoint"; + ColumnEndPoint.Width = 125; + // + // FormRouteSheet + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(467, 487); + Controls.Add(groupBox1); + Controls.Add(comboBoxCarID); + Controls.Add(comboBoxDriverID); + Controls.Add(numericUpDownConsumptionRate); + Controls.Add(dateTimePickerEndDate); + Controls.Add(dateTimePickerStartDate); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(label5); + Controls.Add(label4); + Controls.Add(label3); + Controls.Add(label2); + Controls.Add(label1); + Name = "FormRouteSheet"; + StartPosition = FormStartPosition.CenterParent; + Text = "Маршрутный лист"; + ((System.ComponentModel.ISupportInitialize)numericUpDownConsumptionRate).EndInit(); + groupBox1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridViewRoutes).EndInit(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label label1; + private Label label2; + private Label label3; + private Label label4; + private Label label5; + private Button buttonSave; + private Button buttonCancel; + private DateTimePicker dateTimePickerStartDate; + private DateTimePicker dateTimePickerEndDate; + private NumericUpDown numericUpDownConsumptionRate; + private ComboBox comboBoxDriverID; + private ComboBox comboBoxCarID; + private GroupBox groupBox1; + private DataGridView dataGridViewRoutes; + private DataGridViewComboBoxColumn ColumnRoute; + private DataGridViewTextBoxColumn ColumnEndPoint; + } +} \ No newline at end of file diff --git a/ProjectGSM/Forms/FormRouteSheet.cs b/ProjectGSM/Forms/FormRouteSheet.cs new file mode 100644 index 0000000..a86aa42 --- /dev/null +++ b/ProjectGSM/Forms/FormRouteSheet.cs @@ -0,0 +1,71 @@ +using ProjectGSM.Entities; +using ProjectGSM.Repositories; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace ProjectGSM.Forms +{ + public partial class FormRouteSheet : Form + { + private readonly IRouteSheetRepository _routeSheetRepository; + + public FormRouteSheet(IRouteSheetRepository routeSheetRepository, ICarRepository carRepository, IDriverRepository driverRepository, IRouteRepository routeRepository) + { + InitializeComponent(); + + _routeSheetRepository = routeSheetRepository ?? + throw new ArgumentNullException(nameof(routeSheetRepository)); + + comboBoxCarID.DataSource = routeSheetRepository.ReadTrips(); + comboBoxCarID.DisplayMember = "Car_Mark"; + comboBoxCarID.ValueMember = "Car_ID"; + + comboBoxDriverID.DataSource = routeSheetRepository.ReadTrips(); + comboBoxDriverID.DisplayMember = "Firstname"; + comboBoxDriverID.ValueMember = "Driver_ID"; + + ColumnRoute.DataSource = routeRepository.ReadRoutes(); + ColumnRoute.DisplayMember = "Start_Point"; + ColumnRoute.ValueMember = "Route_ID"; + } + + private List 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; + } + + private void buttonSave_Click(object sender, EventArgs e) + { + try + { + if (comboBoxCarID.SelectedIndex < 0 || comboBoxDriverID.SelectedIndex < 0 || dataGridViewRoutes.RowCount < 0) + throw new Exception("Имеются незаполненные поля"); + + _routeSheetRepository.CreateTrip(RouteSheet.CreateOperation(0, dateTimePickerStartDate.Value, dateTimePickerEndDate.Value, (float)numericUpDownConsumptionRate.Value, (int)comboBoxCarID.SelectedValue!, (int)comboBoxDriverID.SelectedValue!, CreateListDriversFromDataGrid())); + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void buttonCancel_Click(object sender, EventArgs e) => Close(); + } +} \ No newline at end of file diff --git a/ProjectGSM/Forms/FormRouteSheet.resx b/ProjectGSM/Forms/FormRouteSheet.resx new file mode 100644 index 0000000..3d683f0 --- /dev/null +++ b/ProjectGSM/Forms/FormRouteSheet.resx @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + \ No newline at end of file diff --git a/ProjectGSM/Forms/FormRouteSheets.Designer.cs b/ProjectGSM/Forms/FormRouteSheets.Designer.cs new file mode 100644 index 0000000..48d2f4e --- /dev/null +++ b/ProjectGSM/Forms/FormRouteSheets.Designer.cs @@ -0,0 +1,99 @@ +namespace ProjectGSM.Forms +{ + partial class FormRouteSheets + { + /// + /// 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(641, 0); + panel1.Name = "panel1"; + panel1.Size = new Size(159, 450); + panel1.TabIndex = 0; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.Плюс; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(38, 64); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(79, 82); + buttonAdd.TabIndex = 2; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += buttonAdd_Click; + // + // dataGridView + // + dataGridView.AllowUserToAddRows = false; + dataGridView.AllowUserToDeleteRows = false; + dataGridView.AllowUserToResizeColumns = false; + dataGridView.AllowUserToResizeRows = false; + dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Dock = DockStyle.Fill; + dataGridView.Location = new Point(0, 0); + dataGridView.MultiSelect = false; + dataGridView.Name = "dataGridView"; + dataGridView.ReadOnly = true; + dataGridView.RowHeadersVisible = false; + dataGridView.RowHeadersWidth = 51; + dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridView.Size = new Size(641, 450); + dataGridView.TabIndex = 3; + // + // FormRouteSheets + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(800, 450); + Controls.Add(dataGridView); + Controls.Add(panel1); + Name = "FormRouteSheets"; + StartPosition = FormStartPosition.CenterParent; + Text = "Маршрутные листы"; + Load += FormRouteSheets_Load; + panel1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + } + + #endregion + + private Panel panel1; + private Button buttonAdd; + private DataGridView dataGridView; + } +} \ No newline at end of file diff --git a/ProjectGSM/Forms/FormRouteSheets.cs b/ProjectGSM/Forms/FormRouteSheets.cs new file mode 100644 index 0000000..190ac92 --- /dev/null +++ b/ProjectGSM/Forms/FormRouteSheets.cs @@ -0,0 +1,61 @@ +using ProjectGSM.Repositories; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using Unity; + +namespace ProjectGSM.Forms +{ + public partial class FormRouteSheets : Form + { + private readonly IUnityContainer _container; + + private readonly IRouteSheetRepository _routeSheetRepository; + + public FormRouteSheets(IUnityContainer container, IRouteSheetRepository routeSheetRepository) + { + InitializeComponent(); + + _container = container ?? + throw new ArgumentNullException(nameof(container)); + + _routeSheetRepository = routeSheetRepository ?? + throw new ArgumentNullException(nameof(routeSheetRepository)); + } + + private void LoadList() => dataGridView.DataSource = _routeSheetRepository.ReadTrips(); + + private void buttonAdd_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при добавлении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void FormRouteSheets_Load(object sender, EventArgs e) + { + try + { + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при загрузке", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } +} \ No newline at end of file diff --git a/ProjectGSM/Forms/FormRouteSheets.resx b/ProjectGSM/Forms/FormRouteSheets.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/ProjectGSM/Forms/FormRouteSheets.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/ProjectGSM/Forms/FormRoutes.Designer.cs b/ProjectGSM/Forms/FormRoutes.Designer.cs new file mode 100644 index 0000000..69c4161 --- /dev/null +++ b/ProjectGSM/Forms/FormRoutes.Designer.cs @@ -0,0 +1,127 @@ +namespace ProjectGSM.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(634, 0); + panel1.Name = "panel1"; + panel1.Size = new Size(166, 450); + panel1.TabIndex = 0; + // + // buttonDel + // + buttonDel.BackgroundImage = Properties.Resources.минус; + buttonDel.BackgroundImageLayout = ImageLayout.Stretch; + buttonDel.Location = new Point(45, 291); + buttonDel.Name = "buttonDel"; + buttonDel.Size = new Size(79, 82); + buttonDel.TabIndex = 4; + buttonDel.UseVisualStyleBackColor = true; + buttonDel.Click += buttonDel_Click; + // + // buttonUpd + // + buttonUpd.BackgroundImage = Properties.Resources.кисть; + buttonUpd.BackgroundImageLayout = ImageLayout.Stretch; + buttonUpd.Location = new Point(45, 171); + buttonUpd.Name = "buttonUpd"; + buttonUpd.Size = new Size(79, 82); + buttonUpd.TabIndex = 3; + buttonUpd.UseVisualStyleBackColor = true; + buttonUpd.Click += buttonUpd_Click; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.Плюс; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(45, 52); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(79, 82); + buttonAdd.TabIndex = 2; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += buttonAdd_Click; + // + // dataGridView + // + dataGridView.AllowUserToAddRows = false; + dataGridView.AllowUserToDeleteRows = false; + dataGridView.AllowUserToResizeColumns = false; + dataGridView.AllowUserToResizeRows = false; + dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Dock = DockStyle.Fill; + dataGridView.Location = new Point(0, 0); + dataGridView.MultiSelect = false; + dataGridView.Name = "dataGridView"; + dataGridView.ReadOnly = true; + dataGridView.RowHeadersVisible = false; + dataGridView.RowHeadersWidth = 51; + dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridView.Size = new Size(634, 450); + dataGridView.TabIndex = 3; + // + // FormRoutes + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(800, 450); + Controls.Add(dataGridView); + Controls.Add(panel1); + Name = "FormRoutes"; + StartPosition = FormStartPosition.CenterParent; + Text = "Маршруты"; + Load += FormRoutes_Load; + panel1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + } + + #endregion + + private Panel panel1; + private Button buttonAdd; + private Button buttonUpd; + private Button buttonDel; + private DataGridView dataGridView; + } +} \ No newline at end of file diff --git a/ProjectGSM/Forms/FormRoutes.cs b/ProjectGSM/Forms/FormRoutes.cs new file mode 100644 index 0000000..d8868c3 --- /dev/null +++ b/ProjectGSM/Forms/FormRoutes.cs @@ -0,0 +1,106 @@ +using ProjectGSM.Repositories; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using Unity; + +namespace ProjectGSM.Forms +{ + public partial class FormRoutes : Form + { + private readonly IUnityContainer _container; + + private readonly IRouteRepository _routeRepository; + public FormRoutes(IUnityContainer container, IRouteRepository routeRepository) + { + InitializeComponent(); + _container = container ?? + throw new ArgumentNullException(nameof(container)); + _routeRepository = routeRepository ?? + throw new ArgumentNullException(nameof(routeRepository)); + } + + private void LoadList() => dataGridView.DataSource = _routeRepository.ReadRoutes(); + + private bool TryGetIdentifierFromSelectedRow(out int id) + { + id = 0; + if (dataGridView.SelectedRows.Count < 1) + { + MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Route_ID"].Value); + return true; + } + + private void buttonAdd_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().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 FormRoutes_Load(object sender, EventArgs e) + { + try + { + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } +} \ No newline at end of file diff --git a/ProjectGSM/Forms/FormRoutes.resx b/ProjectGSM/Forms/FormRoutes.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/ProjectGSM/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/ProjectGSM/Program.cs b/ProjectGSM/Program.cs index cea8648..c3e2ca5 100644 --- a/ProjectGSM/Program.cs +++ b/ProjectGSM/Program.cs @@ -1,3 +1,7 @@ +using ProjectGSM.Repositories; +using ProjectGSM.Repositories.Implementations; +using Unity; + namespace ProjectGSM { internal static class Program @@ -11,7 +15,19 @@ namespace ProjectGSM // To customize application configuration such as set high DPI settings or default font, // see https://aka.ms/applicationconfiguration. ApplicationConfiguration.Initialize(); - Application.Run(new Form1()); + Application.Run(CreateContainer().Resolve()); } + private static IUnityContainer 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/ProjectGSM/ProjectGSM.csproj b/ProjectGSM/ProjectGSM.csproj index 663fdb8..accbdf0 100644 --- a/ProjectGSM/ProjectGSM.csproj +++ b/ProjectGSM/ProjectGSM.csproj @@ -8,4 +8,23 @@ enable + + + + + + + True + True + Resources.resx + + + + + + ResXFileCodeGenerator + Resources.Designer.cs + + + \ No newline at end of file diff --git a/ProjectGSM/Properties/Resources.Designer.cs b/ProjectGSM/Properties/Resources.Designer.cs new file mode 100644 index 0000000..6adceb5 --- /dev/null +++ b/ProjectGSM/Properties/Resources.Designer.cs @@ -0,0 +1,134 @@ +//------------------------------------------------------------------------------ +// +// Этот код создан программой. +// Исполняемая версия:4.0.30319.42000 +// +// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае +// повторной генерации кода. +// +//------------------------------------------------------------------------------ + +namespace ProjectGSM.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("ProjectGSM.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 _5332808188908660305 { + get { + object obj = ResourceManager.GetObject("5332808188908660305", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap b92558ff3f28ceedac1c70e9435a9483 { + get { + object obj = ResourceManager.GetObject("b92558ff3f28ceedac1c70e9435a9483", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap b92558ff3f28ceedac1c70e9435a94831 { + get { + object obj = ResourceManager.GetObject("b92558ff3f28ceedac1c70e9435a94831", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap kisspng_computer_icons_meno_plus_and_minus_signs_symbol_5b1084ada4b796_8808036715278091976747 { + get { + object obj = ResourceManager.GetObject("kisspng-computer-icons-meno-plus-and-minus-signs-symbol-5b1084ada4b796.8808036715" + + "278091976747", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа 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/ProjectGSM/Properties/Resources.resx b/ProjectGSM/Properties/Resources.resx new file mode 100644 index 0000000..a82604b --- /dev/null +++ b/ProjectGSM/Properties/Resources.resx @@ -0,0 +1,142 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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\5332808188908660305.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\b92558ff3f28ceedac1c70e9435a9483.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\кисть.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\kisspng-computer-icons-meno-plus-and-minus-signs-symbol-5b1084ada4b796.8808036715278091976747.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\b92558ff3f28ceedac1c70e9435a94831.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\минус.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + \ No newline at end of file diff --git a/ProjectGSM/Repositories/ICarRepository.cs b/ProjectGSM/Repositories/ICarRepository.cs new file mode 100644 index 0000000..011c5ea --- /dev/null +++ b/ProjectGSM/Repositories/ICarRepository.cs @@ -0,0 +1,21 @@ +using ProjectGSM.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectGSM.Repositories; + +public interface ICarRepository +{ + IEnumerable ReadCars(); + + Car ReadCarByID(int id); + + void CreateCar(Car car); + + void UpdateCar(Car car); + + void DeleteCar(int id); +} diff --git a/ProjectGSM/Repositories/IDriverRepository.cs b/ProjectGSM/Repositories/IDriverRepository.cs new file mode 100644 index 0000000..6aa73e6 --- /dev/null +++ b/ProjectGSM/Repositories/IDriverRepository.cs @@ -0,0 +1,21 @@ +using ProjectGSM.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectGSM.Repositories; + +public interface IDriverRepository +{ + IEnumerable ReadDrivers(); + + Driver ReadDriverByID(int id); + + void CreateDriver(Driver driver); + + void UpdateDriver(Driver driver); + + void DeleteDriver(int id); +} diff --git a/ProjectGSM/Repositories/IPetrolStationRepository.cs b/ProjectGSM/Repositories/IPetrolStationRepository.cs new file mode 100644 index 0000000..5787680 --- /dev/null +++ b/ProjectGSM/Repositories/IPetrolStationRepository.cs @@ -0,0 +1,21 @@ +using ProjectGSM.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectGSM.Repositories; + +public interface IPetrolStationRepository +{ + IEnumerable ReadPetrolStations(); + + PetrolStation ReadPetrolStationByID(int id); + + void CreatePetrolStation(PetrolStation petrolStations); + + void UpdatePetrolStation(PetrolStation petrolStations); + + void DeletePetrolStation(int id); +} diff --git a/ProjectGSM/Repositories/IRefillRepository.cs b/ProjectGSM/Repositories/IRefillRepository.cs new file mode 100644 index 0000000..df305bb --- /dev/null +++ b/ProjectGSM/Repositories/IRefillRepository.cs @@ -0,0 +1,15 @@ +using ProjectGSM.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectGSM.Repositories; + +public interface IRefillRepository +{ + IEnumerable ReadRefills(DateTime? dateFrom = null, DateTime? dateTo = null, int? fuelId = null, int? carId = null); + + void CreateRefill(Refill refill); +} diff --git a/ProjectGSM/Repositories/IRouteRepository.cs b/ProjectGSM/Repositories/IRouteRepository.cs new file mode 100644 index 0000000..54e23c6 --- /dev/null +++ b/ProjectGSM/Repositories/IRouteRepository.cs @@ -0,0 +1,21 @@ +using ProjectGSM.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectGSM.Repositories; + +public interface IRouteRepository +{ + IEnumerable ReadRoutes(); + + Route ReadRouteByID(int id); + + void CreateRoute(Route route); + + void UpdateRoute(Route route); + + void DeleteRoute(int id); +} diff --git a/ProjectGSM/Repositories/IRouteSheetRepository.cs b/ProjectGSM/Repositories/IRouteSheetRepository.cs new file mode 100644 index 0000000..1a4c65d --- /dev/null +++ b/ProjectGSM/Repositories/IRouteSheetRepository.cs @@ -0,0 +1,15 @@ +using ProjectGSM.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectGSM.Repositories; + +public interface IRouteSheetRepository +{ + IEnumerable ReadTrips(DateTime? dateFrom = null, DateTime? dateTo = null, int? carId = null, int? driverId = null, int? routeId = null); + + void CreateTrip(RouteSheet trip); +} diff --git a/ProjectGSM/Repositories/Implementation/CarRepository.cs b/ProjectGSM/Repositories/Implementation/CarRepository.cs new file mode 100644 index 0000000..c618d45 --- /dev/null +++ b/ProjectGSM/Repositories/Implementation/CarRepository.cs @@ -0,0 +1,34 @@ +using ProjectGSM.Entities; +using ProjectGSM.Repositories; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectGSM.Repositories.Implementations; + +public class CarRepository : ICarRepository +{ + public void CreateCar(Car car) + { + } + + public void DeleteCar(int id) + { + } + + public Car ReadCarByID(int id) + { + return Car.CreateEntity(0, string.Empty, string.Empty, 0, 0, 0); + } + + public IEnumerable ReadCars() + { + return []; + } + + public void UpdateCar(Car car) + { + } +} diff --git a/ProjectGSM/Repositories/Implementation/DriverRepository.cs b/ProjectGSM/Repositories/Implementation/DriverRepository.cs new file mode 100644 index 0000000..40e14a3 --- /dev/null +++ b/ProjectGSM/Repositories/Implementation/DriverRepository.cs @@ -0,0 +1,34 @@ +using ProjectGSM.Entities; +using ProjectGSM.Repositories; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectGSM.Repositories.Implementations; + +public class DriverRepository : IDriverRepository +{ + public void CreateDriver(Driver driver) + { + } + + public void DeleteDriver(int id) + { + } + + public Driver ReadDriverByID(int id) + { + return Driver.CreateEntity(0, string.Empty, string.Empty, 0); + } + + public IEnumerable ReadDrivers() + { + return []; + } + + public void UpdateDriver(Driver driver) + { + } +} diff --git a/ProjectGSM/Repositories/Implementation/PetrolStationRepository.cs b/ProjectGSM/Repositories/Implementation/PetrolStationRepository.cs new file mode 100644 index 0000000..f6f9ece --- /dev/null +++ b/ProjectGSM/Repositories/Implementation/PetrolStationRepository.cs @@ -0,0 +1,34 @@ +using ProjectGSM.Entities; +using ProjectGSM.Repositories; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectGSM.Repositories.Implementations; + +public class PetrolStationRepository : IPetrolStationRepository +{ + public void CreatePetrolStation(PetrolStation fuel) + { + } + + public void DeletePetrolStation(int id) + { + } + + public PetrolStation ReadPetrolStationByID(int id) + { + return PetrolStation.CreateEntity(0, 0, 0, 0); + } + + public IEnumerable ReadPetrolStations() + { + return []; + } + + public void UpdatePetrolStation(PetrolStation PetrolStation) + { + } +} diff --git a/ProjectGSM/Repositories/Implementation/RefillRepository.cs b/ProjectGSM/Repositories/Implementation/RefillRepository.cs new file mode 100644 index 0000000..ad829f0 --- /dev/null +++ b/ProjectGSM/Repositories/Implementation/RefillRepository.cs @@ -0,0 +1,21 @@ +using ProjectGSM.Entities; +using ProjectGSM.Repositories; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectGSM.Repositories.Implementations; + +public class RefillRepository : IRefillRepository +{ + public void CreateRefill(Refill refill) + { + } + + public IEnumerable ReadRefills(DateTime? dateFrom = null, DateTime? dateTo = null, int? fuelId = null, int? carId = null) + { + return []; + } +} diff --git a/ProjectGSM/Repositories/Implementation/RouteRepository.cs b/ProjectGSM/Repositories/Implementation/RouteRepository.cs new file mode 100644 index 0000000..2e31bdf --- /dev/null +++ b/ProjectGSM/Repositories/Implementation/RouteRepository.cs @@ -0,0 +1,34 @@ +using ProjectGSM.Entities; +using ProjectGSM.Repositories; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectGSM.Repositories.Implementations; + +public class RouteRepository : IRouteRepository +{ + public void CreateRoute(Route route) + { + } + + public void DeleteRoute(int id) + { + } + + public Route ReadRouteByID(int id) + { + return Route.CreateEntity(0, string.Empty, string.Empty, 0); + } + + public IEnumerable ReadRoutes() + { + return []; + } + + public void UpdateRoute(Route route) + { + } +} diff --git a/ProjectGSM/Repositories/Implementation/RouteSheetRepository.cs b/ProjectGSM/Repositories/Implementation/RouteSheetRepository.cs new file mode 100644 index 0000000..d012897 --- /dev/null +++ b/ProjectGSM/Repositories/Implementation/RouteSheetRepository.cs @@ -0,0 +1,21 @@ +using ProjectGSM.Entities; +using ProjectGSM.Repositories; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectGSM.Repositories.Implementations; + +public class RouteSheetRepository : IRouteSheetRepository +{ + public void CreateTrip(RouteSheet routeSheet) + { + } + + public IEnumerable ReadTrips(DateTime? dateFrom = null, DateTime? dateTo = null, int? carId = null, int? driverId = null, int? routeId = null) + { + return []; + } +} diff --git a/ProjectGSM/Resources/5332808188908660305.jpg b/ProjectGSM/Resources/5332808188908660305.jpg new file mode 100644 index 0000000..8cf71d9 Binary files /dev/null and b/ProjectGSM/Resources/5332808188908660305.jpg differ diff --git a/ProjectGSM/Resources/b92558ff3f28ceedac1c70e9435a9483.png b/ProjectGSM/Resources/b92558ff3f28ceedac1c70e9435a9483.png new file mode 100644 index 0000000..9f2c9bf Binary files /dev/null and b/ProjectGSM/Resources/b92558ff3f28ceedac1c70e9435a9483.png differ diff --git a/ProjectGSM/Resources/b92558ff3f28ceedac1c70e9435a94831.png b/ProjectGSM/Resources/b92558ff3f28ceedac1c70e9435a94831.png new file mode 100644 index 0000000..9f2c9bf Binary files /dev/null and b/ProjectGSM/Resources/b92558ff3f28ceedac1c70e9435a94831.png differ diff --git a/ProjectGSM/Resources/kisspng-computer-icons-meno-plus-and-minus-signs-symbol-5b1084ada4b796.8808036715278091976747.jpg b/ProjectGSM/Resources/kisspng-computer-icons-meno-plus-and-minus-signs-symbol-5b1084ada4b796.8808036715278091976747.jpg new file mode 100644 index 0000000..3e73f4e Binary files /dev/null and b/ProjectGSM/Resources/kisspng-computer-icons-meno-plus-and-minus-signs-symbol-5b1084ada4b796.8808036715278091976747.jpg differ diff --git a/ProjectGSM/Resources/Плюс.png b/ProjectGSM/Resources/Плюс.png new file mode 100644 index 0000000..9f2c9bf Binary files /dev/null and b/ProjectGSM/Resources/Плюс.png differ diff --git a/ProjectGSM/Resources/кисть.jpg b/ProjectGSM/Resources/кисть.jpg new file mode 100644 index 0000000..6ac55e6 Binary files /dev/null and b/ProjectGSM/Resources/кисть.jpg differ diff --git a/ProjectGSM/Resources/минус.jpg b/ProjectGSM/Resources/минус.jpg new file mode 100644 index 0000000..9a9aaf7 Binary files /dev/null and b/ProjectGSM/Resources/минус.jpg differ