diff --git a/AircraftPlant/AircraftPlantBusinessLogic/BusinessLogics/ReportLogic.cs b/AircraftPlant/AircraftPlantBusinessLogic/BusinessLogics/ReportLogic.cs
index bc84035..f8b9be9 100644
--- a/AircraftPlant/AircraftPlantBusinessLogic/BusinessLogics/ReportLogic.cs
+++ b/AircraftPlant/AircraftPlantBusinessLogic/BusinessLogics/ReportLogic.cs
@@ -33,6 +33,11 @@ namespace AircraftPlantBusinessLogic.BusinessLogics
///
private readonly IOrderStorage _orderStorage;
+ ///
+ /// Хранилище магазинов
+ ///
+ private readonly IShopStorage _shopStorage;
+
///
/// Взаимодействие с отчетами в Excel-формате
///
@@ -57,12 +62,13 @@ namespace AircraftPlantBusinessLogic.BusinessLogics
///
///
///
- public ReportLogic(IPlaneStorage planeStorage, IComponentStorage componentStorage, IOrderStorage orderStorage,
+ public ReportLogic(IPlaneStorage planeStorage, IComponentStorage componentStorage, IOrderStorage orderStorage, IShopStorage shopStorage,
AbstractSaveToExcel saveToExcel, AbstractSaveToWord saveToWord, AbstractSaveToPdf saveToPdf)
{
_planeStorage = planeStorage;
_componentStorage = componentStorage;
_orderStorage = orderStorage;
+ _shopStorage = shopStorage;
_saveToExcel = saveToExcel;
_saveToWord = saveToWord;
@@ -102,6 +108,39 @@ namespace AircraftPlantBusinessLogic.BusinessLogics
.ToList();
}
+ ///
+ /// Получение списка заказов с группировкой по датам
+ ///
+ ///
+ public List GetGroupOrders()
+ {
+ return _orderStorage.GetFullList()
+ .GroupBy(x => x.DateCreate.Date)
+ .Select(x => new ReportGroupOrdersViewModel
+ {
+ DateCreate = x.Key,
+ Count = x.Count(),
+ Sum = x.Select(y => y.Sum).Sum()
+ })
+ .ToList();
+ }
+
+ ///
+ /// Получение списка магазинов с указанием хранимых изделий
+ ///
+ ///
+ public List GetShopPlanes()
+ {
+ return _shopStorage.GetFullList()
+ .Select(x => new ReportShopPlanesViewModel
+ {
+ ShopName = x.ShopName,
+ Planes = x.ShopPlanes.Select(x => (x.Value.Item1.PlaneName, x.Value.Item2)).ToList(),
+ TotalCount = x.ShopPlanes.Select(x => x.Value.Item2).Sum()
+ })
+ .ToList();
+ }
+
///
/// Сохранение изделий в Word-файл
///
@@ -145,5 +184,47 @@ namespace AircraftPlantBusinessLogic.BusinessLogics
Orders = GetOrders(model)
});
}
+
+ ///
+ /// Сохранение магазинов в Word-файл
+ ///
+ ///
+ public void SaveShopsToWordFile(ReportBindingModel model)
+ {
+ _saveToWord.CreateShopsDoc(new WordInfo
+ {
+ FileName = model.FileName,
+ Title = "Список магазинов",
+ Shops = _shopStorage.GetFullList()
+ });
+ }
+
+ ///
+ /// Сохранение магазинов с указанием изделий в файл-Excel
+ ///
+ ///
+ public void SaveShopPlanesToExcelFile(ReportBindingModel model)
+ {
+ _saveToExcel.CreateShopPlanesReport(new ExcelInfo
+ {
+ FileName = model.FileName,
+ Title = "Ассортимент магазинов",
+ ShopPlanes = GetShopPlanes()
+ });
+ }
+
+ ///
+ /// Сохранение заказов с группировкой по датам в файл-Pdf
+ ///
+ ///
+ public void SaveGroupOrdersToPdfFile(ReportBindingModel model)
+ {
+ _saveToPdf.CreateGroupOrdersDoc(new PdfInfo
+ {
+ FileName= model.FileName,
+ Title = "Список заказов с группировкой по датам",
+ GroupOrders = GetGroupOrders()
+ });
+ }
}
}
diff --git a/AircraftPlant/AircraftPlantBusinessLogic/OfficePackage/AbstractSaveToExcel.cs b/AircraftPlant/AircraftPlantBusinessLogic/OfficePackage/AbstractSaveToExcel.cs
index 24a60fe..91bc3fa 100644
--- a/AircraftPlant/AircraftPlantBusinessLogic/OfficePackage/AbstractSaveToExcel.cs
+++ b/AircraftPlant/AircraftPlantBusinessLogic/OfficePackage/AbstractSaveToExcel.cs
@@ -88,6 +88,82 @@ namespace AircraftPlantBusinessLogic.OfficePackage
SaveExcel(info);
}
+ ///
+ /// Создание отчета в Excel-формате
+ /// по магазинам с расшифровкой по изделиям
+ ///
+ ///
+ public void CreateShopPlanesReport(ExcelInfo info)
+ {
+ CreateExcel(info);
+
+ InsertCellInWorksheet(new ExcelCellParameters
+ {
+ ColumnName = "A",
+ RowIndex = 1,
+ Text = info.Title,
+ StyleInfo = ExcelStyleInfoType.Title
+ });
+
+ MergeCells(new ExcelMergeParameters
+ {
+ CellFromName = "A1",
+ CellToName = "C1"
+ });
+
+ uint rowIndex = 2;
+ foreach (var sp in info.ShopPlanes)
+ {
+ InsertCellInWorksheet(new ExcelCellParameters
+ {
+ ColumnName = "A",
+ RowIndex = rowIndex,
+ Text = sp.ShopName,
+ StyleInfo = ExcelStyleInfoType.Text
+ });
+ rowIndex++;
+
+ foreach (var (Plane, Count) in sp.Planes)
+ {
+ InsertCellInWorksheet(new ExcelCellParameters
+ {
+ ColumnName = "B",
+ RowIndex = rowIndex,
+ Text = Plane,
+ StyleInfo = ExcelStyleInfoType.TextWithBroder
+ });
+
+ InsertCellInWorksheet(new ExcelCellParameters
+ {
+ ColumnName = "C",
+ RowIndex = rowIndex,
+ Text = Count.ToString(),
+ StyleInfo = ExcelStyleInfoType.TextWithBroder
+ });
+
+ rowIndex++;
+ }
+
+ InsertCellInWorksheet(new ExcelCellParameters
+ {
+ ColumnName = "A",
+ RowIndex = rowIndex,
+ Text = "Итого",
+ StyleInfo = ExcelStyleInfoType.Text
+ });
+ InsertCellInWorksheet(new ExcelCellParameters
+ {
+ ColumnName = "C",
+ RowIndex = rowIndex,
+ Text = sp.TotalCount.ToString(),
+ StyleInfo = ExcelStyleInfoType.Text
+ });
+ rowIndex++;
+ }
+
+ SaveExcel(info);
+ }
+
///
/// Создание excel-файла
///
diff --git a/AircraftPlant/AircraftPlantBusinessLogic/OfficePackage/AbstractSaveToPdf.cs b/AircraftPlant/AircraftPlantBusinessLogic/OfficePackage/AbstractSaveToPdf.cs
index 3c94b74..2854b8d 100644
--- a/AircraftPlant/AircraftPlantBusinessLogic/OfficePackage/AbstractSaveToPdf.cs
+++ b/AircraftPlant/AircraftPlantBusinessLogic/OfficePackage/AbstractSaveToPdf.cs
@@ -46,6 +46,39 @@ namespace AircraftPlantBusinessLogic.OfficePackage
SavePdf(info);
}
+ ///
+ /// Создание отчета в Pdf-формате
+ /// по закзам с группировкой по датам
+ ///
+ ///
+ public void CreateGroupOrdersDoc(PdfInfo info)
+ {
+ CreatePdf(info);
+ CreateParagraph(new PdfParagraph { Text = info.Title, Style = "NormalTitle", ParagraphAlignment = PdfParagraphAlignmentType.Center });
+
+ CreateTable(new List { "4cm", "3cm", "2cm" });
+
+ CreateRow(new PdfRowParameters
+ {
+ Texts = new List { "Дата заказа", "Количество", "Сумма" },
+ Style = "NormalTitle",
+ ParagraphAlignment = PdfParagraphAlignmentType.Center
+ });
+
+ foreach (var order in info.GroupOrders)
+ {
+ CreateRow(new PdfRowParameters
+ {
+ Texts = new List { order.DateCreate.ToShortDateString(), order.Count.ToString(), order.Sum.ToString() },
+ Style = "Normal",
+ ParagraphAlignment = PdfParagraphAlignmentType.Left
+ });
+ }
+ CreateParagraph(new PdfParagraph { Text = $"Итого: {info.GroupOrders.Sum(x => x.Sum)}\t", Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Right });
+
+ SavePdf(info);
+ }
+
///
/// Создание pdf-файла
///
diff --git a/AircraftPlant/AircraftPlantBusinessLogic/OfficePackage/AbstractSaveToWord.cs b/AircraftPlant/AircraftPlantBusinessLogic/OfficePackage/AbstractSaveToWord.cs
index 14ef29e..6dd7d35 100644
--- a/AircraftPlant/AircraftPlantBusinessLogic/OfficePackage/AbstractSaveToWord.cs
+++ b/AircraftPlant/AircraftPlantBusinessLogic/OfficePackage/AbstractSaveToWord.cs
@@ -1,5 +1,6 @@
using AircraftPlantBusinessLogic.OfficePackage.HelperEnums;
using AircraftPlantBusinessLogic.OfficePackage.HelperModels;
+using DocumentFormat.OpenXml.Wordprocessing;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -51,6 +52,52 @@ namespace AircraftPlantBusinessLogic.OfficePackage
SaveWord(info);
}
+ ///
+ /// Создание отчета по магазинам в doc-формате
+ ///
+ ///
+ public void CreateShopsDoc(WordInfo info)
+ {
+ CreateWord(info);
+
+ CreateParagraph(new WordParagraph
+ {
+ Texts = new List<(string, WordTextProperties)> { (info.Title, new WordTextProperties { Bold = true, Size = "24", }) },
+ TextProperties = new WordTextProperties
+ {
+ Size = "24",
+ JustificationType = WordJustificationType.Center
+ }
+ });
+
+ CreateTable(new List { "3000", "3000", "3000" });
+ CreateRow(new WordRow
+ {
+ Texts = new List { "Название", "Адрес", "Дата открытия" },
+ TextProperties = new WordTextProperties
+ {
+ Size = "24",
+ Bold = true,
+ JustificationType = WordJustificationType.Center
+ }
+ });
+
+ foreach (var shop in info.Shops)
+ {
+ CreateRow(new WordRow
+ {
+ Texts = new List { shop.ShopName, shop.Address, shop.DateOpening.ToString() },
+ TextProperties = new WordTextProperties
+ {
+ Size = "22",
+ JustificationType = WordJustificationType.Both
+ }
+ });
+ }
+
+ SaveWord(info);
+ }
+
///
/// Создание doc-файла
///
@@ -63,6 +110,18 @@ namespace AircraftPlantBusinessLogic.OfficePackage
///
protected abstract void CreateParagraph(WordParagraph paragraph);
+ ///
+ /// Создание таблицы
+ ///
+ ///
+ protected abstract void CreateTable(List columns);
+
+ ///
+ /// Создание строки
+ ///
+ ///
+ protected abstract void CreateRow(WordRow row);
+
///
/// Сохранение файла
///
diff --git a/AircraftPlant/AircraftPlantBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs b/AircraftPlant/AircraftPlantBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs
index 4cfd44d..68846b8 100644
--- a/AircraftPlant/AircraftPlantBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs
+++ b/AircraftPlant/AircraftPlantBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs
@@ -27,5 +27,10 @@ namespace AircraftPlantBusinessLogic.OfficePackage.HelperModels
/// Список изделий с расшифровкой по компонентам
///
public List PlaneComponents { get; set; } = new();
+
+ ///
+ /// Список магазинов с расшифровкой по изделиям
+ ///
+ public List ShopPlanes { get; set; } = new();
}
}
diff --git a/AircraftPlant/AircraftPlantBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs b/AircraftPlant/AircraftPlantBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs
index 9a4090a..db84a6f 100644
--- a/AircraftPlant/AircraftPlantBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs
+++ b/AircraftPlant/AircraftPlantBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs
@@ -37,5 +37,10 @@ namespace AircraftPlantBusinessLogic.OfficePackage.HelperModels
/// Список заказов
///
public List Orders { get; set; } = new();
+
+ ///
+ /// Список заказов с группировкой по датам
+ ///
+ public List GroupOrders { get; set; } = new();
}
}
diff --git a/AircraftPlant/AircraftPlantBusinessLogic/OfficePackage/HelperModels/WordInfo.cs b/AircraftPlant/AircraftPlantBusinessLogic/OfficePackage/HelperModels/WordInfo.cs
index cb2f368..728c63a 100644
--- a/AircraftPlant/AircraftPlantBusinessLogic/OfficePackage/HelperModels/WordInfo.cs
+++ b/AircraftPlant/AircraftPlantBusinessLogic/OfficePackage/HelperModels/WordInfo.cs
@@ -27,5 +27,10 @@ namespace AircraftPlantBusinessLogic.OfficePackage.HelperModels
/// Список изделий
///
public List Planes { get; set; } = new();
+
+ ///
+ /// Список магазинов
+ ///
+ public List Shops { get; set; } = new();
}
}
diff --git a/AircraftPlant/AircraftPlantBusinessLogic/OfficePackage/HelperModels/WordRow.cs b/AircraftPlant/AircraftPlantBusinessLogic/OfficePackage/HelperModels/WordRow.cs
new file mode 100644
index 0000000..fec096b
--- /dev/null
+++ b/AircraftPlant/AircraftPlantBusinessLogic/OfficePackage/HelperModels/WordRow.cs
@@ -0,0 +1,25 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AircraftPlantBusinessLogic.OfficePackage.HelperModels
+{
+ ///
+ /// Модель для передачи данных
+ /// для создания строки файла-Word
+ ///
+ public class WordRow
+ {
+ ///
+ /// Список текстов в строке
+ ///
+ public List Texts { get; set; } = new();
+
+ ///
+ /// Свойства строки
+ ///
+ public WordTextProperties? TextProperties { get; set; }
+ }
+}
diff --git a/AircraftPlant/AircraftPlantBusinessLogic/OfficePackage/Implements/SaveToWord.cs b/AircraftPlant/AircraftPlantBusinessLogic/OfficePackage/Implements/SaveToWord.cs
index 4645dca..57ba632 100644
--- a/AircraftPlant/AircraftPlantBusinessLogic/OfficePackage/Implements/SaveToWord.cs
+++ b/AircraftPlant/AircraftPlantBusinessLogic/OfficePackage/Implements/SaveToWord.cs
@@ -6,6 +6,7 @@ using DocumentFormat.OpenXml.Wordprocessing;
using System;
using System.Collections.Generic;
using System.Linq;
+using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
@@ -26,6 +27,11 @@ namespace AircraftPlantBusinessLogic.OfficePackage.Implements
///
private Body? _docBody;
+ ///
+ /// Таблица
+ ///
+ private Table? _table;
+
///
/// Получение типа выравнивания текста
///
@@ -141,6 +147,90 @@ namespace AircraftPlantBusinessLogic.OfficePackage.Implements
_docBody.AppendChild(docParagraph);
}
+ ///
+ /// Создание таблицы
+ ///
+ ///
+ protected override void CreateTable(List columns)
+ {
+ if (_docBody == null)
+ {
+ return;
+ }
+
+ _table = new Table();
+
+ var tableProperties = new TableProperties();
+ tableProperties.AppendChild(new TableLayout { Type = TableLayoutValues.Fixed });
+ tableProperties.AppendChild(new TableBorders(
+ new TopBorder() { Val = new EnumValue(BorderValues.Single), Size = 4 },
+ new LeftBorder() { Val = new EnumValue(BorderValues.Single), Size = 4 },
+ new RightBorder() { Val = new EnumValue(BorderValues.Single), Size = 4 },
+ new BottomBorder() { Val = new EnumValue(BorderValues.Single), Size = 4 },
+ new InsideHorizontalBorder() { Val = new EnumValue(BorderValues.Single), Size = 4 },
+ new InsideVerticalBorder() { Val = new EnumValue(BorderValues.Single), Size = 4 }
+ ));
+ tableProperties.AppendChild(new TableWidth { Type = TableWidthUnitValues.Auto });
+ _table.AppendChild(tableProperties);
+
+ TableGrid tableGrid = new TableGrid();
+ foreach (var column in columns)
+ {
+ tableGrid.AppendChild(new GridColumn() { Width = column });
+ }
+ _table.AppendChild(tableGrid);
+
+ _docBody.AppendChild(_table);
+ }
+
+ ///
+ /// Создание строки
+ ///
+ ///
+ protected override void CreateRow(WordRow row)
+ {
+ if (_docBody == null || _table == null)
+ {
+ return;
+ }
+
+ TableRow docRow = new TableRow();
+ foreach (var column in row.Texts)
+ {
+ var docParagraph = new Paragraph();
+ WordParagraph paragraph = new WordParagraph
+ {
+ Texts = new List<(string, WordTextProperties)> { (column, row.TextProperties) },
+ TextProperties = row.TextProperties
+ };
+
+ docParagraph.AppendChild(CreateParagraphProperties(paragraph.TextProperties));
+
+ foreach (var run in paragraph.Texts)
+ {
+ var docRun = new Run();
+
+ var properties = new RunProperties();
+ properties.AppendChild(new FontSize { Val = run.Item2.Size });
+ if (run.Item2.Bold)
+ {
+ properties.AppendChild(new Bold());
+ }
+ docRun.AppendChild(properties);
+
+ docRun.AppendChild(new Text { Text = run.Item1, Space = SpaceProcessingModeValues.Preserve });
+
+ docParagraph.AppendChild(docRun);
+ }
+
+ TableCell docCell = new TableCell();
+ docCell.AppendChild(docParagraph);
+ docRow.AppendChild(docCell);
+ }
+
+ _table.AppendChild(docRow);
+ }
+
///
/// Сохранение файла
///
diff --git a/AircraftPlant/AircraftPlantContracts/BusinessLogicsContracts/IReportLogic.cs b/AircraftPlant/AircraftPlantContracts/BusinessLogicsContracts/IReportLogic.cs
index e53d342..98b0bd5 100644
--- a/AircraftPlant/AircraftPlantContracts/BusinessLogicsContracts/IReportLogic.cs
+++ b/AircraftPlant/AircraftPlantContracts/BusinessLogicsContracts/IReportLogic.cs
@@ -26,6 +26,18 @@ namespace AircraftPlantContracts.BusinessLogicsContracts
///
List GetOrders(ReportBindingModel model);
+ ///
+ /// Получение списка заказов с группировкой по датам
+ ///
+ ///
+ List GetGroupOrders();
+
+ ///
+ /// Получение списка магазинов с указанием хранимых изделий
+ ///
+ ///
+ List GetShopPlanes();
+
///
/// Сохранение изделий в файл-Word
///
@@ -43,5 +55,23 @@ namespace AircraftPlantContracts.BusinessLogicsContracts
///
///
void SaveOrdersToPdfFile(ReportBindingModel model);
+
+ ///
+ /// Сохранение магазинов в Word-файл
+ ///
+ ///
+ void SaveShopsToWordFile(ReportBindingModel model);
+
+ ///
+ /// Сохранение магазинов с указанием изделий в файл-Excel
+ ///
+ ///
+ void SaveShopPlanesToExcelFile(ReportBindingModel model);
+
+ ///
+ /// Сохранение заказов с группировкой по датам в файл-Pdf
+ ///
+ ///
+ void SaveGroupOrdersToPdfFile(ReportBindingModel model);
}
}
diff --git a/AircraftPlant/AircraftPlantContracts/ViewModels/ReportGroupOrdersViewModel.cs b/AircraftPlant/AircraftPlantContracts/ViewModels/ReportGroupOrdersViewModel.cs
new file mode 100644
index 0000000..b7d8a75
--- /dev/null
+++ b/AircraftPlant/AircraftPlantContracts/ViewModels/ReportGroupOrdersViewModel.cs
@@ -0,0 +1,29 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AircraftPlantContracts.ViewModels
+{
+ ///
+ /// Модель для отчета по заказам с группировкой по датам
+ ///
+ public class ReportGroupOrdersViewModel
+ {
+ ///
+ /// Дата создания заказа
+ ///
+ public DateTime DateCreate { get; set; }
+
+ ///
+ /// Количество изделий
+ ///
+ public int Count { get; set; }
+
+ ///
+ /// Сумма заказа
+ ///
+ public double Sum { get; set; }
+ }
+}
diff --git a/AircraftPlant/AircraftPlantContracts/ViewModels/ReportShopPlanesViewModel.cs b/AircraftPlant/AircraftPlantContracts/ViewModels/ReportShopPlanesViewModel.cs
new file mode 100644
index 0000000..290471b
--- /dev/null
+++ b/AircraftPlant/AircraftPlantContracts/ViewModels/ReportShopPlanesViewModel.cs
@@ -0,0 +1,29 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AircraftPlantContracts.ViewModels
+{
+ ///
+ /// Модель для отчета по магазинам с расшифровкой по изделиям
+ ///
+ public class ReportShopPlanesViewModel
+ {
+ ///
+ /// Название магазина
+ ///
+ public string ShopName { get; set; } = string.Empty;
+
+ ///
+ /// Максимальное количество изделий
+ ///
+ public int TotalCount { get; set; }
+
+ ///
+ /// Список изделий в магазине
+ ///
+ public List<(string Plane, int Count)> Planes { get; set; } = new();
+ }
+}
diff --git a/AircraftPlant/AircraftPlantView/FormMain.Designer.cs b/AircraftPlant/AircraftPlantView/FormMain.Designer.cs
index 6a7ada2..ab50ec4 100644
--- a/AircraftPlant/AircraftPlantView/FormMain.Designer.cs
+++ b/AircraftPlant/AircraftPlantView/FormMain.Designer.cs
@@ -39,12 +39,15 @@
компонентыToolStripMenuItem = new ToolStripMenuItem();
изделияToolStripMenuItem = new ToolStripMenuItem();
магазиныToolStripMenuItem = new ToolStripMenuItem();
- buttonAddPlaneInShop = new Button();
- buttonSellPlanes = new Button();
отчетыToolStripMenuItem = new ToolStripMenuItem();
изделияToolStripMenuItem1 = new ToolStripMenuItem();
изделияСКомпонентамиToolStripMenuItem = new ToolStripMenuItem();
списокЗаказовToolStripMenuItem = new ToolStripMenuItem();
+ buttonAddPlaneInShop = new Button();
+ buttonSellPlanes = new Button();
+ заказыСГруппировкойToolStripMenuItem = new ToolStripMenuItem();
+ списокМагазиновToolStripMenuItem = new ToolStripMenuItem();
+ ассортиментМагазиновToolStripMenuItem = new ToolStripMenuItem();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
menuStrip.SuspendLayout();
SuspendLayout();
@@ -154,29 +157,9 @@
магазиныToolStripMenuItem.Text = "Магазины";
магазиныToolStripMenuItem.Click += магазиныToolStripMenuItem_Click;
//
- // buttonAddPlaneInShop
- //
- buttonAddPlaneInShop.Location = new Point(822, 210);
- buttonAddPlaneInShop.Name = "buttonAddPlaneInShop";
- buttonAddPlaneInShop.Size = new Size(150, 50);
- buttonAddPlaneInShop.TabIndex = 7;
- buttonAddPlaneInShop.Text = "Добавить изделие\r\nв магазин";
- buttonAddPlaneInShop.UseVisualStyleBackColor = true;
- buttonAddPlaneInShop.Click += buttonAddPlaneInShop_Click;
- //
- // buttonSellPlanes
- //
- buttonSellPlanes.Location = new Point(822, 266);
- buttonSellPlanes.Name = "buttonSellPlanes";
- buttonSellPlanes.Size = new Size(150, 23);
- buttonSellPlanes.TabIndex = 8;
- buttonSellPlanes.Text = "Продать изделия";
- buttonSellPlanes.UseVisualStyleBackColor = true;
- buttonSellPlanes.Click += buttonSellPlanes_Click;
- //
// отчетыToolStripMenuItem
//
- отчетыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { изделияToolStripMenuItem1, изделияСКомпонентамиToolStripMenuItem, списокЗаказовToolStripMenuItem });
+ отчетыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { изделияToolStripMenuItem1, изделияСКомпонентамиToolStripMenuItem, списокЗаказовToolStripMenuItem, заказыСГруппировкойToolStripMenuItem, списокМагазиновToolStripMenuItem, ассортиментМагазиновToolStripMenuItem });
отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem";
отчетыToolStripMenuItem.Size = new Size(60, 20);
отчетыToolStripMenuItem.Text = "Отчеты";
@@ -202,6 +185,47 @@
списокЗаказовToolStripMenuItem.Text = "Список заказов";
списокЗаказовToolStripMenuItem.Click += списокЗаказовToolStripMenuItem_Click;
//
+ // buttonAddPlaneInShop
+ //
+ buttonAddPlaneInShop.Location = new Point(822, 210);
+ buttonAddPlaneInShop.Name = "buttonAddPlaneInShop";
+ buttonAddPlaneInShop.Size = new Size(150, 50);
+ buttonAddPlaneInShop.TabIndex = 7;
+ buttonAddPlaneInShop.Text = "Добавить изделие\r\nв магазин";
+ buttonAddPlaneInShop.UseVisualStyleBackColor = true;
+ buttonAddPlaneInShop.Click += buttonAddPlaneInShop_Click;
+ //
+ // buttonSellPlanes
+ //
+ buttonSellPlanes.Location = new Point(822, 266);
+ buttonSellPlanes.Name = "buttonSellPlanes";
+ buttonSellPlanes.Size = new Size(150, 23);
+ buttonSellPlanes.TabIndex = 8;
+ buttonSellPlanes.Text = "Продать изделия";
+ buttonSellPlanes.UseVisualStyleBackColor = true;
+ buttonSellPlanes.Click += buttonSellPlanes_Click;
+ //
+ // заказыСГруппировкойToolStripMenuItem
+ //
+ заказыСГруппировкойToolStripMenuItem.Name = "заказыСГруппировкойToolStripMenuItem";
+ заказыСГруппировкойToolStripMenuItem.Size = new Size(250, 22);
+ заказыСГруппировкойToolStripMenuItem.Text = "Список заказов с группировкой";
+ заказыСГруппировкойToolStripMenuItem.Click += заказыСГруппировкойToolStripMenuItem_Click;
+ //
+ // списокМагазиновToolStripMenuItem
+ //
+ списокМагазиновToolStripMenuItem.Name = "списокМагазиновToolStripMenuItem";
+ списокМагазиновToolStripMenuItem.Size = new Size(250, 22);
+ списокМагазиновToolStripMenuItem.Text = "Список магазинов";
+ списокМагазиновToolStripMenuItem.Click += списокМагазиновToolStripMenuItem_Click;
+ //
+ // ассортиментМагазиновToolStripMenuItem
+ //
+ ассортиментМагазиновToolStripMenuItem.Name = "ассортиментМагазиновToolStripMenuItem";
+ ассортиментМагазиновToolStripMenuItem.Size = new Size(250, 22);
+ ассортиментМагазиновToolStripMenuItem.Text = "Ассортимент магазинов";
+ ассортиментМагазиновToolStripMenuItem.Click += ассортиментМагазиновToolStripMenuItem_Click;
+ //
// FormMain
//
AutoScaleDimensions = new SizeF(7F, 15F);
@@ -246,5 +270,8 @@
private ToolStripMenuItem изделияToolStripMenuItem1;
private ToolStripMenuItem изделияСКомпонентамиToolStripMenuItem;
private ToolStripMenuItem списокЗаказовToolStripMenuItem;
+ private ToolStripMenuItem заказыСГруппировкойToolStripMenuItem;
+ private ToolStripMenuItem списокМагазиновToolStripMenuItem;
+ private ToolStripMenuItem ассортиментМагазиновToolStripMenuItem;
}
}
\ No newline at end of file
diff --git a/AircraftPlant/AircraftPlantView/FormMain.cs b/AircraftPlant/AircraftPlantView/FormMain.cs
index f7e8e3a..6ba6319 100644
--- a/AircraftPlant/AircraftPlantView/FormMain.cs
+++ b/AircraftPlant/AircraftPlantView/FormMain.cs
@@ -113,7 +113,7 @@ namespace AircraftPlantView
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
-
+
///
/// Получить отчет по изделиям с расшифровкой по компонентам
///
@@ -142,6 +142,49 @@ namespace AircraftPlantView
}
}
+ ///
+ /// Получить отчет по заказам с группировкой по датам
+ ///
+ ///
+ ///
+ private void заказыСГруппировкойToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormReportGroupOrders));
+ if (service is FormReportGroupOrders 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.SaveShopsToWordFile(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(FormReportShopPlanes));
+ if (service is FormReportShopPlanes form)
+ {
+ form.ShowDialog();
+ }
+ }
+
///
/// Кнопка "Создать заказ"
///
diff --git a/AircraftPlant/AircraftPlantView/FormReportGroupOrders.Designer.cs b/AircraftPlant/AircraftPlantView/FormReportGroupOrders.Designer.cs
new file mode 100644
index 0000000..66e1889
--- /dev/null
+++ b/AircraftPlant/AircraftPlantView/FormReportGroupOrders.Designer.cs
@@ -0,0 +1,85 @@
+namespace AircraftPlantView
+{
+ partial class FormReportGroupOrders
+ {
+ ///
+ /// 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()
+ {
+ panelControl = new Panel();
+ buttonMake = new Button();
+ buttonToPdf = new Button();
+ panelControl.SuspendLayout();
+ SuspendLayout();
+ //
+ // panelControl
+ //
+ panelControl.Controls.Add(buttonMake);
+ panelControl.Controls.Add(buttonToPdf);
+ panelControl.Dock = DockStyle.Top;
+ panelControl.Location = new Point(0, 0);
+ panelControl.Name = "panelControl";
+ panelControl.Size = new Size(800, 47);
+ panelControl.TabIndex = 5;
+ //
+ // buttonMake
+ //
+ buttonMake.Location = new Point(589, 12);
+ buttonMake.Name = "buttonMake";
+ buttonMake.Size = new Size(118, 23);
+ buttonMake.TabIndex = 5;
+ buttonMake.Text = "Сформировать";
+ buttonMake.UseVisualStyleBackColor = true;
+ buttonMake.Click += buttonMake_Click;
+ //
+ // buttonToPdf
+ //
+ buttonToPdf.Location = new Point(713, 12);
+ buttonToPdf.Name = "buttonToPdf";
+ buttonToPdf.Size = new Size(75, 23);
+ buttonToPdf.TabIndex = 4;
+ buttonToPdf.Text = "В Pdf";
+ buttonToPdf.UseVisualStyleBackColor = true;
+ buttonToPdf.Click += buttonToPdf_Click;
+ //
+ // FormReportGroupOrders
+ //
+ AutoScaleDimensions = new SizeF(7F, 15F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(800, 361);
+ Controls.Add(panelControl);
+ Name = "FormReportGroupOrders";
+ Text = "Заказы с группировкой по датам";
+ panelControl.ResumeLayout(false);
+ ResumeLayout(false);
+ }
+
+ #endregion
+
+ private Panel panelControl;
+ private Button buttonMake;
+ private Button buttonToPdf;
+ }
+}
\ No newline at end of file
diff --git a/AircraftPlant/AircraftPlantView/FormReportGroupOrders.cs b/AircraftPlant/AircraftPlantView/FormReportGroupOrders.cs
new file mode 100644
index 0000000..eb89468
--- /dev/null
+++ b/AircraftPlant/AircraftPlantView/FormReportGroupOrders.cs
@@ -0,0 +1,107 @@
+using AircraftPlantContracts.BindingModels;
+using AircraftPlantContracts.BusinessLogicsContracts;
+using Microsoft.Extensions.Logging;
+using Microsoft.Reporting.WinForms;
+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 AircraftPlantView
+{
+ ///
+ /// Форма формирования отчета по заказам с группировкой по датам
+ ///
+ public partial class FormReportGroupOrders : Form
+ {
+ ///
+ /// Отчет
+ ///
+ private readonly ReportViewer reportViewer;
+
+ ///
+ /// Логгер
+ ///
+ private readonly ILogger _logger;
+
+ ///
+ /// Бизнес-логика для отчетов
+ ///
+ private readonly IReportLogic _logic;
+
+ ///
+ /// Конструктор
+ ///
+ public FormReportGroupOrders(ILogger logger, IReportLogic logic)
+ {
+ InitializeComponent();
+
+ _logger = logger;
+ _logic = logic;
+
+ reportViewer = new ReportViewer
+ {
+ Dock = DockStyle.Fill
+ };
+ reportViewer.LocalReport.LoadReportDefinition(new FileStream("ReportGroupOrders.rdlc", FileMode.Open));
+ Controls.Clear();
+ Controls.Add(reportViewer);
+ Controls.Add(panelControl);
+ }
+
+ ///
+ /// Кнопка "Сформировать"
+ ///
+ ///
+ ///
+ private void buttonMake_Click(object sender, EventArgs e)
+ {
+ try
+ {
+ var dataSource = _logic.GetGroupOrders();
+ var source = new ReportDataSource("DataSetGroupOrders", dataSource);
+ reportViewer.LocalReport.DataSources.Clear();
+ reportViewer.LocalReport.DataSources.Add(source);
+ reportViewer.RefreshReport();
+ _logger.LogInformation("Загрузка списка заказов с группировкой по датам");
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка загрузки списка заказов c группировкой по датам");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ ///
+ /// Кнопка "В Pdf"
+ ///
+ ///
+ ///
+ private void buttonToPdf_Click(object sender, EventArgs e)
+ {
+ using var dialog = new SaveFileDialog { Filter = "pdf|*.pdf" };
+ if (dialog.ShowDialog() == DialogResult.OK)
+ {
+ try
+ {
+ _logic.SaveGroupOrdersToPdfFile(new ReportBindingModel
+ {
+ FileName = dialog.FileName
+ });
+ _logger.LogInformation("Сохранение списка заказов с группировкой по датам");
+ MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка сохранения списка заказов с группировкой по датам");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+ }
+}
diff --git a/AircraftPlant/AircraftPlantView/FormReportGroupOrders.resx b/AircraftPlant/AircraftPlantView/FormReportGroupOrders.resx
new file mode 100644
index 0000000..af32865
--- /dev/null
+++ b/AircraftPlant/AircraftPlantView/FormReportGroupOrders.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/AircraftPlant/AircraftPlantView/FormReportShopPlanes.Designer.cs b/AircraftPlant/AircraftPlantView/FormReportShopPlanes.Designer.cs
new file mode 100644
index 0000000..9f95e2d
--- /dev/null
+++ b/AircraftPlant/AircraftPlantView/FormReportShopPlanes.Designer.cs
@@ -0,0 +1,110 @@
+namespace AircraftPlantView
+{
+ partial class FormReportShopPlanes
+ {
+ ///
+ /// 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()
+ {
+ buttonSaveToExcel = new Button();
+ dataGridView = new DataGridView();
+ ColumnShopName = new DataGridViewTextBoxColumn();
+ ColumnPlaneName = new DataGridViewTextBoxColumn();
+ ColumnCount = new DataGridViewTextBoxColumn();
+ ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
+ SuspendLayout();
+ //
+ // buttonSaveToExcel
+ //
+ buttonSaveToExcel.Dock = DockStyle.Top;
+ buttonSaveToExcel.Location = new Point(0, 0);
+ buttonSaveToExcel.Name = "buttonSaveToExcel";
+ buttonSaveToExcel.Size = new Size(584, 23);
+ buttonSaveToExcel.TabIndex = 2;
+ buttonSaveToExcel.Text = "Сохранить в Excel";
+ buttonSaveToExcel.UseVisualStyleBackColor = true;
+ buttonSaveToExcel.Click += buttonSaveToExcel_Click;
+ //
+ // dataGridView
+ //
+ dataGridView.AllowUserToAddRows = false;
+ dataGridView.AllowUserToDeleteRows = false;
+ dataGridView.BackgroundColor = Color.White;
+ dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridView.Columns.AddRange(new DataGridViewColumn[] { ColumnShopName, ColumnPlaneName, ColumnCount });
+ dataGridView.Dock = DockStyle.Bottom;
+ dataGridView.GridColor = Color.Black;
+ dataGridView.Location = new Point(0, 29);
+ dataGridView.MultiSelect = false;
+ dataGridView.Name = "dataGridView";
+ dataGridView.ReadOnly = true;
+ dataGridView.RowTemplate.Height = 25;
+ dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
+ dataGridView.Size = new Size(584, 332);
+ dataGridView.TabIndex = 3;
+ //
+ // ColumnShopName
+ //
+ ColumnShopName.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
+ ColumnShopName.HeaderText = "Магазин";
+ ColumnShopName.Name = "ColumnShopName";
+ ColumnShopName.ReadOnly = true;
+ //
+ // ColumnPlaneName
+ //
+ ColumnPlaneName.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
+ ColumnPlaneName.HeaderText = "Изделие";
+ ColumnPlaneName.Name = "ColumnPlaneName";
+ ColumnPlaneName.ReadOnly = true;
+ //
+ // ColumnCount
+ //
+ ColumnCount.HeaderText = "Количество";
+ ColumnCount.Name = "ColumnCount";
+ ColumnCount.ReadOnly = true;
+ //
+ // FormReportShopPlanes
+ //
+ AutoScaleDimensions = new SizeF(7F, 15F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(584, 361);
+ Controls.Add(dataGridView);
+ Controls.Add(buttonSaveToExcel);
+ Name = "FormReportShopPlanes";
+ Text = "Ассортимент магазинов";
+ Load += FormReportShopPlanes_Load;
+ ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
+ ResumeLayout(false);
+ }
+
+ #endregion
+
+ private Button buttonSaveToExcel;
+ private DataGridView dataGridView;
+ private DataGridViewTextBoxColumn ColumnShopName;
+ private DataGridViewTextBoxColumn ColumnPlaneName;
+ private DataGridViewTextBoxColumn ColumnCount;
+ }
+}
\ No newline at end of file
diff --git a/AircraftPlant/AircraftPlantView/FormReportShopPlanes.cs b/AircraftPlant/AircraftPlantView/FormReportShopPlanes.cs
new file mode 100644
index 0000000..60c13a2
--- /dev/null
+++ b/AircraftPlant/AircraftPlantView/FormReportShopPlanes.cs
@@ -0,0 +1,101 @@
+using AircraftPlantContracts.BindingModels;
+using AircraftPlantContracts.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 AircraftPlantView
+{
+ ///
+ /// Форма формирования отчета с ассортиментом магазинов
+ ///
+ public partial class FormReportShopPlanes : Form
+ {
+ ///
+ /// Логгер
+ ///
+ private readonly ILogger _logger;
+
+ ///
+ /// Взаимодействие с отчетами
+ ///
+ private readonly IReportLogic _logic;
+
+ ///
+ /// Конструктор
+ ///
+ public FormReportShopPlanes(ILogger logger, IReportLogic logic)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _logic = logic;
+ }
+
+ ///
+ /// Загрузка данных
+ ///
+ ///
+ ///
+ private void FormReportShopPlanes_Load(object sender, EventArgs e)
+ {
+ try
+ {
+ var dict = _logic.GetShopPlanes();
+ if (dict != null)
+ {
+ dataGridView.Rows.Clear();
+ foreach (var elem in dict)
+ {
+ dataGridView.Rows.Add(new object[] { elem.ShopName, "", "" });
+ foreach (var listElem in elem.Planes)
+ {
+ dataGridView.Rows.Add(new object[] { "", listElem.Item1, listElem.Item2 });
+ }
+ dataGridView.Rows.Add(new object[] { "Итого", "", elem.TotalCount });
+ dataGridView.Rows.Add(Array.Empty