Tsukanova_I.V. LabWork05_hard #13
@ -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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -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<ReportShopWorkloadViewModel> GetShopDocuments()
|
||||
{
|
||||
var shops = _shopStorage.GetFullList();
|
||||
var list = new List<ReportShopWorkloadViewModel>();
|
||||
foreach (var shop in shops)
|
||||
{
|
||||
var record = new ReportShopWorkloadViewModel
|
||||
{
|
||||
ShopName = shop.Name,
|
||||
IceCreams = new List<Tuple<string, int>>(),
|
||||
Count = 0
|
||||
};
|
||||
foreach (var docCount in shop.ShopIceCreams.Values)
|
||||
{
|
||||
record.IceCreams.Add(new Tuple<string, int>(docCount.Item1.IceCreamName, docCount.Item2));
|
||||
record.Count += docCount.Item2;
|
||||
}
|
||||
list.Add(record);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Сохранение компонент в файл-Word
|
||||
/// </summary>
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Создание excel-файла
|
||||
/// </summary>
|
||||
|
@ -38,6 +38,30 @@ namespace IceCreamBusinessLogic.OfficePackage
|
||||
SaveWord(info);
|
||||
}
|
||||
|
||||
public void CreateTableDoc(WordInfo wordInfo)
|
||||
{
|
||||
CreateWord(wordInfo);
|
||||
var list = new List<string>();
|
||||
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<string> {
|
||||
"Название",
|
||||
"Адрес",
|
||||
"Дата открытия"},
|
||||
Texts = list
|
||||
};
|
||||
CreateTable(wordTable);
|
||||
|
||||
SaveWord(wordInfo);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Создание doc-файла
|
||||
/// </summary>
|
||||
@ -56,5 +80,6 @@ namespace IceCreamBusinessLogic.OfficePackage
|
||||
/// </summary>
|
||||
/// <param name="info"></param>
|
||||
protected abstract void SaveWord(WordInfo info);
|
||||
protected abstract void CreateTable(WordTable info);
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,6 @@ namespace IceCreamBusinessLogic.OfficePackage.HelperEnums
|
||||
|
||||
Text,
|
||||
|
||||
TextWithBroder
|
||||
TextWithBorder
|
||||
}
|
||||
}
|
||||
|
@ -9,5 +9,6 @@ namespace IceCreamBusinessLogic.OfficePackage.HelperModels
|
||||
public string Title { get; set; } = string.Empty;
|
||||
|
||||
public List<ReportIceCreamComponentViewModel> IceCreamComponents { get; set; } = new();
|
||||
public List<ReportShopWorkloadViewModel> ShopIceCreams { get; set; } = new();
|
||||
}
|
||||
}
|
@ -9,5 +9,6 @@ namespace IceCreamBusinessLogic.OfficePackage.HelperModels
|
||||
public string Title { get; set; } = string.Empty;
|
||||
|
||||
public List<IceCreamViewModel> IceCreams { get; set; } = new();
|
||||
public List<ShopViewModel> Shops { get; set; } = new();
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
|
||||
namespace IceCreamBusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
public class WordTable
|
||||
{
|
||||
public List<string> Headers { get; set; } = new();
|
||||
public List<string> Texts { get; set; } = new();
|
||||
}
|
||||
}
|
@ -145,7 +145,7 @@ namespace IceCreamBusinessLogic.OfficePackage.Implements
|
||||
return styleInfo switch
|
||||
{
|
||||
ExcelStyleInfoType.Title => 2U,
|
||||
ExcelStyleInfoType.TextWithBroder => 1U,
|
||||
ExcelStyleInfoType.TextWithBorder => 1U,
|
||||
ExcelStyleInfoType.Text => 0U,
|
||||
_ => 0U,
|
||||
};
|
||||
|
@ -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>(BorderValues.Single),
|
||||
Size = 12
|
||||
},
|
||||
new BottomBorder
|
||||
{
|
||||
Val = new EnumValue<BorderValues>(BorderValues.Single),
|
||||
Size = 12
|
||||
},
|
||||
new LeftBorder
|
||||
{
|
||||
Val = new EnumValue<BorderValues>(BorderValues.Single),
|
||||
Size = 12
|
||||
},
|
||||
new RightBorder
|
||||
{
|
||||
Val = new EnumValue<BorderValues>(BorderValues.Single),
|
||||
Size = 12
|
||||
},
|
||||
new InsideHorizontalBorder
|
||||
{
|
||||
Val = new EnumValue<BorderValues>(BorderValues.Single),
|
||||
Size = 12
|
||||
},
|
||||
new InsideVerticalBorder
|
||||
{
|
||||
Val = new EnumValue<BorderValues>(BorderValues.Single),
|
||||
Size = 12
|
||||
}
|
||||
)
|
||||
);
|
||||
tab.AppendChild<TableProperties>(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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
62
IceCreamShop/IceCreamShop/FormMain.Designer.cs
generated
62
IceCreamShop/IceCreamShop/FormMain.Designer.cs
generated
@ -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;
|
||||
}
|
||||
}
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
107
IceCreamShop/IceCreamShop/FormReportShopWorkload.Designer.cs
generated
Normal file
107
IceCreamShop/IceCreamShop/FormReportShopWorkload.Designer.cs
generated
Normal file
@ -0,0 +1,107 @@
|
||||
namespace IceCreamShopView
|
||||
{
|
||||
partial class FormReportShopWorkload
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
}
|
74
IceCreamShop/IceCreamShop/FormReportShopWorkload.cs
Normal file
74
IceCreamShop/IceCreamShop/FormReportShopWorkload.cs
Normal file
@ -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<FormReportShopWorkload> 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<object>());
|
||||
}
|
||||
}
|
||||
_logger.LogInformation("Загрузка списка магазинов с изделиями в них");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки списка магазинов с изделиями в них");
|
||||
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
78
IceCreamShop/IceCreamShop/FormReportShopWorkload.resx
Normal file
78
IceCreamShop/IceCreamShop/FormReportShopWorkload.resx
Normal file
@ -0,0 +1,78 @@
|
||||
<root>
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="Shop.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="Document.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="Count.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="Shop.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="Document.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="Count.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
</root>
|
@ -66,6 +66,7 @@ namespace IceCreamShop
|
||||
services.AddTransient<FormShops>();
|
||||
services.AddTransient<FormShopSupply>();
|
||||
services.AddTransient<FormSellIceCream>();
|
||||
services.AddTransient<FormReportShopWorkload>();
|
||||
}
|
||||
}
|
||||
}
|
@ -40,5 +40,11 @@ namespace IceCreamShopContracts.BusinessLogicsContracts
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
void SaveOrdersToPdfFile(ReportBindingModel model);
|
||||
/// <summary>
|
||||
/// Сохранение магазинов в файл-Word
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
void SaveShopsToWordFile(ReportBindingModel model);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,10 @@
|
||||
|
||||
namespace IceCreamShopContracts.ViewModels
|
||||
{
|
||||
public class ReportShopWorkloadViewModel
|
||||
{
|
||||
public string ShopName { get; set; } = string.Empty;
|
||||
public int Count { get; set; }
|
||||
public List<Tuple<string, int>> IceCreams { get; set; } = new();
|
||||
}
|
||||
}
|
@ -92,16 +92,5 @@ namespace IceCreamShopFileImplement.Implements
|
||||
}
|
||||
return viewModel;
|
||||
}
|
||||
|
||||
private OrderViewModel GetViewModel(Order order)
|
||||
{
|
||||
var viewModel = order.GetViewModel;
|
||||
var document = source.IceCreams.FirstOrDefault(x => x.Id == order.IceCreamId);
|
||||
if (document != null)
|
||||
{
|
||||
viewModel.IceCreamName = document.IceCreamName;
|
||||
}
|
||||
return viewModel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user