diff --git a/AutomobilePlant/AutomobilePlant.csproj b/AutomobilePlant/AutomobilePlant.csproj
index da453a9..cb30119 100644
--- a/AutomobilePlant/AutomobilePlant.csproj
+++ b/AutomobilePlant/AutomobilePlant.csproj
@@ -2,24 +2,20 @@
WinExe
- net7.0-windows
+ net6.0-windows
enable
true
enable
-
all
runtime; build; native; contentfiles; analyzers; buildtransitive
-
- all
- runtime; build; native; contentfiles; analyzers; buildtransitive
-
+
@@ -31,4 +27,10 @@
+
+
+ Always
+
+
+
\ No newline at end of file
diff --git a/AutomobilePlant/FormMain.Designer.cs b/AutomobilePlant/FormMain.Designer.cs
index 8ad81b0..7b0b9de 100644
--- a/AutomobilePlant/FormMain.Designer.cs
+++ b/AutomobilePlant/FormMain.Designer.cs
@@ -32,6 +32,10 @@
this.справочникиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.компонентыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.автомобилиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.отчетыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ 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.buttonCreateOrder = new System.Windows.Forms.Button();
this.buttonSetToWork = new System.Windows.Forms.Button();
@@ -46,7 +50,8 @@
//
this.menuStrip.ImageScalingSize = new System.Drawing.Size(20, 20);
this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
- this.справочникиToolStripMenuItem});
+ this.справочникиToolStripMenuItem,
+ this.отчетыToolStripMenuItem});
this.menuStrip.Location = new System.Drawing.Point(0, 0);
this.menuStrip.Name = "menuStrip";
this.menuStrip.Size = new System.Drawing.Size(1176, 28);
@@ -76,6 +81,38 @@
this.автомобилиToolStripMenuItem.Text = "Автомобили";
this.автомобилиToolStripMenuItem.Click += new System.EventHandler(this.автомобилиToolStripMenuItem_Click);
//
+ // отчетыToolStripMenuItem
+ //
+ this.отчетыToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.списокАвтомобилейToolStripMenuItem,
+ this.компонентыПоАвтомобилямToolStripMenuItem,
+ this.списокЗаказовToolStripMenuItem});
+ this.отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem";
+ this.отчетыToolStripMenuItem.Size = new System.Drawing.Size(73, 24);
+ this.отчетыToolStripMenuItem.Text = "Отчеты";
+ //
+ // списокАвтомобилейToolStripMenuItem
+ //
+ this.списокАвтомобилейToolStripMenuItem.Name = "списокАвтомобилейToolStripMenuItem";
+ this.списокАвтомобилейToolStripMenuItem.Size = new System.Drawing.Size(252, 26);
+ this.списокАвтомобилейToolStripMenuItem.Text = "Список автомобилей";
+ this.списокАвтомобилейToolStripMenuItem.Click += new System.EventHandler(this.списокАвтомобилейToolStripMenuItem_Click);
+ //
+ // компонентыПоАвтомобилямToolStripMenuItem
+ //
+ this.компонентыПоАвтомобилямToolStripMenuItem.Name = "компонентыПоАвтомобилямToolStripMenuItem";
+ this.компонентыПоАвтомобилямToolStripMenuItem.Size = new System.Drawing.Size(252, 26);
+ this.компонентыПоАвтомобилямToolStripMenuItem.Text = "Компоненты по автомобилям";
+ this.компонентыПоАвтомобилямToolStripMenuItem.Click += new System.EventHandler(this.компонентыПоАвтомобилямToolStripMenuItem_Click);
+ //
+ // списокЗаказовToolStripMenuItem
+ //
+ this.списокЗаказовToolStripMenuItem.Name = "списокЗаказовToolStripMenuItem";
+ this.списокЗаказовToolStripMenuItem.Size = new System.Drawing.Size(252, 26);
+ this.списокЗаказовToolStripMenuItem.Text = "Список заказов";
+ this.списокЗаказовToolStripMenuItem.Click += new System.EventHandler(this.списокЗаказовToolStripMenuItem_Click);
+ //
+ //
// dataGridView
//
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
@@ -172,5 +209,9 @@
private Button buttonSetToDone;
private Button buttonSetToFinish;
private Button buttonUpdate;
+ private ToolStripMenuItem отчетыToolStripMenuItem;
+ private ToolStripMenuItem списокАвтомобилейToolStripMenuItem;
+ private ToolStripMenuItem компонентыПоАвтомобилямToolStripMenuItem;
+ private ToolStripMenuItem списокЗаказовToolStripMenuItem;
}
}
\ No newline at end of file
diff --git a/AutomobilePlant/FormMain.cs b/AutomobilePlant/FormMain.cs
index 02cfdf1..72f6283 100644
--- a/AutomobilePlant/FormMain.cs
+++ b/AutomobilePlant/FormMain.cs
@@ -1,4 +1,5 @@
-using AutomobilePlantContracts.BindingModels;
+using AutomobilePlantBusinessLogic.BusinessLogics;
+using AutomobilePlantContracts.BindingModels;
using AutomobilePlantContracts.BusinessLogicContracts;
using AutomobilePlantDataModels.Enums;
using Microsoft.Extensions.Logging;
@@ -18,11 +19,13 @@ namespace AutomobilePlant
{
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 FormMain_Load(object sender, EventArgs e)
@@ -69,6 +72,38 @@ namespace AutomobilePlant
}
}
+ private void компонентыПоАвтомобилямToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormReportCarComponents));
+ if (service is FormReportCarComponents form)
+ {
+ form.ShowDialog();
+ }
+ }
+
+ private void списокЗаказовToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormReportOrder));
+ if (service is FormReportOrder form)
+ {
+ form.ShowDialog();
+ }
+ }
+
+ private void списокАвтомобилейToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ using var dialog = new SaveFileDialog { Filter = "docx|*.docx" };
+ if (dialog.ShowDialog() == DialogResult.OK)
+ {
+ _reportLogic.SaveCarsToWordFile(new ReportBindingModel
+ {
+ FileName = dialog.FileName
+ });
+ MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ }
+
+ }
+
private void ButtonCreateOrder_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder));
diff --git a/AutomobilePlant/FormReportCarComponents.Designer.cs b/AutomobilePlant/FormReportCarComponents.Designer.cs
new file mode 100644
index 0000000..e286896
--- /dev/null
+++ b/AutomobilePlant/FormReportCarComponents.Designer.cs
@@ -0,0 +1,110 @@
+namespace AutomobilePlant
+{
+ partial class FormReportCarComponents
+ {
+ ///
+ /// 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.buttonSaveToExcel = new System.Windows.Forms.Button();
+ this.Car = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.Component = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.Count = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
+ this.SuspendLayout();
+ //
+ // dataGridView
+ //
+ this.dataGridView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+ | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
+ this.Car,
+ this.Component,
+ this.Count});
+ this.dataGridView.Location = new System.Drawing.Point(12, 37);
+ this.dataGridView.Name = "dataGridView";
+ this.dataGridView.RowHeadersWidth = 51;
+ this.dataGridView.RowTemplate.Height = 29;
+ this.dataGridView.Size = new System.Drawing.Size(776, 401);
+ this.dataGridView.TabIndex = 0;
+ //
+ // buttonSaveToExcel
+ //
+ this.buttonSaveToExcel.Location = new System.Drawing.Point(12, 2);
+ this.buttonSaveToExcel.Name = "buttonSaveToExcel";
+ this.buttonSaveToExcel.Size = new System.Drawing.Size(220, 29);
+ this.buttonSaveToExcel.TabIndex = 1;
+ this.buttonSaveToExcel.Text = "Сохранить в Excel";
+ this.buttonSaveToExcel.UseVisualStyleBackColor = true;
+ this.buttonSaveToExcel.Click += new System.EventHandler(this.buttonSaveToExcel_Click);
+ //
+ // Car
+ //
+ this.Car.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
+ this.Car.HeaderText = "Автомобиль";
+ this.Car.MinimumWidth = 6;
+ this.Car.Name = "Car";
+ //
+ // Component
+ //
+ this.Component.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
+ this.Component.HeaderText = "Компонент";
+ this.Component.MinimumWidth = 6;
+ this.Component.Name = "Component";
+ //
+ // Count
+ //
+ this.Count.HeaderText = "Количество";
+ this.Count.MinimumWidth = 6;
+ this.Count.Name = "Count";
+ this.Count.Width = 125;
+ //
+ // FormReportCarComponents
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(800, 450);
+ this.Controls.Add(this.buttonSaveToExcel);
+ this.Controls.Add(this.dataGridView);
+ this.Name = "FormReportCarComponents";
+ this.Text = "Компоненты по автомобилям";
+ this.Load += new System.EventHandler(this.FormReportCarComponents_Load);
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private DataGridView dataGridView;
+ private Button buttonSaveToExcel;
+ private DataGridViewTextBoxColumn Car;
+ private DataGridViewTextBoxColumn Component;
+ private DataGridViewTextBoxColumn Count;
+ }
+}
\ No newline at end of file
diff --git a/AutomobilePlant/FormReportCarComponents.cs b/AutomobilePlant/FormReportCarComponents.cs
new file mode 100644
index 0000000..3416a7a
--- /dev/null
+++ b/AutomobilePlant/FormReportCarComponents.cs
@@ -0,0 +1,85 @@
+using AutomobilePlantContracts.BindingModels;
+using AutomobilePlantContracts.BusinessLogicContracts;
+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 AutomobilePlant
+{
+ public partial class FormReportCarComponents : Form
+ {
+ private readonly ILogger _logger;
+ private readonly IReportLogic _logic;
+
+ public FormReportCarComponents(ILogger logger, IReportLogic logic)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _logic = logic;
+ }
+
+ private void FormReportCarComponents_Load(object sender, EventArgs e)
+ {
+ try
+ {
+ var dict = _logic.GetCarComponents();
+ if (dict != null)
+ {
+ dataGridView.Rows.Clear();
+ foreach (var elem in dict)
+ {
+ dataGridView.Rows.Add(new object[] { elem.CarName, "", "" });
+ foreach (var listElem in elem.Components)
+ {
+ dataGridView.Rows.Add(new object[] { "", listElem.Item1, listElem.Item2 });
+ }
+ dataGridView.Rows.Add(new object[] { "Итого", "", elem.TotalCount });
+ dataGridView.Rows.Add(Array.Empty