diff --git a/Publication/Forms/FormMaterialsDistributionReport.Designer.cs b/Publication/Forms/FormMaterialsDistributionReport.Designer.cs
new file mode 100644
index 0000000..3d7af08
--- /dev/null
+++ b/Publication/Forms/FormMaterialsDistributionReport.Designer.cs
@@ -0,0 +1,109 @@
+namespace Publication.Forms
+{
+ partial class FormMaterialsDistributionReport
+ {
+ ///
+ /// 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()
+ {
+ buttonSelectFileName = new Button();
+ labelFileName = new Label();
+ label1 = new Label();
+ dateTimePicker = new DateTimePicker();
+ buttonCreate = new Button();
+ SuspendLayout();
+ //
+ // buttonSelectFileName
+ //
+ buttonSelectFileName.BackColor = Color.FromArgb(192, 255, 192);
+ buttonSelectFileName.Location = new Point(12, 23);
+ buttonSelectFileName.Name = "buttonSelectFileName";
+ buttonSelectFileName.Size = new Size(129, 29);
+ buttonSelectFileName.TabIndex = 0;
+ buttonSelectFileName.Text = "Выбрать";
+ buttonSelectFileName.UseVisualStyleBackColor = false;
+ buttonSelectFileName.Click += ButtonSelectFileName_Click;
+ //
+ // labelFileName
+ //
+ labelFileName.AutoSize = true;
+ labelFileName.Location = new Point(179, 27);
+ labelFileName.Name = "labelFileName";
+ labelFileName.Size = new Size(45, 20);
+ labelFileName.TabIndex = 1;
+ labelFileName.Text = "Файл";
+ //
+ // label1
+ //
+ label1.AutoSize = true;
+ label1.Location = new Point(12, 81);
+ label1.Name = "label1";
+ label1.Size = new Size(44, 20);
+ label1.TabIndex = 2;
+ label1.Text = "Дата:";
+ //
+ // dateTimePicker
+ //
+ dateTimePicker.Location = new Point(179, 76);
+ dateTimePicker.Name = "dateTimePicker";
+ dateTimePicker.Size = new Size(183, 27);
+ dateTimePicker.TabIndex = 3;
+ //
+ // buttonCreate
+ //
+ buttonCreate.BackColor = Color.FromArgb(192, 255, 192);
+ buttonCreate.Location = new Point(12, 146);
+ buttonCreate.Name = "buttonCreate";
+ buttonCreate.Size = new Size(350, 29);
+ buttonCreate.TabIndex = 4;
+ buttonCreate.Text = "Сформировать";
+ buttonCreate.UseVisualStyleBackColor = false;
+ buttonCreate.Click += ButtonCreate_Click;
+ //
+ // FormMaterialsDistributionReport
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(395, 227);
+ Controls.Add(buttonCreate);
+ Controls.Add(dateTimePicker);
+ Controls.Add(label1);
+ Controls.Add(labelFileName);
+ Controls.Add(buttonSelectFileName);
+ Name = "FormMaterialsDistributionReport";
+ Text = "FormInvoiceDistributionReport";
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private Button buttonSelectFileName;
+ private Label labelFileName;
+ private Label label1;
+ private DateTimePicker dateTimePicker;
+ private Button buttonCreate;
+ }
+}
diff --git a/Publication/Forms/FormMaterialsDistributionReport.cs b/Publication/Forms/FormMaterialsDistributionReport.cs
new file mode 100644
index 0000000..5ec465f
--- /dev/null
+++ b/Publication/Forms/FormMaterialsDistributionReport.cs
@@ -0,0 +1,65 @@
+using Publication.Reports;
+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 Unity;
+
+namespace Publication.Forms;
+
+public partial class FormMaterialsDistributionReport : Form
+{
+ private string _fileName = string.Empty;
+
+ private readonly IUnityContainer _container;
+
+ public FormMaterialsDistributionReport(IUnityContainer container)
+ {
+ InitializeComponent();
+ _container = container ?? throw new ArgumentNullException(nameof(container));
+ }
+
+ private void ButtonSelectFileName_Click(object sender, EventArgs e)
+ {
+ var sfd = new SaveFileDialog()
+ {
+ Filter = "Pdf Files | *.pdf"
+ };
+ if (sfd.ShowDialog() == DialogResult.OK)
+ {
+ _fileName = sfd.FileName;
+ labelFileName.Text = Path.GetFileName(_fileName);
+ }
+ }
+
+ private void ButtonCreate_Click(object sender, EventArgs e)
+ {
+ try
+ {
+ if (string.IsNullOrWhiteSpace(_fileName))
+ {
+ throw new Exception("Отсутствует имя файла для отчета");
+ }
+ if
+ (_container.Resolve().CreateChart(_fileName, dateTimePicker.Value))
+ {
+ MessageBox.Show("Документ сформирован", "Формирование документа",
+ MessageBoxButtons.OK, MessageBoxIcon.Information);
+ }
+ else
+ {
+ MessageBox.Show("Возникли ошибки при формировании документа.Подробности в логах",
+ "Формирование документа", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ }
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка при создании очета", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+}
diff --git a/Publication/Forms/FormMaterialsDistributionReport.resx b/Publication/Forms/FormMaterialsDistributionReport.resx
new file mode 100644
index 0000000..af32865
--- /dev/null
+++ b/Publication/Forms/FormMaterialsDistributionReport.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/Publication/Forms/Publication.Designer.cs b/Publication/Forms/Publication.Designer.cs
index af60789..20e6bde 100644
--- a/Publication/Forms/Publication.Designer.cs
+++ b/Publication/Forms/Publication.Designer.cs
@@ -40,6 +40,7 @@
ReportsToolStripMenuItem = new ToolStripMenuItem();
DirectoryReportToolStripMenuItem = new ToolStripMenuItem();
CountReportToolStripMenuItem = new ToolStripMenuItem();
+ MaterialDistributionToolStripMenuItem = new ToolStripMenuItem();
menuStrip.SuspendLayout();
SuspendLayout();
//
@@ -94,7 +95,7 @@
//
// ReportsToolStripMenuItem
//
- ReportsToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { DirectoryReportToolStripMenuItem, CountReportToolStripMenuItem });
+ ReportsToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { DirectoryReportToolStripMenuItem, CountReportToolStripMenuItem, MaterialDistributionToolStripMenuItem });
ReportsToolStripMenuItem.Name = "ReportsToolStripMenuItem";
resources.ApplyResources(ReportsToolStripMenuItem, "ReportsToolStripMenuItem");
//
@@ -110,6 +111,12 @@
resources.ApplyResources(CountReportToolStripMenuItem, "CountReportToolStripMenuItem");
CountReportToolStripMenuItem.Click += CountReportToolStripMenuItem_Click;
//
+ // MaterialDistributionToolStripMenuItem
+ //
+ MaterialDistributionToolStripMenuItem.Name = "MaterialDistributionToolStripMenuItem";
+ resources.ApplyResources(MaterialDistributionToolStripMenuItem, "MaterialDistributionToolStripMenuItem");
+ MaterialDistributionToolStripMenuItem.Click += MaterialDistributionToolStripMenuItem_Click;
+ //
// Publication
//
resources.ApplyResources(this, "$this");
@@ -136,5 +143,6 @@
private ToolStripMenuItem ReportsToolStripMenuItem;
private ToolStripMenuItem DirectoryReportToolStripMenuItem;
private ToolStripMenuItem CountReportToolStripMenuItem;
+ private ToolStripMenuItem MaterialDistributionToolStripMenuItem;
}
}
diff --git a/Publication/Forms/Publication.cs b/Publication/Forms/Publication.cs
index 00569c7..fad35d2 100644
--- a/Publication/Forms/Publication.cs
+++ b/Publication/Forms/Publication.cs
@@ -105,4 +105,16 @@ public partial class Publication : Form
MessageBox.Show(ex.Message, " ", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
+
+ private void MaterialDistributionToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ try
+ {
+ unityContainer.Resolve().ShowDialog();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, " ", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
}
diff --git a/Publication/Forms/Publication.resx b/Publication/Forms/Publication.resx
index 9d79e54..2ecd179 100644
--- a/Publication/Forms/Publication.resx
+++ b/Publication/Forms/Publication.resx
@@ -121,12 +121,42 @@
17, 17
+
+ 185, 26
+
+
+ Заказчики
+
+
+ 185, 26
+
+
+ Материалы
+
+
+ 185, 26
+
+
+ Издательства
+
117, 24
Справочники
+
+ 188, 26
+
+
+ Создать заказ
+
+
+ 188, 26
+
+
+ Печать
+
95, 24
@@ -152,6 +182,12 @@
Движение заказов
+
+ 350, 26
+
+
+ Распределение материалов
+
73, 24
@@ -183,36 +219,6 @@
0
-
- 185, 26
-
-
- Заказчики
-
-
- 185, 26
-
-
- Материалы
-
-
- 185, 26
-
-
- Издательства
-
-
- 188, 26
-
-
- Создать заказ
-
-
- 188, 26
-
-
- Печать
-
True
@@ -2247,6 +2253,12 @@
System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+ MaterialDistributionToolStripMenuItem
+
+
+ System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
Publication
diff --git a/Publication/Reports/ChartReport.cs b/Publication/Reports/ChartReport.cs
index 803fc7b..64fe62b 100644
--- a/Publication/Reports/ChartReport.cs
+++ b/Publication/Reports/ChartReport.cs
@@ -1,4 +1,6 @@
using Microsoft.Extensions.Logging;
+using Publication.Repositories;
+using Publication.Repositories.Implementations;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -9,11 +11,11 @@ namespace Publication.Reports;
public class ChartReport
{
- /*private readonly IOrderRepository _invoiceRepository;
+ private readonly IMaterialRepository _materialRepository;
private readonly ILogger _logger;
- public ChartReport(IInvoiceRepository invoiceRepository, ILogger logger)
+ public ChartReport(IMaterialRepository materialRepository, ILogger logger)
{
- _invoiceRepository = invoiceRepository ?? throw new ArgumentNullException(nameof(invoiceRepository));
+ _materialRepository = materialRepository ?? throw new ArgumentNullException(nameof(materialRepository));
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
}
public bool CreateChart(string filePath, DateTime dateTime)
@@ -21,8 +23,8 @@ public class ChartReport
try
{
new PdfBuilder(filePath)
- .AddHeader("Сумма покупки каждого клиента")
- .AddPieChart("Клиенты", GetData(dateTime))
+ .AddHeader("Количество материалов")
+ .AddPieChart("Материалы", GetData(dateTime))
.Build();
return true;
}
@@ -35,11 +37,11 @@ public class ChartReport
private List<(string Caption, double Value)> GetData(DateTime dateTime)
{
- return _invoiceRepository
- .ReadInvoices()
- .Where(x => x.DateInvoice.Date == dateTime.Date)
- .GroupBy(x => x.ClientID, (key, group) => new { ID = key, Count = group.Sum(y => y.SellingPrice) })
+ return _materialRepository
+ .ReadMaterials()
+ .Where(x => x.DateMaterials.Date == dateTime.Date)
+ .GroupBy(x => x.Id, (key, group) => new { ID = key, Count = group.Sum(y => y.Count) })
.Select(x => (x.ID.ToString(), (double)x.Count))
.ToList();
- }*/
+ }
}