diff --git a/CarpentryWorkshop/CarpentryWorkshop/CarpentryWorkshopView.csproj b/CarpentryWorkshop/CarpentryWorkshop/CarpentryWorkshopView.csproj
index f9f9743..1f871b3 100644
--- a/CarpentryWorkshop/CarpentryWorkshop/CarpentryWorkshopView.csproj
+++ b/CarpentryWorkshop/CarpentryWorkshop/CarpentryWorkshopView.csproj
@@ -12,6 +12,10 @@
+
+
+
+
Always
@@ -25,6 +29,7 @@
+
@@ -36,4 +41,23 @@
+
+
+
+
+
+
+ True
+ True
+ Resources.resx
+
+
+
+
+
+ ResXFileCodeGenerator
+ Resources.Designer.cs
+
+
+
\ No newline at end of file
diff --git a/CarpentryWorkshop/CarpentryWorkshop/FormMain.Designer.cs b/CarpentryWorkshop/CarpentryWorkshop/FormMain.Designer.cs
index 08dbbfe..865c038 100644
--- a/CarpentryWorkshop/CarpentryWorkshop/FormMain.Designer.cs
+++ b/CarpentryWorkshop/CarpentryWorkshop/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();
@@ -44,7 +48,7 @@
//
// menuStrip1
//
- menuStrip1.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem });
+ menuStrip1.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, отчётыToolStripMenuItem });
menuStrip1.Location = new Point(0, 0);
menuStrip1.Name = "menuStrip1";
menuStrip1.Size = new Size(896, 24);
@@ -61,17 +65,45 @@
// КомпонентыToolStripMenuItem
//
КомпонентыToolStripMenuItem.Name = "КомпонентыToolStripMenuItem";
- КомпонентыToolStripMenuItem.Size = new Size(180, 22);
+ КомпонентыToolStripMenuItem.Size = new Size(145, 22);
КомпонентыToolStripMenuItem.Text = "Компоненты";
КомпонентыToolStripMenuItem.Click += КомпонентыToolStripMenuItem_Click;
//
// ИзделияToolStripMenuItem
//
ИзделияToolStripMenuItem.Name = "ИзделияToolStripMenuItem";
- ИзделияToolStripMenuItem.Size = new Size(180, 22);
+ ИзделияToolStripMenuItem.Size = new Size(145, 22);
ИзделияToolStripMenuItem.Text = "Изделия";
ИзделияToolStripMenuItem.Click += ИзделияToolStripMenuItem_Click;
//
+ // отчётыToolStripMenuItem
+ //
+ отчётыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { списокИзделийToolStripMenuItem, компонентыПоИзделиямToolStripMenuItem, списокЗаказовToolStripMenuItem });
+ отчётыToolStripMenuItem.Name = "отчётыToolStripMenuItem";
+ отчётыToolStripMenuItem.Size = new Size(60, 20);
+ отчётыToolStripMenuItem.Text = "Отчёты";
+ //
+ // списокИзделийToolStripMenuItem
+ //
+ списокИзделийToolStripMenuItem.Name = "списокИзделийToolStripMenuItem";
+ списокИзделийToolStripMenuItem.Size = new Size(218, 22);
+ списокИзделийToolStripMenuItem.Text = "Список изделий";
+ списокИзделийToolStripMenuItem.Click += списокИзделийToolStripMenuItem_Click;
+ //
+ // компонентыПоИзделиямToolStripMenuItem
+ //
+ компонентыПоИзделиямToolStripMenuItem.Name = "компонентыПоИзделиямToolStripMenuItem";
+ компонентыПоИзделиямToolStripMenuItem.Size = new Size(218, 22);
+ компонентыПоИзделиямToolStripMenuItem.Text = "Компоненты по изделиям";
+ компонентыПоИзделиямToolStripMenuItem.Click += компонентыПоИзделиямToolStripMenuItem_Click;
+ //
+ // списокЗаказовToolStripMenuItem
+ //
+ списокЗаказовToolStripMenuItem.Name = "списокЗаказовToolStripMenuItem";
+ списокЗаказовToolStripMenuItem.Size = new Size(218, 22);
+ списокЗаказовToolStripMenuItem.Text = "Список заказов";
+ списокЗаказовToolStripMenuItem.Click += списокЗаказовToolStripMenuItem_Click;
+ //
// dataGridView
//
dataGridView.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
@@ -174,5 +206,9 @@
private Button ButtonRef;
private ToolStripMenuItem КомпонентыToolStripMenuItem;
private ToolStripMenuItem ИзделияToolStripMenuItem;
+ private ToolStripMenuItem отчётыToolStripMenuItem;
+ private ToolStripMenuItem списокИзделийToolStripMenuItem;
+ private ToolStripMenuItem компонентыПоИзделиямToolStripMenuItem;
+ private ToolStripMenuItem списокЗаказовToolStripMenuItem;
}
}
\ No newline at end of file
diff --git a/CarpentryWorkshop/CarpentryWorkshop/FormMain.cs b/CarpentryWorkshop/CarpentryWorkshop/FormMain.cs
index 73d980e..c283592 100644
--- a/CarpentryWorkshop/CarpentryWorkshop/FormMain.cs
+++ b/CarpentryWorkshop/CarpentryWorkshop/FormMain.cs
@@ -10,11 +10,13 @@ namespace CarpentryWorkshopView
{
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)
{
@@ -147,6 +149,40 @@ namespace CarpentryWorkshopView
}
}
}
+
+ 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(FormReportWoodComponents));
+ if (service is FormReportWoodComponents 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 void ButtonRef_Click(object sender, EventArgs e)
{
LoadData();
diff --git a/CarpentryWorkshop/CarpentryWorkshop/FormReportOrders.Designer.cs b/CarpentryWorkshop/CarpentryWorkshop/FormReportOrders.Designer.cs
new file mode 100644
index 0000000..e29ba57
--- /dev/null
+++ b/CarpentryWorkshop/CarpentryWorkshop/FormReportOrders.Designer.cs
@@ -0,0 +1,133 @@
+using static System.Windows.Forms.VisualStyles.VisualStyleElement.Window;
+using System.Windows.Forms;
+
+namespace CarpentryWorkshopView
+{
+ partial class FormReportOrders
+ {
+ ///
+ /// 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()
+ {
+ panel = new Panel();
+ labelFrom = new Label();
+ buttonToPdf = new Button();
+ dateTimePickerDateFrom = new DateTimePicker();
+ labelTo = new Label();
+ dateTimePickerDateTo = new DateTimePicker();
+ buttonMake = new Button();
+ panel.SuspendLayout();
+ SuspendLayout();
+ //
+ // panel
+ //
+ panel.Controls.Add(labelFrom);
+ panel.Controls.Add(buttonToPdf);
+ panel.Controls.Add(dateTimePickerDateFrom);
+ panel.Controls.Add(labelTo);
+ panel.Controls.Add(dateTimePickerDateTo);
+ panel.Controls.Add(buttonMake);
+ panel.Dock = DockStyle.Top;
+ panel.Location = new Point(0, 0);
+ panel.Name = "panel";
+ panel.Size = new Size(1321, 71);
+ panel.TabIndex = 3;
+ //
+ // labelFrom
+ //
+ labelFrom.AutoSize = true;
+ labelFrom.Location = new Point(16, 31);
+ labelFrom.Name = "labelFrom";
+ labelFrom.Size = new Size(18, 20);
+ labelFrom.TabIndex = 3;
+ labelFrom.Text = "С";
+ //
+ // buttonToPdf
+ //
+ buttonToPdf.Location = new Point(1200, 27);
+ buttonToPdf.Name = "buttonToPdf";
+ buttonToPdf.Size = new Size(94, 29);
+ buttonToPdf.TabIndex = 4;
+ buttonToPdf.Text = "В PDF";
+ buttonToPdf.UseVisualStyleBackColor = true;
+ buttonToPdf.Click += ButtonToPdf_Click;
+ //
+ // dateTimePickerDateFrom
+ //
+ dateTimePickerDateFrom.Location = new Point(51, 27);
+ dateTimePickerDateFrom.Name = "dateTimePickerDateFrom";
+ dateTimePickerDateFrom.Size = new Size(250, 27);
+ dateTimePickerDateFrom.TabIndex = 0;
+ //
+ // labelTo
+ //
+ labelTo.AutoSize = true;
+ labelTo.Location = new Point(317, 31);
+ labelTo.Name = "labelTo";
+ labelTo.Size = new Size(29, 20);
+ labelTo.TabIndex = 4;
+ labelTo.Text = "По";
+ //
+ // dateTimePickerDateTo
+ //
+ dateTimePickerDateTo.Location = new Point(365, 27);
+ dateTimePickerDateTo.Name = "dateTimePickerDateTo";
+ dateTimePickerDateTo.Size = new Size(250, 27);
+ dateTimePickerDateTo.TabIndex = 1;
+ //
+ // buttonMake
+ //
+ buttonMake.Location = new Point(677, 27);
+ buttonMake.Name = "buttonMake";
+ buttonMake.Size = new Size(132, 29);
+ buttonMake.TabIndex = 3;
+ buttonMake.Text = "Сформировать";
+ buttonMake.UseVisualStyleBackColor = true;
+ buttonMake.Click += ButtonMake_Click;
+ //
+ // FormReportOrders
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(1321, 450);
+ Controls.Add(panel);
+ Name = "FormReportOrders";
+ Text = "FormReportOrders";
+ panel.ResumeLayout(false);
+ panel.PerformLayout();
+ ResumeLayout(false);
+ }
+
+ #endregion
+
+ private Panel panel;
+ private DateTimePicker dateTimePickerDateTo;
+ private DateTimePicker dateTimePickerDateFrom;
+ private Button buttonMake;
+ private Button buttonToPdf;
+ private Label labelTo;
+ private Label labelFrom;
+ }
+}
\ No newline at end of file
diff --git a/CarpentryWorkshop/CarpentryWorkshop/FormReportOrders.cs b/CarpentryWorkshop/CarpentryWorkshop/FormReportOrders.cs
new file mode 100644
index 0000000..eb4374d
--- /dev/null
+++ b/CarpentryWorkshop/CarpentryWorkshop/FormReportOrders.cs
@@ -0,0 +1,93 @@
+using CarpentryWorkshopContracts.BindingModels;
+using CarpentryWorkshopContracts.BusinessLogicsContracts;
+using Microsoft.Extensions.Logging;
+using Microsoft.Reporting.WinForms;
+using System.IO;
+
+namespace CarpentryWorkshopView
+{
+ public partial class FormReportOrders : Form
+ {
+ private readonly ReportViewer reportViewer;
+ private readonly ILogger _logger;
+ private readonly IReportLogic _logic;
+ public FormReportOrders(ILogger logger, IReportLogic logic)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _logic = logic;
+ reportViewer = new ReportViewer
+ {
+ Dock = DockStyle.Fill
+ };
+ var path = Directory.GetParent(Directory.GetCurrentDirectory())?.Parent?.Parent?.ToString() + "\\ReportOrders.rdlc";
+ reportViewer.LocalReport.LoadReportDefinition(new FileStream(path, FileMode.Open));
+ Controls.Clear();
+ Controls.Add(reportViewer);
+ Controls.Add(panel);
+ }
+ private void ButtonMake_Click(object sender, EventArgs e)
+ {
+ if (dateTimePickerDateFrom.Value.Date >= dateTimePickerDateTo.Value.Date)
+ {
+ MessageBox.Show("Дата начала должна быть меньше даты окончания",
+ "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ try
+ {
+ var dataSource = _logic.GetOrders(new ReportBindingModel
+ {
+ DateFrom = dateTimePickerDateFrom.Value,
+ DateTo = dateTimePickerDateTo.Value
+ });
+ var source = new ReportDataSource("DataSetOrders", dataSource);
+ reportViewer.LocalReport.DataSources.Clear();
+ reportViewer.LocalReport.DataSources.Add(source);
+ var parameters = new[] { new ReportParameter("ReportParameterPeriod", $"c {dateTimePickerDateFrom.Value.ToShortDateString()} по {dateTimePickerDateTo.Value.ToShortDateString()}") };
+
+ reportViewer.LocalReport.SetParameters(parameters);
+ reportViewer.RefreshReport();
+ _logger.LogInformation("Загрузка списка заказов на период {From}-{To}",
+ dateTimePickerDateFrom.Value.ToShortDateString(), dateTimePickerDateTo.Value.ToShortDateString());
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка загрузки списка заказов на период");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ private void ButtonToPdf_Click(object sender, EventArgs e)
+ {
+ if (dateTimePickerDateFrom.Value.Date >= dateTimePickerDateTo.Value.Date)
+ {
+ MessageBox.Show("Дата начала должна быть меньше даты окончания", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ using var dialog = new SaveFileDialog
+ {
+ Filter = "pdf|*.pdf"
+ };
+ if (dialog.ShowDialog() == DialogResult.OK)
+ {
+ try
+ {
+ _logic.SaveOrdersToPdfFile(new ReportBindingModel
+ {
+ FileName = dialog.FileName,
+ DateFrom = dateTimePickerDateFrom.Value,
+ DateTo = dateTimePickerDateTo.Value
+ });
+ _logger.LogInformation("Сохранение списка заказов на период {From}-{To} ",
+ dateTimePickerDateFrom.Value.ToShortDateString(), dateTimePickerDateTo.Value.ToShortDateString());
+ MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка сохранения списка заказов на период");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+ }
+}
diff --git a/CarpentryWorkshop/CarpentryWorkshop/FormReportOrders.resx b/CarpentryWorkshop/CarpentryWorkshop/FormReportOrders.resx
new file mode 100644
index 0000000..1af7de1
--- /dev/null
+++ b/CarpentryWorkshop/CarpentryWorkshop/FormReportOrders.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/CarpentryWorkshop/CarpentryWorkshop/FormReportWoodComponents.Designer.cs b/CarpentryWorkshop/CarpentryWorkshop/FormReportWoodComponents.Designer.cs
new file mode 100644
index 0000000..0e2656d
--- /dev/null
+++ b/CarpentryWorkshop/CarpentryWorkshop/FormReportWoodComponents.Designer.cs
@@ -0,0 +1,106 @@
+namespace CarpentryWorkshopView
+{
+ partial class FormReportWoodComponents
+ {
+ ///
+ /// 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();
+ WoodColumn = new DataGridViewTextBoxColumn();
+ CountColumn = new DataGridViewTextBoxColumn();
+ ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
+ SuspendLayout();
+ //
+ // dataGridView
+ //
+ dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridView.Columns.AddRange(new DataGridViewColumn[] { ComponentColumn, WoodColumn, 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";
+ //
+ // WoodColumn
+ //
+ WoodColumn.HeaderText = "Изделие";
+ WoodColumn.MinimumWidth = 6;
+ WoodColumn.Name = "WoodColumn";
+ WoodColumn.Width = 200;
+ //
+ // CountColumn
+ //
+ CountColumn.HeaderText = "Количество";
+ CountColumn.MinimumWidth = 6;
+ CountColumn.Name = "CountColumn";
+ CountColumn.Width = 130;
+ //
+ // FormReportWoodComponents
+ //
+ 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 = "FormReportWoodComponents";
+ Text = "Компоненты по изделиям";
+ Load += FormReportWoodComponents_Load;
+ ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
+ ResumeLayout(false);
+ }
+
+ #endregion
+
+ private DataGridView dataGridView;
+ private Button SaveButton;
+ private DataGridViewTextBoxColumn ComponentColumn;
+ private DataGridViewTextBoxColumn WoodColumn;
+ private DataGridViewTextBoxColumn CountColumn;
+ }
+}
\ No newline at end of file
diff --git a/CarpentryWorkshop/CarpentryWorkshop/FormReportWoodComponents.cs b/CarpentryWorkshop/CarpentryWorkshop/FormReportWoodComponents.cs
new file mode 100644
index 0000000..a4d2aa0
--- /dev/null
+++ b/CarpentryWorkshop/CarpentryWorkshop/FormReportWoodComponents.cs
@@ -0,0 +1,88 @@
+using CarpentryWorkshopContracts.BindingModels;
+using CarpentryWorkshopContracts.BusinessLogicsContracts;
+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 CarpentryWorkshopView
+{
+ public partial class FormReportWoodComponents : Form
+ {
+ private readonly ILogger _logger;
+ private readonly IReportLogic _logic;
+
+ public FormReportWoodComponents(ILogger logger, IReportLogic logic)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _logic = logic;
+ }
+
+ private void FormReportWoodComponents_Load(object sender, EventArgs e)
+ {
+ try
+ {
+ var dict = _logic.GetWoodComponent();
+ if (dict != null)
+ {
+ dataGridView.Rows.Clear();
+ foreach (var elem in dict)
+ {
+ dataGridView.Rows.Add(new object[] { elem.WoodName, "", "" });
+ 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