diff --git a/IceCreamShop/IceCreamBusinessLogic/BusinessLogics/ReportLogic.cs b/IceCreamShop/IceCreamBusinessLogic/BusinessLogics/ReportLogic.cs
index 5f0f0d4..6e32592 100644
--- a/IceCreamShop/IceCreamBusinessLogic/BusinessLogics/ReportLogic.cs
+++ b/IceCreamShop/IceCreamBusinessLogic/BusinessLogics/ReportLogic.cs
@@ -21,14 +21,16 @@ namespace IceCreamBusinessLogic.BusinessLogics
private readonly IOrderStorage _orderStorage;
+ private readonly IShopStorage _shopStorage;
+
private readonly AbstractSaveToExcel _saveToExcel;
private readonly AbstractSaveToWord _saveToWord;
private readonly AbstractSaveToPdf _saveToPdf;
- public ReportLogic(IIceCreamStorage iceCreamStorage, IComponentStorage componentStorage, IOrderStorage orderStorage,
- AbstractSaveToExcel saveToExcel, AbstractSaveToWord saveToWord, AbstractSaveToPdf saveToPdf)
+ public ReportLogic(IIceCreamStorage iceCreamStorage, IComponentStorage componentStorage, IOrderStorage orderStorage,
+ AbstractSaveToExcel saveToExcel, AbstractSaveToWord saveToWord, AbstractSaveToPdf saveToPdf, IShopStorage shopStorage)
{
_iceCreamStorage = iceCreamStorage;
_componentStorage = componentStorage;
@@ -37,6 +39,7 @@ namespace IceCreamBusinessLogic.BusinessLogics
_saveToExcel = saveToExcel;
_saveToWord = saveToWord;
_saveToPdf = saveToPdf;
+ this._shopStorage = shopStorage;
}
///
@@ -93,6 +96,48 @@ namespace IceCreamBusinessLogic.BusinessLogics
.ToList();
}
+ public void SaveShopsToWordFile(ReportBindingModel model)
+ {
+ _saveToWord.CreateTableDoc(new WordInfo
+ {
+ FileName = model.FileName,
+ Title = "Список магазинов",
+ Shops = _shopStorage.GetFullList()
+ });
+ }
+
+ public void SaveShopWorkloadToExcelFile(ReportBindingModel model)
+ {
+ _saveToExcel.CreateShopReport(new ExcelInfo
+ {
+ FileName = model.FileName,
+ Title = "Загруженность магазинов",
+ ShopIceCreams = GetShopDocuments()
+ });
+ }
+
+ public List GetShopDocuments()
+ {
+ var shops = _shopStorage.GetFullList();
+ var list = new List();
+ foreach (var shop in shops)
+ {
+ var record = new ReportShopWorkloadViewModel
+ {
+ ShopName = shop.Name,
+ IceCreams = new List>(),
+ Count = 0
+ };
+ foreach (var docCount in shop.ShopIceCreams.Values)
+ {
+ record.IceCreams.Add(new Tuple(docCount.Item1.IceCreamName, docCount.Item2));
+ record.Count += docCount.Item2;
+ }
+ list.Add(record);
+ }
+ return list;
+ }
+
///
/// Сохранение компонент в файл-Word
///
diff --git a/IceCreamShop/IceCreamBusinessLogic/OfficePackage/AbstractSaveToExcel.cs b/IceCreamShop/IceCreamBusinessLogic/OfficePackage/AbstractSaveToExcel.cs
index e0f80fa..0a34c1b 100644
--- a/IceCreamShop/IceCreamBusinessLogic/OfficePackage/AbstractSaveToExcel.cs
+++ b/IceCreamShop/IceCreamBusinessLogic/OfficePackage/AbstractSaveToExcel.cs
@@ -46,7 +46,7 @@ namespace IceCreamBusinessLogic.OfficePackage
ColumnName = "B",
RowIndex = rowIndex,
Text = IceCream,
- StyleInfo = ExcelStyleInfoType.TextWithBroder
+ StyleInfo = ExcelStyleInfoType.TextWithBorder
});
InsertCellInWorksheet(new ExcelCellParameters
@@ -54,7 +54,7 @@ namespace IceCreamBusinessLogic.OfficePackage
ColumnName = "C",
RowIndex = rowIndex,
Text = Count.ToString(),
- StyleInfo = ExcelStyleInfoType.TextWithBroder
+ StyleInfo = ExcelStyleInfoType.TextWithBorder
});
rowIndex++;
@@ -80,6 +80,69 @@ namespace IceCreamBusinessLogic.OfficePackage
SaveExcel(info);
}
+ public void CreateShopReport(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 pc in info.ShopIceCreams)
+ {
+ InsertCellInWorksheet(new ExcelCellParameters
+ {
+ ColumnName = "A",
+ RowIndex = rowIndex,
+ Text = pc.ShopName,
+ StyleInfo = ExcelStyleInfoType.Text
+ });
+ rowIndex++;
+ foreach (var (IceCreamName, Count) in pc.IceCreams)
+ {
+ InsertCellInWorksheet(new ExcelCellParameters
+ {
+ ColumnName = "B",
+ RowIndex = rowIndex,
+ Text = IceCreamName,
+ StyleInfo = ExcelStyleInfoType.TextWithBorder
+ });
+ InsertCellInWorksheet(new ExcelCellParameters
+ {
+ ColumnName = "C",
+ RowIndex = rowIndex,
+ Text = Count.ToString(),
+ StyleInfo = ExcelStyleInfoType.TextWithBorder
+ });
+ rowIndex++;
+ }
+ InsertCellInWorksheet(new ExcelCellParameters
+ {
+ ColumnName = "A",
+ RowIndex = rowIndex,
+ Text = "Итого",
+ StyleInfo = ExcelStyleInfoType.Text
+ });
+ InsertCellInWorksheet(new ExcelCellParameters
+ {
+ ColumnName = "C",
+ RowIndex = rowIndex,
+ Text = pc.Count.ToString(),
+ StyleInfo = ExcelStyleInfoType.Text
+ });
+ rowIndex++;
+ }
+ SaveExcel(info);
+ }
+
///
/// Создание excel-файла
///
diff --git a/IceCreamShop/IceCreamBusinessLogic/OfficePackage/AbstractSaveToWord.cs b/IceCreamShop/IceCreamBusinessLogic/OfficePackage/AbstractSaveToWord.cs
index bc73496..ae9ccbe 100644
--- a/IceCreamShop/IceCreamBusinessLogic/OfficePackage/AbstractSaveToWord.cs
+++ b/IceCreamShop/IceCreamBusinessLogic/OfficePackage/AbstractSaveToWord.cs
@@ -38,6 +38,30 @@ namespace IceCreamBusinessLogic.OfficePackage
SaveWord(info);
}
+ public void CreateTableDoc(WordInfo wordInfo)
+ {
+ CreateWord(wordInfo);
+ var list = new List();
+ foreach (var shop in wordInfo.Shops)
+ {
+ list.Add(shop.Name);
+ list.Add(shop.Adress);
+ list.Add(shop.OpeningDate.ToString());
+ }
+ var wordTable = new WordTable
+ {
+ Headers = new List {
+ "Название",
+ "Адрес",
+ "Дата открытия"},
+ Texts = list
+ };
+ CreateTable(wordTable);
+
+ SaveWord(wordInfo);
+
+ }
+
///
/// Создание doc-файла
///
@@ -56,5 +80,6 @@ namespace IceCreamBusinessLogic.OfficePackage
///
///
protected abstract void SaveWord(WordInfo info);
+ protected abstract void CreateTable(WordTable info);
}
}
diff --git a/IceCreamShop/IceCreamBusinessLogic/OfficePackage/HelperEnums/ExcelStyleInfoType.cs b/IceCreamShop/IceCreamBusinessLogic/OfficePackage/HelperEnums/ExcelStyleInfoType.cs
index 056b55f..2c7a9a4 100644
--- a/IceCreamShop/IceCreamBusinessLogic/OfficePackage/HelperEnums/ExcelStyleInfoType.cs
+++ b/IceCreamShop/IceCreamBusinessLogic/OfficePackage/HelperEnums/ExcelStyleInfoType.cs
@@ -12,6 +12,6 @@ namespace IceCreamBusinessLogic.OfficePackage.HelperEnums
Text,
- TextWithBroder
+ TextWithBorder
}
}
diff --git a/IceCreamShop/IceCreamBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs b/IceCreamShop/IceCreamBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs
index 6fa1f90..214c123 100644
--- a/IceCreamShop/IceCreamBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs
+++ b/IceCreamShop/IceCreamBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs
@@ -9,5 +9,6 @@ namespace IceCreamBusinessLogic.OfficePackage.HelperModels
public string Title { get; set; } = string.Empty;
public List IceCreamComponents { get; set; } = new();
+ public List ShopIceCreams { get; set; } = new();
}
}
\ No newline at end of file
diff --git a/IceCreamShop/IceCreamBusinessLogic/OfficePackage/HelperModels/WordInfo.cs b/IceCreamShop/IceCreamBusinessLogic/OfficePackage/HelperModels/WordInfo.cs
index 8e6de3a..ddae283 100644
--- a/IceCreamShop/IceCreamBusinessLogic/OfficePackage/HelperModels/WordInfo.cs
+++ b/IceCreamShop/IceCreamBusinessLogic/OfficePackage/HelperModels/WordInfo.cs
@@ -9,5 +9,6 @@ namespace IceCreamBusinessLogic.OfficePackage.HelperModels
public string Title { get; set; } = string.Empty;
public List IceCreams { get; set; } = new();
+ public List Shops { get; set; } = new();
}
}
\ No newline at end of file
diff --git a/IceCreamShop/IceCreamBusinessLogic/OfficePackage/HelperModels/WordTable.cs b/IceCreamShop/IceCreamBusinessLogic/OfficePackage/HelperModels/WordTable.cs
new file mode 100644
index 0000000..dc92d9c
--- /dev/null
+++ b/IceCreamShop/IceCreamBusinessLogic/OfficePackage/HelperModels/WordTable.cs
@@ -0,0 +1,9 @@
+
+namespace IceCreamBusinessLogic.OfficePackage.HelperModels
+{
+ public class WordTable
+ {
+ public List Headers { get; set; } = new();
+ public List Texts { get; set; } = new();
+ }
+}
diff --git a/IceCreamShop/IceCreamBusinessLogic/OfficePackage/Implements/SaveToExcel.cs b/IceCreamShop/IceCreamBusinessLogic/OfficePackage/Implements/SaveToExcel.cs
index e084785..bce798f 100644
--- a/IceCreamShop/IceCreamBusinessLogic/OfficePackage/Implements/SaveToExcel.cs
+++ b/IceCreamShop/IceCreamBusinessLogic/OfficePackage/Implements/SaveToExcel.cs
@@ -145,7 +145,7 @@ namespace IceCreamBusinessLogic.OfficePackage.Implements
return styleInfo switch
{
ExcelStyleInfoType.Title => 2U,
- ExcelStyleInfoType.TextWithBroder => 1U,
+ ExcelStyleInfoType.TextWithBorder => 1U,
ExcelStyleInfoType.Text => 0U,
_ => 0U,
};
diff --git a/IceCreamShop/IceCreamBusinessLogic/OfficePackage/Implements/SaveToWord.cs b/IceCreamShop/IceCreamBusinessLogic/OfficePackage/Implements/SaveToWord.cs
index c88af35..07ab95f 100644
--- a/IceCreamShop/IceCreamBusinessLogic/OfficePackage/Implements/SaveToWord.cs
+++ b/IceCreamShop/IceCreamBusinessLogic/OfficePackage/Implements/SaveToWord.cs
@@ -131,5 +131,87 @@ namespace IceCreamBusinessLogic.OfficePackage.Implements
_wordDocument.Close();
}
+
+ protected override void CreateTable(WordTable table)
+ {
+ if (_docBody == null || table == null)
+ {
+ return;
+ }
+ Table tab = new Table();
+ TableProperties props = new TableProperties(
+ new TableBorders(
+ new TopBorder
+ {
+ Val = new EnumValue(BorderValues.Single),
+ Size = 12
+ },
+ new BottomBorder
+ {
+ Val = new EnumValue(BorderValues.Single),
+ Size = 12
+ },
+ new LeftBorder
+ {
+ Val = new EnumValue(BorderValues.Single),
+ Size = 12
+ },
+ new RightBorder
+ {
+ Val = new EnumValue(BorderValues.Single),
+ Size = 12
+ },
+ new InsideHorizontalBorder
+ {
+ Val = new EnumValue(BorderValues.Single),
+ Size = 12
+ },
+ new InsideVerticalBorder
+ {
+ Val = new EnumValue(BorderValues.Single),
+ Size = 12
+ }
+ )
+ );
+ tab.AppendChild(props);
+ TableGrid tableGrid = new TableGrid();
+ for (int i = 0; i < table.Headers.Count; i++)
+ {
+ tableGrid.AppendChild(new GridColumn());
+ }
+ tab.AppendChild(tableGrid);
+ TableRow tableRow = new TableRow();
+ foreach (var text in table.Headers)
+ {
+ tableRow.AppendChild(CreateTableCell(text));
+ }
+ tab.AppendChild(tableRow);
+ int height = table.Texts.Count / table.Headers.Count;
+ int width = table.Headers.Count;
+ for (int i = 0; i < height; i++)
+ {
+ tableRow = new TableRow();
+ for (int j = 0; j < width; j++)
+ {
+ var element = table.Texts[i * table.Headers.Count + j];
+ tableRow.AppendChild(CreateTableCell(element));
+ }
+ tab.AppendChild(tableRow);
+ }
+
+ _docBody.AppendChild(tab);
+
+ }
+
+ private TableCell CreateTableCell(string element)
+ {
+ var tableParagraph = new Paragraph();
+ var run = new Run();
+ run.AppendChild(new Text { Text = element });
+ tableParagraph.AppendChild(run);
+ var tableCell = new TableCell();
+ tableCell.AppendChild(tableParagraph);
+ return tableCell;
+ }
}
}
diff --git a/IceCreamShop/IceCreamShop/FormMain.Designer.cs b/IceCreamShop/IceCreamShop/FormMain.Designer.cs
index ad6a851..5f0563b 100644
--- a/IceCreamShop/IceCreamShop/FormMain.Designer.cs
+++ b/IceCreamShop/IceCreamShop/FormMain.Designer.cs
@@ -38,13 +38,15 @@
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.iceCreamComponentsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.iceCreamToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ordersToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.магазиныToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.listShopsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.buttonSupplyShop = new System.Windows.Forms.Button();
this.SellIceCreamButton = new System.Windows.Forms.Button();
+ this.shopWorkloadToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
this.menuStrip.SuspendLayout();
this.SuspendLayout();
@@ -61,8 +63,7 @@
//
// buttonSetToFinish
//
- this.buttonSetToFinish.Location = new System.Drawing.Point(1003, 300);
- this.buttonSetToFinish.Location = new System.Drawing.Point(878, 149);
+ this.buttonSetToFinish.Location = new System.Drawing.Point(1003, 195);
this.buttonSetToFinish.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonSetToFinish.Name = "buttonSetToFinish";
this.buttonSetToFinish.Size = new System.Drawing.Size(194, 49);
@@ -73,8 +74,7 @@
//
// buttonSetToDone
//
- this.buttonSetToDone.Location = new System.Drawing.Point(1003, 213);
- this.buttonSetToDone.Location = new System.Drawing.Point(878, 108);
+ this.buttonSetToDone.Location = new System.Drawing.Point(1003, 142);
this.buttonSetToDone.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonSetToDone.Name = "buttonSetToDone";
this.buttonSetToDone.Size = new System.Drawing.Size(194, 49);
@@ -85,8 +85,7 @@
//
// buttonSetToWork
//
- this.buttonSetToWork.Location = new System.Drawing.Point(1003, 124);
- this.buttonSetToWork.Location = new System.Drawing.Point(878, 67);
+ this.buttonSetToWork.Location = new System.Drawing.Point(1003, 89);
this.buttonSetToWork.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonSetToWork.Name = "buttonSetToWork";
this.buttonSetToWork.Size = new System.Drawing.Size(194, 49);
@@ -124,7 +123,7 @@
this.menuStrip.Location = new System.Drawing.Point(0, 0);
this.menuStrip.Name = "menuStrip";
this.menuStrip.Padding = new System.Windows.Forms.Padding(6, 3, 0, 3);
- this.menuStrip.Size = new System.Drawing.Size(1225, 30);
+ this.menuStrip.Size = new System.Drawing.Size(1260, 30);
this.menuStrip.TabIndex = 7;
this.menuStrip.Text = "Справочники";
//
@@ -141,25 +140,32 @@
// компонентыToolStripMenuItem
//
this.компонентыToolStripMenuItem.Name = "компонентыToolStripMenuItem";
- this.компонентыToolStripMenuItem.Size = new System.Drawing.Size(224, 26);
- this.компонентыToolStripMenuItem.Size = new System.Drawing.Size(145, 22);
+ this.компонентыToolStripMenuItem.Size = new System.Drawing.Size(182, 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(224, 26);
- this.мороженоеToolStripMenuItem.Size = new System.Drawing.Size(145, 22);
+ this.мороженоеToolStripMenuItem.Size = new System.Drawing.Size(182, 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(182, 26);
+ this.магазиныToolStripMenuItem.Text = "Магазины";
+ this.магазиныToolStripMenuItem.Click += new System.EventHandler(this.магазиныToolStripMenuItem_Click);
+ //
// отчетыToolStripMenuItem
//
this.отчетыToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.iceCreamComponentsToolStripMenuItem,
this.iceCreamToolStripMenuItem,
- this.ordersToolStripMenuItem});
+ this.ordersToolStripMenuItem,
+ this.listShopsToolStripMenuItem,
+ this.shopWorkloadToolStripMenuItem});
this.отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem";
this.отчетыToolStripMenuItem.Size = new System.Drawing.Size(73, 24);
this.отчетыToolStripMenuItem.Text = "Отчеты";
@@ -185,19 +191,19 @@
this.ordersToolStripMenuItem.Text = "Список заказов";
this.ordersToolStripMenuItem.Click += new System.EventHandler(this.OrdersToolStripMenuItem_Click);
//
- // магазиныToolStripMenuItem
+ // listShopsToolStripMenuItem
//
- this.магазиныToolStripMenuItem.Name = "магазиныToolStripMenuItem";
- this.магазиныToolStripMenuItem.Size = new System.Drawing.Size(145, 22);
- this.магазиныToolStripMenuItem.Text = "Магазины";
- this.магазиныToolStripMenuItem.Click += new System.EventHandler(this.магазиныToolStripMenuItem_Click);
+ this.listShopsToolStripMenuItem.Name = "listShopsToolStripMenuItem";
+ this.listShopsToolStripMenuItem.Size = new System.Drawing.Size(299, 26);
+ this.listShopsToolStripMenuItem.Text = "Список магазинов";
+ this.listShopsToolStripMenuItem.Click += new System.EventHandler(this.listShopsToolStripMenuItem_Click);
//
// buttonSupplyShop
//
- this.buttonSupplyShop.Location = new System.Drawing.Point(878, 190);
+ this.buttonSupplyShop.Location = new System.Drawing.Point(1003, 292);
this.buttonSupplyShop.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonSupplyShop.Name = "buttonSupplyShop";
- this.buttonSupplyShop.Size = new System.Drawing.Size(170, 37);
+ this.buttonSupplyShop.Size = new System.Drawing.Size(194, 44);
this.buttonSupplyShop.TabIndex = 14;
this.buttonSupplyShop.Text = "Пополнение магазина";
this.buttonSupplyShop.UseVisualStyleBackColor = true;
@@ -205,21 +211,27 @@
//
// SellIceCreamButton
//
- this.SellIceCreamButton.Location = new System.Drawing.Point(878, 231);
+ this.SellIceCreamButton.Location = new System.Drawing.Point(1003, 248);
this.SellIceCreamButton.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.SellIceCreamButton.Name = "SellIceCreamButton";
- this.SellIceCreamButton.Size = new System.Drawing.Size(170, 37);
+ this.SellIceCreamButton.Size = new System.Drawing.Size(194, 40);
this.SellIceCreamButton.TabIndex = 15;
this.SellIceCreamButton.Text = "Продажа мороженого";
this.SellIceCreamButton.UseVisualStyleBackColor = true;
this.SellIceCreamButton.Click += new System.EventHandler(this.SellIceCreamButton_Click);
//
+ // shopWorkloadToolStripMenuItem
+ //
+ this.shopWorkloadToolStripMenuItem.Name = "shopWorkloadToolStripMenuItem";
+ this.shopWorkloadToolStripMenuItem.Size = new System.Drawing.Size(299, 26);
+ this.shopWorkloadToolStripMenuItem.Text = "Загруженность магазинов";
+ this.shopWorkloadToolStripMenuItem.Click += new System.EventHandler(this.shopWorkloadToolStripMenuItem_Click);
+ //
// FormMain
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(1225, 463);
- this.ClientSize = new System.Drawing.Size(1072, 347);
+ this.ClientSize = new System.Drawing.Size(1260, 467);
this.Controls.Add(this.SellIceCreamButton);
this.Controls.Add(this.buttonSupplyShop);
this.Controls.Add(this.buttonUpdate);
@@ -260,5 +272,7 @@
private ToolStripMenuItem магазиныToolStripMenuItem;
private Button buttonSupplyShop;
private Button SellIceCreamButton;
+ private ToolStripMenuItem listShopsToolStripMenuItem;
+ private ToolStripMenuItem shopWorkloadToolStripMenuItem;
}
}
\ No newline at end of file
diff --git a/IceCreamShop/IceCreamShop/FormMain.cs b/IceCreamShop/IceCreamShop/FormMain.cs
index 5146fd3..6a47e1c 100644
--- a/IceCreamShop/IceCreamShop/FormMain.cs
+++ b/IceCreamShop/IceCreamShop/FormMain.cs
@@ -222,5 +222,27 @@ namespace IceCreamShopView
form.ShowDialog();
}
}
+
+ private void listShopsToolStripMenuItem_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 shopWorkloadToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormReportShopDocuments));
+ if (service is FormReportShopDocuments form)
+ {
+ form.ShowDialog();
+ }
+ }
}
}
diff --git a/IceCreamShop/IceCreamShop/FormReportShopWorkload.Designer.cs b/IceCreamShop/IceCreamShop/FormReportShopWorkload.Designer.cs
new file mode 100644
index 0000000..fb0ee88
--- /dev/null
+++ b/IceCreamShop/IceCreamShop/FormReportShopWorkload.Designer.cs
@@ -0,0 +1,107 @@
+namespace IceCreamShopView
+{
+ partial class FormReportShopWorkload
+ {
+ ///
+ /// 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.Shop = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.Document = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.Count = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
+ this.SuspendLayout();
+ //
+ // dataGridView
+ //
+ this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
+ this.Shop,
+ this.Document,
+ this.Count});
+ this.dataGridView.Location = new System.Drawing.Point(12, 45);
+ this.dataGridView.Name = "dataGridView";
+ this.dataGridView.RowHeadersWidth = 51;
+ this.dataGridView.RowTemplate.Height = 29;
+ this.dataGridView.Size = new System.Drawing.Size(776, 395);
+ this.dataGridView.TabIndex = 3;
+ //
+ // buttonSaveToExcel
+ //
+ this.buttonSaveToExcel.Location = new System.Drawing.Point(12, 10);
+ this.buttonSaveToExcel.Name = "buttonSaveToExcel";
+ this.buttonSaveToExcel.Size = new System.Drawing.Size(176, 29);
+ this.buttonSaveToExcel.TabIndex = 2;
+ this.buttonSaveToExcel.Text = "Сохранить в Excel";
+ this.buttonSaveToExcel.UseVisualStyleBackColor = true;
+ this.buttonSaveToExcel.Click += new System.EventHandler(this.buttonSaveToExcel_Click);
+ //
+ // Shop
+ //
+ this.Shop.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
+ this.Shop.HeaderText = "Магазин";
+ this.Shop.MinimumWidth = 6;
+ this.Shop.Name = "Shop";
+ //
+ // Document
+ //
+ this.Document.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
+ this.Document.HeaderText = "Мороженое";
+ this.Document.MinimumWidth = 6;
+ this.Document.Name = "Document";
+ //
+ // Count
+ //
+ this.Count.HeaderText = "Количество";
+ this.Count.MinimumWidth = 6;
+ this.Count.Name = "Count";
+ this.Count.Width = 125;
+ //
+ // FormReportShopWorkload
+ //
+ 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.dataGridView);
+ this.Controls.Add(this.buttonSaveToExcel);
+ this.Name = "FormReportShopWorkload";
+ this.Text = "Загруженность магазинов";
+ this.Load += new System.EventHandler(this.FormReportShopWorkload_Load);
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private DataGridView dataGridView;
+ private Button buttonSaveToExcel;
+ private DataGridViewTextBoxColumn Shop;
+ private DataGridViewTextBoxColumn Document;
+ private DataGridViewTextBoxColumn Count;
+ }
+}
\ No newline at end of file
diff --git a/IceCreamShop/IceCreamShop/FormReportShopWorkload.cs b/IceCreamShop/IceCreamShop/FormReportShopWorkload.cs
new file mode 100644
index 0000000..377d476
--- /dev/null
+++ b/IceCreamShop/IceCreamShop/FormReportShopWorkload.cs
@@ -0,0 +1,74 @@
+using IceCreamShopContracts.BindingModels;
+using IceCreamShopContracts.BusinessLogicsContracts;
+using Microsoft.Extensions.Logging;
+
+namespace IceCreamShopView
+{
+ public partial class FormReportShopWorkload : Form
+ {
+ private readonly ILogger _logger;
+ private readonly IReportLogic _logic;
+ public FormReportShopWorkload(ILogger logger, IReportLogic reportLogic)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _logic = reportLogic;
+ }
+
+ private void buttonSaveToExcel_Click(object sender, EventArgs e)
+ {
+ using var dialog = new SaveFileDialog
+ {
+ Filter = "xlsx|*.xlsx"
+ };
+ if (dialog.ShowDialog() == DialogResult.OK)
+ {
+ try
+ {
+ _logic.SaveShopDocumentsToExcelFile(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);
+ }
+ }
+ }
+
+ private void FormReportShopWorkload_Load(object sender, EventArgs e)
+ {
+ try
+ {
+ var dict = _logic.GetShopDocuments();
+ if (dict != null)
+ {
+ dataGridView.Rows.Clear();
+ foreach (var elem in dict)
+ {
+ dataGridView.Rows.Add(new object[] { elem.ShopName, "", "" });
+ foreach (var listElem in elem.Documents)
+ {
+ dataGridView.Rows.Add(new object[] { "", listElem.Item1, listElem.Item2 });
+ }
+ dataGridView.Rows.Add(new object[] { "Всего:", "", elem.Count });
+ dataGridView.Rows.Add(Array.Empty