diff --git a/SoftwareInstallation/SofrwareInstallationContracts/SofrwareInstallationContracts.csproj b/SoftwareInstallation/SofrwareInstallationContracts/SofrwareInstallationContracts.csproj
index f1230e8..ae95ff3 100644
--- a/SoftwareInstallation/SofrwareInstallationContracts/SofrwareInstallationContracts.csproj
+++ b/SoftwareInstallation/SofrwareInstallationContracts/SofrwareInstallationContracts.csproj
@@ -22,6 +22,8 @@
+
+
diff --git a/SoftwareInstallation/SoftwareInstallation/FormComponents.Designer.cs b/SoftwareInstallation/SoftwareInstallation/FormComponents.Designer.cs
index 637687b..474528d 100644
--- a/SoftwareInstallation/SoftwareInstallation/FormComponents.Designer.cs
+++ b/SoftwareInstallation/SoftwareInstallation/FormComponents.Designer.cs
@@ -28,34 +28,82 @@
///
private void InitializeComponent()
{
- this.dataGridView1 = new System.Windows.Forms.DataGridView();
- ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
+ this.DataGridView = new System.Windows.Forms.DataGridView();
+ this.AddButton = new System.Windows.Forms.Button();
+ this.ChangeButton = new System.Windows.Forms.Button();
+ this.DeleteButton = new System.Windows.Forms.Button();
+ this.UpdateButton = new System.Windows.Forms.Button();
+ ((System.ComponentModel.ISupportInitialize)(this.DataGridView)).BeginInit();
this.SuspendLayout();
//
- // dataGridView1
+ // DataGridView
//
- this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
- this.dataGridView1.Location = new System.Drawing.Point(2, 0);
- this.dataGridView1.Name = "dataGridView1";
- this.dataGridView1.RowTemplate.Height = 25;
- this.dataGridView1.Size = new System.Drawing.Size(551, 551);
- this.dataGridView1.TabIndex = 0;
+ this.DataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ this.DataGridView.Location = new System.Drawing.Point(2, 0);
+ this.DataGridView.Name = "DataGridView";
+ this.DataGridView.RowTemplate.Height = 25;
+ this.DataGridView.Size = new System.Drawing.Size(551, 551);
+ this.DataGridView.TabIndex = 0;
+ //
+ // AddButton
+ //
+ this.AddButton.Location = new System.Drawing.Point(571, 26);
+ this.AddButton.Name = "AddButton";
+ this.AddButton.Size = new System.Drawing.Size(142, 45);
+ this.AddButton.TabIndex = 1;
+ this.AddButton.Text = "Добавить";
+ this.AddButton.UseVisualStyleBackColor = true;
+ //
+ // ChangeButton
+ //
+ this.ChangeButton.Location = new System.Drawing.Point(571, 93);
+ this.ChangeButton.Name = "ChangeButton";
+ this.ChangeButton.Size = new System.Drawing.Size(142, 45);
+ this.ChangeButton.TabIndex = 2;
+ this.ChangeButton.Text = "Изменить";
+ this.ChangeButton.UseVisualStyleBackColor = true;
+ //
+ // DeleteButton
+ //
+ this.DeleteButton.Location = new System.Drawing.Point(571, 162);
+ this.DeleteButton.Name = "DeleteButton";
+ this.DeleteButton.Size = new System.Drawing.Size(142, 45);
+ this.DeleteButton.TabIndex = 3;
+ this.DeleteButton.Text = "Удалить";
+ this.DeleteButton.UseVisualStyleBackColor = true;
+ //
+ // UpdateButton
+ //
+ this.UpdateButton.Location = new System.Drawing.Point(571, 230);
+ this.UpdateButton.Name = "UpdateButton";
+ this.UpdateButton.Size = new System.Drawing.Size(142, 45);
+ this.UpdateButton.TabIndex = 4;
+ this.UpdateButton.Text = "Обновить";
+ this.UpdateButton.UseVisualStyleBackColor = true;
//
// FormComponents
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(725, 552);
- this.Controls.Add(this.dataGridView1);
+ this.Controls.Add(this.UpdateButton);
+ this.Controls.Add(this.DeleteButton);
+ this.Controls.Add(this.ChangeButton);
+ this.Controls.Add(this.AddButton);
+ this.Controls.Add(this.DataGridView);
this.Name = "FormComponents";
this.Text = "Компоненты";
- ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
+ ((System.ComponentModel.ISupportInitialize)(this.DataGridView)).EndInit();
this.ResumeLayout(false);
}
#endregion
- private DataGridView dataGridView1;
+ private DataGridView DataGridView;
+ private Button AddButton;
+ private Button ChangeButton;
+ private Button DeleteButton;
+ private Button UpdateButton;
}
}
\ No newline at end of file
diff --git a/SoftwareInstallation/SoftwareInstallation/FormComponents.cs b/SoftwareInstallation/SoftwareInstallation/FormComponents.cs
index cfb1026..5d0f184 100644
--- a/SoftwareInstallation/SoftwareInstallation/FormComponents.cs
+++ b/SoftwareInstallation/SoftwareInstallation/FormComponents.cs
@@ -1,4 +1,7 @@
-using System;
+using Microsoft.Extensions.Logging;
+using SofrwareInstallationContracts.BindingModels;
+using SofrwareInstallationContracts.BusinessLogicsContracts;
+using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
@@ -12,9 +15,106 @@ namespace SoftwareInstallationView
{
public partial class FormComponents : Form
{
- public FormComponents()
+ private readonly ILogger _logger;
+ private readonly IComponentLogic _logic;
+
+ public FormComponents(ILogger logger, IComponentLogic logic)
{
InitializeComponent();
+ _logger = logger;
+ _logic = logic;
}
+
+ private void FormComponents_Load(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+
+ private void LoadData()
+ {
+ try
+ {
+ var list = _logic.ReadList(null);
+
+ if (list != null)
+ {
+ DataGridView.DataSource = list;
+ DataGridView.Columns["Id"].Visible = false;
+ DataGridView.Columns["ComponentName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
+ }
+
+ _logger.LogInformation("Загрузка компонентов");
+
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка загрузки компонентов");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void AddButton_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormComponent));
+
+ if (service is FormComponent form)
+ {
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ LoadData();
+ }
+ }
+ }
+ private void ChangeButton_Click(object sender, EventArgs e)
+ {
+ if (DataGridView.SelectedRows.Count == 1)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormComponent));
+
+ if (service is FormComponent form)
+ {
+ form.Id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value);
+
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ LoadData();
+ }
+ }
+ }
+ }
+ private void DeleteButton_Click(object sender, EventArgs e)
+ {
+ if (DataGridView.SelectedRows.Count == 1)
+ {
+ if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
+ {
+ int id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value);
+ _logger.LogInformation("Удаление компонента");
+
+ try
+ {
+ if (!_logic.Delete(new ComponentBindingModel
+ {
+ Id = id
+ }))
+ {
+ throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
+ }
+
+ LoadData();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка удаления компонента");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+ }
+ private void UpdateButton_Click(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+
}
}
diff --git a/SoftwareInstallation/SoftwareInstallation/FormCreateOrder.Designer.cs b/SoftwareInstallation/SoftwareInstallation/FormCreateOrder.Designer.cs
new file mode 100644
index 0000000..920f686
--- /dev/null
+++ b/SoftwareInstallation/SoftwareInstallation/FormCreateOrder.Designer.cs
@@ -0,0 +1,139 @@
+namespace SoftwareInstallationView
+{
+ partial class FormCreateOrder
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.PackageNameLabel = new System.Windows.Forms.Label();
+ this.CountLabel = new System.Windows.Forms.Label();
+ this.SumLabel = new System.Windows.Forms.Label();
+ this.PackageComboBox = new System.Windows.Forms.ComboBox();
+ this.CountTextBox = new System.Windows.Forms.TextBox();
+ this.SumTextBox = new System.Windows.Forms.TextBox();
+ this.CancelButton = new System.Windows.Forms.Button();
+ this.SaveButton = new System.Windows.Forms.Button();
+ this.SuspendLayout();
+ //
+ // PackageNameLabel
+ //
+ this.PackageNameLabel.AutoSize = true;
+ this.PackageNameLabel.Location = new System.Drawing.Point(12, 9);
+ this.PackageNameLabel.Name = "PackageNameLabel";
+ this.PackageNameLabel.Size = new System.Drawing.Size(59, 15);
+ this.PackageNameLabel.TabIndex = 0;
+ this.PackageNameLabel.Text = "Изделие: ";
+ //
+ // CountLabel
+ //
+ this.CountLabel.AutoSize = true;
+ this.CountLabel.Location = new System.Drawing.Point(12, 40);
+ this.CountLabel.Name = "CountLabel";
+ this.CountLabel.Size = new System.Drawing.Size(78, 15);
+ this.CountLabel.TabIndex = 1;
+ this.CountLabel.Text = "Количество: ";
+ //
+ // SumLabel
+ //
+ this.SumLabel.AutoSize = true;
+ this.SumLabel.Location = new System.Drawing.Point(12, 72);
+ this.SumLabel.Name = "SumLabel";
+ this.SumLabel.Size = new System.Drawing.Size(51, 15);
+ this.SumLabel.TabIndex = 2;
+ this.SumLabel.Text = "Сумма: ";
+ //
+ // PackageComboBox
+ //
+ this.PackageComboBox.FormattingEnabled = true;
+ this.PackageComboBox.Location = new System.Drawing.Point(93, 6);
+ this.PackageComboBox.Name = "PackageComboBox";
+ this.PackageComboBox.Size = new System.Drawing.Size(201, 23);
+ this.PackageComboBox.TabIndex = 3;
+ //
+ // CountTextBox
+ //
+ this.CountTextBox.Location = new System.Drawing.Point(93, 37);
+ this.CountTextBox.Name = "CountTextBox";
+ this.CountTextBox.Size = new System.Drawing.Size(201, 23);
+ this.CountTextBox.TabIndex = 4;
+ //
+ // SumTextBox
+ //
+ this.SumTextBox.Location = new System.Drawing.Point(93, 69);
+ this.SumTextBox.Name = "SumTextBox";
+ this.SumTextBox.Size = new System.Drawing.Size(201, 23);
+ this.SumTextBox.TabIndex = 5;
+ //
+ // CancelButton
+ //
+ this.CancelButton.Location = new System.Drawing.Point(219, 113);
+ this.CancelButton.Name = "CancelButton";
+ this.CancelButton.Size = new System.Drawing.Size(75, 23);
+ this.CancelButton.TabIndex = 6;
+ this.CancelButton.Text = "Отменить";
+ this.CancelButton.UseVisualStyleBackColor = true;
+ //
+ // SaveButton
+ //
+ this.SaveButton.Location = new System.Drawing.Point(138, 113);
+ this.SaveButton.Name = "SaveButton";
+ this.SaveButton.Size = new System.Drawing.Size(75, 23);
+ this.SaveButton.TabIndex = 7;
+ this.SaveButton.Text = "Сохранить";
+ this.SaveButton.UseVisualStyleBackColor = true;
+ //
+ // FormCreateOrder
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(309, 153);
+ this.Controls.Add(this.SaveButton);
+ this.Controls.Add(this.CancelButton);
+ this.Controls.Add(this.SumTextBox);
+ this.Controls.Add(this.CountTextBox);
+ this.Controls.Add(this.PackageComboBox);
+ this.Controls.Add(this.SumLabel);
+ this.Controls.Add(this.CountLabel);
+ this.Controls.Add(this.PackageNameLabel);
+ this.Name = "FormCreateOrder";
+ this.Text = "Заказ";
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private Label PackageNameLabel;
+ private Label CountLabel;
+ private Label SumLabel;
+ private ComboBox PackageComboBox;
+ private TextBox CountTextBox;
+ private TextBox SumTextBox;
+ private Button CancelButton;
+ private Button SaveButton;
+ }
+}
\ No newline at end of file
diff --git a/SoftwareInstallation/SoftwareInstallation/FormCreateOrder.cs b/SoftwareInstallation/SoftwareInstallation/FormCreateOrder.cs
new file mode 100644
index 0000000..dc17b9b
--- /dev/null
+++ b/SoftwareInstallation/SoftwareInstallation/FormCreateOrder.cs
@@ -0,0 +1,137 @@
+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 SofrwareInstallationContracts.BindingModels;
+using SofrwareInstallationContracts.BusinessLogicsContracts;
+using SofrwareInstallationContracts.SearchModels;
+using Microsoft.Extensions.Logging;
+
+
+namespace SoftwareInstallationView
+{
+ public partial class FormCreateOrder : Form
+ {
+ private readonly ILogger _logger;
+ private readonly IPackageLogic _logicP;
+ private readonly IOrderLogic _logicO;
+
+ public FormCreateOrder(ILogger logger, IPackageLogic logicP, IOrderLogic logicO)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _logicP = logicP;
+ _logicO = logicO;
+ }
+
+ private void FormCreateOrder_Load(object sender, EventArgs e)
+ {
+ _logger.LogInformation("Загрузка изделий для заказа");
+
+ try
+ {
+ var list = _logicP.ReadList(null);
+ if (list != null)
+ {
+ PackageComboBox.DisplayMember = "PackageName";
+ PackageComboBox.ValueMember = "Id";
+ PackageComboBox.DataSource = list;
+ PackageComboBox.SelectedItem = null;
+ }
+
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка загрузки списка изделий");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void CalcSum()
+ {
+ if (PackageComboBox.SelectedValue != null && !string.IsNullOrEmpty(CountTextBox.Text))
+ {
+ try
+ {
+ int id = Convert.ToInt32(PackageComboBox.SelectedValue);
+
+ var product = _logicP.ReadElement(new PackageSearchModel
+ {
+ Id = id
+ });
+
+ int count = Convert.ToInt32(CountTextBox.Text);
+ SumTextBox.Text = Math.Round(count * (product?.Price ?? 0), 2).ToString();
+ _logger.LogInformation("Расчет суммы заказа");
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка расчета суммы заказа");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+
+ private void CountTextBox_TextChanged(object sender, EventArgs e)
+ {
+ CalcSum();
+ }
+
+ private void PackageComboBox_SelectedIndexChanged(object sender, EventArgs e)
+ {
+ CalcSum();
+ }
+
+ private void SaveButton_Click(object sender, EventArgs e)
+ {
+ if (string.IsNullOrEmpty(CountTextBox.Text))
+ {
+ MessageBox.Show("Заполните поле Количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+
+ if (PackageComboBox.SelectedValue == null)
+ {
+ MessageBox.Show("Выберите изделие", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+
+ _logger.LogInformation("Создание заказа");
+
+ try
+ {
+ var operationResult = _logicO.CreateOrder(new OrderBindingModel
+ {
+ PackageId = Convert.ToInt32(PackageComboBox.SelectedValue),
+ Count = Convert.ToInt32(CountTextBox.Text),
+ Sum = Convert.ToDouble(SumTextBox.Text)
+ });
+
+ if (!operationResult)
+ {
+ throw new Exception("Ошибка при создании заказа. Дополнительная информация в логах.");
+ }
+
+ MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ DialogResult = DialogResult.OK;
+ Close();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка создания заказа");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void CancelButton_Click(object sender, EventArgs e)
+ {
+ DialogResult = DialogResult.Cancel;
+ Close();
+ }
+ }
+}
diff --git a/SoftwareInstallation/SoftwareInstallation/FormCreateOrder.resx b/SoftwareInstallation/SoftwareInstallation/FormCreateOrder.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/SoftwareInstallation/SoftwareInstallation/FormCreateOrder.resx
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 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/SoftwareInstallation/SoftwareInstallation/FormMain.Designer.cs b/SoftwareInstallation/SoftwareInstallation/FormMain.Designer.cs
new file mode 100644
index 0000000..6641ede
--- /dev/null
+++ b/SoftwareInstallation/SoftwareInstallation/FormMain.Designer.cs
@@ -0,0 +1,166 @@
+namespace SoftwareInstallationView
+{
+ partial class FormMain
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.MenuStrip = new System.Windows.Forms.MenuStrip();
+ this.СправочникиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.ИзделияToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.КомпонентыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.DataGridView = new System.Windows.Forms.DataGridView();
+ this.CreateOrderButton = new System.Windows.Forms.Button();
+ this.TakeOrderInWorkButton = new System.Windows.Forms.Button();
+ this.OrderReadyButton = new System.Windows.Forms.Button();
+ this.IssuedOrderButton = new System.Windows.Forms.Button();
+ this.UpdateListButton = new System.Windows.Forms.Button();
+ this.MenuStrip.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.DataGridView)).BeginInit();
+ this.SuspendLayout();
+ //
+ // MenuStrip
+ //
+ this.MenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.СправочникиToolStripMenuItem});
+ this.MenuStrip.Location = new System.Drawing.Point(0, 0);
+ this.MenuStrip.Name = "MenuStrip";
+ this.MenuStrip.Size = new System.Drawing.Size(800, 24);
+ this.MenuStrip.TabIndex = 0;
+ this.MenuStrip.Text = "menuStrip1";
+ //
+ // СправочникиToolStripMenuItem
+ //
+ this.СправочникиToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.ИзделияToolStripMenuItem,
+ this.КомпонентыToolStripMenuItem});
+ this.СправочникиToolStripMenuItem.Name = "СправочникиToolStripMenuItem";
+ this.СправочникиToolStripMenuItem.Size = new System.Drawing.Size(94, 20);
+ this.СправочникиToolStripMenuItem.Text = "Cправочники";
+ //
+ // ИзделияToolStripMenuItem
+ //
+ this.ИзделияToolStripMenuItem.Name = "ИзделияToolStripMenuItem";
+ this.ИзделияToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
+ this.ИзделияToolStripMenuItem.Text = "Изделия";
+ //
+ // КомпонентыToolStripMenuItem
+ //
+ this.КомпонентыToolStripMenuItem.Name = "КомпонентыToolStripMenuItem";
+ this.КомпонентыToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
+ this.КомпонентыToolStripMenuItem.Text = "Компоненты";
+ //
+ // DataGridView
+ //
+ this.DataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ this.DataGridView.Location = new System.Drawing.Point(0, 27);
+ this.DataGridView.Name = "DataGridView";
+ this.DataGridView.RowTemplate.Height = 25;
+ this.DataGridView.Size = new System.Drawing.Size(657, 421);
+ this.DataGridView.TabIndex = 1;
+ //
+ // CreateOrderButton
+ //
+ this.CreateOrderButton.Location = new System.Drawing.Point(663, 27);
+ this.CreateOrderButton.Name = "CreateOrderButton";
+ this.CreateOrderButton.Size = new System.Drawing.Size(125, 33);
+ this.CreateOrderButton.TabIndex = 2;
+ this.CreateOrderButton.Text = "Создать заказ";
+ this.CreateOrderButton.UseVisualStyleBackColor = true;
+ //
+ // TakeOrderInWorkButton
+ //
+ this.TakeOrderInWorkButton.Location = new System.Drawing.Point(663, 82);
+ this.TakeOrderInWorkButton.Name = "TakeOrderInWorkButton";
+ this.TakeOrderInWorkButton.Size = new System.Drawing.Size(125, 39);
+ this.TakeOrderInWorkButton.TabIndex = 3;
+ this.TakeOrderInWorkButton.Text = "Отдать на выполнение";
+ this.TakeOrderInWorkButton.UseVisualStyleBackColor = true;
+ //
+ // OrderReadyButton
+ //
+ this.OrderReadyButton.Location = new System.Drawing.Point(663, 145);
+ this.OrderReadyButton.Name = "OrderReadyButton";
+ this.OrderReadyButton.Size = new System.Drawing.Size(125, 33);
+ this.OrderReadyButton.TabIndex = 4;
+ this.OrderReadyButton.Text = "Заказ готов";
+ this.OrderReadyButton.UseVisualStyleBackColor = true;
+ //
+ // IssuedOrderButton
+ //
+ this.IssuedOrderButton.Location = new System.Drawing.Point(663, 203);
+ this.IssuedOrderButton.Name = "IssuedOrderButton";
+ this.IssuedOrderButton.Size = new System.Drawing.Size(125, 33);
+ this.IssuedOrderButton.TabIndex = 5;
+ this.IssuedOrderButton.Text = "Заказ выдан";
+ this.IssuedOrderButton.UseVisualStyleBackColor = true;
+ //
+ // UpdateListButton
+ //
+ this.UpdateListButton.Location = new System.Drawing.Point(663, 261);
+ this.UpdateListButton.Name = "UpdateListButton";
+ this.UpdateListButton.Size = new System.Drawing.Size(125, 33);
+ this.UpdateListButton.TabIndex = 6;
+ this.UpdateListButton.Text = "Обновить список";
+ this.UpdateListButton.UseVisualStyleBackColor = true;
+ //
+ // FormMain
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(800, 450);
+ this.Controls.Add(this.UpdateListButton);
+ this.Controls.Add(this.IssuedOrderButton);
+ this.Controls.Add(this.OrderReadyButton);
+ this.Controls.Add(this.TakeOrderInWorkButton);
+ this.Controls.Add(this.CreateOrderButton);
+ this.Controls.Add(this.DataGridView);
+ this.Controls.Add(this.MenuStrip);
+ this.MainMenuStrip = this.MenuStrip;
+ this.Name = "FormMain";
+ this.Text = "Установка ПО";
+ this.MenuStrip.ResumeLayout(false);
+ this.MenuStrip.PerformLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.DataGridView)).EndInit();
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private MenuStrip MenuStrip;
+ private ToolStripMenuItem СправочникиToolStripMenuItem;
+ private ToolStripMenuItem ИзделияToolStripMenuItem;
+ private ToolStripMenuItem КомпонентыToolStripMenuItem;
+ private DataGridView DataGridView;
+ private Button CreateOrderButton;
+ private Button TakeOrderInWorkButton;
+ private Button OrderReadyButton;
+ private Button IssuedOrderButton;
+ private Button UpdateListButton;
+ }
+}
\ No newline at end of file
diff --git a/SoftwareInstallation/SoftwareInstallation/FormMain.cs b/SoftwareInstallation/SoftwareInstallation/FormMain.cs
new file mode 100644
index 0000000..17dea0d
--- /dev/null
+++ b/SoftwareInstallation/SoftwareInstallation/FormMain.cs
@@ -0,0 +1,182 @@
+using Microsoft.Extensions.Logging;
+using SofrwareInstallationContracts.BindingModels;
+using SofrwareInstallationContracts.BusinessLogicsContracts;
+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 SoftwareInstallationView
+{
+ public partial class FormMain : Form
+ {
+
+ private readonly ILogger _logger;
+ private readonly IOrderLogic _orderLogic;
+
+ public FormMain(ILogger logger, IOrderLogic orderLogic)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _orderLogic = orderLogic;
+ }
+
+ private void FormMain_Load(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+
+ private void LoadData()
+ {
+ _logger.LogInformation("Загрузка заказов");
+
+ try
+ {
+ var list = _orderLogic.ReadList(null);
+
+ if (list != null)
+ {
+ DataGridView.DataSource = list;
+ DataGridView.Columns["PackageId"].Visible = false;
+ }
+
+ _logger.LogInformation("Загрузка заказов");
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка загрузки заказов");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void КомпонентыToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormComponents));
+
+ if (service is FormComponents form)
+ {
+ form.ShowDialog();
+ }
+ }
+
+ private void ИзделияToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormPackages));
+
+ if (service is FormPackages form)
+ {
+ form.ShowDialog();
+ }
+ }
+
+ private void CreateOrderButton_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder));
+
+ if (service is FormCreateOrder form)
+ {
+ form.ShowDialog();
+ LoadData();
+ }
+ }
+
+ private void TakeOrderInWorkButton_Click(object sender, EventArgs e)
+ {
+ if (DataGridView.SelectedRows.Count == 1)
+ {
+ int id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value);
+ _logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id);
+
+ try
+ {
+ var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel
+ {
+ Id = id
+ });
+
+ if (!operationResult)
+ {
+ throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
+ }
+
+ LoadData();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка передачи заказа в работу");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+
+ private void OrderReadyButton_Click(object sender, EventArgs e)
+ {
+ if (DataGridView.SelectedRows.Count == 1)
+ {
+ int id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value);
+ _logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'", id);
+
+ try
+ {
+ var operationResult = _orderLogic.FinishOrder(new OrderBindingModel
+ {
+ Id = id
+ });
+
+ if (!operationResult)
+ {
+ throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
+ }
+
+ LoadData();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка отметки о готовности заказа");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+
+ private void IssuedOrderButton_Click(object sender, EventArgs e)
+ {
+ if (DataGridView.SelectedRows.Count == 1)
+ {
+ int id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value);
+ _logger.LogInformation("Заказ №{id}. Меняется статус на 'Выдан'", id);
+
+ try
+ {
+ var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel
+ {
+ Id = id
+ });
+
+ if (!operationResult)
+ {
+ throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
+ }
+
+ _logger.LogInformation("Заказ №{id} выдан", id);
+ LoadData();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка отметки о выдачи заказа");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+
+ private void UpdateButton_Click(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+
+ }
+}
diff --git a/SoftwareInstallation/SoftwareInstallation/FormMain.resx b/SoftwareInstallation/SoftwareInstallation/FormMain.resx
new file mode 100644
index 0000000..a694815
--- /dev/null
+++ b/SoftwareInstallation/SoftwareInstallation/FormMain.resx
@@ -0,0 +1,63 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 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/SoftwareInstallation/SoftwareInstallation/FormPackage.Designer.cs b/SoftwareInstallation/SoftwareInstallation/FormPackage.Designer.cs
new file mode 100644
index 0000000..5454d02
--- /dev/null
+++ b/SoftwareInstallation/SoftwareInstallation/FormPackage.Designer.cs
@@ -0,0 +1,246 @@
+namespace SoftwareInstallationView
+{
+ partial class FormPackage
+ {
+ ///
+ /// 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()
+ {
+ System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
+ System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
+ System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle();
+ this.PackageNameLabel = new System.Windows.Forms.Label();
+ this.PriceLabel = new System.Windows.Forms.Label();
+ this.PackageNameTextBox = new System.Windows.Forms.TextBox();
+ this.PriceTextBox = new System.Windows.Forms.TextBox();
+ this.ComponentsGroupBox = new System.Windows.Forms.GroupBox();
+ this.UpdateButton = new System.Windows.Forms.Button();
+ this.DeleteButton = new System.Windows.Forms.Button();
+ this.ChangeButton = new System.Windows.Forms.Button();
+ this.AddButton = new System.Windows.Forms.Button();
+ this.DataGridView = new System.Windows.Forms.DataGridView();
+ this.ID = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.ComponentNameField = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.CountField = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.CancelButton = new System.Windows.Forms.Button();
+ this.SaveButton = new System.Windows.Forms.Button();
+ this.ComponentsGroupBox.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.DataGridView)).BeginInit();
+ this.SuspendLayout();
+ //
+ // PackageNameLabel
+ //
+ this.PackageNameLabel.AutoSize = true;
+ this.PackageNameLabel.Location = new System.Drawing.Point(12, 9);
+ this.PackageNameLabel.Name = "PackageNameLabel";
+ this.PackageNameLabel.Size = new System.Drawing.Size(65, 15);
+ this.PackageNameLabel.TabIndex = 0;
+ this.PackageNameLabel.Text = "Название: ";
+ //
+ // PriceLabel
+ //
+ this.PriceLabel.AutoSize = true;
+ this.PriceLabel.Location = new System.Drawing.Point(12, 43);
+ this.PriceLabel.Name = "PriceLabel";
+ this.PriceLabel.Size = new System.Drawing.Size(73, 15);
+ this.PriceLabel.TabIndex = 1;
+ this.PriceLabel.Text = "Стоимость: ";
+ //
+ // PackageNameTextBox
+ //
+ this.PackageNameTextBox.Location = new System.Drawing.Point(83, 6);
+ this.PackageNameTextBox.Name = "PackageNameTextBox";
+ this.PackageNameTextBox.Size = new System.Drawing.Size(283, 23);
+ this.PackageNameTextBox.TabIndex = 2;
+ //
+ // PriceTextBox
+ //
+ this.PriceTextBox.Location = new System.Drawing.Point(83, 40);
+ this.PriceTextBox.Name = "PriceTextBox";
+ this.PriceTextBox.Size = new System.Drawing.Size(283, 23);
+ this.PriceTextBox.TabIndex = 3;
+ //
+ // ComponentsGroupBox
+ //
+ this.ComponentsGroupBox.Controls.Add(this.UpdateButton);
+ this.ComponentsGroupBox.Controls.Add(this.DeleteButton);
+ this.ComponentsGroupBox.Controls.Add(this.ChangeButton);
+ this.ComponentsGroupBox.Controls.Add(this.AddButton);
+ this.ComponentsGroupBox.Controls.Add(this.DataGridView);
+ this.ComponentsGroupBox.Location = new System.Drawing.Point(12, 80);
+ this.ComponentsGroupBox.Name = "ComponentsGroupBox";
+ this.ComponentsGroupBox.Size = new System.Drawing.Size(722, 350);
+ this.ComponentsGroupBox.TabIndex = 5;
+ this.ComponentsGroupBox.TabStop = false;
+ this.ComponentsGroupBox.Text = "Компоненты";
+ //
+ // UpdateButton
+ //
+ this.UpdateButton.Location = new System.Drawing.Point(590, 203);
+ this.UpdateButton.Name = "UpdateButton";
+ this.UpdateButton.Size = new System.Drawing.Size(110, 38);
+ this.UpdateButton.TabIndex = 4;
+ this.UpdateButton.Text = "Обновить";
+ this.UpdateButton.UseVisualStyleBackColor = true;
+ //
+ // DeleteButton
+ //
+ this.DeleteButton.Location = new System.Drawing.Point(590, 143);
+ this.DeleteButton.Name = "DeleteButton";
+ this.DeleteButton.Size = new System.Drawing.Size(110, 38);
+ this.DeleteButton.TabIndex = 3;
+ this.DeleteButton.Text = "Удалить";
+ this.DeleteButton.UseVisualStyleBackColor = true;
+ //
+ // ChangeButton
+ //
+ this.ChangeButton.Location = new System.Drawing.Point(590, 82);
+ this.ChangeButton.Name = "ChangeButton";
+ this.ChangeButton.Size = new System.Drawing.Size(110, 38);
+ this.ChangeButton.TabIndex = 2;
+ this.ChangeButton.Text = "Изменить";
+ this.ChangeButton.UseVisualStyleBackColor = true;
+ //
+ // AddButton
+ //
+ this.AddButton.Location = new System.Drawing.Point(590, 22);
+ this.AddButton.Name = "AddButton";
+ this.AddButton.Size = new System.Drawing.Size(110, 38);
+ this.AddButton.TabIndex = 1;
+ this.AddButton.Text = "Добавить";
+ this.AddButton.UseVisualStyleBackColor = true;
+ //
+ // DataGridView
+ //
+ dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
+ dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Control;
+ dataGridViewCellStyle1.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
+ dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.WindowText;
+ dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight;
+ dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
+ dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
+ this.DataGridView.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1;
+ this.DataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ this.DataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
+ this.ID,
+ this.ComponentNameField,
+ this.CountField});
+ dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
+ dataGridViewCellStyle2.BackColor = System.Drawing.SystemColors.Window;
+ dataGridViewCellStyle2.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
+ dataGridViewCellStyle2.ForeColor = System.Drawing.SystemColors.ControlText;
+ dataGridViewCellStyle2.SelectionBackColor = System.Drawing.SystemColors.Highlight;
+ dataGridViewCellStyle2.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
+ dataGridViewCellStyle2.WrapMode = System.Windows.Forms.DataGridViewTriState.False;
+ this.DataGridView.DefaultCellStyle = dataGridViewCellStyle2;
+ this.DataGridView.Location = new System.Drawing.Point(6, 22);
+ this.DataGridView.Name = "DataGridView";
+ dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
+ dataGridViewCellStyle3.BackColor = System.Drawing.SystemColors.Control;
+ dataGridViewCellStyle3.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
+ dataGridViewCellStyle3.ForeColor = System.Drawing.SystemColors.WindowText;
+ dataGridViewCellStyle3.SelectionBackColor = System.Drawing.SystemColors.Highlight;
+ dataGridViewCellStyle3.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
+ dataGridViewCellStyle3.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
+ this.DataGridView.RowHeadersDefaultCellStyle = dataGridViewCellStyle3;
+ this.DataGridView.RowTemplate.Height = 25;
+ this.DataGridView.Size = new System.Drawing.Size(561, 322);
+ this.DataGridView.TabIndex = 0;
+ //
+ // ID
+ //
+ this.ID.HeaderText = "ID";
+ this.ID.Name = "ID";
+ this.ID.Visible = false;
+ //
+ // ComponentNameField
+ //
+ this.ComponentNameField.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
+ this.ComponentNameField.HeaderText = "Компонент";
+ this.ComponentNameField.Name = "ComponentNameField";
+ //
+ // CountField
+ //
+ this.CountField.HeaderText = "Количество";
+ this.CountField.Name = "CountField";
+ //
+ // CancelButton
+ //
+ this.CancelButton.Location = new System.Drawing.Point(602, 446);
+ this.CancelButton.Name = "CancelButton";
+ this.CancelButton.Size = new System.Drawing.Size(110, 34);
+ this.CancelButton.TabIndex = 7;
+ this.CancelButton.Text = "Отмена";
+ this.CancelButton.UseVisualStyleBackColor = true;
+ //
+ // SaveButton
+ //
+ this.SaveButton.Location = new System.Drawing.Point(486, 446);
+ this.SaveButton.Name = "SaveButton";
+ this.SaveButton.Size = new System.Drawing.Size(110, 34);
+ this.SaveButton.TabIndex = 8;
+ this.SaveButton.Text = "Сохранить";
+ this.SaveButton.UseVisualStyleBackColor = true;
+ //
+ // FormPackage
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(746, 498);
+ this.Controls.Add(this.SaveButton);
+ this.Controls.Add(this.CancelButton);
+ this.Controls.Add(this.ComponentsGroupBox);
+ this.Controls.Add(this.PriceTextBox);
+ this.Controls.Add(this.PackageNameTextBox);
+ this.Controls.Add(this.PriceLabel);
+ this.Controls.Add(this.PackageNameLabel);
+ this.Name = "FormPackage";
+ this.Text = "Изделие";
+ this.ComponentsGroupBox.ResumeLayout(false);
+ ((System.ComponentModel.ISupportInitialize)(this.DataGridView)).EndInit();
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private Label PackageNameLabel;
+ private Label PriceLabel;
+ private TextBox PackageNameTextBox;
+ private TextBox PriceTextBox;
+ private GroupBox ComponentsGroupBox;
+ private Button UpdateButton;
+ private Button DeleteButton;
+ private Button ChangeButton;
+ private Button AddButton;
+ private DataGridView DataGridView;
+ private DataGridViewTextBoxColumn ID;
+ private DataGridViewTextBoxColumn ComponentNameField;
+ private DataGridViewTextBoxColumn CountField;
+ private Button CancelButton;
+ private Button SaveButton;
+ }
+}
\ No newline at end of file
diff --git a/SoftwareInstallation/SoftwareInstallation/FormPackage.cs b/SoftwareInstallation/SoftwareInstallation/FormPackage.cs
new file mode 100644
index 0000000..f763aa8
--- /dev/null
+++ b/SoftwareInstallation/SoftwareInstallation/FormPackage.cs
@@ -0,0 +1,238 @@
+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 SofrwareInstallationContracts.BindingModels;
+using SofrwareInstallationContracts.BusinessLogicsContracts;
+using SofrwareInstallationContracts.SearchModels;
+using SoftwareInstallationDataModels.Models;
+using Microsoft.Extensions.Logging;
+
+
+namespace SoftwareInstallationView
+{
+ public partial class FormPackage : Form
+ {
+ private readonly ILogger _logger;
+
+ private readonly IPackageLogic _logic;
+
+ private int? _id;
+
+ private Dictionary _packageComponents;
+
+ public int Id { set { _id = value; } }
+ public FormPackage(ILogger logger, IPackageLogic logic)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _logic = logic;
+ _packageComponents = new Dictionary();
+ }
+ private void FormPackage_Load(object sender, EventArgs e)
+ {
+ if (_id.HasValue)
+ {
+ _logger.LogInformation("Загрузка изделия");
+
+ try
+ {
+ var view = _logic.ReadElement(new PackageSearchModel
+ {
+ Id = _id.Value
+ });
+
+ if (view != null)
+ {
+ PackageNameTextBox.Text = view.PackageName;
+ PriceTextBox.Text = view.Price.ToString();
+ _packageComponents = view.PackageComponents ?? new Dictionary();
+ LoadData();
+ }
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка загрузки изделия");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+ private void LoadData()
+ {
+ _logger.LogInformation("Загрузка компонент изделия");
+
+ try
+ {
+ if (_packageComponents != null)
+ {
+ DataGridView.Rows.Clear();
+ foreach (var pc in _packageComponents)
+ {
+ DataGridView.Rows.Add(new object[] { pc.Key, pc.Value.Item1.ComponentName, pc.Value.Item2 });
+ }
+ PriceTextBox.Text = CalcPrice().ToString();
+ }
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка загрузки компонент изделия");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ private void AddButton_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormPackageComponent));
+
+ if (service is FormPackageComponent form)
+ {
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ if (form.ComponentModel == null)
+ {
+ return;
+ }
+
+ _logger.LogInformation("Добавление нового компонента: { ComponentName} - { Count}", form.ComponentModel.ComponentName, form.Count);
+
+ if (_packageComponents.ContainsKey(form.Id))
+ {
+ _packageComponents[form.Id] = (form.ComponentModel, form.Count);
+ }
+
+ else
+ {
+ _packageComponents.Add(form.Id, (form.ComponentModel, form.Count));
+ }
+
+ LoadData();
+ }
+ }
+ }
+
+ private void ChangeButton_Click(object sender, EventArgs e)
+ {
+ if (DataGridView.SelectedRows.Count == 1)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormPackageComponent));
+
+ if (service is FormPackageComponent form)
+ {
+ int id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells[0].Value);
+ form.Id = id;
+ form.Count = _packageComponents[id].Item2;
+
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ if (form.ComponentModel == null)
+ {
+ return;
+ }
+
+ _logger.LogInformation("Изменение компонента: { ComponentName} - { Count}", form.ComponentModel.ComponentName, form.Count);
+ _packageComponents[form.Id] = (form.ComponentModel, form.Count);
+ LoadData();
+ }
+ }
+ }
+ }
+
+ private void DeleteButtonl_Click(object sender, EventArgs e)
+ {
+ if (DataGridView.SelectedRows.Count == 1)
+ {
+ if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
+ {
+ try
+ {
+ _logger.LogInformation("Удаление компонента: { ComponentName} - { Count}", DataGridView.SelectedRows[0].Cells[1].Value);
+ _packageComponents?.Remove(Convert.ToInt32(DataGridView.SelectedRows[0].Cells[0].Value));
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+
+ LoadData();
+ }
+ }
+ }
+
+ private void UpdateButton_Click(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+
+ private void SaveButton_Click(object sender, EventArgs e)
+ {
+ if (string.IsNullOrEmpty(PackageNameTextBox.Text))
+ {
+ MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+
+ if (string.IsNullOrEmpty(PriceTextBox.Text))
+ {
+ MessageBox.Show("Заполните цену", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+
+ if (_packageComponents == null || _packageComponents.Count == 0)
+ {
+ MessageBox.Show("Заполните компоненты", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+
+ _logger.LogInformation("Сохранение изделия");
+
+ try
+ {
+ var model = new PackageBindingModel
+ {
+ Id = _id ?? 0,
+ PackageName = PackageNameTextBox.Text,
+ Price = Convert.ToDouble(PriceTextBox.Text),
+ PackageComponents = _packageComponents
+ };
+
+ var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
+
+ if (!operationResult)
+ {
+ throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
+ }
+
+ MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ DialogResult = DialogResult.OK;
+ Close();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка сохранения изделия");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void CancelButton_Click(object sender, EventArgs e)
+ {
+ DialogResult = DialogResult.Cancel;
+ Close();
+ }
+
+ private double CalcPrice()
+ {
+ double price = 0;
+
+ foreach (var elem in _packageComponents)
+ {
+ price += ((elem.Value.Item1?.Cost ?? 0) * elem.Value.Item2);
+ }
+
+ return Math.Round(price * 1.1, 2);
+ }
+ }
+}
diff --git a/SoftwareInstallation/SoftwareInstallation/FormPackage.resx b/SoftwareInstallation/SoftwareInstallation/FormPackage.resx
new file mode 100644
index 0000000..cdfd0f5
--- /dev/null
+++ b/SoftwareInstallation/SoftwareInstallation/FormPackage.resx
@@ -0,0 +1,66 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 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/SoftwareInstallation/SoftwareInstallation/FormPackageComponent.Designer.cs b/SoftwareInstallation/SoftwareInstallation/FormPackageComponent.Designer.cs
new file mode 100644
index 0000000..7ff5916
--- /dev/null
+++ b/SoftwareInstallation/SoftwareInstallation/FormPackageComponent.Designer.cs
@@ -0,0 +1,119 @@
+namespace SoftwareInstallationView
+{
+ partial class FormPackageComponent
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.ComponentSelectLabel = new System.Windows.Forms.Label();
+ this.CountLabel = new System.Windows.Forms.Label();
+ this.ComponentComboBox = new System.Windows.Forms.ComboBox();
+ this.CountTextBox = new System.Windows.Forms.TextBox();
+ this.SaveButton = new System.Windows.Forms.Button();
+ this.CancelButton = new System.Windows.Forms.Button();
+ this.SuspendLayout();
+ //
+ // ComponentSelectLabel
+ //
+ this.ComponentSelectLabel.AutoSize = true;
+ this.ComponentSelectLabel.Location = new System.Drawing.Point(26, 20);
+ this.ComponentSelectLabel.Name = "ComponentSelectLabel";
+ this.ComponentSelectLabel.Size = new System.Drawing.Size(75, 15);
+ this.ComponentSelectLabel.TabIndex = 0;
+ this.ComponentSelectLabel.Text = "Компонент: ";
+ //
+ // CountLabel
+ //
+ this.CountLabel.AutoSize = true;
+ this.CountLabel.Location = new System.Drawing.Point(26, 56);
+ this.CountLabel.Name = "CountLabel";
+ this.CountLabel.Size = new System.Drawing.Size(78, 15);
+ this.CountLabel.TabIndex = 1;
+ this.CountLabel.Text = "Количество: ";
+ //
+ // ComponentComboBox
+ //
+ this.ComponentComboBox.FormattingEnabled = true;
+ this.ComponentComboBox.Location = new System.Drawing.Point(107, 17);
+ this.ComponentComboBox.Name = "ComponentComboBox";
+ this.ComponentComboBox.Size = new System.Drawing.Size(190, 23);
+ this.ComponentComboBox.TabIndex = 2;
+ //
+ // CountTextBox
+ //
+ this.CountTextBox.Location = new System.Drawing.Point(107, 53);
+ this.CountTextBox.Name = "CountTextBox";
+ this.CountTextBox.Size = new System.Drawing.Size(190, 23);
+ this.CountTextBox.TabIndex = 3;
+ //
+ // SaveButton
+ //
+ this.SaveButton.Location = new System.Drawing.Point(141, 98);
+ this.SaveButton.Name = "SaveButton";
+ this.SaveButton.Size = new System.Drawing.Size(75, 23);
+ this.SaveButton.TabIndex = 4;
+ this.SaveButton.Text = "Сохранить";
+ this.SaveButton.UseVisualStyleBackColor = true;
+ this.SaveButton.Click += new System.EventHandler(this.SaveButton_Click);
+ //
+ // CancelButton
+ //
+ this.CancelButton.Location = new System.Drawing.Point(222, 98);
+ this.CancelButton.Name = "CancelButton";
+ this.CancelButton.Size = new System.Drawing.Size(75, 23);
+ this.CancelButton.TabIndex = 5;
+ this.CancelButton.Text = "Отмена";
+ this.CancelButton.UseVisualStyleBackColor = true;
+ this.CancelButton.Click += new System.EventHandler(this.CancelButton_Click);
+ //
+ // FormPackageComponent
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(337, 141);
+ this.Controls.Add(this.CancelButton);
+ this.Controls.Add(this.SaveButton);
+ this.Controls.Add(this.CountTextBox);
+ this.Controls.Add(this.ComponentComboBox);
+ this.Controls.Add(this.CountLabel);
+ this.Controls.Add(this.ComponentSelectLabel);
+ this.Name = "FormPackageComponent";
+ this.Text = "Компонент изделия";
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private Label ComponentSelectLabel;
+ private Label CountLabel;
+ private ComboBox ComponentComboBox;
+ private TextBox CountTextBox;
+ private Button SaveButton;
+ private Button CancelButton;
+ }
+}
\ No newline at end of file
diff --git a/SoftwareInstallation/SoftwareInstallation/FormPackageComponent.cs b/SoftwareInstallation/SoftwareInstallation/FormPackageComponent.cs
new file mode 100644
index 0000000..3a6ef66
--- /dev/null
+++ b/SoftwareInstallation/SoftwareInstallation/FormPackageComponent.cs
@@ -0,0 +1,95 @@
+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 SofrwareInstallationContracts.BusinessLogicsContracts;
+using SofrwareInstallationContracts.ViewModels;
+using SoftwareInstallationDataModels.Models;
+
+namespace SoftwareInstallationView
+{
+ public partial class FormPackageComponent : Form
+ {
+ private readonly List? _list;
+
+ public int Id
+ {
+ get
+ {
+ return Convert.ToInt32(ComponentComboBox.SelectedValue);
+ }
+ set
+ {
+ ComponentComboBox.SelectedValue = value;
+ }
+ }
+
+ public IComponentModel? ComponentModel
+ {
+ get
+ {
+ if (_list == null)
+ {
+ return null;
+ }
+ foreach (var elem in _list)
+ {
+ if (elem.Id == Id)
+ {
+ return elem;
+ }
+ }
+ return null;
+ }
+ }
+
+ public int Count
+ {
+ get { return Convert.ToInt32(CountTextBox.Text); }
+ set { CountTextBox.Text = value.ToString(); }
+ }
+
+ public FormPackageComponent(IComponentLogic logic)
+ {
+ InitializeComponent();
+ _list = logic.ReadList(null);
+ if (_list != null)
+ {
+ ComponentComboBox.DisplayMember = "ComponentName";
+ ComponentComboBox.ValueMember = "Id";
+ ComponentComboBox.DataSource = _list;
+ ComponentComboBox.SelectedItem = null;
+ }
+ }
+
+
+ private void SaveButton_Click(object sender, EventArgs e)
+ {
+ if (string.IsNullOrEmpty(CountTextBox.Text))
+ {
+ MessageBox.Show("Заполните поле Количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+
+ if (ComponentComboBox.SelectedValue == null)
+ {
+ MessageBox.Show("Выберите компонент", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+
+ DialogResult = DialogResult.OK;
+ Close();
+ }
+
+ private void CancelButton_Click(object sender, EventArgs e)
+ {
+ DialogResult = DialogResult.Cancel;
+ Close();
+ }
+ }
+}
diff --git a/SoftwareInstallation/SoftwareInstallation/FormPackageComponent.resx b/SoftwareInstallation/SoftwareInstallation/FormPackageComponent.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/SoftwareInstallation/SoftwareInstallation/FormPackageComponent.resx
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 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/SoftwareInstallation/SoftwareInstallation/FormPackages.Designer.cs b/SoftwareInstallation/SoftwareInstallation/FormPackages.Designer.cs
new file mode 100644
index 0000000..624b372
--- /dev/null
+++ b/SoftwareInstallation/SoftwareInstallation/FormPackages.Designer.cs
@@ -0,0 +1,109 @@
+namespace SoftwareInstallationView
+{
+ partial class FormPackages
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.DataGridView = new System.Windows.Forms.DataGridView();
+ this.AddButton = new System.Windows.Forms.Button();
+ this.ChangeButton = new System.Windows.Forms.Button();
+ this.DeleteButton = new System.Windows.Forms.Button();
+ this.UpdateButton = new System.Windows.Forms.Button();
+ ((System.ComponentModel.ISupportInitialize)(this.DataGridView)).BeginInit();
+ this.SuspendLayout();
+ //
+ // DataGridView
+ //
+ this.DataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ this.DataGridView.Location = new System.Drawing.Point(1, 1);
+ this.DataGridView.Name = "DataGridView";
+ this.DataGridView.RowTemplate.Height = 25;
+ this.DataGridView.Size = new System.Drawing.Size(562, 495);
+ this.DataGridView.TabIndex = 0;
+ //
+ // AddButton
+ //
+ this.AddButton.Location = new System.Drawing.Point(585, 12);
+ this.AddButton.Name = "AddButton";
+ this.AddButton.Size = new System.Drawing.Size(120, 41);
+ this.AddButton.TabIndex = 1;
+ this.AddButton.Text = "Добавить";
+ this.AddButton.UseVisualStyleBackColor = true;
+ //
+ // ChangeButton
+ //
+ this.ChangeButton.Location = new System.Drawing.Point(585, 71);
+ this.ChangeButton.Name = "ChangeButton";
+ this.ChangeButton.Size = new System.Drawing.Size(120, 41);
+ this.ChangeButton.TabIndex = 2;
+ this.ChangeButton.Text = "Изменить";
+ this.ChangeButton.UseVisualStyleBackColor = true;
+ //
+ // DeleteButton
+ //
+ this.DeleteButton.Location = new System.Drawing.Point(585, 130);
+ this.DeleteButton.Name = "DeleteButton";
+ this.DeleteButton.Size = new System.Drawing.Size(120, 41);
+ this.DeleteButton.TabIndex = 3;
+ this.DeleteButton.Text = "Удалить";
+ this.DeleteButton.UseVisualStyleBackColor = true;
+ //
+ // UpdateButton
+ //
+ this.UpdateButton.Location = new System.Drawing.Point(585, 191);
+ this.UpdateButton.Name = "UpdateButton";
+ this.UpdateButton.Size = new System.Drawing.Size(120, 41);
+ this.UpdateButton.TabIndex = 4;
+ this.UpdateButton.Text = "Обновить";
+ this.UpdateButton.UseVisualStyleBackColor = true;
+ //
+ // FormPackages
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(717, 502);
+ this.Controls.Add(this.UpdateButton);
+ this.Controls.Add(this.DeleteButton);
+ this.Controls.Add(this.ChangeButton);
+ this.Controls.Add(this.AddButton);
+ this.Controls.Add(this.DataGridView);
+ this.Name = "FormPackages";
+ this.Text = "Изделия";
+ ((System.ComponentModel.ISupportInitialize)(this.DataGridView)).EndInit();
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private DataGridView DataGridView;
+ private Button AddButton;
+ private Button ChangeButton;
+ private Button DeleteButton;
+ private Button UpdateButton;
+ }
+}
\ No newline at end of file
diff --git a/SoftwareInstallation/SoftwareInstallation/FormPackages.cs b/SoftwareInstallation/SoftwareInstallation/FormPackages.cs
new file mode 100644
index 0000000..9f7d5e8
--- /dev/null
+++ b/SoftwareInstallation/SoftwareInstallation/FormPackages.cs
@@ -0,0 +1,119 @@
+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 Microsoft.Extensions.Logging;
+using SofrwareInstallationContracts.BindingModels;
+using SofrwareInstallationContracts.BusinessLogicsContracts;
+
+namespace SoftwareInstallationView
+{
+ public partial class FormPackages : Form
+ {
+ private readonly ILogger _logger;
+ private readonly IPackageLogic _logic;
+
+ public FormPackages(ILogger logger, IPackageLogic logic)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _logic = logic;
+ }
+
+ private void FormComponents_Load(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+
+ private void LoadData()
+ {
+ try
+ {
+ var list = _logic.ReadList(null);
+
+ if (list != null)
+ {
+ DataGridView.DataSource = list;
+ DataGridView.Columns["Id"].Visible = false;
+ DataGridView.Columns["PackageName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
+ }
+
+ _logger.LogInformation("Загрузка компонентов");
+
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка загрузки компонентов");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void AddButton_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormPackage));
+
+ if (service is FormPackage form)
+ {
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ LoadData();
+ }
+ }
+ }
+ private void ChangeButton_Click(object sender, EventArgs e)
+ {
+ if (DataGridView.SelectedRows.Count == 1)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormPackage));
+
+ if (service is FormPackage form)
+ {
+ form.Id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value);
+
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ LoadData();
+ }
+ }
+ }
+ }
+ private void DeleteButton_Click(object sender, EventArgs e)
+ {
+ if (DataGridView.SelectedRows.Count == 1)
+ {
+ if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
+ {
+ int id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value);
+ _logger.LogInformation("Удаление компонента");
+
+ try
+ {
+ if (!_logic.Delete(new PackageBindingModel
+ {
+ Id = id
+ }))
+ {
+ throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
+ }
+
+ LoadData();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка удаления компонента");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+ }
+ private void UpdateButton_Click(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+ }
+}
diff --git a/SoftwareInstallation/SoftwareInstallation/FormPackages.resx b/SoftwareInstallation/SoftwareInstallation/FormPackages.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/SoftwareInstallation/SoftwareInstallation/FormPackages.resx
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 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/SoftwareInstallation/SoftwareInstallation/Program.cs b/SoftwareInstallation/SoftwareInstallation/Program.cs
index df13930..b6759a0 100644
--- a/SoftwareInstallation/SoftwareInstallation/Program.cs
+++ b/SoftwareInstallation/SoftwareInstallation/Program.cs
@@ -1,19 +1,51 @@
+using SoftwareInstallationBusinessLogic.BusinessLogic;
+using Microsoft.Extensions.DependencyInjection;
+using SofrwareInstallationContracts.BusinessLogicsContracts;
+using SofrwareInstallationContracts.StoragesContracts;
using SoftwareInstallationView;
+using System.Drawing;
+using SoftwareInstallationListImplement.Implements;
+using Microsoft.Extensions.Logging;
+using NLog.Extensions.Logging;
-namespace SoftwareInstallation
+
+namespace SoftwareInstallationView
{
internal static class Program
{
- ///
- /// The main entry point for the application.
- ///
+ private static ServiceProvider? _serviceProvider;
+ public static ServiceProvider? ServiceProvider => _serviceProvider;
+
[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(new FormComponents());
+ var services = new ServiceCollection();
+ ConfigureServices(services);
+ _serviceProvider = services.BuildServiceProvider();
+ Application.Run(_serviceProvider.GetRequiredService());
+ }
+
+ private static void ConfigureServices(ServiceCollection services)
+ {
+ services.AddLogging(option =>
+ {
+ option.SetMinimumLevel(LogLevel.Information);
+ option.AddNLog("nlog.config");
+ });
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
}
}
-}
\ No newline at end of file
+}
diff --git a/SoftwareInstallation/SoftwareInstallation/Properties/Resources.Designer.cs b/SoftwareInstallation/SoftwareInstallation/Properties/Resources.Designer.cs
new file mode 100644
index 0000000..46ddebe
--- /dev/null
+++ b/SoftwareInstallation/SoftwareInstallation/Properties/Resources.Designer.cs
@@ -0,0 +1,63 @@
+//------------------------------------------------------------------------------
+//
+// Этот код создан программой.
+// Исполняемая версия:4.0.30319.42000
+//
+// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
+// повторной генерации кода.
+//
+//------------------------------------------------------------------------------
+
+namespace SoftwareInstallationView.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("SoftwareInstallationView.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;
+ }
+ }
+ }
+}
diff --git a/SoftwareInstallation/SoftwareInstallation/Properties/Resources.resx b/SoftwareInstallation/SoftwareInstallation/Properties/Resources.resx
new file mode 100644
index 0000000..1af7de1
--- /dev/null
+++ b/SoftwareInstallation/SoftwareInstallation/Properties/Resources.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/SoftwareInstallation/SoftwareInstallation/SoftwareInstallationView.csproj b/SoftwareInstallation/SoftwareInstallation/SoftwareInstallationView.csproj
index 023da90..ae265fb 100644
--- a/SoftwareInstallation/SoftwareInstallation/SoftwareInstallationView.csproj
+++ b/SoftwareInstallation/SoftwareInstallation/SoftwareInstallationView.csproj
@@ -24,6 +24,8 @@
+
+
@@ -35,6 +37,23 @@
+
+
+
+
+
+
+ True
+ True
+ Resources.resx
+
+
+
+
+
+ ResXFileCodeGenerator
+ Resources.Designer.cs
+
\ No newline at end of file
diff --git a/SoftwareInstallation/SoftwareInstallationBusinessLogic/BusinessLogic/OrderLogic.cs b/SoftwareInstallation/SoftwareInstallationBusinessLogic/BusinessLogic/OrderLogic.cs
index 40aef69..1e021a9 100644
--- a/SoftwareInstallation/SoftwareInstallationBusinessLogic/BusinessLogic/OrderLogic.cs
+++ b/SoftwareInstallation/SoftwareInstallationBusinessLogic/BusinessLogic/OrderLogic.cs
@@ -9,34 +9,127 @@ using SofrwareInstallationContracts.SearchModels;
using SofrwareInstallationContracts.StoragesContracts;
using SofrwareInstallationContracts.ViewModels;
using Microsoft.Extensions.Logging;
+using SoftwareInstallationDataModels.Enums;
namespace SoftwareInstallationBusinessLogic.BusinessLogic
{
public class OrderLogic : IOrderLogic
{
+ private readonly ILogger _logger;
+ private readonly IOrderStorage _orderStorage;
+
+ public OrderLogic(ILogger logger, IOrderStorage orderStorage)
+ {
+ _logger = logger;
+ _orderStorage = orderStorage;
+ }
+
public bool CreateOrder(OrderBindingModel model)
{
- throw new NotImplementedException();
+ CheckModel(model);
+
+ if (model.Status != OrderStatus.Неизвестен)
+ {
+ _logger.LogWarning("Insert operation failed. Order status incorrect.");
+ return false;
+ }
+
+ model.Status = OrderStatus.Принят;
+
+ if (_orderStorage.Insert(model) == null)
+ {
+ model.Status = OrderStatus.Неизвестен;
+ _logger.LogWarning("Insert operation failed");
+ return false;
+ }
+
+ return true;
}
- public bool DeliveryOrder(OrderBindingModel model)
+ public bool StatusUpdate(OrderBindingModel model, OrderStatus newStatus)
{
- throw new NotImplementedException();
- }
+ CheckModel(model);
- public bool FinishOrder(OrderBindingModel model)
- {
- throw new NotImplementedException();
- }
+ if (model.Status + 1 != newStatus)
+ {
+ _logger.LogWarning("Status update to " + newStatus.ToString() + " operation failed. Order status incorrect.");
+ return false;
+ }
- public List? ReadList(OrderSearchModel? model)
- {
- throw new NotImplementedException();
+ model.Status = newStatus;
+
+ if (model.Status == OrderStatus.Выдан)
+ model.DateImplement = DateTime.Now;
+
+ if (_orderStorage.Update(model) == null)
+ {
+ model.Status--;
+ _logger.LogWarning("Update operation failed");
+ return false;
+ }
+
+ return true;
}
public bool TakeOrderInWork(OrderBindingModel model)
{
- throw new NotImplementedException();
+ return StatusUpdate(model, OrderStatus.Выполняется);
+ }
+
+ public bool DeliveryOrder(OrderBindingModel model)
+ {
+ return StatusUpdate(model, OrderStatus.Готов);
+ }
+
+ public bool FinishOrder(OrderBindingModel model)
+ {
+ return StatusUpdate(model, OrderStatus.Выдан);
+ }
+
+ public List? ReadList(OrderSearchModel? model)
+ {
+ _logger.LogInformation("Order. OrderId:{Id}", model?.Id);
+
+ var list = model == null ? _orderStorage.GetFullList() : _orderStorage.GetFilteredList(model);
+
+ if (list == null)
+ {
+ _logger.LogWarning("ReadList return null list");
+ return null;
+ }
+
+ _logger.LogInformation("ReadList. Count:{Count}", list.Count);
+ return list;
+ }
+
+ private void CheckModel(OrderBindingModel model, bool withParams = true)
+ {
+ if (model == null)
+ {
+ throw new ArgumentNullException(nameof(model));
+ }
+
+ if (!withParams)
+ {
+ return;
+ }
+
+ if (model.PackageId < 0)
+ {
+ throw new ArgumentNullException("Некорректный идентификатор изделия", nameof(model.PackageId));
+ }
+
+ if (model.Count <= 0)
+ {
+ throw new ArgumentNullException("Количество изделий в заказе должно быть больше 0", nameof(model.Count));
+ }
+
+ if (model.Sum <= 0)
+ {
+ throw new ArgumentNullException("Сумма заказа должна быть больше 0", nameof(model.Sum));
+ }
+
+ _logger.LogInformation("Order. OrderId:{Id}.Sum:{ Sum}. PackageId: { PackageId}", model.Id, model.Sum, model.PackageId);
}
}
}
diff --git a/SoftwareInstallation/SoftwareInstallationBusinessLogic/SoftwareInstallationBusinessLogic.csproj b/SoftwareInstallation/SoftwareInstallationBusinessLogic/SoftwareInstallationBusinessLogic.csproj
index e90c31a..29f29c0 100644
--- a/SoftwareInstallation/SoftwareInstallationBusinessLogic/SoftwareInstallationBusinessLogic.csproj
+++ b/SoftwareInstallation/SoftwareInstallationBusinessLogic/SoftwareInstallationBusinessLogic.csproj
@@ -22,6 +22,8 @@
+
+
diff --git a/SoftwareInstallation/SoftwareInstallationDataModels/SoftwareInstallationDataModels.csproj b/SoftwareInstallation/SoftwareInstallationDataModels/SoftwareInstallationDataModels.csproj
index b047637..c02b0d1 100644
--- a/SoftwareInstallation/SoftwareInstallationDataModels/SoftwareInstallationDataModels.csproj
+++ b/SoftwareInstallation/SoftwareInstallationDataModels/SoftwareInstallationDataModels.csproj
@@ -22,6 +22,8 @@
+
+
diff --git a/SoftwareInstallation/SoftwareInstallationListImplement/SoftwareInstallationListImplement.csproj b/SoftwareInstallation/SoftwareInstallationListImplement/SoftwareInstallationListImplement.csproj
index fe1c43b..6ec57b2 100644
--- a/SoftwareInstallation/SoftwareInstallationListImplement/SoftwareInstallationListImplement.csproj
+++ b/SoftwareInstallation/SoftwareInstallationListImplement/SoftwareInstallationListImplement.csproj
@@ -6,6 +6,12 @@
enable
+
+
+
+
+
+