diff --git a/FuelAccounting/FuelAccounting.sln b/FuelAccounting/FuelAccounting.sln new file mode 100644 index 0000000..ae39750 --- /dev/null +++ b/FuelAccounting/FuelAccounting.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.9.34701.34 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FuelAccounting", "FuelAccounting\FuelAccounting.csproj", "{2A77B8C6-6A8A-48F4-AA0D-BB31D73D3AEF}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {2A77B8C6-6A8A-48F4-AA0D-BB31D73D3AEF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2A77B8C6-6A8A-48F4-AA0D-BB31D73D3AEF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2A77B8C6-6A8A-48F4-AA0D-BB31D73D3AEF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2A77B8C6-6A8A-48F4-AA0D-BB31D73D3AEF}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {EE4FC1B6-1A66-4F56-8BA5-5F5227657A9E} + EndGlobalSection +EndGlobal diff --git a/FuelAccounting/FuelAccounting/Entities/Car.cs b/FuelAccounting/FuelAccounting/Entities/Car.cs new file mode 100644 index 0000000..3ca6a6b --- /dev/null +++ b/FuelAccounting/FuelAccounting/Entities/Car.cs @@ -0,0 +1,25 @@ +using FuelAccounting.Entities.Enums; + +namespace FuelAccounting.Entities; + +public class Car +{ + public int Id { get; private set; } + + public string Model { get; private set; } = string.Empty; + + public CarCategory Category { get; private set; } + + public int DriverID { get; private set; } + + public static Car CreateEntity(int id, string model, CarCategory category, int driverId) + { + return new Car + { + Id = id, + Model = model ?? string.Empty, + Category = category, + DriverID = driverId + }; + } +} diff --git a/FuelAccounting/FuelAccounting/Entities/Driver.cs b/FuelAccounting/FuelAccounting/Entities/Driver.cs new file mode 100644 index 0000000..6c6bddb --- /dev/null +++ b/FuelAccounting/FuelAccounting/Entities/Driver.cs @@ -0,0 +1,25 @@ +using FuelAccounting.Entities.Enums; + +namespace FuelAccounting.Entities; + +public class Driver +{ + public int Id { get; private set; } + + public string FirstName { get; private set; } = string.Empty; + + public string LastName { get; private set; } = string.Empty; + + public DriverLicenceCategory DriverLicenceCategory { get; private set; } + + public static Driver CreateEntity(int id, string firstName, string lastName, DriverLicenceCategory driverLicenceCategory) + { + return new Driver + { + Id = id, + FirstName = firstName, + LastName = lastName, + DriverLicenceCategory = driverLicenceCategory + }; + } +} diff --git a/FuelAccounting/FuelAccounting/Entities/Enums/CarCategory.cs b/FuelAccounting/FuelAccounting/Entities/Enums/CarCategory.cs new file mode 100644 index 0000000..ca04fb3 --- /dev/null +++ b/FuelAccounting/FuelAccounting/Entities/Enums/CarCategory.cs @@ -0,0 +1,10 @@ +namespace FuelAccounting.Entities.Enums; + +public enum CarCategory +{ + None = 0, + B = 1, + C = 2, + CE = 3, + D = 4 +} diff --git a/FuelAccounting/FuelAccounting/Entities/Enums/DriverLicenceCategory.cs b/FuelAccounting/FuelAccounting/Entities/Enums/DriverLicenceCategory.cs new file mode 100644 index 0000000..efdff3b --- /dev/null +++ b/FuelAccounting/FuelAccounting/Entities/Enums/DriverLicenceCategory.cs @@ -0,0 +1,11 @@ +namespace FuelAccounting.Entities.Enums; + +[Flags] +public enum DriverLicenceCategory +{ + None = 0, + B = 1, + C = 2, + CE = 4, + D = 8 +} diff --git a/FuelAccounting/FuelAccounting/Entities/Equipage.cs b/FuelAccounting/FuelAccounting/Entities/Equipage.cs new file mode 100644 index 0000000..181cc7d --- /dev/null +++ b/FuelAccounting/FuelAccounting/Entities/Equipage.cs @@ -0,0 +1,29 @@ +namespace FuelAccounting.Entities; + +public class Equipage +{ + public int Id { get; private set; } + + public int CarId { get; private set; } + + public int DriverId { get; private set; } + + public int ShiftId { get; private set; } + + public IEnumerable RoutesEqipage { get; private set; } = []; + + public DateTime EquipageDate { get; private set; } + + public static Equipage CreateOperation(int id, int carId, int driverId, int shiftId, IEnumerable routesEqipage) + { + return new Equipage + { + Id = id, + CarId = carId, + DriverId = driverId, + ShiftId = shiftId, + RoutesEqipage = routesEqipage, + EquipageDate = DateTime.Now + }; + } +} diff --git a/FuelAccounting/FuelAccounting/Entities/Refueling.cs b/FuelAccounting/FuelAccounting/Entities/Refueling.cs new file mode 100644 index 0000000..a637a63 --- /dev/null +++ b/FuelAccounting/FuelAccounting/Entities/Refueling.cs @@ -0,0 +1,29 @@ +namespace FuelAccounting.Entities; + +public class Refueling +{ + public int Id { get; private set; } + + public int CarId { get; private set; } + + public double Kilometers { get; private set; } + + public double LitersSpent { get; private set; } + + public string TypeOfFuel { get; private set; } = string.Empty; + + public DateTime RefuelingDate { get; private set; } + + public static Refueling CreateOperation(int id, int carId, double kilometers, double litersSpent, string typeOfFuel) + { + return new Refueling + { + Id = id, + CarId = carId, + Kilometers = kilometers, + LitersSpent = litersSpent, + TypeOfFuel = typeOfFuel ?? string.Empty, + RefuelingDate = DateTime.Now + }; + } +} diff --git a/FuelAccounting/FuelAccounting/Entities/Route.cs b/FuelAccounting/FuelAccounting/Entities/Route.cs new file mode 100644 index 0000000..0cde77f --- /dev/null +++ b/FuelAccounting/FuelAccounting/Entities/Route.cs @@ -0,0 +1,17 @@ +namespace FuelAccounting.Entities; + +public class Route +{ + public int Id { get; private set; } + + public string Description { get; private set; } = string.Empty; + + public static Route CreateEntity(int id, string description) + { + return new Route + { + Id = id, + Description = description ?? string.Empty + }; + } +} diff --git a/FuelAccounting/FuelAccounting/Entities/RoutesEqipage.cs b/FuelAccounting/FuelAccounting/Entities/RoutesEqipage.cs new file mode 100644 index 0000000..d704366 --- /dev/null +++ b/FuelAccounting/FuelAccounting/Entities/RoutesEqipage.cs @@ -0,0 +1,20 @@ +namespace FuelAccounting.Entities; + +public class RoutesEqipage +{ + public int Id { get; private set; } + + public int RouteID { get; private set; } + + public int Count { get; private set; } + + public static RoutesEqipage CreateElement(int id, int routeId, int count) + { + return new RoutesEqipage + { + Id = id, + RouteID = routeId, + Count = count + }; + } +} diff --git a/FuelAccounting/FuelAccounting/Entities/Shift.cs b/FuelAccounting/FuelAccounting/Entities/Shift.cs new file mode 100644 index 0000000..0192722 --- /dev/null +++ b/FuelAccounting/FuelAccounting/Entities/Shift.cs @@ -0,0 +1,20 @@ +namespace FuelAccounting.Entities; + +public class Shift +{ + public int Id { get; private set; } + + public int AmountOfHours { get; private set; } + + public string Description { get; private set; } = string.Empty; + + public static Shift CreateEntity(int id, int amountOfHours, string description) + { + return new Shift + { + Id = id, + AmountOfHours = amountOfHours, + Description = description ?? string.Empty + }; + } +} diff --git a/FuelAccounting/FuelAccounting/FormFuelAccounting.Designer.cs b/FuelAccounting/FuelAccounting/FormFuelAccounting.Designer.cs new file mode 100644 index 0000000..9c86b78 --- /dev/null +++ b/FuelAccounting/FuelAccounting/FormFuelAccounting.Designer.cs @@ -0,0 +1,146 @@ +namespace FuelAccounting +{ + partial class FormFuelAccounting + { + /// + /// 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(); + автомобилиToolStripMenuItem = new ToolStripMenuItem(); + водителиToolStripMenuItem = new ToolStripMenuItem(); + сменыToolStripMenuItem = new ToolStripMenuItem(); + маршрутыToolStripMenuItem = new ToolStripMenuItem(); + операцииToolStripMenuItem = new ToolStripMenuItem(); + выездToolStripMenuItem = new ToolStripMenuItem(); + заправкаToolStripMenuItem = new ToolStripMenuItem(); + отчетыToolStripMenuItem = new ToolStripMenuItem(); + menuStrip.SuspendLayout(); + SuspendLayout(); + // + // menuStrip + // + menuStrip.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, операцииToolStripMenuItem, отчетыToolStripMenuItem }); + menuStrip.Location = new Point(0, 0); + menuStrip.Name = "menuStrip"; + menuStrip.Size = new Size(800, 24); + menuStrip.TabIndex = 0; + menuStrip.Text = "menuStrip1"; + // + // справочникиToolStripMenuItem + // + справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { автомобилиToolStripMenuItem, водителиToolStripMenuItem, сменыToolStripMenuItem, маршрутыToolStripMenuItem }); + справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem"; + справочникиToolStripMenuItem.Size = new Size(94, 20); + справочникиToolStripMenuItem.Text = "Справочники"; + // + // автомобилиToolStripMenuItem + // + автомобилиToolStripMenuItem.Name = "автомобилиToolStripMenuItem"; + автомобилиToolStripMenuItem.Size = new Size(180, 22); + автомобилиToolStripMenuItem.Text = "Автомобили"; + автомобилиToolStripMenuItem.Click += CarsToolStripMenuItem_Click; + // + // водителиToolStripMenuItem + // + водителиToolStripMenuItem.Name = "водителиToolStripMenuItem"; + водителиToolStripMenuItem.Size = new Size(180, 22); + водителиToolStripMenuItem.Text = "Водители"; + водителиToolStripMenuItem.Click += DriversToolStripMenuItem_Click; + // + // сменыToolStripMenuItem + // + сменыToolStripMenuItem.Name = "сменыToolStripMenuItem"; + сменыToolStripMenuItem.Size = new Size(180, 22); + сменыToolStripMenuItem.Text = "Смены"; + сменыToolStripMenuItem.Click += ShiftsToolStripMenuItem_Click; + // + // маршрутыToolStripMenuItem + // + маршрутыToolStripMenuItem.Name = "маршрутыToolStripMenuItem"; + маршрутыToolStripMenuItem.Size = new Size(180, 22); + маршрутыToolStripMenuItem.Text = "Маршруты"; + маршрутыToolStripMenuItem.Click += RoutesToolStripMenuItem_Click; + // + // операцииToolStripMenuItem + // + операцииToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { выездToolStripMenuItem, заправкаToolStripMenuItem }); + операцииToolStripMenuItem.Name = "операцииToolStripMenuItem"; + операцииToolStripMenuItem.Size = new Size(75, 20); + операцииToolStripMenuItem.Text = "Операции"; + // + // выездToolStripMenuItem + // + выездToolStripMenuItem.Name = "выездToolStripMenuItem"; + выездToolStripMenuItem.Size = new Size(180, 22); + выездToolStripMenuItem.Text = "Выезд"; + выездToolStripMenuItem.Click += EquipageToolStripMenuItem_Click; + // + // заправкаToolStripMenuItem + // + заправкаToolStripMenuItem.Name = "заправкаToolStripMenuItem"; + заправкаToolStripMenuItem.Size = new Size(180, 22); + заправкаToolStripMenuItem.Text = "Заправка"; + заправкаToolStripMenuItem.Click += RefuelingToolStripMenuItem_Click; + // + // отчетыToolStripMenuItem + // + отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem"; + отчетыToolStripMenuItem.Size = new Size(60, 20); + отчетыToolStripMenuItem.Text = "Отчеты"; + // + // FormFuelAccounting + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + BackgroundImage = Properties.Resources._4298; + BackgroundImageLayout = ImageLayout.Stretch; + ClientSize = new Size(800, 450); + Controls.Add(menuStrip); + MainMenuStrip = menuStrip; + Name = "FormFuelAccounting"; + StartPosition = FormStartPosition.CenterScreen; + Text = "Учет ГСМ"; + menuStrip.ResumeLayout(false); + menuStrip.PerformLayout(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private MenuStrip menuStrip; + private ToolStripMenuItem справочникиToolStripMenuItem; + private ToolStripMenuItem автомобилиToolStripMenuItem; + private ToolStripMenuItem водителиToolStripMenuItem; + private ToolStripMenuItem сменыToolStripMenuItem; + private ToolStripMenuItem маршрутыToolStripMenuItem; + private ToolStripMenuItem операцииToolStripMenuItem; + private ToolStripMenuItem выездToolStripMenuItem; + private ToolStripMenuItem заправкаToolStripMenuItem; + private ToolStripMenuItem отчетыToolStripMenuItem; + } +} \ No newline at end of file diff --git a/FuelAccounting/FuelAccounting/FormFuelAccounting.cs b/FuelAccounting/FuelAccounting/FormFuelAccounting.cs new file mode 100644 index 0000000..0f76a57 --- /dev/null +++ b/FuelAccounting/FuelAccounting/FormFuelAccounting.cs @@ -0,0 +1,110 @@ +using FuelAccounting.Forms; +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 FuelAccounting +{ + public partial class FormFuelAccounting : Form + { + private readonly IUnityContainer _container; + + public FormFuelAccounting(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 ShiftsToolStripMenuItem_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 EquipageToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при загрузке", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + } + + private void RefuelingToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при загрузке", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + } + } +} diff --git a/FuelAccounting/FuelAccounting/FormFuelAccounting.resx b/FuelAccounting/FuelAccounting/FormFuelAccounting.resx new file mode 100644 index 0000000..6c82d08 --- /dev/null +++ b/FuelAccounting/FuelAccounting/FormFuelAccounting.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/FuelAccounting/FuelAccounting/Forms/FormCar.Designer.cs b/FuelAccounting/FuelAccounting/Forms/FormCar.Designer.cs new file mode 100644 index 0000000..fd30abf --- /dev/null +++ b/FuelAccounting/FuelAccounting/Forms/FormCar.Designer.cs @@ -0,0 +1,142 @@ +namespace FuelAccounting.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() + { + label1 = new Label(); + label2 = new Label(); + label3 = new Label(); + textBoxModel = new TextBox(); + comboBoxCategory = new ComboBox(); + buttonCancel = new Button(); + buttonSave = new Button(); + comboBoxDriverId = new ComboBox(); + SuspendLayout(); + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(12, 18); + label1.Name = "label1"; + label1.Size = new Size(50, 15); + label1.TabIndex = 0; + label1.Text = "Модель"; + // + // label2 + // + label2.AutoSize = true; + label2.Location = new Point(12, 101); + label2.Name = "label2"; + label2.Size = new Size(170, 15); + label2.TabIndex = 1; + label2.Text = "ID закрепленного сотрудника"; + // + // label3 + // + label3.AutoSize = true; + label3.Location = new Point(12, 58); + label3.Name = "label3"; + label3.Size = new Size(63, 15); + label3.TabIndex = 2; + label3.Text = "Категория"; + // + // textBoxModel + // + textBoxModel.Location = new Point(118, 15); + textBoxModel.Name = "textBoxModel"; + textBoxModel.Size = new Size(154, 23); + textBoxModel.TabIndex = 3; + // + // comboBoxCategory + // + comboBoxCategory.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxCategory.FormattingEnabled = true; + comboBoxCategory.Location = new Point(118, 55); + comboBoxCategory.Name = "comboBoxCategory"; + comboBoxCategory.Size = new Size(154, 23); + comboBoxCategory.TabIndex = 4; + // + // buttonCancel + // + buttonCancel.Location = new Point(164, 140); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(108, 38); + buttonCancel.TabIndex = 7; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += ButtonCancel_Click; + // + // buttonSave + // + buttonSave.Location = new Point(12, 140); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(108, 38); + buttonSave.TabIndex = 6; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += ButtonSave_Click; + // + // comboBoxDriverId + // + comboBoxDriverId.FormattingEnabled = true; + comboBoxDriverId.Location = new Point(188, 98); + comboBoxDriverId.Name = "comboBoxDriverId"; + comboBoxDriverId.Size = new Size(84, 23); + comboBoxDriverId.TabIndex = 8; + // + // FormCar + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(297, 203); + Controls.Add(comboBoxDriverId); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(comboBoxCategory); + Controls.Add(textBoxModel); + Controls.Add(label3); + Controls.Add(label2); + Controls.Add(label1); + Name = "FormCar"; + Text = "Автомобиль"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label label1; + private Label label2; + private Label label3; + private TextBox textBoxModel; + private ComboBox comboBoxCategory; + private Button buttonCancel; + private Button buttonSave; + private ComboBox comboBoxDriverId; + } +} \ No newline at end of file diff --git a/FuelAccounting/FuelAccounting/Forms/FormCar.cs b/FuelAccounting/FuelAccounting/Forms/FormCar.cs new file mode 100644 index 0000000..3b8c52d --- /dev/null +++ b/FuelAccounting/FuelAccounting/Forms/FormCar.cs @@ -0,0 +1,85 @@ +using FuelAccounting.Entities; +using FuelAccounting.Entities.Enums; +using FuelAccounting.Repositories; + +namespace FuelAccounting.Forms +{ + public partial class FormCar : Form + { + private readonly ICarsRepository _carsRepository; + + private int? _carId; + + public int Id + { + set + { + try + { + var car = _carsRepository.ReadCarById(value); + if (car == null) + { + throw new InvalidDataException(nameof(car)); + } + + textBoxModel.Text = car.Model; + comboBoxCategory.SelectedItem = car.Category; + comboBoxDriverId.SelectedItem = car.DriverID; + _carId = value; + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + } + } + + public FormCar(ICarsRepository carsRepository, IDriversRepository driversRepository) + { + InitializeComponent(); + _carsRepository = carsRepository ?? + throw new ArgumentNullException(nameof(carsRepository)); + + comboBoxCategory.DataSource = Enum.GetValues(typeof(CarCategory)); + + comboBoxDriverId.DataSource = driversRepository.ReadDrivers(); + comboBoxDriverId.DisplayMember = "FirstName"; + comboBoxDriverId.ValueMember = "Id"; + } + + private void ButtonSave_Click(object sender, EventArgs e) + { + try + { + if (string.IsNullOrWhiteSpace(textBoxModel.Text) || + comboBoxCategory.SelectedIndex < 1) + { + throw new Exception("Имеются незаполненные поля"); + } + + if (_carId.HasValue) + { + _carsRepository.UpdateCar(CreateCar(_carId.Value)); + } + else + { + _carsRepository.CreateCar(CreateCar(0)); + } + + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonCancel_Click(object sender, EventArgs e) => Close(); + + private Car CreateCar(int id) => + Car.CreateEntity(id, textBoxModel.Text, + (CarCategory)comboBoxCategory.SelectedItem!, + (int)comboBoxDriverId.SelectedItem!); + } +} diff --git a/FuelAccounting/FuelAccounting/Forms/FormCar.resx b/FuelAccounting/FuelAccounting/Forms/FormCar.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/FuelAccounting/FuelAccounting/Forms/FormCar.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/FuelAccounting/FuelAccounting/Forms/FormCars.Designer.cs b/FuelAccounting/FuelAccounting/Forms/FormCars.Designer.cs new file mode 100644 index 0000000..346af6f --- /dev/null +++ b/FuelAccounting/FuelAccounting/Forms/FormCars.Designer.cs @@ -0,0 +1,124 @@ +namespace FuelAccounting.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() + { + dataGridViewData = new DataGridView(); + panelButtons = new Panel(); + buttonDelete = new Button(); + buttonUpdate = new Button(); + buttonAdd = new Button(); + ((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit(); + panelButtons.SuspendLayout(); + SuspendLayout(); + // + // dataGridViewData + // + dataGridViewData.AllowUserToAddRows = false; + dataGridViewData.AllowUserToDeleteRows = false; + dataGridViewData.AllowUserToResizeRows = false; + dataGridViewData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewData.Dock = DockStyle.Fill; + dataGridViewData.Location = new Point(0, 0); + dataGridViewData.MultiSelect = false; + dataGridViewData.Name = "dataGridViewData"; + dataGridViewData.ReadOnly = true; + dataGridViewData.RowHeadersVisible = false; + dataGridViewData.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridViewData.Size = new Size(640, 450); + dataGridViewData.TabIndex = 5; + // + // panelButtons + // + panelButtons.Controls.Add(buttonDelete); + panelButtons.Controls.Add(buttonUpdate); + panelButtons.Controls.Add(buttonAdd); + panelButtons.Dock = DockStyle.Right; + panelButtons.Location = new Point(640, 0); + panelButtons.Name = "panelButtons"; + panelButtons.Size = new Size(160, 450); + panelButtons.TabIndex = 4; + // + // buttonDelete + // + buttonDelete.BackgroundImage = Properties.Resources.images; + buttonDelete.BackgroundImageLayout = ImageLayout.Stretch; + buttonDelete.Location = new Point(18, 308); + buttonDelete.Name = "buttonDelete"; + buttonDelete.Size = new Size(130, 130); + buttonDelete.TabIndex = 4; + buttonDelete.UseVisualStyleBackColor = true; + buttonDelete.Click += ButtonDelete_Click; + // + // buttonUpdate + // + buttonUpdate.BackgroundImage = Properties.Resources._73c1e0a4_66bb_443c_a632_108fa967fec1; + buttonUpdate.BackgroundImageLayout = ImageLayout.Stretch; + buttonUpdate.Location = new Point(18, 160); + buttonUpdate.Name = "buttonUpdate"; + buttonUpdate.Size = new Size(130, 130); + buttonUpdate.TabIndex = 3; + buttonUpdate.UseVisualStyleBackColor = true; + buttonUpdate.Click += ButtonUpdate_Click; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.pngimg_com___plus_PNG84; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(18, 12); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(130, 130); + buttonAdd.TabIndex = 2; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += ButtonAdd_Click; + // + // FormCars + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(800, 450); + Controls.Add(dataGridViewData); + Controls.Add(panelButtons); + Name = "FormCars"; + Text = "Автомобили"; + Load += FormCars_Load; + ((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit(); + panelButtons.ResumeLayout(false); + ResumeLayout(false); + } + + #endregion + + private DataGridView dataGridViewData; + private Panel panelButtons; + private Button buttonDelete; + private Button buttonUpdate; + private Button buttonAdd; + } +} \ No newline at end of file diff --git a/FuelAccounting/FuelAccounting/Forms/FormCars.cs b/FuelAccounting/FuelAccounting/Forms/FormCars.cs new file mode 100644 index 0000000..f0677d5 --- /dev/null +++ b/FuelAccounting/FuelAccounting/Forms/FormCars.cs @@ -0,0 +1,102 @@ +using FuelAccounting.Repositories; +using Unity; + +namespace FuelAccounting.Forms +{ + public partial class FormCars : Form + { + private readonly IUnityContainer _container; + + private readonly ICarsRepository _carsRepository; + + public FormCars(IUnityContainer container, ICarsRepository carsRepository) + { + InitializeComponent(); + _container = container ?? throw new ArgumentNullException(nameof(container)); + _carsRepository = carsRepository ?? throw new ArgumentNullException(nameof(carsRepository)); + } + + private void FormCars_Load(object sender, EventArgs e) + { + try + { + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonAdd_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonUpdate_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 ButtonDelete_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromSelectedRow(out var findId)) + { + return; + } + + if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes) + { + return; + } + + try + { + _carsRepository.DeleteCar(findId); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void LoadList() => dataGridViewData.DataSource = _carsRepository.ReadCars(); + + private bool TryGetIdentifierFromSelectedRow(out int id) + { + id = 0; + if (dataGridViewData.SelectedRows.Count < 1) + { + MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + + id = Convert.ToInt32(dataGridViewData.SelectedRows[0].Cells["Id"].Value); + return true; + } + } +} diff --git a/FuelAccounting/FuelAccounting/Forms/FormCars.resx b/FuelAccounting/FuelAccounting/Forms/FormCars.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/FuelAccounting/FuelAccounting/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/FuelAccounting/FuelAccounting/Forms/FormDriver.Designer.cs b/FuelAccounting/FuelAccounting/Forms/FormDriver.Designer.cs new file mode 100644 index 0000000..324c49a --- /dev/null +++ b/FuelAccounting/FuelAccounting/Forms/FormDriver.Designer.cs @@ -0,0 +1,140 @@ +namespace FuelAccounting.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() + { + checkedListBoxDriverLicenceCategory = new CheckedListBox(); + label1 = new Label(); + label2 = new Label(); + label3 = new Label(); + textBoxFirstName = new TextBox(); + textBoxLastName = new TextBox(); + buttonCancel = new Button(); + buttonSave = new Button(); + SuspendLayout(); + // + // checkedListBoxDriverLicenceCategory + // + checkedListBoxDriverLicenceCategory.FormattingEnabled = true; + checkedListBoxDriverLicenceCategory.Location = new Point(154, 90); + checkedListBoxDriverLicenceCategory.Name = "checkedListBoxDriverLicenceCategory"; + checkedListBoxDriverLicenceCategory.Size = new Size(120, 94); + checkedListBoxDriverLicenceCategory.TabIndex = 0; + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(12, 20); + label1.Name = "label1"; + label1.Size = new Size(31, 15); + label1.TabIndex = 1; + label1.Text = "Имя"; + // + // label2 + // + label2.AutoSize = true; + label2.Location = new Point(12, 53); + label2.Name = "label2"; + label2.Size = new Size(58, 15); + label2.TabIndex = 2; + label2.Text = "Фамилия"; + // + // label3 + // + label3.AutoSize = true; + label3.Location = new Point(12, 90); + label3.Name = "label3"; + label3.Size = new Size(114, 15); + label3.TabIndex = 3; + label3.Text = "Категория(ии) прав"; + // + // textBoxFirstName + // + textBoxFirstName.Location = new Point(104, 17); + textBoxFirstName.Name = "textBoxFirstName"; + textBoxFirstName.Size = new Size(170, 23); + textBoxFirstName.TabIndex = 4; + // + // textBoxLastName + // + textBoxLastName.Location = new Point(104, 50); + textBoxLastName.Name = "textBoxLastName"; + textBoxLastName.Size = new Size(170, 23); + textBoxLastName.TabIndex = 5; + // + // buttonCancel + // + buttonCancel.Location = new Point(166, 202); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(108, 38); + buttonCancel.TabIndex = 9; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += ButtonCancel_Click; + // + // buttonSave + // + buttonSave.Location = new Point(12, 202); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(108, 38); + buttonSave.TabIndex = 8; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += ButtonSave_Click; + // + // FormDriver + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(295, 261); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(textBoxLastName); + Controls.Add(textBoxFirstName); + Controls.Add(label3); + Controls.Add(label2); + Controls.Add(label1); + Controls.Add(checkedListBoxDriverLicenceCategory); + Name = "FormDriver"; + Text = "FormDriver"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private CheckedListBox checkedListBoxDriverLicenceCategory; + private Label label1; + private Label label2; + private Label label3; + private TextBox textBoxFirstName; + private TextBox textBoxLastName; + private Button buttonCancel; + private Button buttonSave; + } +} \ No newline at end of file diff --git a/FuelAccounting/FuelAccounting/Forms/FormDriver.cs b/FuelAccounting/FuelAccounting/Forms/FormDriver.cs new file mode 100644 index 0000000..fc272cf --- /dev/null +++ b/FuelAccounting/FuelAccounting/Forms/FormDriver.cs @@ -0,0 +1,99 @@ +using FuelAccounting.Entities; +using FuelAccounting.Entities.Enums; +using FuelAccounting.Repositories; +using FuelAccounting.Repositories.Implementations; + +namespace FuelAccounting.Forms +{ + public partial class FormDriver : Form + { + private readonly IDriversRepository _driverRepository; + + private int? _driverId; + + public int Id + { + set + { + try + { + var driver = _driverRepository.ReadDriverById(value); + if (driver == null) + { + throw new InvalidDataException(nameof(driver)); + } + + foreach (DriverLicenceCategory elem in Enum.GetValues(typeof(DriverLicenceCategory))) + { + if ((elem & driver.DriverLicenceCategory) != 0) + { + checkedListBoxDriverLicenceCategory.SetItemChecked(checkedListBoxDriverLicenceCategory.Items.IndexOf(elem), true); + } + } + + textBoxFirstName.Text = driver.FirstName; + textBoxLastName.Text = driver.LastName; + _driverId = value; + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + } + } + + public FormDriver(IDriversRepository driverRepository) + { + InitializeComponent(); + _driverRepository = driverRepository ?? + throw new ArgumentNullException(nameof(driverRepository)); + + foreach (var elem in Enum.GetValues(typeof(DriverLicenceCategory))) + { + checkedListBoxDriverLicenceCategory.Items.Add(elem); + } + } + + private void ButtonSave_Click(object sender, EventArgs e) + { + try + { + if (string.IsNullOrWhiteSpace(textBoxFirstName.Text) || + string.IsNullOrWhiteSpace(textBoxLastName.Text) || + checkedListBoxDriverLicenceCategory.CheckedItems.Count == 0) + { + throw new Exception("Имеются незаполненные поля"); + } + + if (_driverId.HasValue) + { + _driverRepository.UpdateDriver(CreateDriver(_driverId.Value)); + } + else + { + _driverRepository.UpdateDriver(CreateDriver(0)); + } + + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonCancel_Click(object sender, EventArgs e) => Close(); + + private Driver CreateDriver(int id) + { + DriverLicenceCategory driverCategory = DriverLicenceCategory.None; + foreach (var elem in checkedListBoxDriverLicenceCategory.CheckedItems) + { + driverCategory |= (DriverLicenceCategory)elem; + } + + return Driver.CreateEntity(id, textBoxFirstName.Text, textBoxLastName.Text, driverCategory); + } + } +} diff --git a/FuelAccounting/FuelAccounting/Forms/FormDriver.resx b/FuelAccounting/FuelAccounting/Forms/FormDriver.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/FuelAccounting/FuelAccounting/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/FuelAccounting/FuelAccounting/Forms/FormDrivers.Designer.cs b/FuelAccounting/FuelAccounting/Forms/FormDrivers.Designer.cs new file mode 100644 index 0000000..48cbea3 --- /dev/null +++ b/FuelAccounting/FuelAccounting/Forms/FormDrivers.Designer.cs @@ -0,0 +1,124 @@ +namespace FuelAccounting.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() + { + dataGridViewData = new DataGridView(); + panelButtons = new Panel(); + buttonDelete = new Button(); + buttonUpdate = new Button(); + buttonAdd = new Button(); + ((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit(); + panelButtons.SuspendLayout(); + SuspendLayout(); + // + // dataGridViewData + // + dataGridViewData.AllowUserToAddRows = false; + dataGridViewData.AllowUserToDeleteRows = false; + dataGridViewData.AllowUserToResizeRows = false; + dataGridViewData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewData.Dock = DockStyle.Fill; + dataGridViewData.Location = new Point(0, 0); + dataGridViewData.MultiSelect = false; + dataGridViewData.Name = "dataGridViewData"; + dataGridViewData.ReadOnly = true; + dataGridViewData.RowHeadersVisible = false; + dataGridViewData.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridViewData.Size = new Size(640, 450); + dataGridViewData.TabIndex = 7; + // + // panelButtons + // + panelButtons.Controls.Add(buttonDelete); + panelButtons.Controls.Add(buttonUpdate); + panelButtons.Controls.Add(buttonAdd); + panelButtons.Dock = DockStyle.Right; + panelButtons.Location = new Point(640, 0); + panelButtons.Name = "panelButtons"; + panelButtons.Size = new Size(160, 450); + panelButtons.TabIndex = 6; + // + // buttonDelete + // + buttonDelete.BackgroundImage = Properties.Resources.images; + buttonDelete.BackgroundImageLayout = ImageLayout.Stretch; + buttonDelete.Location = new Point(18, 308); + buttonDelete.Name = "buttonDelete"; + buttonDelete.Size = new Size(130, 130); + buttonDelete.TabIndex = 4; + buttonDelete.UseVisualStyleBackColor = true; + buttonDelete.Click += ButtonDelete_Click; + // + // buttonUpdate + // + buttonUpdate.BackgroundImage = Properties.Resources._73c1e0a4_66bb_443c_a632_108fa967fec1; + buttonUpdate.BackgroundImageLayout = ImageLayout.Stretch; + buttonUpdate.Location = new Point(18, 160); + buttonUpdate.Name = "buttonUpdate"; + buttonUpdate.Size = new Size(130, 130); + buttonUpdate.TabIndex = 3; + buttonUpdate.UseVisualStyleBackColor = true; + buttonUpdate.Click += ButtonUpdate_Click; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.pngimg_com___plus_PNG84; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(18, 12); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(130, 130); + buttonAdd.TabIndex = 2; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += ButtonAdd_Click; + // + // FormDrivers + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(800, 450); + Controls.Add(dataGridViewData); + Controls.Add(panelButtons); + Name = "FormDrivers"; + Text = "Водители"; + Load += FormDrivers_Load; + ((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit(); + panelButtons.ResumeLayout(false); + ResumeLayout(false); + } + + #endregion + + private DataGridView dataGridViewData; + private Panel panelButtons; + private Button buttonDelete; + private Button buttonUpdate; + private Button buttonAdd; + } +} \ No newline at end of file diff --git a/FuelAccounting/FuelAccounting/Forms/FormDrivers.cs b/FuelAccounting/FuelAccounting/Forms/FormDrivers.cs new file mode 100644 index 0000000..7a0f242 --- /dev/null +++ b/FuelAccounting/FuelAccounting/Forms/FormDrivers.cs @@ -0,0 +1,112 @@ +using FuelAccounting.Repositories; +using FuelAccounting.Repositories.Implementations; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using Unity; + +namespace FuelAccounting.Forms +{ + public partial class FormDrivers : Form + { + private readonly IUnityContainer _container; + + private readonly IDriversRepository _driversRepository; + + public FormDrivers(IUnityContainer container, IDriversRepository driversRepository) + { + InitializeComponent(); + _container = container ?? throw new ArgumentNullException(nameof(container)); + _driversRepository = driversRepository ?? throw new ArgumentNullException(nameof(driversRepository)); + } + + private void FormDrivers_Load(object sender, EventArgs e) + { + try + { + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonAdd_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonUpdate_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 ButtonDelete_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromSelectedRow(out var findId)) + { + return; + } + + if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes) + { + return; + } + + try + { + _driversRepository.DeleteDriver(findId); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void LoadList() => dataGridViewData.DataSource = _driversRepository.ReadDrivers(); + + private bool TryGetIdentifierFromSelectedRow(out int id) + { + id = 0; + if (dataGridViewData.SelectedRows.Count < 1) + { + MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + + id = Convert.ToInt32(dataGridViewData.SelectedRows[0].Cells["Id"].Value); + return true; + } + } +} diff --git a/FuelAccounting/FuelAccounting/Forms/FormDrivers.resx b/FuelAccounting/FuelAccounting/Forms/FormDrivers.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/FuelAccounting/FuelAccounting/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/FuelAccounting/FuelAccounting/Forms/FormEquipage.Designer.cs b/FuelAccounting/FuelAccounting/Forms/FormEquipage.Designer.cs new file mode 100644 index 0000000..4e65e01 --- /dev/null +++ b/FuelAccounting/FuelAccounting/Forms/FormEquipage.Designer.cs @@ -0,0 +1,194 @@ +namespace FuelAccounting.Forms +{ + partial class FormEquipage + { + /// + /// 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() + { + comboBoxCar = new ComboBox(); + label1 = new Label(); + comboBoxDriver = new ComboBox(); + label2 = new Label(); + comboBoxShift = new ComboBox(); + label3 = new Label(); + groupBoxRoutes = new GroupBox(); + dataGridViewRoutes = new DataGridView(); + ColumnRoute = new DataGridViewComboBoxColumn(); + ColumnCount = new DataGridViewTextBoxColumn(); + buttonCancel = new Button(); + buttonSave = new Button(); + groupBoxRoutes.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridViewRoutes).BeginInit(); + SuspendLayout(); + // + // comboBoxCar + // + comboBoxCar.FormattingEnabled = true; + comboBoxCar.Location = new Point(115, 21); + comboBoxCar.Name = "comboBoxCar"; + comboBoxCar.Size = new Size(146, 23); + comboBoxCar.TabIndex = 6; + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(12, 24); + label1.Name = "label1"; + label1.Size = new Size(76, 15); + label1.TabIndex = 5; + label1.Text = "Автомобиль"; + // + // comboBoxDriver + // + comboBoxDriver.FormattingEnabled = true; + comboBoxDriver.Location = new Point(115, 58); + comboBoxDriver.Name = "comboBoxDriver"; + comboBoxDriver.Size = new Size(146, 23); + comboBoxDriver.TabIndex = 8; + // + // label2 + // + label2.AutoSize = true; + label2.Location = new Point(12, 61); + label2.Name = "label2"; + label2.Size = new Size(58, 15); + label2.TabIndex = 7; + label2.Text = "Водитель"; + // + // comboBoxShift + // + comboBoxShift.FormattingEnabled = true; + comboBoxShift.Location = new Point(115, 96); + comboBoxShift.Name = "comboBoxShift"; + comboBoxShift.Size = new Size(146, 23); + comboBoxShift.TabIndex = 10; + // + // label3 + // + label3.AutoSize = true; + label3.Location = new Point(12, 99); + label3.Name = "label3"; + label3.Size = new Size(43, 15); + label3.TabIndex = 9; + label3.Text = "Смена"; + // + // groupBoxRoutes + // + groupBoxRoutes.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; + groupBoxRoutes.Controls.Add(dataGridViewRoutes); + groupBoxRoutes.Location = new Point(12, 125); + groupBoxRoutes.Name = "groupBoxRoutes"; + groupBoxRoutes.Size = new Size(262, 223); + groupBoxRoutes.TabIndex = 12; + groupBoxRoutes.TabStop = false; + groupBoxRoutes.Text = "Маршруты"; + // + // dataGridViewRoutes + // + dataGridViewRoutes.AllowUserToResizeColumns = false; + dataGridViewRoutes.AllowUserToResizeRows = false; + dataGridViewRoutes.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; + dataGridViewRoutes.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridViewRoutes.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewRoutes.Columns.AddRange(new DataGridViewColumn[] { ColumnRoute, ColumnCount }); + dataGridViewRoutes.Location = new Point(0, 22); + dataGridViewRoutes.MultiSelect = false; + dataGridViewRoutes.Name = "dataGridViewRoutes"; + dataGridViewRoutes.RowHeadersVisible = false; + dataGridViewRoutes.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridViewRoutes.Size = new Size(262, 201); + dataGridViewRoutes.TabIndex = 0; + // + // ColumnRoute + // + ColumnRoute.HeaderText = "Описание маршрута"; + ColumnRoute.Name = "ColumnRoute"; + // + // ColumnCount + // + ColumnCount.HeaderText = "Количество поездок"; + ColumnCount.Name = "ColumnCount"; + // + // buttonCancel + // + buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonCancel.Location = new Point(170, 368); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(108, 38); + buttonCancel.TabIndex = 14; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += ButtonCancel_Click; + // + // buttonSave + // + buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; + buttonSave.Location = new Point(12, 368); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(108, 38); + buttonSave.TabIndex = 13; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += ButtonSave_Click; + // + // FormEquipage + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(291, 416); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(groupBoxRoutes); + Controls.Add(comboBoxShift); + Controls.Add(label3); + Controls.Add(comboBoxDriver); + Controls.Add(label2); + Controls.Add(comboBoxCar); + Controls.Add(label1); + Name = "FormEquipage"; + Text = "Выезд"; + groupBoxRoutes.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridViewRoutes).EndInit(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private ComboBox comboBoxCar; + private Label label1; + private ComboBox comboBoxDriver; + private Label label2; + private ComboBox comboBoxShift; + private Label label3; + private GroupBox groupBoxRoutes; + private DataGridView dataGridViewRoutes; + private Button buttonCancel; + private Button buttonSave; + private DataGridViewComboBoxColumn ColumnRoute; + private DataGridViewTextBoxColumn ColumnCount; + } +} \ No newline at end of file diff --git a/FuelAccounting/FuelAccounting/Forms/FormEquipage.cs b/FuelAccounting/FuelAccounting/Forms/FormEquipage.cs new file mode 100644 index 0000000..7887ea5 --- /dev/null +++ b/FuelAccounting/FuelAccounting/Forms/FormEquipage.cs @@ -0,0 +1,88 @@ +using FuelAccounting.Entities; +using FuelAccounting.Repositories; +using FuelAccounting.Repositories.Implementations; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace FuelAccounting.Forms +{ + public partial class FormEquipage : Form + { + private readonly IEquipageRepository _equipageRepository; + + public FormEquipage(IEquipageRepository equipageRepository, + ICarsRepository carsRepository, IDriversRepository driversRepository, + IRouteRepository routeRepository, IShiftRepository shiftRepository) + { + InitializeComponent(); + _equipageRepository = equipageRepository ?? + throw new ArgumentNullException(nameof(equipageRepository)); + + comboBoxCar.DataSource = carsRepository.ReadCars(); + comboBoxCar.DisplayMember = "Model"; + comboBoxCar.ValueMember = "Id"; + + comboBoxDriver.DataSource = driversRepository.ReadDrivers(); + comboBoxDriver.DisplayMember = "FirstName"; + comboBoxDriver.ValueMember = "Id"; + + comboBoxShift.DataSource = shiftRepository.ReadShifts(); + comboBoxShift.DisplayMember = "Description"; + comboBoxShift.ValueMember = "Id"; + + ColumnRoute.DataSource = routeRepository.ReadRoutes(); + ColumnRoute.DisplayMember = "Description"; + ColumnRoute.ValueMember = "Id"; + } + + private void ButtonSave_Click(object sender, EventArgs e) + { + try + { + if (dataGridViewRoutes.RowCount < 1 || + comboBoxCar.SelectedIndex < 0 || + comboBoxDriver.SelectedIndex < 0 || + comboBoxShift.SelectedIndex < 0) + { + throw new Exception("Имеются незаполненные поля"); + } + + _equipageRepository.CreateEquipage(Equipage.CreateOperation(0, + (int)comboBoxCar.SelectedValue!, (int)comboBoxDriver.SelectedValue!, + (int)comboBoxShift.SelectedValue!, CreateListRoutesEquipageFromDataGrid())); + + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonCancel_Click(object sender, EventArgs e) => Close(); + + private List CreateListRoutesEquipageFromDataGrid() + { + var list = new List(); + foreach (DataGridViewRow row in dataGridViewRoutes.Rows) + { + if (row.Cells["ColumnRoute"].Value == null || row.Cells["ColumnCount"].Value == null) + { + continue; + } + + list.Add(RoutesEqipage.CreateElement(0, Convert.ToInt32(row.Cells["ColumnRoute"].Value), + Convert.ToInt32(row.Cells["ColumnCount"].Value))); + } + + return list; + } + } +} diff --git a/FuelAccounting/FuelAccounting/Forms/FormEquipage.resx b/FuelAccounting/FuelAccounting/Forms/FormEquipage.resx new file mode 100644 index 0000000..daf8f5d --- /dev/null +++ b/FuelAccounting/FuelAccounting/Forms/FormEquipage.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/FuelAccounting/FuelAccounting/Forms/FormEquipages.Designer.cs b/FuelAccounting/FuelAccounting/Forms/FormEquipages.Designer.cs new file mode 100644 index 0000000..ace13f1 --- /dev/null +++ b/FuelAccounting/FuelAccounting/Forms/FormEquipages.Designer.cs @@ -0,0 +1,110 @@ +namespace FuelAccounting.Forms +{ + partial class FormEquipages + { + /// + /// 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() + { + dataGridViewData = new DataGridView(); + panelButtons = new Panel(); + buttonAdd = new Button(); + buttonDelete = new Button(); + ((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit(); + panelButtons.SuspendLayout(); + SuspendLayout(); + // + // dataGridViewData + // + dataGridViewData.AllowUserToAddRows = false; + dataGridViewData.AllowUserToDeleteRows = false; + dataGridViewData.AllowUserToResizeRows = false; + dataGridViewData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewData.Dock = DockStyle.Fill; + dataGridViewData.Location = new Point(0, 0); + dataGridViewData.MultiSelect = false; + dataGridViewData.Name = "dataGridViewData"; + dataGridViewData.ReadOnly = true; + dataGridViewData.RowHeadersVisible = false; + dataGridViewData.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridViewData.Size = new Size(640, 450); + dataGridViewData.TabIndex = 11; + // + // panelButtons + // + panelButtons.Controls.Add(buttonDelete); + panelButtons.Controls.Add(buttonAdd); + panelButtons.Dock = DockStyle.Right; + panelButtons.Location = new Point(640, 0); + panelButtons.Name = "panelButtons"; + panelButtons.Size = new Size(160, 450); + panelButtons.TabIndex = 10; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.pngimg_com___plus_PNG84; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(18, 12); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(130, 130); + buttonAdd.TabIndex = 2; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += ButtonAdd_Click; + // + // buttonDelete + // + buttonDelete.BackgroundImage = Properties.Resources.images; + buttonDelete.BackgroundImageLayout = ImageLayout.Stretch; + buttonDelete.Location = new Point(15, 160); + buttonDelete.Name = "buttonDelete"; + buttonDelete.Size = new Size(130, 130); + buttonDelete.TabIndex = 5; + buttonDelete.UseVisualStyleBackColor = true; + buttonDelete.Click += ButtonDelete_Click; + // + // FormEquipages + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(800, 450); + Controls.Add(dataGridViewData); + Controls.Add(panelButtons); + Name = "FormEquipages"; + Text = "Выезды"; + Load += FormEquipages_Load; + ((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit(); + panelButtons.ResumeLayout(false); + ResumeLayout(false); + } + + #endregion + + private DataGridView dataGridViewData; + private Panel panelButtons; + private Button buttonAdd; + private Button buttonDelete; + } +} \ No newline at end of file diff --git a/FuelAccounting/FuelAccounting/Forms/FormEquipages.cs b/FuelAccounting/FuelAccounting/Forms/FormEquipages.cs new file mode 100644 index 0000000..161d777 --- /dev/null +++ b/FuelAccounting/FuelAccounting/Forms/FormEquipages.cs @@ -0,0 +1,93 @@ +using FuelAccounting.Repositories; +using FuelAccounting.Repositories.Implementations; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using Unity; + +namespace FuelAccounting.Forms +{ + public partial class FormEquipages : Form + { + private readonly IUnityContainer _container; + + private readonly IEquipageRepository _equipageRepository; + + public FormEquipages(IUnityContainer container, IEquipageRepository equipageRepository) + { + InitializeComponent(); + _container = container ?? + throw new ArgumentNullException(nameof(container)); + _equipageRepository = equipageRepository ?? + throw new ArgumentNullException(nameof(equipageRepository)); + } + + private void FormEquipages_Load(object sender, EventArgs e) + { + try + { + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonAdd_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void LoadList() => dataGridViewData.DataSource = _equipageRepository.ReadEquipages(); + + private void ButtonDelete_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromSelectedRow(out var findId)) + { + return; + } + if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes) + { + return; + } + try + { + _equipageRepository.DeleteEquipage(findId); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при удалении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private bool TryGetIdentifierFromSelectedRow(out int id) + { + id = 0; + if (dataGridViewData.SelectedRows.Count < 1) + { + MessageBox.Show("Нет выбранной записи", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + id = Convert.ToInt32(dataGridViewData.SelectedRows[0].Cells["Id"].Value); + return true; + } + } +} diff --git a/FuelAccounting/FuelAccounting/Forms/FormEquipages.resx b/FuelAccounting/FuelAccounting/Forms/FormEquipages.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/FuelAccounting/FuelAccounting/Forms/FormEquipages.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/FuelAccounting/FuelAccounting/Forms/FormRefueling.Designer.cs b/FuelAccounting/FuelAccounting/Forms/FormRefueling.Designer.cs new file mode 100644 index 0000000..9341c02 --- /dev/null +++ b/FuelAccounting/FuelAccounting/Forms/FormRefueling.Designer.cs @@ -0,0 +1,172 @@ +namespace FuelAccounting.Forms +{ + partial class FormRefueling + { + /// + /// 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(); + comboBoxCar = new ComboBox(); + numericUpDownKm = new NumericUpDown(); + numericUpDownLiters = new NumericUpDown(); + textBoxTypeOfFuel = new TextBox(); + buttonCancel = new Button(); + buttonSave = new Button(); + ((System.ComponentModel.ISupportInitialize)numericUpDownKm).BeginInit(); + ((System.ComponentModel.ISupportInitialize)numericUpDownLiters).BeginInit(); + SuspendLayout(); + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(12, 19); + label1.Name = "label1"; + label1.Size = new Size(76, 15); + label1.TabIndex = 0; + label1.Text = "Автомобиль"; + // + // label2 + // + label2.AutoSize = true; + label2.Location = new Point(12, 53); + label2.Name = "label2"; + label2.Size = new Size(23, 15); + label2.TabIndex = 1; + label2.Text = "Км"; + // + // label3 + // + label3.AutoSize = true; + label3.Location = new Point(12, 90); + label3.Name = "label3"; + label3.Size = new Size(88, 15); + label3.TabIndex = 2; + label3.Text = "Кол-во литров"; + // + // label4 + // + label4.AutoSize = true; + label4.Location = new Point(12, 126); + label4.Name = "label4"; + label4.Size = new Size(75, 15); + label4.TabIndex = 3; + label4.Text = "Тип топлива"; + // + // comboBoxCar + // + comboBoxCar.FormattingEnabled = true; + comboBoxCar.Location = new Point(115, 16); + comboBoxCar.Name = "comboBoxCar"; + comboBoxCar.Size = new Size(146, 23); + comboBoxCar.TabIndex = 4; + // + // numericUpDownKm + // + numericUpDownKm.Location = new Point(115, 51); + numericUpDownKm.Maximum = new decimal(new int[] { 1000000, 0, 0, 0 }); + numericUpDownKm.Minimum = new decimal(new int[] { 1, 0, 0, 0 }); + numericUpDownKm.Name = "numericUpDownKm"; + numericUpDownKm.Size = new Size(146, 23); + numericUpDownKm.TabIndex = 5; + numericUpDownKm.Value = new decimal(new int[] { 1, 0, 0, 0 }); + // + // numericUpDownLiters + // + numericUpDownLiters.Location = new Point(115, 88); + numericUpDownLiters.Maximum = new decimal(new int[] { 1500, 0, 0, 0 }); + numericUpDownLiters.Minimum = new decimal(new int[] { 1, 0, 0, 0 }); + numericUpDownLiters.Name = "numericUpDownLiters"; + numericUpDownLiters.Size = new Size(146, 23); + numericUpDownLiters.TabIndex = 6; + numericUpDownLiters.Value = new decimal(new int[] { 1, 0, 0, 0 }); + // + // textBoxTypeOfFuel + // + textBoxTypeOfFuel.Location = new Point(115, 123); + textBoxTypeOfFuel.Name = "textBoxTypeOfFuel"; + textBoxTypeOfFuel.Size = new Size(146, 23); + textBoxTypeOfFuel.TabIndex = 7; + // + // buttonCancel + // + buttonCancel.Location = new Point(153, 164); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(108, 38); + buttonCancel.TabIndex = 11; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += buttonCancel_Click; + // + // buttonSave + // + buttonSave.Location = new Point(12, 164); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(108, 38); + buttonSave.TabIndex = 10; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += buttonSave_Click; + // + // FormRefueling + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(279, 218); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(textBoxTypeOfFuel); + Controls.Add(numericUpDownLiters); + Controls.Add(numericUpDownKm); + Controls.Add(comboBoxCar); + Controls.Add(label4); + Controls.Add(label3); + Controls.Add(label2); + Controls.Add(label1); + Name = "FormRefueling"; + Text = "FormRefueling"; + ((System.ComponentModel.ISupportInitialize)numericUpDownKm).EndInit(); + ((System.ComponentModel.ISupportInitialize)numericUpDownLiters).EndInit(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label label1; + private Label label2; + private Label label3; + private Label label4; + private ComboBox comboBoxCar; + private NumericUpDown numericUpDownKm; + private NumericUpDown numericUpDownLiters; + private TextBox textBoxTypeOfFuel; + private Button buttonCancel; + private Button buttonSave; + } +} \ No newline at end of file diff --git a/FuelAccounting/FuelAccounting/Forms/FormRefueling.cs b/FuelAccounting/FuelAccounting/Forms/FormRefueling.cs new file mode 100644 index 0000000..f8f6b4b --- /dev/null +++ b/FuelAccounting/FuelAccounting/Forms/FormRefueling.cs @@ -0,0 +1,53 @@ +using FuelAccounting.Entities; +using FuelAccounting.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 FuelAccounting.Forms +{ + public partial class FormRefueling : Form + { + private readonly IRefuelingRepository _refuelingRepository; + + public FormRefueling(IRefuelingRepository refuelingRepository, ICarsRepository carsRepository) + { + InitializeComponent(); + _refuelingRepository = refuelingRepository ?? + throw new ArgumentNullException(nameof(refuelingRepository)); + + comboBoxCar.DataSource = carsRepository.ReadCars(); + comboBoxCar.DisplayMember = "Model"; + comboBoxCar.ValueMember = "Id"; + } + + private void buttonSave_Click(object sender, EventArgs e) + { + try + { + if (comboBoxCar.SelectedIndex < 0 || + string.IsNullOrWhiteSpace(textBoxTypeOfFuel.Text)) + { + throw new Exception("Имеются незаполненные поля"); + } + + _refuelingRepository.CreateRefueling(Refueling.CreateOperation(0, (int)comboBoxCar.SelectedValue!, + Convert.ToDouble(numericUpDownKm), Convert.ToDouble(numericUpDownLiters), textBoxTypeOfFuel.Text)); + + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void buttonCancel_Click(object sender, EventArgs e) => Close(); + } +} diff --git a/FuelAccounting/FuelAccounting/Forms/FormRefueling.resx b/FuelAccounting/FuelAccounting/Forms/FormRefueling.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/FuelAccounting/FuelAccounting/Forms/FormRefueling.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/FuelAccounting/FuelAccounting/Forms/FormRefuelings.Designer.cs b/FuelAccounting/FuelAccounting/Forms/FormRefuelings.Designer.cs new file mode 100644 index 0000000..d998f5b --- /dev/null +++ b/FuelAccounting/FuelAccounting/Forms/FormRefuelings.Designer.cs @@ -0,0 +1,96 @@ +namespace FuelAccounting.Forms +{ + partial class FormRefuelings + { + /// + /// 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() + { + buttonAdd = new Button(); + dataGridViewData = new DataGridView(); + panelButtons = new Panel(); + ((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit(); + panelButtons.SuspendLayout(); + SuspendLayout(); + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.pngimg_com___plus_PNG84; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(18, 12); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(130, 130); + buttonAdd.TabIndex = 2; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += buttonAdd_Click; + // + // dataGridViewData + // + dataGridViewData.AllowUserToAddRows = false; + dataGridViewData.AllowUserToDeleteRows = false; + dataGridViewData.AllowUserToResizeRows = false; + dataGridViewData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewData.Dock = DockStyle.Fill; + dataGridViewData.Location = new Point(0, 0); + dataGridViewData.MultiSelect = false; + dataGridViewData.Name = "dataGridViewData"; + dataGridViewData.ReadOnly = true; + dataGridViewData.RowHeadersVisible = false; + dataGridViewData.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridViewData.Size = new Size(640, 450); + dataGridViewData.TabIndex = 9; + // + // panelButtons + // + panelButtons.Controls.Add(buttonAdd); + panelButtons.Dock = DockStyle.Right; + panelButtons.Location = new Point(640, 0); + panelButtons.Name = "panelButtons"; + panelButtons.Size = new Size(160, 450); + panelButtons.TabIndex = 8; + // + // FormRefuelings + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(800, 450); + Controls.Add(dataGridViewData); + Controls.Add(panelButtons); + Name = "FormRefuelings"; + Text = "Заправки"; + Load += FormRefuelings_Load; + ((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit(); + panelButtons.ResumeLayout(false); + ResumeLayout(false); + } + + #endregion + + private Button buttonAdd; + private DataGridView dataGridViewData; + private Panel panelButtons; + } +} \ No newline at end of file diff --git a/FuelAccounting/FuelAccounting/Forms/FormRefuelings.cs b/FuelAccounting/FuelAccounting/Forms/FormRefuelings.cs new file mode 100644 index 0000000..3426de7 --- /dev/null +++ b/FuelAccounting/FuelAccounting/Forms/FormRefuelings.cs @@ -0,0 +1,58 @@ +using FuelAccounting.Repositories; +using FuelAccounting.Repositories.Implementations; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using Unity; + +namespace FuelAccounting.Forms +{ + public partial class FormRefuelings : Form + { + private readonly IUnityContainer _container; + + private readonly IRefuelingRepository _refuelingRepository; + + public FormRefuelings(IUnityContainer container, IRefuelingRepository refuelingRepository) + { + InitializeComponent(); + _container = container ?? + throw new ArgumentNullException(nameof(container)); + _refuelingRepository = refuelingRepository ?? + throw new ArgumentNullException(nameof(refuelingRepository)); + } + + private void FormRefuelings_Load(object sender, EventArgs e) + { + try + { + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void buttonAdd_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void LoadList() => dataGridViewData.DataSource = _refuelingRepository.ReadRefuelings(); + } +} diff --git a/FuelAccounting/FuelAccounting/Forms/FormRefuelings.resx b/FuelAccounting/FuelAccounting/Forms/FormRefuelings.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/FuelAccounting/FuelAccounting/Forms/FormRefuelings.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/FuelAccounting/FuelAccounting/Forms/FormRoute.Designer.cs b/FuelAccounting/FuelAccounting/Forms/FormRoute.Designer.cs new file mode 100644 index 0000000..e3e2123 --- /dev/null +++ b/FuelAccounting/FuelAccounting/Forms/FormRoute.Designer.cs @@ -0,0 +1,97 @@ +namespace FuelAccounting.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() + { + Descriptoin = new Label(); + textBoxDescription = new TextBox(); + buttonCancel = new Button(); + buttonSave = new Button(); + SuspendLayout(); + // + // Descriptoin + // + Descriptoin.AutoSize = true; + Descriptoin.Location = new Point(12, 9); + Descriptoin.Name = "Descriptoin"; + Descriptoin.Size = new Size(125, 15); + Descriptoin.TabIndex = 0; + Descriptoin.Text = "Описание маршрута:"; + // + // textBoxDescription + // + textBoxDescription.Location = new Point(12, 42); + textBoxDescription.Multiline = true; + textBoxDescription.Name = "textBoxDescription"; + textBoxDescription.Size = new Size(308, 77); + textBoxDescription.TabIndex = 1; + // + // buttonCancel + // + buttonCancel.Location = new Point(210, 135); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(108, 38); + buttonCancel.TabIndex = 7; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += ButtonCancel_Click; + // + // buttonSave + // + buttonSave.Location = new Point(12, 135); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(108, 38); + buttonSave.TabIndex = 6; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += ButtonSave_Click; + // + // FormRoute + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(332, 187); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(textBoxDescription); + Controls.Add(Descriptoin); + Name = "FormRoute"; + StartPosition = FormStartPosition.CenterScreen; + Text = "Маршрут"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label Descriptoin; + private TextBox textBoxDescription; + private Button buttonCancel; + private Button buttonSave; + } +} \ No newline at end of file diff --git a/FuelAccounting/FuelAccounting/Forms/FormRoute.cs b/FuelAccounting/FuelAccounting/Forms/FormRoute.cs new file mode 100644 index 0000000..76a5d8f --- /dev/null +++ b/FuelAccounting/FuelAccounting/Forms/FormRoute.cs @@ -0,0 +1,81 @@ +using FuelAccounting.Entities; +using FuelAccounting.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 FuelAccounting.Forms +{ + public partial class FormRoute : Form + { + private readonly IRouteRepository _routeRepository; + + private int? _routeId; + + public int Id + { + set + { + try + { + var route = _routeRepository.ReadRouteById(value); + if (route == null) + { + throw new InvalidDataException(nameof(route)); + } + + textBoxDescription.Text = route.Description; + _routeId = value; + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + } + } + + public FormRoute(IRouteRepository routeRepository) + { + InitializeComponent(); + _routeRepository = routeRepository ?? + throw new ArgumentNullException(nameof(routeRepository)); + } + + private void ButtonSave_Click(object sender, EventArgs e) + { + try + { + if (string.IsNullOrWhiteSpace(textBoxDescription.Text)) + { + throw new Exception("Незаполненное поле!"); + } + + if (_routeId.HasValue) + { + _routeRepository.UpdateRoute(CreateRoute(_routeId.Value)); + } + else + { + _routeRepository.CreateRoute(CreateRoute(0)); + } + + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonCancel_Click(object sender, EventArgs e) => Close(); + + private Route CreateRoute(int id) => Route.CreateEntity(id, textBoxDescription.Text); + } +} diff --git a/FuelAccounting/FuelAccounting/Forms/FormRoute.resx b/FuelAccounting/FuelAccounting/Forms/FormRoute.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/FuelAccounting/FuelAccounting/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/FuelAccounting/FuelAccounting/Forms/FormRoutes.Designer.cs b/FuelAccounting/FuelAccounting/Forms/FormRoutes.Designer.cs new file mode 100644 index 0000000..8fa0409 --- /dev/null +++ b/FuelAccounting/FuelAccounting/Forms/FormRoutes.Designer.cs @@ -0,0 +1,125 @@ +namespace FuelAccounting.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() + { + panelButtons = new Panel(); + buttonDelete = new Button(); + buttonUpdate = new Button(); + buttonAdd = new Button(); + dataGridViewData = new DataGridView(); + panelButtons.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit(); + SuspendLayout(); + // + // panelButtons + // + panelButtons.Controls.Add(buttonDelete); + panelButtons.Controls.Add(buttonUpdate); + panelButtons.Controls.Add(buttonAdd); + panelButtons.Dock = DockStyle.Right; + panelButtons.Location = new Point(640, 0); + panelButtons.Name = "panelButtons"; + panelButtons.Size = new Size(160, 450); + panelButtons.TabIndex = 0; + // + // buttonDelete + // + buttonDelete.BackgroundImage = Properties.Resources.images; + buttonDelete.BackgroundImageLayout = ImageLayout.Stretch; + buttonDelete.Location = new Point(18, 308); + buttonDelete.Name = "buttonDelete"; + buttonDelete.Size = new Size(130, 130); + buttonDelete.TabIndex = 4; + buttonDelete.UseVisualStyleBackColor = true; + buttonDelete.Click += buttonDelete_Click; + // + // buttonUpdate + // + buttonUpdate.BackgroundImage = Properties.Resources._73c1e0a4_66bb_443c_a632_108fa967fec1; + buttonUpdate.BackgroundImageLayout = ImageLayout.Stretch; + buttonUpdate.Location = new Point(18, 160); + buttonUpdate.Name = "buttonUpdate"; + buttonUpdate.Size = new Size(130, 130); + buttonUpdate.TabIndex = 3; + buttonUpdate.UseVisualStyleBackColor = true; + buttonUpdate.Click += buttonUpdate_Click; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.pngimg_com___plus_PNG84; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(18, 12); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(130, 130); + buttonAdd.TabIndex = 2; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += buttonAdd_Click; + // + // dataGridViewData + // + dataGridViewData.AllowUserToAddRows = false; + dataGridViewData.AllowUserToDeleteRows = false; + dataGridViewData.AllowUserToResizeRows = false; + dataGridViewData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewData.Dock = DockStyle.Fill; + dataGridViewData.Location = new Point(0, 0); + dataGridViewData.MultiSelect = false; + dataGridViewData.Name = "dataGridViewData"; + dataGridViewData.ReadOnly = true; + dataGridViewData.RowHeadersVisible = false; + dataGridViewData.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridViewData.Size = new Size(640, 450); + dataGridViewData.TabIndex = 1; + // + // FormRoutes + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(800, 450); + Controls.Add(dataGridViewData); + Controls.Add(panelButtons); + Name = "FormRoutes"; + StartPosition = FormStartPosition.CenterScreen; + Text = "Маршруты"; + Load += FormRoutes_Load; + panelButtons.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit(); + ResumeLayout(false); + } + + #endregion + + private Panel panelButtons; + private Button buttonDelete; + private Button buttonUpdate; + private Button buttonAdd; + private DataGridView dataGridViewData; + } +} \ No newline at end of file diff --git a/FuelAccounting/FuelAccounting/Forms/FormRoutes.cs b/FuelAccounting/FuelAccounting/Forms/FormRoutes.cs new file mode 100644 index 0000000..89e625a --- /dev/null +++ b/FuelAccounting/FuelAccounting/Forms/FormRoutes.cs @@ -0,0 +1,111 @@ +using FuelAccounting.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 FuelAccounting.Forms +{ + public partial class FormRoutes : Form + { + private readonly IUnityContainer _container; + + private readonly IRouteRepository _routeRepository; + + public FormRoutes(IUnityContainer container, IRouteRepository routeRepository) + { + InitializeComponent(); + _container = container ?? throw new ArgumentNullException(nameof(container)); + _routeRepository = routeRepository ?? throw new ArgumentNullException(nameof(routeRepository)); + } + + private void FormRoutes_Load(object sender, EventArgs e) + { + try + { + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void buttonAdd_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void buttonUpdate_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 buttonDelete_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromSelectedRow(out var findId)) + { + return; + } + + if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes) + { + return; + } + + try + { + _routeRepository.DeleteRoute(findId); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void LoadList() => dataGridViewData.DataSource = _routeRepository.ReadRoutes(); + + private bool TryGetIdentifierFromSelectedRow(out int id) + { + id = 0; + if (dataGridViewData.SelectedRows.Count < 1) + { + MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + + id = Convert.ToInt32(dataGridViewData.SelectedRows[0].Cells["Id"].Value); + return true; + } + } +} diff --git a/FuelAccounting/FuelAccounting/Forms/FormRoutes.resx b/FuelAccounting/FuelAccounting/Forms/FormRoutes.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/FuelAccounting/FuelAccounting/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/FuelAccounting/FuelAccounting/Forms/FormShift.Designer.cs b/FuelAccounting/FuelAccounting/Forms/FormShift.Designer.cs new file mode 100644 index 0000000..473b196 --- /dev/null +++ b/FuelAccounting/FuelAccounting/Forms/FormShift.Designer.cs @@ -0,0 +1,123 @@ +namespace FuelAccounting.Forms +{ + partial class FormShift + { + /// + /// 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() + { + AmountOfHours = new Label(); + numericUpDownHours = new NumericUpDown(); + label1 = new Label(); + textBoxDescription = new TextBox(); + buttonSave = new Button(); + buttonCancel = new Button(); + ((System.ComponentModel.ISupportInitialize)numericUpDownHours).BeginInit(); + SuspendLayout(); + // + // AmountOfHours + // + AmountOfHours.AutoSize = true; + AmountOfHours.Location = new Point(12, 19); + AmountOfHours.Name = "AmountOfHours"; + AmountOfHours.Size = new Size(101, 15); + AmountOfHours.TabIndex = 0; + AmountOfHours.Text = "Количетво часов"; + // + // numericUpDownHours + // + numericUpDownHours.Location = new Point(136, 17); + numericUpDownHours.Maximum = new decimal(new int[] { 16, 0, 0, 0 }); + numericUpDownHours.Minimum = new decimal(new int[] { 2, 0, 0, 0 }); + numericUpDownHours.Name = "numericUpDownHours"; + numericUpDownHours.Size = new Size(120, 23); + numericUpDownHours.TabIndex = 1; + numericUpDownHours.Value = new decimal(new int[] { 2, 0, 0, 0 }); + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(12, 55); + label1.Name = "label1"; + label1.Size = new Size(108, 15); + label1.TabIndex = 2; + label1.Text = "Описание смены: "; + // + // textBoxDescription + // + textBoxDescription.Location = new Point(136, 52); + textBoxDescription.Name = "textBoxDescription"; + textBoxDescription.Size = new Size(162, 23); + textBoxDescription.TabIndex = 3; + // + // buttonSave + // + buttonSave.Location = new Point(12, 86); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(108, 38); + buttonSave.TabIndex = 4; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += this.ButtonSave_Click; + // + // buttonCancel + // + buttonCancel.Location = new Point(210, 86); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(108, 38); + buttonCancel.TabIndex = 5; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += ButtonCancel_Click; + // + // FormShift + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(330, 136); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(textBoxDescription); + Controls.Add(label1); + Controls.Add(numericUpDownHours); + Controls.Add(AmountOfHours); + Name = "FormShift"; + StartPosition = FormStartPosition.CenterScreen; + Text = "Смена"; + ((System.ComponentModel.ISupportInitialize)numericUpDownHours).EndInit(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label AmountOfHours; + private NumericUpDown numericUpDownHours; + private Label label1; + private TextBox textBoxDescription; + private Button buttonSave; + private Button buttonCancel; + } +} \ No newline at end of file diff --git a/FuelAccounting/FuelAccounting/Forms/FormShift.cs b/FuelAccounting/FuelAccounting/Forms/FormShift.cs new file mode 100644 index 0000000..2c1a5d4 --- /dev/null +++ b/FuelAccounting/FuelAccounting/Forms/FormShift.cs @@ -0,0 +1,83 @@ +using FuelAccounting.Entities; +using FuelAccounting.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 FuelAccounting.Forms +{ + public partial class FormShift : Form + { + private readonly IShiftRepository _shiftRepository; + + private int? _shiftId; + + public int Id + { + set + { + try + { + var shift = _shiftRepository.ReadShiftById(value); + if (shift == null) + { + throw new InvalidDataException(nameof(Route)); + } + + textBoxDescription.Text = shift.Description; + numericUpDownHours.Value = shift.AmountOfHours; + _shiftId = value; + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + } + } + + public FormShift(IShiftRepository shiftRepository) + { + InitializeComponent(); + _shiftRepository = shiftRepository ?? + throw new ArgumentNullException(nameof(shiftRepository)); ; + } + + private void ButtonSave_Click(object sender, EventArgs e) + { + try + { + if (string.IsNullOrWhiteSpace(textBoxDescription.Text)) + { + throw new Exception("Незаполненное поле!"); + } + + if (_shiftId.HasValue) + { + _shiftRepository.UpdateShift(CreateShift(_shiftId.Value)); + } + else + { + _shiftRepository.CreateShift(CreateShift(0)); + } + + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonCancel_Click(object sender, EventArgs e) => Close(); + + private Shift CreateShift(int id) => Shift.CreateEntity(id, Convert.ToInt32(numericUpDownHours.Value), + textBoxDescription.Text); + } +} diff --git a/FuelAccounting/FuelAccounting/Forms/FormShift.resx b/FuelAccounting/FuelAccounting/Forms/FormShift.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/FuelAccounting/FuelAccounting/Forms/FormShift.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/FuelAccounting/FuelAccounting/Forms/FormShifts.Designer.cs b/FuelAccounting/FuelAccounting/Forms/FormShifts.Designer.cs new file mode 100644 index 0000000..151e14d --- /dev/null +++ b/FuelAccounting/FuelAccounting/Forms/FormShifts.Designer.cs @@ -0,0 +1,124 @@ +namespace FuelAccounting.Forms +{ + partial class FormShifts + { + /// + /// 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() + { + dataGridViewData = new DataGridView(); + panelButtons = new Panel(); + buttonDelete = new Button(); + buttonUpdate = new Button(); + buttonAdd = new Button(); + ((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit(); + panelButtons.SuspendLayout(); + SuspendLayout(); + // + // dataGridViewData + // + dataGridViewData.AllowUserToAddRows = false; + dataGridViewData.AllowUserToDeleteRows = false; + dataGridViewData.AllowUserToResizeRows = false; + dataGridViewData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewData.Dock = DockStyle.Fill; + dataGridViewData.Location = new Point(0, 0); + dataGridViewData.MultiSelect = false; + dataGridViewData.Name = "dataGridViewData"; + dataGridViewData.ReadOnly = true; + dataGridViewData.RowHeadersVisible = false; + dataGridViewData.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridViewData.Size = new Size(640, 450); + dataGridViewData.TabIndex = 3; + // + // panelButtons + // + panelButtons.Controls.Add(buttonDelete); + panelButtons.Controls.Add(buttonUpdate); + panelButtons.Controls.Add(buttonAdd); + panelButtons.Dock = DockStyle.Right; + panelButtons.Location = new Point(640, 0); + panelButtons.Name = "panelButtons"; + panelButtons.Size = new Size(160, 450); + panelButtons.TabIndex = 2; + // + // buttonDelete + // + buttonDelete.BackgroundImage = Properties.Resources.images; + buttonDelete.BackgroundImageLayout = ImageLayout.Stretch; + buttonDelete.Location = new Point(18, 308); + buttonDelete.Name = "buttonDelete"; + buttonDelete.Size = new Size(130, 130); + buttonDelete.TabIndex = 4; + buttonDelete.UseVisualStyleBackColor = true; + buttonDelete.Click += ButtonDelete_Click; + // + // buttonUpdate + // + buttonUpdate.BackgroundImage = Properties.Resources._73c1e0a4_66bb_443c_a632_108fa967fec1; + buttonUpdate.BackgroundImageLayout = ImageLayout.Stretch; + buttonUpdate.Location = new Point(18, 160); + buttonUpdate.Name = "buttonUpdate"; + buttonUpdate.Size = new Size(130, 130); + buttonUpdate.TabIndex = 3; + buttonUpdate.UseVisualStyleBackColor = true; + buttonUpdate.Click += ButtonUpdate_Click; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.pngimg_com___plus_PNG84; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(18, 12); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(130, 130); + buttonAdd.TabIndex = 2; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += ButtonAdd_Click; + // + // FormShifts + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(800, 450); + Controls.Add(dataGridViewData); + Controls.Add(panelButtons); + Name = "FormShifts"; + Text = "Смены"; + Load += FormShifts_Load; + ((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit(); + panelButtons.ResumeLayout(false); + ResumeLayout(false); + } + + #endregion + + private DataGridView dataGridViewData; + private Panel panelButtons; + private Button buttonDelete; + private Button buttonUpdate; + private Button buttonAdd; + } +} \ No newline at end of file diff --git a/FuelAccounting/FuelAccounting/Forms/FormShifts.cs b/FuelAccounting/FuelAccounting/Forms/FormShifts.cs new file mode 100644 index 0000000..d488f3a --- /dev/null +++ b/FuelAccounting/FuelAccounting/Forms/FormShifts.cs @@ -0,0 +1,103 @@ +using FuelAccounting.Repositories; +using Unity; + +namespace FuelAccounting.Forms +{ + public partial class FormShifts : Form + { + private readonly IUnityContainer _container; + + private readonly IShiftRepository _shiftRepository; + + public FormShifts(IUnityContainer container, IShiftRepository shiftRepository) + { + InitializeComponent(); + _container = container ?? throw new ArgumentNullException(nameof(container)); + _shiftRepository = shiftRepository ?? throw new ArgumentNullException(nameof(shiftRepository)); + + } + + private void FormShifts_Load(object sender, EventArgs e) + { + try + { + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonAdd_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonUpdate_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 ButtonDelete_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromSelectedRow(out var findId)) + { + return; + } + + if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes) + { + return; + } + + try + { + _shiftRepository.DeleteShift(findId); + LoadList(); + } + catch(Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void LoadList() => dataGridViewData.DataSource = _shiftRepository.ReadShifts(); + + private bool TryGetIdentifierFromSelectedRow(out int id) + { + id = 0; + if (dataGridViewData.SelectedRows.Count < 1) + { + MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + + id = Convert.ToInt32(dataGridViewData.SelectedRows[0].Cells["Id"].Value); + return true; + } + } +} diff --git a/FuelAccounting/FuelAccounting/Forms/FormShifts.resx b/FuelAccounting/FuelAccounting/Forms/FormShifts.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/FuelAccounting/FuelAccounting/Forms/FormShifts.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/FuelAccounting/FuelAccounting/FuelAccounting.csproj b/FuelAccounting/FuelAccounting/FuelAccounting.csproj new file mode 100644 index 0000000..accbdf0 --- /dev/null +++ b/FuelAccounting/FuelAccounting/FuelAccounting.csproj @@ -0,0 +1,30 @@ + + + + WinExe + net8.0-windows + enable + true + enable + + + + + + + + + True + True + Resources.resx + + + + + + ResXFileCodeGenerator + Resources.Designer.cs + + + + \ No newline at end of file diff --git a/FuelAccounting/FuelAccounting/Program.cs b/FuelAccounting/FuelAccounting/Program.cs new file mode 100644 index 0000000..ae085e0 --- /dev/null +++ b/FuelAccounting/FuelAccounting/Program.cs @@ -0,0 +1,35 @@ +using FuelAccounting.Repositories; +using FuelAccounting.Repositories.Implementations; +using Unity; +using Unity.Lifetime; + +namespace FuelAccounting; + +internal static class Program +{ + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + // To customize application configuration such as set high DPI settings or default font, + // see https://aka.ms/applicationconfiguration. + ApplicationConfiguration.Initialize(); + Application.Run(CreateContainer().Resolve()); + } + + private static IUnityContainer CreateContainer() + { + var container = new UnityContainer(); + + container.RegisterType(new TransientLifetimeManager()); + container.RegisterType(new TransientLifetimeManager()); + container.RegisterType(new TransientLifetimeManager()); + container.RegisterType(new TransientLifetimeManager()); + container.RegisterType(new TransientLifetimeManager()); + container.RegisterType(new TransientLifetimeManager()); + + return container; + } +} \ No newline at end of file diff --git a/FuelAccounting/FuelAccounting/Properties/Resources.Designer.cs b/FuelAccounting/FuelAccounting/Properties/Resources.Designer.cs new file mode 100644 index 0000000..261c0cc --- /dev/null +++ b/FuelAccounting/FuelAccounting/Properties/Resources.Designer.cs @@ -0,0 +1,144 @@ +//------------------------------------------------------------------------------ +// +// Этот код создан программой. +// Исполняемая версия:4.0.30319.42000 +// +// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае +// повторной генерации кода. +// +//------------------------------------------------------------------------------ + +namespace FuelAccounting.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("FuelAccounting.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 _4298 { + get { + object obj = ResourceManager.GetObject("4298", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap _73c1e0a4_66bb_443c_a632_108fa967fec1 { + get { + object obj = ResourceManager.GetObject("73c1e0a4-66bb-443c-a632-108fa967fec1", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap Cancel { + get { + object obj = ResourceManager.GetObject("Cancel", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap images { + get { + object obj = ResourceManager.GetObject("images", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap png_clipart_plus_plus { + get { + object obj = ResourceManager.GetObject("png-clipart-plus-plus", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap png_clipart_plus_plus__1_ { + get { + object obj = ResourceManager.GetObject("png-clipart-plus-plus (1)", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap png_transparent_pencil_illustration_hand_painted_pencil_material_watercolor_painting_text_color_pencil { + get { + object obj = ResourceManager.GetObject("png-transparent-pencil-illustration-hand-painted-pencil-material-watercolor-paint" + + "ing-text-color-pencil", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap pngimg_com___plus_PNG84 { + get { + object obj = ResourceManager.GetObject("pngimg.com - plus_PNG84", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + } +} diff --git a/FuelAccounting/FuelAccounting/Properties/Resources.resx b/FuelAccounting/FuelAccounting/Properties/Resources.resx new file mode 100644 index 0000000..d11221e --- /dev/null +++ b/FuelAccounting/FuelAccounting/Properties/Resources.resx @@ -0,0 +1,145 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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\png-clipart-plus-plus.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\png-transparent-pencil-illustration-hand-painted-pencil-material-watercolor-painting-text-color-pencil.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\Cancel.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\pngimg.com - plus_PNG84.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\73c1e0a4-66bb-443c-a632-108fa967fec1.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\4298.jpeg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\png-clipart-plus-plus (1).png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\images.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + \ No newline at end of file diff --git a/FuelAccounting/FuelAccounting/Repositories/ICarsRepository.cs b/FuelAccounting/FuelAccounting/Repositories/ICarsRepository.cs new file mode 100644 index 0000000..1d2fe86 --- /dev/null +++ b/FuelAccounting/FuelAccounting/Repositories/ICarsRepository.cs @@ -0,0 +1,16 @@ +using FuelAccounting.Entities; + +namespace FuelAccounting.Repositories; + +public interface ICarsRepository +{ + IEnumerable ReadCars(); + + Car ReadCarById(int id); + + void CreateCar(Car car); + + void UpdateCar(Car car); + + void DeleteCar(int id); +} diff --git a/FuelAccounting/FuelAccounting/Repositories/IDriversRepository.cs b/FuelAccounting/FuelAccounting/Repositories/IDriversRepository.cs new file mode 100644 index 0000000..71411a8 --- /dev/null +++ b/FuelAccounting/FuelAccounting/Repositories/IDriversRepository.cs @@ -0,0 +1,16 @@ +using FuelAccounting.Entities; + +namespace FuelAccounting.Repositories; + +public interface IDriversRepository +{ + IEnumerable ReadDrivers(); + + Driver ReadDriverById(int id); + + void CreateDriver(Driver driver); + + void UpdateDriver(Driver driver); + + void DeleteDriver(int id); +} diff --git a/FuelAccounting/FuelAccounting/Repositories/IEquipageRepository.cs b/FuelAccounting/FuelAccounting/Repositories/IEquipageRepository.cs new file mode 100644 index 0000000..ea41169 --- /dev/null +++ b/FuelAccounting/FuelAccounting/Repositories/IEquipageRepository.cs @@ -0,0 +1,13 @@ +using FuelAccounting.Entities; + +namespace FuelAccounting.Repositories; + +public interface IEquipageRepository +{ + IEnumerable ReadEquipages(DateTime? dateForm = null, DateTime? dateTo = null, int? carId = null, + int? driverId = null, int? shiftId = null, int? routeId = null); + + void CreateEquipage(Equipage equipage); + + void DeleteEquipage(int id); +} diff --git a/FuelAccounting/FuelAccounting/Repositories/IRefuelingRepository.cs b/FuelAccounting/FuelAccounting/Repositories/IRefuelingRepository.cs new file mode 100644 index 0000000..8a362ee --- /dev/null +++ b/FuelAccounting/FuelAccounting/Repositories/IRefuelingRepository.cs @@ -0,0 +1,10 @@ +using FuelAccounting.Entities; + +namespace FuelAccounting.Repositories; + +public interface IRefuelingRepository +{ + IEnumerable ReadRefuelings(DateTime? dateForm = null, DateTime? dateTo = null, int? carId = null); + + void CreateRefueling (Refueling refueling); +} diff --git a/FuelAccounting/FuelAccounting/Repositories/IRouteRepository.cs b/FuelAccounting/FuelAccounting/Repositories/IRouteRepository.cs new file mode 100644 index 0000000..37a8827 --- /dev/null +++ b/FuelAccounting/FuelAccounting/Repositories/IRouteRepository.cs @@ -0,0 +1,16 @@ +using FuelAccounting.Entities; + +namespace FuelAccounting.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/FuelAccounting/FuelAccounting/Repositories/IShiftRepository.cs b/FuelAccounting/FuelAccounting/Repositories/IShiftRepository.cs new file mode 100644 index 0000000..ae71128 --- /dev/null +++ b/FuelAccounting/FuelAccounting/Repositories/IShiftRepository.cs @@ -0,0 +1,16 @@ +using FuelAccounting.Entities; + +namespace FuelAccounting.Repositories; + +public interface IShiftRepository +{ + IEnumerable ReadShifts(); + + Shift ReadShiftById(int id); + + void CreateShift(Shift shift); + + void UpdateShift(Shift shift); + + void DeleteShift(int id); +} diff --git a/FuelAccounting/FuelAccounting/Repositories/Implementations/CarRepository.cs b/FuelAccounting/FuelAccounting/Repositories/Implementations/CarRepository.cs new file mode 100644 index 0000000..8ad2c7e --- /dev/null +++ b/FuelAccounting/FuelAccounting/Repositories/Implementations/CarRepository.cs @@ -0,0 +1,29 @@ +using FuelAccounting.Entities; +using FuelAccounting.Entities.Enums; + +namespace FuelAccounting.Repositories.Implementations; + +internal class CarRepository : ICarsRepository +{ + public void CreateCar(Car car) + { + } + + public void DeleteCar(int id) + { + } + + public Car ReadCarById(int id) + { + return Car.CreateEntity(0, string.Empty, CarCategory.None, 0); + } + + public IEnumerable ReadCars() + { + return []; + } + + public void UpdateCar(Car car) + { + } +} diff --git a/FuelAccounting/FuelAccounting/Repositories/Implementations/DriverRepository.cs b/FuelAccounting/FuelAccounting/Repositories/Implementations/DriverRepository.cs new file mode 100644 index 0000000..0bbf6b0 --- /dev/null +++ b/FuelAccounting/FuelAccounting/Repositories/Implementations/DriverRepository.cs @@ -0,0 +1,29 @@ +using FuelAccounting.Entities; +using FuelAccounting.Entities.Enums; + +namespace FuelAccounting.Repositories.Implementations; + +internal class DriverRepository : IDriversRepository +{ + public void CreateDriver(Driver driver) + { + } + + public void DeleteDriver(int id) + { + } + + public Driver ReadDriverById(int id) + { + return Driver.CreateEntity(0, string.Empty, string.Empty, DriverLicenceCategory.None); + } + + public IEnumerable ReadDrivers() + { + return []; + } + + public void UpdateDriver(Driver driver) + { + } +} diff --git a/FuelAccounting/FuelAccounting/Repositories/Implementations/EquipageRepository.cs b/FuelAccounting/FuelAccounting/Repositories/Implementations/EquipageRepository.cs new file mode 100644 index 0000000..29051af --- /dev/null +++ b/FuelAccounting/FuelAccounting/Repositories/Implementations/EquipageRepository.cs @@ -0,0 +1,20 @@ +using FuelAccounting.Entities; + +namespace FuelAccounting.Repositories.Implementations; + +internal class EquipageRepository : IEquipageRepository +{ + public void CreateEquipage(Equipage equipage) + { + } + + public void DeleteEquipage(int id) + { + } + + public IEnumerable ReadEquipages(DateTime? dateForm = null, DateTime? dateTo = null, + int? carId = null, int? driverId = null, int? shiftId = null, int? routeId = null) + { + return []; + } +} diff --git a/FuelAccounting/FuelAccounting/Repositories/Implementations/RefuelingRepository.cs b/FuelAccounting/FuelAccounting/Repositories/Implementations/RefuelingRepository.cs new file mode 100644 index 0000000..56e7729 --- /dev/null +++ b/FuelAccounting/FuelAccounting/Repositories/Implementations/RefuelingRepository.cs @@ -0,0 +1,15 @@ +using FuelAccounting.Entities; + +namespace FuelAccounting.Repositories.Implementations; + +internal class RefuelingRepository : IRefuelingRepository +{ + public void CreateRefueling(Refueling refueling) + { + } + + public IEnumerable ReadRefuelings(DateTime? dateForm = null, DateTime? dateTo = null, int? carId = null) + { + return []; + } +} diff --git a/FuelAccounting/FuelAccounting/Repositories/Implementations/RouteRepository.cs b/FuelAccounting/FuelAccounting/Repositories/Implementations/RouteRepository.cs new file mode 100644 index 0000000..c03d03e --- /dev/null +++ b/FuelAccounting/FuelAccounting/Repositories/Implementations/RouteRepository.cs @@ -0,0 +1,28 @@ +using FuelAccounting.Entities; + +namespace FuelAccounting.Repositories.Implementations; + +internal class RouteRepository : IRouteRepository +{ + public void CreateRoute(Route route) + { + } + + public void DeleteRoute(int id) + { + } + + public Route ReadRouteById(int id) + { + return Route.CreateEntity(0, string.Empty); + } + + public IEnumerable ReadRoutes() + { + return []; + } + + public void UpdateRoute(Route route) + { + } +} diff --git a/FuelAccounting/FuelAccounting/Repositories/Implementations/ShiftRepository.cs b/FuelAccounting/FuelAccounting/Repositories/Implementations/ShiftRepository.cs new file mode 100644 index 0000000..ead7ac3 --- /dev/null +++ b/FuelAccounting/FuelAccounting/Repositories/Implementations/ShiftRepository.cs @@ -0,0 +1,28 @@ +using FuelAccounting.Entities; + +namespace FuelAccounting.Repositories.Implementations; + +internal class ShiftRepository : IShiftRepository +{ + public void CreateShift(Shift shift) + { + } + + public void DeleteShift(int id) + { + } + + public Shift ReadShiftById(int id) + { + return Shift.CreateEntity(0, 0, string.Empty); + } + + public IEnumerable ReadShifts() + { + return []; + } + + public void UpdateShift(Shift shift) + { + } +} diff --git a/FuelAccounting/FuelAccounting/Resources/4298.jpeg b/FuelAccounting/FuelAccounting/Resources/4298.jpeg new file mode 100644 index 0000000..d1e4146 Binary files /dev/null and b/FuelAccounting/FuelAccounting/Resources/4298.jpeg differ diff --git a/FuelAccounting/FuelAccounting/Resources/73c1e0a4-66bb-443c-a632-108fa967fec1.jpg b/FuelAccounting/FuelAccounting/Resources/73c1e0a4-66bb-443c-a632-108fa967fec1.jpg new file mode 100644 index 0000000..ab2a986 Binary files /dev/null and b/FuelAccounting/FuelAccounting/Resources/73c1e0a4-66bb-443c-a632-108fa967fec1.jpg differ diff --git a/FuelAccounting/FuelAccounting/Resources/Cancel.png b/FuelAccounting/FuelAccounting/Resources/Cancel.png new file mode 100644 index 0000000..cd4f606 Binary files /dev/null and b/FuelAccounting/FuelAccounting/Resources/Cancel.png differ diff --git a/FuelAccounting/FuelAccounting/Resources/images.png b/FuelAccounting/FuelAccounting/Resources/images.png new file mode 100644 index 0000000..e825ce2 Binary files /dev/null and b/FuelAccounting/FuelAccounting/Resources/images.png differ diff --git a/FuelAccounting/FuelAccounting/Resources/png-clipart-plus-plus (1).png b/FuelAccounting/FuelAccounting/Resources/png-clipart-plus-plus (1).png new file mode 100644 index 0000000..ec53f2e Binary files /dev/null and b/FuelAccounting/FuelAccounting/Resources/png-clipart-plus-plus (1).png differ diff --git a/FuelAccounting/FuelAccounting/Resources/png-clipart-plus-plus.png b/FuelAccounting/FuelAccounting/Resources/png-clipart-plus-plus.png new file mode 100644 index 0000000..b64bb1f Binary files /dev/null and b/FuelAccounting/FuelAccounting/Resources/png-clipart-plus-plus.png differ diff --git a/FuelAccounting/FuelAccounting/Resources/png-transparent-pencil-illustration-hand-painted-pencil-material-watercolor-painting-text-color-pencil.png b/FuelAccounting/FuelAccounting/Resources/png-transparent-pencil-illustration-hand-painted-pencil-material-watercolor-painting-text-color-pencil.png new file mode 100644 index 0000000..5581ebc Binary files /dev/null and b/FuelAccounting/FuelAccounting/Resources/png-transparent-pencil-illustration-hand-painted-pencil-material-watercolor-painting-text-color-pencil.png differ diff --git a/FuelAccounting/FuelAccounting/Resources/pngimg.com - plus_PNG84.png b/FuelAccounting/FuelAccounting/Resources/pngimg.com - plus_PNG84.png new file mode 100644 index 0000000..fc34e00 Binary files /dev/null and b/FuelAccounting/FuelAccounting/Resources/pngimg.com - plus_PNG84.png differ