diff --git a/PlumbingRepair/PlumbingRepair/FormMain.Designer.cs b/PlumbingRepair/PlumbingRepair/FormMain.Designer.cs
index 64d2253..3470fab 100644
--- a/PlumbingRepair/PlumbingRepair/FormMain.Designer.cs
+++ b/PlumbingRepair/PlumbingRepair/FormMain.Designer.cs
@@ -1,31 +1,31 @@
-namespace PlumbingRepairView
-{
- 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.
- ///
+namespace PlumbingRepairView
+{
+ 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()
{
menuStrip1 = new MenuStrip();
@@ -48,7 +48,7 @@
// menuStrip1
//
menuStrip1.ImageScalingSize = new Size(20, 20);
- menuStrip1.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem });
+ menuStrip1.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, отчётыToolStripMenuItem });
menuStrip1.Location = new Point(0, 0);
menuStrip1.Name = "menuStrip1";
menuStrip1.Padding = new Padding(8, 2, 0, 2);
@@ -198,20 +198,20 @@
PerformLayout();
}
- #endregion
+ #endregion
- private MenuStrip menuStrip1;
- private ToolStripMenuItem справочникиToolStripMenuItem;
- private DataGridView dataGridView;
- private Button buttonCreateOrder;
- private Button buttonTakeOrderInWork;
- private Button buttonOrderReady;
- private Button buttonIssuedOrder;
- private Button buttonUpdateList;
+ private MenuStrip menuStrip1;
+ private ToolStripMenuItem справочникиToolStripMenuItem;
+ private DataGridView dataGridView;
+ private Button buttonCreateOrder;
+ private Button buttonTakeOrderInWork;
+ private Button buttonOrderReady;
+ private Button buttonIssuedOrder;
+ private Button buttonUpdateList;
private ToolStripMenuItem магазинToolStripMenuItem;
private Button StoreReplenishment;
- private ToolStripMenuItem компонентыToolStripMenuItem;
- private ToolStripMenuItem работыToolStripMenuItem;
+ private ToolStripMenuItem компонентыToolStripMenuItem;
+ private ToolStripMenuItem работыToolStripMenuItem;
private Button SellWorkButton;
- }
+ }
}
\ No newline at end of file
diff --git a/PlumbingRepair/PlumbingRepair/FormMain.cs b/PlumbingRepair/PlumbingRepair/FormMain.cs
index 48606bd..54df92f 100644
--- a/PlumbingRepair/PlumbingRepair/FormMain.cs
+++ b/PlumbingRepair/PlumbingRepair/FormMain.cs
@@ -1,4 +1,5 @@
using Microsoft.Extensions.Logging;
+using PlumbingRepairBusinessLogic.BusinessLogics;
using PlumbingRepairContracts.BindingModels;
using PlumbingRepairContracts.BusinessLogicsContracts;
using PlumbingRepairDataModels.Enums;
@@ -18,8 +19,9 @@ namespace PlumbingRepairView
{
private readonly ILogger _logger;
private readonly IOrderLogic _orderLogic;
+ private readonly IReportLogic _reportLogic;
- public FormMain(ILogger logger, IOrderLogic orderLogic)
+ public FormMain(ILogger logger, IOrderLogic orderLogic, IReportLogic reportLogic)
{
InitializeComponent();
_logger = logger;
diff --git a/PlumbingRepair/PlumbingRepair/FormReportOrders.Designer.cs b/PlumbingRepair/PlumbingRepair/FormReportOrders.Designer.cs
new file mode 100644
index 0000000..6fea66f
--- /dev/null
+++ b/PlumbingRepair/PlumbingRepair/FormReportOrders.Designer.cs
@@ -0,0 +1,143 @@
+using DocumentFormat.OpenXml.Spreadsheet;
+using DocumentFormat.OpenXml.Wordprocessing;
+
+namespace PlumbingRepairView
+{
+ 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();
+ buttonToPdf = new Button();
+ buttonCreateReport = new Button();
+ dateTimePickerTo = new DateTimePicker();
+ labelTo = new Label();
+ dateTimePickerFrom = new DateTimePicker();
+ labelFrom = new Label();
+ panel.SuspendLayout();
+ SuspendLayout();
+ //
+ // panel
+ //
+ panel.Controls.Add(buttonToPdf);
+ panel.Controls.Add(buttonCreateReport);
+ panel.Controls.Add(dateTimePickerTo);
+ panel.Controls.Add(labelTo);
+ panel.Controls.Add(dateTimePickerFrom);
+ panel.Controls.Add(labelFrom);
+ panel.Dock = DockStyle.Top;
+ panel.Location = new Point(0, 0);
+ panel.Margin = new Padding(4, 3, 4, 3);
+ panel.Name = "panel";
+ panel.Size = new Size(1031, 40);
+ panel.TabIndex = 0;
+ //
+ // buttonToPdf
+ //
+ buttonToPdf.Anchor = AnchorStyles.Top | AnchorStyles.Right;
+ buttonToPdf.Location = new Point(878, 8);
+ buttonToPdf.Margin = new Padding(4, 3, 4, 3);
+ buttonToPdf.Name = "buttonToPdf";
+ buttonToPdf.Size = new Size(139, 27);
+ buttonToPdf.TabIndex = 5;
+ buttonToPdf.Text = "В Pdf";
+ buttonToPdf.UseVisualStyleBackColor = true;
+ buttonToPdf.Click += ButtonToPdf_Click;
+ //
+ // buttonCreateReport
+ //
+ buttonCreateReport.Location = new Point(476, 8);
+ buttonCreateReport.Margin = new Padding(4, 3, 4, 3);
+ buttonCreateReport.Name = "buttonCreateReport";
+ buttonCreateReport.Size = new Size(139, 27);
+ buttonCreateReport.TabIndex = 4;
+ buttonCreateReport.Text = "Сформировать";
+ buttonCreateReport.UseVisualStyleBackColor = true;
+ buttonCreateReport.Click += ButtonCreateReport_Click;
+ //
+ // dateTimePickerTo
+ //
+ dateTimePickerTo.Location = new Point(237, 10);
+ dateTimePickerTo.Margin = new Padding(4, 3, 4, 3);
+ dateTimePickerTo.Name = "dateTimePickerTo";
+ dateTimePickerTo.Size = new Size(163, 23);
+ dateTimePickerTo.TabIndex = 3;
+ //
+ // labelTo
+ //
+ labelTo.AutoSize = true;
+ labelTo.Location = new Point(208, 13);
+ labelTo.Margin = new Padding(4, 0, 4, 0);
+ labelTo.Name = "labelTo";
+ labelTo.Size = new Size(21, 15);
+ labelTo.TabIndex = 2;
+ labelTo.Text = "по";
+ //
+ // dateTimePickerFrom
+ //
+ dateTimePickerFrom.Location = new Point(37, 10);
+ dateTimePickerFrom.Margin = new Padding(4, 3, 4, 3);
+ dateTimePickerFrom.Name = "dateTimePickerFrom";
+ dateTimePickerFrom.Size = new Size(163, 23);
+ dateTimePickerFrom.TabIndex = 1;
+ //
+ // labelFrom
+ //
+ labelFrom.AutoSize = true;
+ labelFrom.Location = new Point(14, 13);
+ labelFrom.Margin = new Padding(4, 0, 4, 0);
+ labelFrom.Name = "labelFrom";
+ labelFrom.Size = new Size(15, 15);
+ labelFrom.TabIndex = 0;
+ labelFrom.Text = "С";
+ //
+ // FormReportOrders
+ //
+ AutoScaleDimensions = new SizeF(7F, 15F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(1031, 647);
+ Controls.Add(panel);
+ Margin = new Padding(4, 3, 4, 3);
+ Name = "FormReportOrders";
+ StartPosition = FormStartPosition.CenterScreen;
+ Text = "Заказы";
+ panel.ResumeLayout(false);
+ panel.PerformLayout();
+ ResumeLayout(false);
+ }
+
+ #endregion
+
+ private System.Windows.Forms.Panel panel;
+ private System.Windows.Forms.Button buttonToPdf;
+ private System.Windows.Forms.Button buttonCreateReport;
+ private System.Windows.Forms.DateTimePicker dateTimePickerTo;
+ private System.Windows.Forms.Label labelTo;
+ private System.Windows.Forms.DateTimePicker dateTimePickerFrom;
+ private System.Windows.Forms.Label labelFrom;
+ }
+}
\ No newline at end of file
diff --git a/PlumbingRepair/PlumbingRepair/FormReportOrders.cs b/PlumbingRepair/PlumbingRepair/FormReportOrders.cs
new file mode 100644
index 0000000..bcabb87
--- /dev/null
+++ b/PlumbingRepair/PlumbingRepair/FormReportOrders.cs
@@ -0,0 +1,102 @@
+using Microsoft.Extensions.Logging;
+using PlumbingRepairContracts.BindingModels;
+using PlumbingRepairContracts.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;
+using Microsoft.Reporting.WinForms;
+using System.Windows.Forms.Design;
+
+namespace PlumbingRepairView
+{
+ 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
+ };
+ reportViewer.LocalReport.LoadReportDefinition(new FileStream("ReportOrders.rdlc", FileMode.Open));
+ Controls.Clear();
+ Controls.Add(reportViewer);
+ Controls.Add(panel);
+ }
+
+ private void ButtonCreateReport_Click(object sender, EventArgs e)
+ {
+ if (dateTimePickerFrom.Value.Date >= dateTimePickerTo.Value.Date)
+ {
+ MessageBox.Show("Дата начала должна быть меньше даты окончания", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ try
+ {
+ var dataSource = _logic.GetOrders(new ReportBindingModel
+ {
+ DateFrom = DateTime.SpecifyKind(dateTimePickerFrom.Value, DateTimeKind.Utc),
+ DateTo = DateTime.SpecifyKind(dateTimePickerTo.Value, DateTimeKind.Utc)
+ });
+ var source = new ReportDataSource("DataSetOrders", dataSource);
+ reportViewer.LocalReport.DataSources.Clear();
+ reportViewer.LocalReport.DataSources.Add(source);
+ var parameters = new[] { new ReportParameter("ReportParameterPeriod",
+ $"c {dateTimePickerFrom.Value.ToShortDateString()} по {dateTimePickerTo.Value.ToShortDateString()}") };
+ reportViewer.LocalReport.SetParameters(parameters);
+
+ reportViewer.RefreshReport();
+ _logger.LogInformation("Loading list of orders for period {From}-{To}", dateTimePickerFrom.Value.ToShortDateString(), dateTimePickerTo.Value.ToShortDateString());
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Loading list of orders for period error");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonToPdf_Click(object sender, EventArgs e)
+ {
+ if (dateTimePickerFrom.Value.Date >= dateTimePickerTo.Value.Date)
+ {
+ MessageBox.Show("Дата начала должна быть меньше даты окончания", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ using var dialog = new SaveFileDialog { Filter = "pdf|*.pdf" };
+ if (dialog.ShowDialog() == DialogResult.OK)
+ {
+ try
+ {
+ System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
+ _logic.SaveOrdersToPdfFile(new ReportBindingModel
+ {
+ FileName = dialog.FileName,
+ DateFrom = DateTime.SpecifyKind(dateTimePickerFrom.Value, DateTimeKind.Utc),
+ DateTo = DateTime.SpecifyKind(dateTimePickerTo.Value, DateTimeKind.Utc)
+ });
+ _logger.LogInformation("Saving list of orders for period {From}-{To}", dateTimePickerFrom.Value.ToShortDateString(), dateTimePickerTo.Value.ToShortDateString());
+ MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Saving list of orders for period error");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+ }
+}
diff --git a/PlumbingRepair/PlumbingRepair/FormReportOrders.resx b/PlumbingRepair/PlumbingRepair/FormReportOrders.resx
new file mode 100644
index 0000000..29dcb1b
--- /dev/null
+++ b/PlumbingRepair/PlumbingRepair/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/PlumbingRepair/PlumbingRepair/FormReportWorkComponents.Designer.cs b/PlumbingRepair/PlumbingRepair/FormReportWorkComponents.Designer.cs
new file mode 100644
index 0000000..b5ab91a
--- /dev/null
+++ b/PlumbingRepair/PlumbingRepair/FormReportWorkComponents.Designer.cs
@@ -0,0 +1,101 @@
+namespace PlumbingRepairView
+{
+ partial class FormReportWorkComponents
+ {
+ ///
+ /// 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();
+ ComponentName = new DataGridViewTextBoxColumn();
+ WorkName = new DataGridViewTextBoxColumn();
+ Count = new DataGridViewTextBoxColumn();
+ button1 = new Button();
+ ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
+ SuspendLayout();
+ //
+ // dataGridView
+ //
+ dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
+ dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridView.Columns.AddRange(new DataGridViewColumn[] { ComponentName, WorkName, Count });
+ dataGridView.Location = new Point(12, 66);
+ dataGridView.Name = "dataGridView";
+ dataGridView.RowHeadersWidth = 51;
+ dataGridView.RowTemplate.Height = 29;
+ dataGridView.Size = new Size(776, 372);
+ dataGridView.TabIndex = 0;
+ //
+ // ComponentName
+ //
+ ComponentName.HeaderText = "Компонент";
+ ComponentName.MinimumWidth = 6;
+ ComponentName.Name = "ComponentName";
+ //
+ // WorkName
+ //
+ WorkName.HeaderText = "Работа";
+ WorkName.MinimumWidth = 6;
+ WorkName.Name = "WorkName";
+ //
+ // Count
+ //
+ Count.HeaderText = "Количество";
+ Count.MinimumWidth = 6;
+ Count.Name = "Count";
+ //
+ // button1
+ //
+ button1.Location = new Point(28, 21);
+ button1.Name = "button1";
+ button1.Size = new Size(158, 29);
+ button1.TabIndex = 1;
+ button1.Text = "Сохранить в Excel";
+ button1.UseVisualStyleBackColor = true;
+ button1.Click += ButtonSaveToExcel_Click;
+ //
+ // FormReportWorkComponents
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(800, 450);
+ Controls.Add(button1);
+ Controls.Add(dataGridView);
+ Name = "FormReportWorkComponents";
+ Text = "FormReportWorkComponent";
+ Load += FormReportProductComponents_Load;
+ ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
+ ResumeLayout(false);
+ }
+
+ #endregion
+
+ private DataGridView dataGridView;
+ private Button button1;
+ private DataGridViewTextBoxColumn ComponentName;
+ private DataGridViewTextBoxColumn WorkName;
+ private DataGridViewTextBoxColumn Count;
+ }
+}
\ No newline at end of file
diff --git a/PlumbingRepair/PlumbingRepair/FormReportWorkComponents.cs b/PlumbingRepair/PlumbingRepair/FormReportWorkComponents.cs
new file mode 100644
index 0000000..a5baffa
--- /dev/null
+++ b/PlumbingRepair/PlumbingRepair/FormReportWorkComponents.cs
@@ -0,0 +1,89 @@
+using Microsoft.Extensions.Logging;
+using PlumbingRepairContracts.BindingModels;
+using PlumbingRepairContracts.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 PlumbingRepairView
+{
+ public partial class FormReportWorkComponents : Form
+ {
+ private readonly ILogger _logger;
+ private readonly IReportLogic _logic;
+ public FormReportWorkComponents(ILogger logger, IReportLogic logic)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _logic = logic;
+ }
+
+ private void FormReportProductComponents_Load(object sender, EventArgs e)
+ {
+ try
+ {
+ var dict = _logic.GetWorkComponent();
+ if (dict != null)
+ {
+ dataGridView.Rows.Clear();
+ foreach (var elem in dict)
+ {
+ dataGridView.Rows.Add(new object[] { elem.WorkName, "", "" });
+ 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