diff --git a/ComputersShop/ComputersShop/ComputersShop.csproj b/ComputersShop/ComputersShop/ComputersShop.csproj
index 1a00870..30d51d0 100644
--- a/ComputersShop/ComputersShop/ComputersShop.csproj
+++ b/ComputersShop/ComputersShop/ComputersShop.csproj
@@ -9,7 +9,7 @@
-
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
@@ -20,6 +20,7 @@
+
diff --git a/ComputersShop/ComputersShop/FormMain.Designer.cs b/ComputersShop/ComputersShop/FormMain.Designer.cs
index b0fd856..4c9d187 100644
--- a/ComputersShop/ComputersShop/FormMain.Designer.cs
+++ b/ComputersShop/ComputersShop/FormMain.Designer.cs
@@ -32,6 +32,10 @@
справочникиToolStripMenuItem = new ToolStripMenuItem();
компонентыToolStripMenuItem = new ToolStripMenuItem();
компьютерыToolStripMenuItem = new ToolStripMenuItem();
+ отчетыToolStripMenuItem = new ToolStripMenuItem();
+ списокКомпонентовToolStripMenuItem = new ToolStripMenuItem();
+ компонентыПоКомпьютерамToolStripMenuItem = new ToolStripMenuItem();
+ списокЗаказовToolStripMenuItem = new ToolStripMenuItem();
dataGridView = new DataGridView();
buttonCreateOrder = new Button();
buttonTakeOrderInWork = new Button();
@@ -45,7 +49,7 @@
// menuStrip
//
menuStrip.ImageScalingSize = new Size(20, 20);
- menuStrip.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem });
+ menuStrip.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, отчетыToolStripMenuItem });
menuStrip.Location = new Point(0, 0);
menuStrip.Name = "menuStrip";
menuStrip.Size = new Size(1209, 28);
@@ -62,17 +66,45 @@
// компонентыToolStripMenuItem
//
компонентыToolStripMenuItem.Name = "компонентыToolStripMenuItem";
- компонентыToolStripMenuItem.Size = new Size(224, 26);
+ компонентыToolStripMenuItem.Size = new Size(184, 26);
компонентыToolStripMenuItem.Text = "Компоненты";
компонентыToolStripMenuItem.Click += ComponentsStripMenuItem_Click;
//
// компьютерыToolStripMenuItem
//
компьютерыToolStripMenuItem.Name = "компьютерыToolStripMenuItem";
- компьютерыToolStripMenuItem.Size = new Size(224, 26);
+ компьютерыToolStripMenuItem.Size = new Size(184, 26);
компьютерыToolStripMenuItem.Text = "Компьютеры";
компьютерыToolStripMenuItem.Click += ComputersStripMenuItem_Click;
//
+ // отчетыToolStripMenuItem
+ //
+ отчетыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { списокКомпонентовToolStripMenuItem, компонентыПоКомпьютерамToolStripMenuItem, списокЗаказовToolStripMenuItem });
+ отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem";
+ отчетыToolStripMenuItem.Size = new Size(73, 24);
+ отчетыToolStripMenuItem.Text = "Отчеты";
+ //
+ // списокКомпонентовToolStripMenuItem
+ //
+ списокКомпонентовToolStripMenuItem.Name = "списокКомпонентовToolStripMenuItem";
+ списокКомпонентовToolStripMenuItem.Size = new Size(306, 26);
+ списокКомпонентовToolStripMenuItem.Text = "Список компонентов";
+ списокКомпонентовToolStripMenuItem.Click += списокКомпонентовToolStripMenuItem_Click;
+ //
+ // компонентыПоКомпьютерамToolStripMenuItem
+ //
+ компонентыПоКомпьютерамToolStripMenuItem.Name = "компонентыПоКомпьютерамToolStripMenuItem";
+ компонентыПоКомпьютерамToolStripMenuItem.Size = new Size(306, 26);
+ компонентыПоКомпьютерамToolStripMenuItem.Text = "Компоненты по компьютерам";
+ компонентыПоКомпьютерамToolStripMenuItem.Click += компонентыПоКомпьютерамToolStripMenuItem_Click;
+ //
+ // списокЗаказовToolStripMenuItem
+ //
+ списокЗаказовToolStripMenuItem.Name = "списокЗаказовToolStripMenuItem";
+ списокЗаказовToolStripMenuItem.Size = new Size(306, 26);
+ списокЗаказовToolStripMenuItem.Text = "Список заказов";
+ списокЗаказовToolStripMenuItem.Click += списокЗаказовToolStripMenuItem_Click;
+ //
// dataGridView
//
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
@@ -168,5 +200,9 @@
private Button buttonOrderReady;
private Button buttonIssuedOrder;
private Button buttonRefresh;
+ private ToolStripMenuItem отчетыToolStripMenuItem;
+ private ToolStripMenuItem списокКомпонентовToolStripMenuItem;
+ private ToolStripMenuItem компонентыПоКомпьютерамToolStripMenuItem;
+ private ToolStripMenuItem списокЗаказовToolStripMenuItem;
}
}
\ No newline at end of file
diff --git a/ComputersShop/ComputersShop/FormMain.cs b/ComputersShop/ComputersShop/FormMain.cs
index d55f106..72e4f3d 100644
--- a/ComputersShop/ComputersShop/FormMain.cs
+++ b/ComputersShop/ComputersShop/FormMain.cs
@@ -18,11 +18,14 @@ namespace ComputersShop
{
private readonly ILogger _logger;
private readonly IOrderLogic _orderLogic;
- public FormMain(ILogger logger, IOrderLogic orderLogic)
+ private readonly IReportLogic _reportLogic;
+
+ public FormMain(ILogger logger, IOrderLogic orderLogic, IReportLogic reportLogic)
{
InitializeComponent();
_logger = logger;
_orderLogic = orderLogic;
+ _reportLogic = reportLogic;
}
private void ComponentsStripMenuItem_Click(object sender, EventArgs e)
@@ -79,6 +82,42 @@ namespace ComputersShop
}
}
+ private void списокКомпонентовToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ using var dialog = new SaveFileDialog { Filter = "docx|*.docx" };
+ if (dialog.ShowDialog() == DialogResult.OK)
+ {
+ _reportLogic.SaveComponentsToWordFile(new ReportBindingModel
+ {
+ FileName = dialog.FileName
+ });
+ MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK,
+ MessageBoxIcon.Information);
+ }
+
+ }
+
+ private void компонентыПоКомпьютерамToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ var service =
+Program.ServiceProvider?.GetService(typeof(FormReportComputerComponents));
+ if (service is FormReportComputerComponents form)
+ {
+ form.ShowDialog();
+ }
+
+ }
+
+ private void списокЗаказовToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormReportOrders));
+ if (service is FormReportOrders form)
+ {
+ form.ShowDialog();
+ }
+
+ }
+
private OrderBindingModel CreateBindingModel(int id, bool isDone = false)
{
return new OrderBindingModel
diff --git a/ComputersShop/ComputersShop/FormReportComputerComponents.Designer.cs b/ComputersShop/ComputersShop/FormReportComputerComponents.Designer.cs
new file mode 100644
index 0000000..46134a4
--- /dev/null
+++ b/ComputersShop/ComputersShop/FormReportComputerComponents.Designer.cs
@@ -0,0 +1,106 @@
+namespace ComputersShop
+{
+ partial class FormReportComputerComponents
+ {
+ ///
+ /// 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()
+ {
+ dataGridView = new DataGridView();
+ SaveButton = new Button();
+ ComponentColumn = new DataGridViewTextBoxColumn();
+ ComputerColumn = new DataGridViewTextBoxColumn();
+ CountColumn = new DataGridViewTextBoxColumn();
+ ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
+ SuspendLayout();
+ //
+ // dataGridView
+ //
+ dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridView.Columns.AddRange(new DataGridViewColumn[] { ComponentColumn, ComputerColumn, CountColumn });
+ dataGridView.Location = new Point(14, 61);
+ dataGridView.Margin = new Padding(3, 4, 3, 4);
+ dataGridView.Name = "dataGridView";
+ dataGridView.RowHeadersWidth = 51;
+ dataGridView.RowTemplate.Height = 25;
+ dataGridView.Size = new Size(651, 523);
+ dataGridView.TabIndex = 0;
+ //
+ // SaveButton
+ //
+ SaveButton.Location = new Point(14, 23);
+ SaveButton.Margin = new Padding(3, 4, 3, 4);
+ SaveButton.Name = "SaveButton";
+ SaveButton.Size = new Size(193, 31);
+ SaveButton.TabIndex = 1;
+ SaveButton.Text = "Сохранить в Excel";
+ SaveButton.UseVisualStyleBackColor = true;
+ SaveButton.Click += SaveButton_Click;
+ //
+ // ComponentColumn
+ //
+ ComponentColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
+ ComponentColumn.HeaderText = "Компонент";
+ ComponentColumn.MinimumWidth = 6;
+ ComponentColumn.Name = "ComponentColumn";
+ //
+ // ComputerColumn
+ //
+ ComputerColumn.HeaderText = "Компьютер";
+ ComputerColumn.MinimumWidth = 6;
+ ComputerColumn.Name = "ComputerColumn";
+ ComputerColumn.Width = 200;
+ //
+ // CountColumn
+ //
+ CountColumn.HeaderText = "Количество";
+ CountColumn.MinimumWidth = 6;
+ CountColumn.Name = "CountColumn";
+ CountColumn.Width = 130;
+ //
+ // FormReportComputerComponents
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(679, 600);
+ Controls.Add(SaveButton);
+ Controls.Add(dataGridView);
+ Margin = new Padding(3, 4, 3, 4);
+ Name = "FormReportComputerComponents";
+ Text = "Компоненты по компьютерам";
+ Load += ReportComputerComponentForm_Load;
+ ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
+ ResumeLayout(false);
+ }
+
+ #endregion
+
+ private DataGridView dataGridView;
+ private Button SaveButton;
+ private DataGridViewTextBoxColumn ComponentColumn;
+ private DataGridViewTextBoxColumn ComputerColumn;
+ private DataGridViewTextBoxColumn CountColumn;
+ }
+}
\ No newline at end of file
diff --git a/ComputersShop/ComputersShop/FormReportComputerComponents.cs b/ComputersShop/ComputersShop/FormReportComputerComponents.cs
new file mode 100644
index 0000000..fc0465a
--- /dev/null
+++ b/ComputersShop/ComputersShop/FormReportComputerComponents.cs
@@ -0,0 +1,91 @@
+using ComputersShopContracts.BindingModels;
+using ComputersShopContracts.BisnessLogicsContracts;
+using Microsoft.Extensions.Logging;
+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 ComputersShop
+{
+ public partial class FormReportComputerComponents : Form
+ {
+ private readonly ILogger _logger;
+ private readonly IReportLogic _logic;
+
+ public FormReportComputerComponents(ILogger
+logger, IReportLogic logic)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _logic = logic;
+
+ }
+
+ private void ReportComputerComponentForm_Load(object sender, EventArgs e)
+ {
+ try
+ {
+ var dict = _logic.GetComputerComponent();
+ if (dict != null)
+ {
+ dataGridView.Rows.Clear();
+ foreach (var elem in dict)
+ {
+ dataGridView.Rows.Add(new object[] { elem.ComponentName, "", "" });
+ foreach (var listElem in elem.Computers)
+ {
+ dataGridView.Rows.Add(new object[] { "", listElem.Item1, listElem.Item2 });
+ }
+ dataGridView.Rows.Add(new object[] { "Итого", "", elem.TotalCount });
+ dataGridView.Rows.Add(Array.Empty