From dbdb29ed29635a1db70f6f383b6e6a806b6f0db3 Mon Sep 17 00:00:00 2001 From: AnnaLioness Date: Sat, 6 Apr 2024 21:27:02 +0400 Subject: [PATCH] =?UTF-8?q?=D1=81=D0=BB=D0=BE=D0=B64=20=D0=B3=D0=BE=D1=82?= =?UTF-8?q?=D0=BE=D0=B2=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BusinessLogic/ReportLogic.cs | 62 ++- .../OfficePackage/AbstractSaveToExcel.cs | 62 +++ .../OfficePackage/AbstractSaveToPdf.cs | 33 ++ .../OfficePackage/AbstractSaveToWord.cs | 22 + .../OfficePackage/HelperModels/ExcelInfo.cs | 6 +- .../OfficePackage/HelperModels/PdfInfo.cs | 1 + .../OfficePackage/HelperModels/WordInfo.cs | 1 + .../OfficePackage/HelperModels/WordTable.cs | 14 + .../OfficePackage/Implements/SaveToWord.cs | 79 ++++ .../BusinessLogicsContracts/IReportLogic.cs | 5 + .../ViewModels/ReportDateOrdersViewModel.cs | 15 + .../ReportShopDocumentsViewModel.cs | 15 + LawFirm/LawFirmView/FormMain.Designer.cs | 38 +- LawFirm/LawFirmView/FormMain.cs | 31 ++ LawFirm/LawFirmView/FormMain.resx | 2 +- .../FormReportDateOrders.Designer.cs | 87 ++++ LawFirm/LawFirmView/FormReportDateOrders.cs | 84 ++++ LawFirm/LawFirmView/FormReportDateOrders.resx | 60 +++ .../FormReportShopDocuments.Designer.cs | 101 +++++ .../LawFirmView/FormReportShopDocuments.cs | 80 ++++ .../LawFirmView/FormReportShopDocuments.resx | 78 ++++ LawFirm/LawFirmView/LawFirmView.csproj | 3 + LawFirm/LawFirmView/Program.cs | 2 + LawFirm/LawFirmView/ReportOrdersByDate.rdlc | 424 ++++++++++++++++++ 24 files changed, 1297 insertions(+), 8 deletions(-) create mode 100644 LawFirm/AbstractLawFirmBusinessLogic/OfficePackage/HelperModels/WordTable.cs create mode 100644 LawFirm/AbstractLawFirmContracts/AbstractLawFirmContracts/ViewModels/ReportDateOrdersViewModel.cs create mode 100644 LawFirm/AbstractLawFirmContracts/AbstractLawFirmContracts/ViewModels/ReportShopDocumentsViewModel.cs create mode 100644 LawFirm/LawFirmView/FormReportDateOrders.Designer.cs create mode 100644 LawFirm/LawFirmView/FormReportDateOrders.cs create mode 100644 LawFirm/LawFirmView/FormReportDateOrders.resx create mode 100644 LawFirm/LawFirmView/FormReportShopDocuments.Designer.cs create mode 100644 LawFirm/LawFirmView/FormReportShopDocuments.cs create mode 100644 LawFirm/LawFirmView/FormReportShopDocuments.resx create mode 100644 LawFirm/LawFirmView/ReportOrdersByDate.rdlc diff --git a/LawFirm/AbstractLawFirmBusinessLogic/BusinessLogic/ReportLogic.cs b/LawFirm/AbstractLawFirmBusinessLogic/BusinessLogic/ReportLogic.cs index 0f727d3..c89bb3b 100644 --- a/LawFirm/AbstractLawFirmBusinessLogic/BusinessLogic/ReportLogic.cs +++ b/LawFirm/AbstractLawFirmBusinessLogic/BusinessLogic/ReportLogic.cs @@ -18,17 +18,19 @@ namespace AbstractLawFirmBusinessLogic.BusinessLogic private readonly IComponentStorage _componentStorage; private readonly IDocumentStorage _documentStorage; private readonly IOrderStorage _orderStorage; + private readonly IShopStorage _shopStorage; private readonly AbstractSaveToExcel _saveToExcel; private readonly AbstractSaveToWord _saveToWord; private readonly AbstractSaveToPdf _saveToPdf; public ReportLogic(IDocumentStorage documentStorage, IComponentStorage - componentStorage, IOrderStorage orderStorage, + componentStorage, IOrderStorage orderStorage, IShopStorage shopStorage, AbstractSaveToExcel saveToExcel, AbstractSaveToWord saveToWord, AbstractSaveToPdf saveToPdf) { _documentStorage = documentStorage; _componentStorage = componentStorage; _orderStorage = orderStorage; + _shopStorage = shopStorage; _saveToExcel = saveToExcel; _saveToWord = saveToWord; _saveToPdf = saveToPdf; @@ -122,6 +124,62 @@ namespace AbstractLawFirmBusinessLogic.BusinessLogic Orders = GetOrders(model) }); } - + public void SaveShopsToWordFile(ReportBindingModel model) + { + _saveToWord.CreateTableDoc(new WordInfo + { + FileName = model.FileName, + Title = "Список магазинов", + Shops = _shopStorage.GetFullList() + }); + } + public void SaveShopDocumentsToExcelFile(ReportBindingModel model) + { + _saveToExcel.CreateShopReport(new ExcelInfo + { + FileName = model.FileName, + Title = "Загруженность магазинов", + ShopDocuments = GetShopDocuments() + }); + } + public List GetShopDocuments() + { + var shops = _shopStorage.GetFullList(); + var list = new List(); + foreach (var shop in shops) + { + var record = new ReportShopDocumentsViewModel + { + ShopName = shop.ShopName, + Documents = new List>(), + Count = 0 + }; + foreach (var docCount in shop.ShopDocuments.Values) + { + record.Documents.Add(new Tuple(docCount.Item1.DocumentName, docCount.Item2)); + record.Count += docCount.Item2; + } + list.Add(record); + } + return list; + } + public List GetDateOrders() + { + return _orderStorage.GetFullList().GroupBy(x => x.DateCreate.Date).Select(x => new ReportDateOrdersViewModel + { + DateCreate = x.Key, + CountOrders = x.Count(), + SumOrders = x.Sum(y => y.Sum) + }).ToList(); + } + public void SaveDateOrdersToPdfFile(ReportBindingModel model) + { + _saveToPdf.CreateReportDateDoc(new PdfInfo + { + FileName = model.FileName, + Title = "Заказы по датам", + DateOrders = GetDateOrders() + }); + } } } diff --git a/LawFirm/AbstractLawFirmBusinessLogic/OfficePackage/AbstractSaveToExcel.cs b/LawFirm/AbstractLawFirmBusinessLogic/OfficePackage/AbstractSaveToExcel.cs index 44c6cbc..8164b9f 100644 --- a/LawFirm/AbstractLawFirmBusinessLogic/OfficePackage/AbstractSaveToExcel.cs +++ b/LawFirm/AbstractLawFirmBusinessLogic/OfficePackage/AbstractSaveToExcel.cs @@ -76,6 +76,68 @@ namespace AbstractLawFirmBusinessLogic.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.ShopDocuments) + { + InsertCellInWorksheet(new ExcelCellParameters + { + ColumnName = "A", + RowIndex = rowIndex, + Text = pc.ShopName, + StyleInfo = ExcelStyleInfoType.Text + }); + rowIndex++; + foreach (var (DocumentName, Count) in pc.Documents) + { + InsertCellInWorksheet(new ExcelCellParameters + { + ColumnName = "B", + RowIndex = rowIndex, + Text = DocumentName, + 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/LawFirm/AbstractLawFirmBusinessLogic/OfficePackage/AbstractSaveToPdf.cs b/LawFirm/AbstractLawFirmBusinessLogic/OfficePackage/AbstractSaveToPdf.cs index 2fe0ac0..da7d3d3 100644 --- a/LawFirm/AbstractLawFirmBusinessLogic/OfficePackage/AbstractSaveToPdf.cs +++ b/LawFirm/AbstractLawFirmBusinessLogic/OfficePackage/AbstractSaveToPdf.cs @@ -50,6 +50,39 @@ order.DateCreate.ToShortDateString(), order.DocumentName, order.Sum.ToString(), }); SavePdf(info); } + public void CreateReportDateDoc(PdfInfo info) + { + CreatePdf(info); + CreateParagraph(new PdfParagraph + { + Text = info.Title, + Style = "NormalTitle", + ParagraphAlignment = PdfParagraphAlignmentType.Center + }); + CreateTable(new List { "3cm", "3cm", "7cm" }); + CreateRow(new PdfRowParameters + { + Texts = new List { "Дата", "Количество", "Сумма" }, + Style = "NormalTitle", + ParagraphAlignment = PdfParagraphAlignmentType.Center + }); + foreach (var order in info.DateOrders) + { + CreateRow(new PdfRowParameters + { + Texts = new List { order.DateCreate.ToShortDateString(), order.CountOrders.ToString(), order.SumOrders.ToString() }, + Style = "Normal", + ParagraphAlignment = PdfParagraphAlignmentType.Left + }); + } + CreateParagraph(new PdfParagraph + { + Text = $"Итого: {info.DateOrders.Sum(x => x.SumOrders)}\t", + Style = "Normal", + ParagraphAlignment = PdfParagraphAlignmentType.Center + }); + SavePdf(info); + } /// /// Создание doc-файла /// diff --git a/LawFirm/AbstractLawFirmBusinessLogic/OfficePackage/AbstractSaveToWord.cs b/LawFirm/AbstractLawFirmBusinessLogic/OfficePackage/AbstractSaveToWord.cs index 65b5531..455456f 100644 --- a/LawFirm/AbstractLawFirmBusinessLogic/OfficePackage/AbstractSaveToWord.cs +++ b/LawFirm/AbstractLawFirmBusinessLogic/OfficePackage/AbstractSaveToWord.cs @@ -39,6 +39,27 @@ namespace AbstractLawFirmBusinessLogic.OfficePackage } SaveWord(info); } + public void CreateTableDoc(WordInfo wordInfo) + { + CreateWord(wordInfo); + var list = new List(); + foreach (var shop in wordInfo.Shops) + { + list.Add(shop.ShopName); + list.Add(shop.Address); + list.Add(shop.OpeningDate.ToString()); + } + var wordTable = new WordTable + { + Headers = new List { + "Название", + "Адрес", + "Дата открытия"}, + Texts = list + }; + CreateTable(wordTable); + SaveWord(wordInfo); + } /// /// Создание doc-файла /// @@ -55,5 +76,6 @@ namespace AbstractLawFirmBusinessLogic.OfficePackage /// /// protected abstract void SaveWord(WordInfo info); + protected abstract void CreateTable(WordTable info); } } diff --git a/LawFirm/AbstractLawFirmBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs b/LawFirm/AbstractLawFirmBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs index f738e91..87f9440 100644 --- a/LawFirm/AbstractLawFirmBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs +++ b/LawFirm/AbstractLawFirmBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs @@ -16,6 +16,10 @@ namespace AbstractLawFirmBusinessLogic.OfficePackage.HelperModels get; set; } = new(); - + public List ShopDocuments + { + get; + set; + } = new(); } } diff --git a/LawFirm/AbstractLawFirmBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs b/LawFirm/AbstractLawFirmBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs index 0d16f6f..5434a16 100644 --- a/LawFirm/AbstractLawFirmBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs +++ b/LawFirm/AbstractLawFirmBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs @@ -14,5 +14,6 @@ namespace AbstractLawFirmBusinessLogic.OfficePackage.HelperModels public DateTime DateFrom { get; set; } public DateTime DateTo { get; set; } public List Orders { get; set; } = new(); + public List DateOrders { get; set; } = new(); } } diff --git a/LawFirm/AbstractLawFirmBusinessLogic/OfficePackage/HelperModels/WordInfo.cs b/LawFirm/AbstractLawFirmBusinessLogic/OfficePackage/HelperModels/WordInfo.cs index f55eab7..23de53d 100644 --- a/LawFirm/AbstractLawFirmBusinessLogic/OfficePackage/HelperModels/WordInfo.cs +++ b/LawFirm/AbstractLawFirmBusinessLogic/OfficePackage/HelperModels/WordInfo.cs @@ -12,5 +12,6 @@ namespace AbstractLawFirmBusinessLogic.OfficePackage.HelperModels public string FileName { get; set; } = string.Empty; public string Title { get; set; } = string.Empty; public List Documents { get; set; } = new(); + public List Shops { get; set; } = new(); } } diff --git a/LawFirm/AbstractLawFirmBusinessLogic/OfficePackage/HelperModels/WordTable.cs b/LawFirm/AbstractLawFirmBusinessLogic/OfficePackage/HelperModels/WordTable.cs new file mode 100644 index 0000000..ab44f51 --- /dev/null +++ b/LawFirm/AbstractLawFirmBusinessLogic/OfficePackage/HelperModels/WordTable.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AbstractLawFirmBusinessLogic.OfficePackage.HelperModels +{ + public class WordTable + { + public List Headers { get; set; } = new(); + public List Texts { get; set; } = new(); + } +} diff --git a/LawFirm/AbstractLawFirmBusinessLogic/OfficePackage/Implements/SaveToWord.cs b/LawFirm/AbstractLawFirmBusinessLogic/OfficePackage/Implements/SaveToWord.cs index 7e8a991..1e39ada 100644 --- a/LawFirm/AbstractLawFirmBusinessLogic/OfficePackage/Implements/SaveToWord.cs +++ b/LawFirm/AbstractLawFirmBusinessLogic/OfficePackage/Implements/SaveToWord.cs @@ -126,6 +126,85 @@ namespace AbstractLawFirmBusinessLogic.OfficePackage.Implements _wordDocument.MainDocumentPart!.Document.Save(); _wordDocument.Dispose(); } + 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/LawFirm/AbstractLawFirmContracts/AbstractLawFirmContracts/BusinessLogicsContracts/IReportLogic.cs b/LawFirm/AbstractLawFirmContracts/AbstractLawFirmContracts/BusinessLogicsContracts/IReportLogic.cs index 8bb9747..18188f2 100644 --- a/LawFirm/AbstractLawFirmContracts/AbstractLawFirmContracts/BusinessLogicsContracts/IReportLogic.cs +++ b/LawFirm/AbstractLawFirmContracts/AbstractLawFirmContracts/BusinessLogicsContracts/IReportLogic.cs @@ -36,5 +36,10 @@ namespace AbstractLawFirmContracts.BusinessLogicsContracts /// /// void SaveOrdersToPdfFile(ReportBindingModel model); + List GetShopDocuments(); + List GetDateOrders(); + void SaveShopsToWordFile(ReportBindingModel model); + void SaveShopDocumentsToExcelFile(ReportBindingModel model); + void SaveDateOrdersToPdfFile(ReportBindingModel model); } } diff --git a/LawFirm/AbstractLawFirmContracts/AbstractLawFirmContracts/ViewModels/ReportDateOrdersViewModel.cs b/LawFirm/AbstractLawFirmContracts/AbstractLawFirmContracts/ViewModels/ReportDateOrdersViewModel.cs new file mode 100644 index 0000000..5a8c16d --- /dev/null +++ b/LawFirm/AbstractLawFirmContracts/AbstractLawFirmContracts/ViewModels/ReportDateOrdersViewModel.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AbstractLawFirmContracts.ViewModels +{ + public class ReportDateOrdersViewModel + { + public DateTime DateCreate { get; set; } + public int CountOrders { get; set; } + public double SumOrders { get; set; } + } +} diff --git a/LawFirm/AbstractLawFirmContracts/AbstractLawFirmContracts/ViewModels/ReportShopDocumentsViewModel.cs b/LawFirm/AbstractLawFirmContracts/AbstractLawFirmContracts/ViewModels/ReportShopDocumentsViewModel.cs new file mode 100644 index 0000000..380a709 --- /dev/null +++ b/LawFirm/AbstractLawFirmContracts/AbstractLawFirmContracts/ViewModels/ReportShopDocumentsViewModel.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AbstractLawFirmContracts.ViewModels +{ + public class ReportShopDocumentsViewModel + { + public string ShopName { get; set; } = string.Empty; + public int Count { get; set; } + public List> Documents { get; set; } = new(); + } +} diff --git a/LawFirm/LawFirmView/FormMain.Designer.cs b/LawFirm/LawFirmView/FormMain.Designer.cs index e3389b3..9ea8da7 100644 --- a/LawFirm/LawFirmView/FormMain.Designer.cs +++ b/LawFirm/LawFirmView/FormMain.Designer.cs @@ -45,6 +45,9 @@ this.buttonRef = new System.Windows.Forms.Button(); this.buttonSupplyShop = new System.Windows.Forms.Button(); this.buttonSellDocs = new System.Windows.Forms.Button(); + this.списокМагазиновToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.загруженностьМагазиновToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.списокЗаказовПоДатамToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.menuStrip1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); this.SuspendLayout(); @@ -96,7 +99,10 @@ this.отчётыToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.списокПакетовДокументовToolStripMenuItem, this.компонентыПоПакетамДокументовToolStripMenuItem, - this.списокЗаказовToolStripMenuItem}); + this.списокЗаказовToolStripMenuItem, + this.списокМагазиновToolStripMenuItem, + this.загруженностьМагазиновToolStripMenuItem, + this.списокЗаказовПоДатамToolStripMenuItem}); this.отчётыToolStripMenuItem.Name = "отчётыToolStripMenuItem"; this.отчётыToolStripMenuItem.Size = new System.Drawing.Size(60, 20); this.отчётыToolStripMenuItem.Text = "Отчёты"; @@ -201,6 +207,27 @@ this.buttonSellDocs.UseVisualStyleBackColor = true; this.buttonSellDocs.Click += new System.EventHandler(this.buttonSellDocs_Click); // + // списокМагазиновToolStripMenuItem + // + this.списокМагазиновToolStripMenuItem.Name = "списокМагазиновToolStripMenuItem"; + this.списокМагазиновToolStripMenuItem.Size = new System.Drawing.Size(278, 22); + this.списокМагазиновToolStripMenuItem.Text = "Список магазинов"; + this.списокМагазиновToolStripMenuItem.Click += new System.EventHandler(this.списокМагазиновToolStripMenuItem_Click); + // + // загруженностьМагазиновToolStripMenuItem + // + this.загруженностьМагазиновToolStripMenuItem.Name = "загруженностьМагазиновToolStripMenuItem"; + this.загруженностьМагазиновToolStripMenuItem.Size = new System.Drawing.Size(278, 22); + this.загруженностьМагазиновToolStripMenuItem.Text = "Загруженность магазинов"; + this.загруженностьМагазиновToolStripMenuItem.Click += new System.EventHandler(this.загруженностьМагазиновToolStripMenuItem_Click); + // + // списокЗаказовПоДатамToolStripMenuItem + // + this.списокЗаказовПоДатамToolStripMenuItem.Name = "списокЗаказовПоДатамToolStripMenuItem"; + this.списокЗаказовПоДатамToolStripMenuItem.Size = new System.Drawing.Size(278, 22); + this.списокЗаказовПоДатамToolStripMenuItem.Text = "Список заказов по датам"; + this.списокЗаказовПоДатамToolStripMenuItem.Click += new System.EventHandler(this.списокЗаказовПоДатамToolStripMenuItem_Click); + // // FormMain // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); @@ -239,12 +266,15 @@ private Button buttonOrderReady; private Button buttonIssuedOrder; private Button buttonRef; - private ToolStripMenuItem магазиныToolStripMenuItem; - private Button buttonSupplyShop; - private Button buttonSellDocs; private ToolStripMenuItem отчётыToolStripMenuItem; private ToolStripMenuItem списокПакетовДокументовToolStripMenuItem; private ToolStripMenuItem компонентыПоПакетамДокументовToolStripMenuItem; private ToolStripMenuItem списокЗаказовToolStripMenuItem; + private ToolStripMenuItem магазиныToolStripMenuItem; + private Button buttonSupplyShop; + private Button buttonSellDocs; + private ToolStripMenuItem списокМагазиновToolStripMenuItem; + private ToolStripMenuItem загруженностьМагазиновToolStripMenuItem; + private ToolStripMenuItem списокЗаказовПоДатамToolStripMenuItem; } } \ No newline at end of file diff --git a/LawFirm/LawFirmView/FormMain.cs b/LawFirm/LawFirmView/FormMain.cs index 2e4a1f9..1a0587d 100644 --- a/LawFirm/LawFirmView/FormMain.cs +++ b/LawFirm/LawFirmView/FormMain.cs @@ -239,5 +239,36 @@ namespace LawFirmView 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(FormReportShopDocuments)); + if (service is FormReportShopDocuments form) + { + form.ShowDialog(); + } + } + + private void списокЗаказовПоДатамToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormReportDateOrders)); + if (service is FormReportDateOrders form) + { + form.ShowDialog(); + } + } } } diff --git a/LawFirm/LawFirmView/FormMain.resx b/LawFirm/LawFirmView/FormMain.resx index 6d8238b..05252e7 100644 --- a/LawFirm/LawFirmView/FormMain.resx +++ b/LawFirm/LawFirmView/FormMain.resx @@ -61,6 +61,6 @@ 17, 17 - 51 + 25 \ No newline at end of file diff --git a/LawFirm/LawFirmView/FormReportDateOrders.Designer.cs b/LawFirm/LawFirmView/FormReportDateOrders.Designer.cs new file mode 100644 index 0000000..3d765c1 --- /dev/null +++ b/LawFirm/LawFirmView/FormReportDateOrders.Designer.cs @@ -0,0 +1,87 @@ +namespace LawFirmView +{ + partial class FormReportDateOrders + { + /// + /// 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.panel = new System.Windows.Forms.Panel(); + this.buttonSaveToPdf = new System.Windows.Forms.Button(); + this.buttonMake = new System.Windows.Forms.Button(); + this.panel.SuspendLayout(); + this.SuspendLayout(); + // + // panel + // + this.panel.Controls.Add(this.buttonSaveToPdf); + this.panel.Controls.Add(this.buttonMake); + this.panel.Dock = System.Windows.Forms.DockStyle.Top; + this.panel.Location = new System.Drawing.Point(0, 0); + this.panel.Name = "panel"; + this.panel.Size = new System.Drawing.Size(800, 51); + this.panel.TabIndex = 0; + // + // buttonSaveToPdf + // + this.buttonSaveToPdf.Location = new System.Drawing.Point(135, 12); + this.buttonSaveToPdf.Name = "buttonSaveToPdf"; + this.buttonSaveToPdf.Size = new System.Drawing.Size(75, 23); + this.buttonSaveToPdf.TabIndex = 1; + this.buttonSaveToPdf.Text = "В Pdf"; + this.buttonSaveToPdf.UseVisualStyleBackColor = true; + this.buttonSaveToPdf.Click += new System.EventHandler(this.buttonSaveToPdf_Click); + // + // buttonMake + // + this.buttonMake.Location = new System.Drawing.Point(12, 12); + this.buttonMake.Name = "buttonMake"; + this.buttonMake.Size = new System.Drawing.Size(104, 23); + this.buttonMake.TabIndex = 0; + this.buttonMake.Text = "Сформировать"; + this.buttonMake.UseVisualStyleBackColor = true; + this.buttonMake.Click += new System.EventHandler(this.buttonMake_Click); + // + // FormReportDateOrders + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(800, 422); + this.Controls.Add(this.panel); + this.Name = "FormReportDateOrders"; + this.Text = "FormReportDateOrders"; + this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.FormReportDateOrders_FormClosed); + this.panel.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + + private Panel panel; + private Button buttonSaveToPdf; + private Button buttonMake; + } +} \ No newline at end of file diff --git a/LawFirm/LawFirmView/FormReportDateOrders.cs b/LawFirm/LawFirmView/FormReportDateOrders.cs new file mode 100644 index 0000000..658b59d --- /dev/null +++ b/LawFirm/LawFirmView/FormReportDateOrders.cs @@ -0,0 +1,84 @@ +using AbstractLawFirmContracts.BindingModels; +using AbstractLawFirmContracts.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 LawFirmView +{ + public partial class FormReportDateOrders : Form + { + private readonly ReportViewer reportViewer; + private readonly ILogger _logger; + private readonly IReportLogic _logic; + private readonly FileStream _fileStream; + public FormReportDateOrders(ILogger logger, IReportLogic reportLogic) + { + InitializeComponent(); + _logger = logger; + _logic = reportLogic; + reportViewer = new ReportViewer + { + Dock = DockStyle.Fill + }; + _fileStream = new FileStream("ReportOrdersByDate.rdlc", FileMode.Open); + reportViewer.LocalReport.LoadReportDefinition(_fileStream); + Controls.Clear(); + Controls.Add(reportViewer); + Controls.Add(panel); + } + + private void buttonMake_Click(object sender, EventArgs e) + { + try + { + var dataSource = _logic.GetDateOrders(); + var source = new ReportDataSource("DataSetOrders", dataSource); + reportViewer.LocalReport.DataSources.Clear(); + reportViewer.LocalReport.DataSources.Add(source); + reportViewer.RefreshReport(); + _logger.LogInformation("Загрузка списка заказов на весь период по датам"); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки списка заказов на период"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void buttonSaveToPdf_Click(object sender, EventArgs e) + { + using var dialog = new SaveFileDialog { Filter = "pdf|*.pdf" }; + if (dialog.ShowDialog() == DialogResult.OK) + { + try + { + _logic.SaveDateOrdersToPdfFile(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 FormReportDateOrders_FormClosed(object sender, FormClosedEventArgs e) + { + _fileStream.Close(); + } + } +} diff --git a/LawFirm/LawFirmView/FormReportDateOrders.resx b/LawFirm/LawFirmView/FormReportDateOrders.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/LawFirm/LawFirmView/FormReportDateOrders.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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/LawFirm/LawFirmView/FormReportShopDocuments.Designer.cs b/LawFirm/LawFirmView/FormReportShopDocuments.Designer.cs new file mode 100644 index 0000000..959f7bc --- /dev/null +++ b/LawFirm/LawFirmView/FormReportShopDocuments.Designer.cs @@ -0,0 +1,101 @@ +namespace LawFirmView +{ + partial class FormReportShopDocuments + { + /// + /// 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.Column1 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Column2 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Column3 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.buttonSaveToExcel = new System.Windows.Forms.Button(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); + this.SuspendLayout(); + // + // dataGridView + // + this.dataGridView.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; + this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.Column1, + this.Column2, + this.Column3}); + this.dataGridView.Location = new System.Drawing.Point(12, 58); + this.dataGridView.Name = "dataGridView"; + this.dataGridView.RowTemplate.Height = 25; + this.dataGridView.Size = new System.Drawing.Size(454, 326); + this.dataGridView.TabIndex = 0; + // + // Column1 + // + this.Column1.HeaderText = "Магазин"; + this.Column1.Name = "Column1"; + // + // Column2 + // + this.Column2.HeaderText = "Пакет документов"; + this.Column2.Name = "Column2"; + // + // Column3 + // + this.Column3.HeaderText = "Количество"; + this.Column3.Name = "Column3"; + // + // buttonSaveToExcel + // + this.buttonSaveToExcel.Location = new System.Drawing.Point(12, 12); + this.buttonSaveToExcel.Name = "buttonSaveToExcel"; + this.buttonSaveToExcel.Size = new System.Drawing.Size(137, 23); + this.buttonSaveToExcel.TabIndex = 1; + this.buttonSaveToExcel.Text = "Сохранить в Excel"; + this.buttonSaveToExcel.UseVisualStyleBackColor = true; + this.buttonSaveToExcel.Click += new System.EventHandler(this.buttonSaveToExcel_Click); + // + // FormReportShopDocuments + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(513, 396); + this.Controls.Add(this.buttonSaveToExcel); + this.Controls.Add(this.dataGridView); + this.Name = "FormReportShopDocuments"; + this.Text = "FormReportShopDocuments"; + this.Load += new System.EventHandler(this.FormReportShopDocuments_Load); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private DataGridView dataGridView; + private DataGridViewTextBoxColumn Column1; + private DataGridViewTextBoxColumn Column2; + private DataGridViewTextBoxColumn Column3; + private Button buttonSaveToExcel; + } +} \ No newline at end of file diff --git a/LawFirm/LawFirmView/FormReportShopDocuments.cs b/LawFirm/LawFirmView/FormReportShopDocuments.cs new file mode 100644 index 0000000..a25a2f3 --- /dev/null +++ b/LawFirm/LawFirmView/FormReportShopDocuments.cs @@ -0,0 +1,80 @@ +using AbstractLawFirmContracts.BindingModels; +using AbstractLawFirmContracts.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 LawFirmView +{ + public partial class FormReportShopDocuments : Form + { + private readonly ILogger _logger; + private readonly IReportLogic _logic; + public FormReportShopDocuments(ILogger logger, IReportLogic reportLogic) + { + InitializeComponent(); + _logger = logger; + _logic = reportLogic; + } + + private void FormReportShopDocuments_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()); + } + } + _logger.LogInformation("Загрузка списка магазинов с пакетами документов в них"); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки списка магазинов с пакетами документов в них"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + 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); + } + } + } + } +} diff --git a/LawFirm/LawFirmView/FormReportShopDocuments.resx b/LawFirm/LawFirmView/FormReportShopDocuments.resx new file mode 100644 index 0000000..a9dc853 --- /dev/null +++ b/LawFirm/LawFirmView/FormReportShopDocuments.resx @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + True + + + True + + + True + + + True + + + True + + + True + + \ No newline at end of file diff --git a/LawFirm/LawFirmView/LawFirmView.csproj b/LawFirm/LawFirmView/LawFirmView.csproj index 4c76643..2ab1801 100644 --- a/LawFirm/LawFirmView/LawFirmView.csproj +++ b/LawFirm/LawFirmView/LawFirmView.csproj @@ -29,6 +29,9 @@ Always + + Always + \ No newline at end of file diff --git a/LawFirm/LawFirmView/Program.cs b/LawFirm/LawFirmView/Program.cs index bb8e891..790f036 100644 --- a/LawFirm/LawFirmView/Program.cs +++ b/LawFirm/LawFirmView/Program.cs @@ -61,6 +61,8 @@ namespace LawFirmView services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); + services.AddTransient(); } } diff --git a/LawFirm/LawFirmView/ReportOrdersByDate.rdlc b/LawFirm/LawFirmView/ReportOrdersByDate.rdlc new file mode 100644 index 0000000..35fb6a2 --- /dev/null +++ b/LawFirm/LawFirmView/ReportOrdersByDate.rdlc @@ -0,0 +1,424 @@ + + + 0 + + + + System.Data.DataSet + /* Local Connection */ + + 10791c83-cee8-4a38-bbd0-245fc17cefb3 + + + + + + AbstractLawFirmContractsViewModels + /* Local Query */ + + + + DateCreate + System.DateTime + + + CountOrders + System.Decimal + + + SumOrders + System.Double + + + + AbstractLawFirmContracts.ViewModels + ReportDateOrdersViewModel + AbstractLawFirmContracts.ViewModels.ReportDateOrdersViewModel, LawFirmContracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + + + + + + + + + true + true + + + + + Заказы + + + + + + + 1cm + 21cm + + + Middle + 2pt + 2pt + 2pt + 2pt + + + + + + + 3cm + + + 3cm + + + 7cm + + + + + 0.6cm + + + + + true + true + + + + + Дата + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Количество + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Сумма + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + 0.6cm + + + + + true + true + + + + + =Fields!DateCreate.Value + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!CountOrders.Value + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!SumOrders.Value + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + + + + + + + + + + + + After + + + + + + + DataSetOrders + 2.48391cm + 0.55245cm + 1.2cm + 13cm + 1 + + + + + + true + true + + + + + Всего: + + + + + + + 4cm + 8.55245cm + 0.6cm + 2.5cm + 2 + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + =Sum(Fields!SumOrders.Value, "DataSetOrders") + + + + + + + 4cm + 11.05245cm + 0.6cm + 2.5cm + 3 + + + 2pt + 2pt + 2pt + 2pt + + + + 5.72875cm +