From 34b0c6502eb0313641178ee4627bcbb2f463abc5 Mon Sep 17 00:00:00 2001 From: Danil Markov Date: Wed, 3 May 2023 00:49:14 +0400 Subject: [PATCH] =?UTF-8?q?=D0=BF=D0=BE=D0=B9=D0=B4=D0=B5=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BusinessLogics/ReportLogic.cs | 85 +++- .../OfficePackage/AbstractSaveToExcel.cs | 80 +++- .../OfficePackage/AbstractSaveToPdf.cs | 48 +- .../OfficePackage/AbstractSaveToWord.cs | 63 ++- .../OfficePackage/HelperModels/ExcelInfo.cs | 10 +- .../OfficePackage/HelperModels/PdfInfo.cs | 3 +- .../OfficePackage/HelperModels/WordInfo.cs | 5 +- .../OfficePackage/Implements/SaveToWord.cs | 54 ++- .../BusinessLogicsContracts/IReportLogic.cs | 39 +- .../ReportOrdersGroupedByDateViewModel.cs | 15 + .../ViewModels/ReportShopDocumentViewModel.cs | 17 + .../Implements/OrderStorage.cs | 16 +- .../Implements/OrderStorage.cs | 17 +- .../Implements/OrderStorage.cs | 15 +- .../LawFirmView/FormDocumentBlank.Designer.cs | 2 +- LawFirm/LawFirmView/FormMain.Designer.cs | 438 ++++++++++-------- LawFirm/LawFirmView/FormMain.cs | 164 ++++--- .../FormReportGroupedOrders.Designer.cs | 86 ++++ .../LawFirmView/FormReportGroupedOrders.cs | 81 ++++ .../LawFirmView/FormReportGroupedOrders.resx | 60 +++ .../FormReportShopDocuments.Designer.cs | 108 +++++ .../LawFirmView/FormReportShopDocuments.cs | 79 ++++ .../LawFirmView/FormReportShopDocuments.resx | 78 ++++ LawFirm/LawFirmView/LawFirmView.csproj | 3 + LawFirm/LawFirmView/Program.cs | 7 +- LawFirm/LawFirmView/ReportGroupedOrders.rdlc | 411 ++++++++++++++++ 26 files changed, 1664 insertions(+), 320 deletions(-) create mode 100644 LawFirm/LawFirmContracts/ViewModels/ReportOrdersGroupedByDateViewModel.cs create mode 100644 LawFirm/LawFirmContracts/ViewModels/ReportShopDocumentViewModel.cs create mode 100644 LawFirm/LawFirmView/FormReportGroupedOrders.Designer.cs create mode 100644 LawFirm/LawFirmView/FormReportGroupedOrders.cs create mode 100644 LawFirm/LawFirmView/FormReportGroupedOrders.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/ReportGroupedOrders.rdlc diff --git a/LawFirm/LawFirmBusinessLogic/BusinessLogics/ReportLogic.cs b/LawFirm/LawFirmBusinessLogic/BusinessLogics/ReportLogic.cs index 772e9b1..537f2f7 100644 --- a/LawFirm/LawFirmBusinessLogic/BusinessLogics/ReportLogic.cs +++ b/LawFirm/LawFirmBusinessLogic/BusinessLogics/ReportLogic.cs @@ -13,13 +13,18 @@ namespace LawFirmBusinessLogic.BusinessLogics private readonly IBlankStorage _blankStorage; 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, IBlankStorage - blankStorage, IOrderStorage orderStorage, - AbstractSaveToExcel saveToExcel, AbstractSaveToWord saveToWord, - AbstractSaveToPdf saveToPdf) + public ReportLogic(IDocumentStorage documentStorage, + IBlankStorage blankStorage, + IOrderStorage orderStorage, + IShopStorage shopStorage, + AbstractSaveToExcel saveToExcel, + AbstractSaveToWord saveToWord, + AbstractSaveToPdf saveToPdf) { _documentStorage = documentStorage; _blankStorage = blankStorage; @@ -27,6 +32,7 @@ namespace LawFirmBusinessLogic.BusinessLogics _saveToExcel = saveToExcel; _saveToWord = saveToWord; _saveToPdf = saveToPdf; + _shopStorage = shopStorage; } /// /// Получение списка компонент с указанием, в каких изделиях используются @@ -89,7 +95,7 @@ namespace LawFirmBusinessLogic.BusinessLogics { FileName = model.FileName, Title = "Список бланков", - Blanks = _blankStorage.GetFullList() + Documents = _documentStorage.GetFullList() }); } /// @@ -120,5 +126,72 @@ namespace LawFirmBusinessLogic.BusinessLogics Orders = GetOrders(model) }); } - } + + public List GetShopDocuments() + { + var shops = _shopStorage.GetFullList(); + + var list = new List(); + + foreach (var shop in shops) + { + var record = new ReportShopDocumentViewModel + { + ShopName = shop.ShopName, + Documents = new List<(string, int)>(), + TotalCount = 0 + }; + foreach (var document in shop.ShopDocuments) + { + record.Documents.Add(new(document.Value.Item1.DocumentName, shop.ShopDocuments[document.Value.Item1.Id].Item2)); + record.TotalCount += shop.ShopDocuments[document.Value.Item1.Id].Item2; + } + + list.Add(record); + } + + return list; + } + public void SaveShopDocumentToExcelFile(ReportBindingModel model) + { + _saveToExcel.CreateShopReport(new ExcelInfo + { + FileName = model.FileName, + Title = "Заполненность магазинов", + ShopDocuments = GetShopDocuments() + }); + } + + public List GetGroupedByDateOrders() + { + return _orderStorage.GetFullList().GroupBy(x => x.DateCreate.Date) + .Select(x => new ReportOrdersGroupedByDateViewModel + { + Date = x.Key, + Count = x.Count(), + Sum = x.Sum(y => y.Sum) + }) + .ToList(); + } + + public void SaveGroupedByDateOrders(ReportBindingModel model) + { + _saveToPdf.CreateDocWithGroupedOrders(new PdfInfo + { + FileName = model.FileName, + Title = "Заказы по дате", + GroupedOrders = GetGroupedByDateOrders(), + }); + } + + public void SaveShopsToWordFile(ReportBindingModel model) + { + _saveToWord.CreateShopsTable(new WordInfo + { + FileName = model.FileName, + Title = "Список магазинов", + Shops = _shopStorage.GetFullList() + }); + } + } } diff --git a/LawFirm/LawFirmBusinessLogic/OfficePackage/AbstractSaveToExcel.cs b/LawFirm/LawFirmBusinessLogic/OfficePackage/AbstractSaveToExcel.cs index 0b5443c..2a94ed8 100644 --- a/LawFirm/LawFirmBusinessLogic/OfficePackage/AbstractSaveToExcel.cs +++ b/LawFirm/LawFirmBusinessLogic/OfficePackage/AbstractSaveToExcel.cs @@ -71,11 +71,81 @@ namespace LawFirmBusinessLogic.OfficePackage } SaveExcel(info); } - /// - /// Создание excel-файла - /// - /// - protected abstract void CreateExcel(ExcelInfo 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 ss in info.ShopDocuments) + { + InsertCellInWorksheet(new ExcelCellParameters + { + ColumnName = "A", + RowIndex = rowIndex, + Text = ss.ShopName, + StyleInfo = ExcelStyleInfoType.Text + }); + rowIndex++; + + foreach (var (Document, Count) in ss.Documents) + { + InsertCellInWorksheet(new ExcelCellParameters + { + ColumnName = "B", + RowIndex = rowIndex, + Text = Document, + StyleInfo = ExcelStyleInfoType.TextWithBroder + }); + + InsertCellInWorksheet(new ExcelCellParameters + { + ColumnName = "C", + RowIndex = rowIndex, + Text = Count.ToString(), + StyleInfo = ExcelStyleInfoType.TextWithBroder + }); + + rowIndex++; + } + + InsertCellInWorksheet(new ExcelCellParameters + { + ColumnName = "A", + RowIndex = rowIndex, + Text = "Итого", + StyleInfo = ExcelStyleInfoType.Text + }); + InsertCellInWorksheet(new ExcelCellParameters + { + ColumnName = "C", + RowIndex = rowIndex, + Text = ss.TotalCount.ToString(), + StyleInfo = ExcelStyleInfoType.Text + }); + rowIndex++; + } + + SaveExcel(info); + } + /// + /// Создание excel-файла + /// + /// + protected abstract void CreateExcel(ExcelInfo info); /// /// Добавляем новую ячейку в лист /// diff --git a/LawFirm/LawFirmBusinessLogic/OfficePackage/AbstractSaveToPdf.cs b/LawFirm/LawFirmBusinessLogic/OfficePackage/AbstractSaveToPdf.cs index fe9c684..79f644a 100644 --- a/LawFirm/LawFirmBusinessLogic/OfficePackage/AbstractSaveToPdf.cs +++ b/LawFirm/LawFirmBusinessLogic/OfficePackage/AbstractSaveToPdf.cs @@ -3,6 +3,7 @@ using LawFirmBusinessLogic.OfficePackage.HelperEnums; using LawFirmBusinessLogic.OfficePackage.HelperModels; using System.Collections.Generic; using System.Linq; +using System.Text; namespace LawFirmBusinessLogic.OfficePackage { @@ -48,11 +49,48 @@ namespace LawFirmBusinessLogic.OfficePackage }); SavePdf(info); } - /// - /// Создание doc-файла - /// - /// - protected abstract void CreatePdf(PdfInfo info); + public void CreateDocWithGroupedOrders(PdfInfo info) + { + CreatePdf(info); + CreateParagraph(new PdfParagraph + { + Text = info.Title, + Style = "NormalTitle", + ParagraphAlignment = PdfParagraphAlignmentType.Center + }); + + CreateTable(new List { "3cm", "3cm", "3cm" }); + + CreateRow(new PdfRowParameters + { + Texts = new List { "Дата", "Количество", "Сумма" }, + Style = "NormalTitle", + ParagraphAlignment = PdfParagraphAlignmentType.Center + }); + + foreach (var order in info.GroupedOrders) + { + CreateRow(new PdfRowParameters + { + Texts = new List { order.Date.ToShortDateString(), order.Count.ToString(), order.Sum.ToString() }, + Style = "Normal", + ParagraphAlignment = PdfParagraphAlignmentType.Left + }); + } + CreateParagraph(new PdfParagraph + { + Text = $"Итого: {info.GroupedOrders.Sum(x => x.Sum)}\t", + Style = "Normal", + ParagraphAlignment = PdfParagraphAlignmentType.Rigth + }); + + SavePdf(info); + } + /// + /// Создание doc-файла + /// + /// + protected abstract void CreatePdf(PdfInfo info); /// /// Создание параграфа с текстом /// diff --git a/LawFirm/LawFirmBusinessLogic/OfficePackage/AbstractSaveToWord.cs b/LawFirm/LawFirmBusinessLogic/OfficePackage/AbstractSaveToWord.cs index 49afb71..fb7a8f5 100644 --- a/LawFirm/LawFirmBusinessLogic/OfficePackage/AbstractSaveToWord.cs +++ b/LawFirm/LawFirmBusinessLogic/OfficePackage/AbstractSaveToWord.cs @@ -18,12 +18,12 @@ namespace LawFirmBusinessLogic.OfficePackage JustificationType = WordJustificationType.Center } }); - foreach (var blank in info.Blanks) + foreach (var blank in info.Documents) { CreateParagraph(new WordParagraph { Texts = new List<(string, WordTextProperties)> { - (blank.BlankName + " - ", new WordTextProperties { Size = "24", Bold=true}), + (blank.DocumentName + " - ", new WordTextProperties { Size = "24", Bold=true}), (blank.Price.ToString(), new WordTextProperties { Size = "24", }) }, TextProperties = new WordTextProperties @@ -35,17 +35,54 @@ namespace LawFirmBusinessLogic.OfficePackage } SaveWord(info); } - /// - /// Создание doc-файла - /// - /// - protected abstract void CreateWord(WordInfo info); - /// - /// Создание абзаца с текстом - /// - /// - /// - protected abstract void CreateParagraph(WordParagraph paragraph); + public void CreateShopsTable(WordInfo info) + { + CreateWord(info); + CreateParagraph(new WordParagraph + { + Texts = new List<(string, WordTextProperties)> { (info.Title, new WordTextProperties { Bold = true, Size = "24" }) }, + TextProperties = new WordTextProperties + { + Size = "24", + JustificationType = WordJustificationType.Center + } + }); + List<(string, WordTextProperties)> shopsInfo = new() + { + { ("Название", new WordTextProperties { Bold = true, Size = "24" }) }, + { ("Адрес", new WordTextProperties { Bold = true, Size = "24" }) }, + { ("Дата открытия", new WordTextProperties { Bold = true, Size = "24" }) } + }; + foreach (var shop in info.Shops) + { + shopsInfo.Add((shop.ShopName, new WordTextProperties { Size = "20" })); + shopsInfo.Add((shop.Address, new WordTextProperties { Size = "20" })); + shopsInfo.Add((shop.DateOpen.ToString(), new WordTextProperties { Size = "20" })); + } + CreateTable(new WordParagraph + { + Texts = shopsInfo, + TextProperties = new WordTextProperties + { + Size = "24", + JustificationType = WordJustificationType.Center + } + }, 3); + SaveWord(info); + + } + /// + /// Создание doc-файла + /// + /// + protected abstract void CreateWord(WordInfo info); + protected abstract void CreateTable(WordParagraph paragraph, int columnCount); + /// + /// Создание абзаца с текстом + /// + /// + /// + protected abstract void CreateParagraph(WordParagraph paragraph); /// /// Сохранение файла /// diff --git a/LawFirm/LawFirmBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs b/LawFirm/LawFirmBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs index 36f00bc..ffd6610 100644 --- a/LawFirm/LawFirmBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs +++ b/LawFirm/LawFirmBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs @@ -6,11 +6,9 @@ namespace LawFirmBusinessLogic.OfficePackage.HelperModels { public string FileName { get; set; } = string.Empty; public string Title { get; set; } = string.Empty; - public List DocumentBlanks - { - get; - set; - } = new(); - } + + public List DocumentBlanks { get; set; } = new(); + public List ShopDocuments { get; set; } = new(); + } } diff --git a/LawFirm/LawFirmBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs b/LawFirm/LawFirmBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs index 8d442b1..602ace5 100644 --- a/LawFirm/LawFirmBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs +++ b/LawFirm/LawFirmBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs @@ -9,5 +9,6 @@ namespace LawFirmBusinessLogic.OfficePackage.HelperModels public DateTime DateFrom { get; set; } public DateTime DateTo { get; set; } public List Orders { get; set; } = new(); - } + public List GroupedOrders { get; set; } = new(); + } } \ No newline at end of file diff --git a/LawFirm/LawFirmBusinessLogic/OfficePackage/HelperModels/WordInfo.cs b/LawFirm/LawFirmBusinessLogic/OfficePackage/HelperModels/WordInfo.cs index c75881d..f6efb4a 100644 --- a/LawFirm/LawFirmBusinessLogic/OfficePackage/HelperModels/WordInfo.cs +++ b/LawFirm/LawFirmBusinessLogic/OfficePackage/HelperModels/WordInfo.cs @@ -6,6 +6,7 @@ namespace LawFirmBusinessLogic.OfficePackage.HelperModels { public string FileName { get; set; } = string.Empty; public string Title { get; set; } = string.Empty; - public List Blanks { get; set; } = new(); - } + public List Documents { get; set; } = new(); + public List Shops { get; set; } = new(); + } } diff --git a/LawFirm/LawFirmBusinessLogic/OfficePackage/Implements/SaveToWord.cs b/LawFirm/LawFirmBusinessLogic/OfficePackage/Implements/SaveToWord.cs index c309228..0bbb248 100644 --- a/LawFirm/LawFirmBusinessLogic/OfficePackage/Implements/SaveToWord.cs +++ b/LawFirm/LawFirmBusinessLogic/OfficePackage/Implements/SaveToWord.cs @@ -72,7 +72,59 @@ namespace LawFirmBusinessLogic.OfficePackage.Implements properties.AppendChild(paragraphMarkRunProperties); return properties; } - protected override void CreateWord(WordInfo info) + protected override void CreateTable(WordParagraph paragraph, int columnCount) + { + if (_docBody == null || paragraph == null) + { + return; + } + Table table = new(); + TableProperties properties = new(); + properties.AppendChild(new TableLayout { Type = TableLayoutValues.Fixed }); + properties.AppendChild(new TableBorders + ( + new TopBorder() { Val = new EnumValue(BorderValues.Single), Size = 4 }, + new LeftBorder() { Val = new EnumValue(BorderValues.Single), Size = 4 }, + new RightBorder() { Val = new EnumValue(BorderValues.Single), Size = 4 }, + new BottomBorder() { Val = new EnumValue(BorderValues.Single), Size = 4 }, + new InsideHorizontalBorder() { Val = new EnumValue(BorderValues.Single), Size = 4 }, + new InsideVerticalBorder() { Val = new EnumValue(BorderValues.Single), Size = 4 } + )); + properties.AppendChild(new TableWidth { Type = TableWidthUnitValues.Auto }); + table.AppendChild(properties); + TableGrid tableGrid = new(); + for (int j = 0; j < columnCount; ++j) + { + tableGrid.AppendChild(new GridColumn() { Width = "3400" }); + } + table.AppendChild(tableGrid); + for (int i = 0; i < paragraph.Texts.Count; ++i) + { + TableRow tableRow = new(); + for (int j = 0; j < columnCount; ++j) + { + var tableParagraph = new Paragraph(); + tableParagraph.AppendChild(CreateParagraphProperties(paragraph.TextProperties)); + var tableRun = new Run(); + var runProperties = new RunProperties(); + runProperties.AppendChild(new FontSize { Val = paragraph.Texts[i + j].Item2.Size }); + if (paragraph.Texts[i + j].Item2.Bold) + { + runProperties.AppendChild(new Bold()); + } + tableRun.AppendChild(runProperties); + tableRun.AppendChild(new Text { Text = paragraph.Texts[i + j].Item1, Space = SpaceProcessingModeValues.Preserve }); + tableParagraph.AppendChild(tableRun); + TableCell cell = new(); + cell.AppendChild(tableParagraph); + tableRow.AppendChild(cell); + } + i += columnCount - 1; + table.AppendChild(tableRow); + } + _docBody.AppendChild(table); + } + protected override void CreateWord(WordInfo info) { _wordDocument = WordprocessingDocument.Create(info.FileName, WordprocessingDocumentType.Document); diff --git a/LawFirm/LawFirmContracts/BusinessLogicsContracts/IReportLogic.cs b/LawFirm/LawFirmContracts/BusinessLogicsContracts/IReportLogic.cs index d285ec6..296e1a1 100644 --- a/LawFirm/LawFirmContracts/BusinessLogicsContracts/IReportLogic.cs +++ b/LawFirm/LawFirmContracts/BusinessLogicsContracts/IReportLogic.cs @@ -11,26 +11,31 @@ namespace LawFirmContracts.BusinessLogicsContracts /// /// List GetDocumentBlank(); - /// - /// Получение списка заказов за определенный период - /// - /// - /// - List GetOrders(ReportBindingModel model); + List GetShopDocuments(); + List GetGroupedByDateOrders(); + /// + /// Получение списка заказов за определенный период + /// + /// + /// + List GetOrders(ReportBindingModel model); /// /// Сохранение компонент в файл-Word /// /// void SaveBlanksToWordFile(ReportBindingModel model); - /// - /// Сохранение компонент с указаеним продуктов в файл-Excel - /// - /// - void SaveDocumentBlankToExcelFile(ReportBindingModel model); - /// - /// Сохранение заказов в файл-Pdf - /// - /// - void SaveOrdersToPdfFile(ReportBindingModel model); - } + void SaveShopsToWordFile(ReportBindingModel model); + /// + /// Сохранение компонент с указаеним продуктов в файл-Excel + /// + /// + void SaveDocumentBlankToExcelFile(ReportBindingModel model); + void SaveShopDocumentToExcelFile(ReportBindingModel model); + /// + /// Сохранение заказов в файл-Pdf + /// + /// + void SaveOrdersToPdfFile(ReportBindingModel model); + void SaveGroupedByDateOrders(ReportBindingModel model); + } } diff --git a/LawFirm/LawFirmContracts/ViewModels/ReportOrdersGroupedByDateViewModel.cs b/LawFirm/LawFirmContracts/ViewModels/ReportOrdersGroupedByDateViewModel.cs new file mode 100644 index 0000000..2079260 --- /dev/null +++ b/LawFirm/LawFirmContracts/ViewModels/ReportOrdersGroupedByDateViewModel.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace LawFirmContracts.ViewModels +{ + public class ReportOrdersGroupedByDateViewModel + { + public DateTime Date { get; set; } + public int Count { get; set; } + public double Sum { get; set; } + } +} diff --git a/LawFirm/LawFirmContracts/ViewModels/ReportShopDocumentViewModel.cs b/LawFirm/LawFirmContracts/ViewModels/ReportShopDocumentViewModel.cs new file mode 100644 index 0000000..cc6e2ee --- /dev/null +++ b/LawFirm/LawFirmContracts/ViewModels/ReportShopDocumentViewModel.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace LawFirmContracts.ViewModels +{ + public class ReportShopDocumentViewModel + { + public string ShopName { get; set; } = string.Empty; + + public int TotalCount { get; set; } + + public List<(string Document, int Count)> Documents { get; set; } = new(); + } +} diff --git a/LawFirm/LawFirmDatabaseImplement/Implements/OrderStorage.cs b/LawFirm/LawFirmDatabaseImplement/Implements/OrderStorage.cs index 6b83e90..5497e2f 100644 --- a/LawFirm/LawFirmDatabaseImplement/Implements/OrderStorage.cs +++ b/LawFirm/LawFirmDatabaseImplement/Implements/OrderStorage.cs @@ -36,9 +36,10 @@ namespace LawFirmDatabaseImplement.Implements using var context = new LawFirmDatabase(); - return GetViewModel(context.Orders + return context.Orders .Include(x => x.Document) - .FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))); + .FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id) + ?.GetViewModel; } public List GetFilteredList(OrderSearchModel model) @@ -49,8 +50,15 @@ namespace LawFirmDatabaseImplement.Implements } using var context = new LawFirmDatabase(); - - return context.Orders + if (model.DateFrom.HasValue) + { + return context.Orders + .Include(x => x.Document) + .Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo) + .Select(x => x.GetViewModel) + .ToList(); + } + return context.Orders .Include(x => x.Document) .Where(x => x.Id == model.Id) .Select(x => GetViewModel(x)) diff --git a/LawFirm/LawFirmFileImplement/Implements/OrderStorage.cs b/LawFirm/LawFirmFileImplement/Implements/OrderStorage.cs index 5b5049f..a83a12e 100644 --- a/LawFirm/LawFirmFileImplement/Implements/OrderStorage.cs +++ b/LawFirm/LawFirmFileImplement/Implements/OrderStorage.cs @@ -19,11 +19,22 @@ namespace LawFirmFileImplement.Implements } public List GetFilteredList(OrderSearchModel model) { - if (!model.Id.HasValue) - { + if(!model.Id.HasValue && !model.DateFrom.HasValue) + + { return new(); } - return source.Orders.Where(x => x.Id.Equals(model.Id) || model.DateFrom <= model.DateFrom && model.DateFrom <= model.DateTo).Select(x => GetViewModel(x)).ToList(); + if (model.DateFrom.HasValue) + { + return source.Orders + .Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo) + .Select(x => x.GetViewModel) + .ToList(); + } + return source.Orders + .Where(x => x.Id.Equals(model.Id)) + .Select(x => GetViewModel(x)) + .ToList(); } public OrderViewModel? GetElement(OrderSearchModel model) { diff --git a/LawFirm/LawFirmListImplement/Implements/OrderStorage.cs b/LawFirm/LawFirmListImplement/Implements/OrderStorage.cs index 39a3c7a..6e3f668 100644 --- a/LawFirm/LawFirmListImplement/Implements/OrderStorage.cs +++ b/LawFirm/LawFirmListImplement/Implements/OrderStorage.cs @@ -29,9 +29,20 @@ namespace LawFirmListImplement.Implements { return result; } - foreach (var order in _source.Orders) + if (model.DateFrom.HasValue) + { + foreach (var order in _source.Orders) + { + if (order.DateCreate >= model.DateFrom && order.DateCreate <= model.DateTo) + { + result.Add(GetViewModel(order)); + } + } + return result; + } + foreach (var order in _source.Orders) { - if (order.Id == model.Id || model.DateFrom <= order.DateCreate && order.DateCreate <= model.DateTo) + if (order.Id == model.Id) { result.Add(GetViewModel(order)); } diff --git a/LawFirm/LawFirmView/FormDocumentBlank.Designer.cs b/LawFirm/LawFirmView/FormDocumentBlank.Designer.cs index dcbc492..011588d 100644 --- a/LawFirm/LawFirmView/FormDocumentBlank.Designer.cs +++ b/LawFirm/LawFirmView/FormDocumentBlank.Designer.cs @@ -4,7 +4,7 @@ { /// /// Required designer variable. - /// + /// private System.ComponentModel.IContainer components = null; /// diff --git a/LawFirm/LawFirmView/FormMain.Designer.cs b/LawFirm/LawFirmView/FormMain.Designer.cs index 9e05242..4eb1204 100644 --- a/LawFirm/LawFirmView/FormMain.Designer.cs +++ b/LawFirm/LawFirmView/FormMain.Designer.cs @@ -28,195 +28,271 @@ /// private void InitializeComponent() { - this.menuStrip1 = new System.Windows.Forms.MenuStrip(); - 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.компонентыПоИзделиямToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.списокЗаказовToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.dataGridView = new System.Windows.Forms.DataGridView(); - this.buttonCreateOrder = new System.Windows.Forms.Button(); - this.buttonTakeOrderInWork = new System.Windows.Forms.Button(); - this.buttonOrderReady = new System.Windows.Forms.Button(); - this.buttonIssuedOrder = new System.Windows.Forms.Button(); - this.buttonUpdate = new System.Windows.Forms.Button(); - this.menuStrip1.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); - this.SuspendLayout(); - // - // menuStrip1 - // - this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.справочникиToolStripMenuItem, + this.ButtonCreateOrder = new System.Windows.Forms.Button(); + this.ButtonTakeOrderInWork = new System.Windows.Forms.Button(); + this.ButtonOrderReady = new System.Windows.Forms.Button(); + this.ButtonIssuedOrder = new System.Windows.Forms.Button(); + this.ButtonRef = new System.Windows.Forms.Button(); + this.menuStrip1 = new System.Windows.Forms.MenuStrip(); + 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.DocumentsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.documentsBlanksToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.ordersToolStripMenuItem = 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.dataGridView = new System.Windows.Forms.DataGridView(); + this.ButtonAddDocument = new System.Windows.Forms.Button(); + this.ButtonSellDocument = new System.Windows.Forms.Button(); + this.menuStrip1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); + this.SuspendLayout(); + // + // ButtonCreateOrder + // + this.ButtonCreateOrder.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.ButtonCreateOrder.Location = new System.Drawing.Point(841, 44); + this.ButtonCreateOrder.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.ButtonCreateOrder.Name = "ButtonCreateOrder"; + this.ButtonCreateOrder.Size = new System.Drawing.Size(164, 22); + this.ButtonCreateOrder.TabIndex = 0; + this.ButtonCreateOrder.Text = "Создать заказ"; + this.ButtonCreateOrder.UseVisualStyleBackColor = true; + this.ButtonCreateOrder.Click += new System.EventHandler(this.ButtonCreateOrder_Click); + // + // ButtonTakeOrderInWork + // + this.ButtonTakeOrderInWork.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.ButtonTakeOrderInWork.Location = new System.Drawing.Point(841, 94); + this.ButtonTakeOrderInWork.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.ButtonTakeOrderInWork.Name = "ButtonTakeOrderInWork"; + this.ButtonTakeOrderInWork.Size = new System.Drawing.Size(164, 22); + this.ButtonTakeOrderInWork.TabIndex = 1; + this.ButtonTakeOrderInWork.Text = "Отдать на выполнение"; + this.ButtonTakeOrderInWork.UseVisualStyleBackColor = true; + this.ButtonTakeOrderInWork.Click += new System.EventHandler(this.ButtonTakeOrderInWork_Click); + // + // ButtonOrderReady + // + this.ButtonOrderReady.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.ButtonOrderReady.Location = new System.Drawing.Point(841, 146); + this.ButtonOrderReady.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.ButtonOrderReady.Name = "ButtonOrderReady"; + this.ButtonOrderReady.Size = new System.Drawing.Size(164, 22); + this.ButtonOrderReady.TabIndex = 2; + this.ButtonOrderReady.Text = "Заказ готов"; + this.ButtonOrderReady.UseVisualStyleBackColor = true; + this.ButtonOrderReady.Click += new System.EventHandler(this.ButtonOrderReady_Click); + // + // ButtonIssuedOrder + // + this.ButtonIssuedOrder.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.ButtonIssuedOrder.Location = new System.Drawing.Point(841, 192); + this.ButtonIssuedOrder.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.ButtonIssuedOrder.Name = "ButtonIssuedOrder"; + this.ButtonIssuedOrder.Size = new System.Drawing.Size(164, 22); + this.ButtonIssuedOrder.TabIndex = 3; + this.ButtonIssuedOrder.Text = "Заказ выдан"; + this.ButtonIssuedOrder.UseVisualStyleBackColor = true; + this.ButtonIssuedOrder.Click += new System.EventHandler(this.ButtonIssuedOrder_Click); + // + // ButtonRef + // + this.ButtonRef.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.ButtonRef.Location = new System.Drawing.Point(841, 243); + this.ButtonRef.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.ButtonRef.Name = "ButtonRef"; + this.ButtonRef.Size = new System.Drawing.Size(164, 22); + this.ButtonRef.TabIndex = 4; + this.ButtonRef.Text = "Обновить список"; + this.ButtonRef.UseVisualStyleBackColor = true; + this.ButtonRef.Click += new System.EventHandler(this.ButtonRef_Click); + // + // menuStrip1 + // + this.menuStrip1.ImageScalingSize = new System.Drawing.Size(20, 20); + this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.ToolStripMenuItem, this.отчетыToolStripMenuItem}); - this.menuStrip1.Location = new System.Drawing.Point(0, 0); - this.menuStrip1.Name = "menuStrip1"; - this.menuStrip1.Size = new System.Drawing.Size(800, 24); - this.menuStrip1.TabIndex = 0; - this.menuStrip1.Text = "menuStrip1"; - // - // справочникиToolStripMenuItem - // - this.справочникиToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.бланкиToolStripMenuItem, - this.документыToolStripMenuItem}); - this.справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem"; - this.справочникиToolStripMenuItem.Size = new System.Drawing.Size(94, 20); - this.справочникиToolStripMenuItem.Text = "Справочники"; - // - // бланкиToolStripMenuItem - // - this.бланкиToolStripMenuItem.Name = "бланкиToolStripMenuItem"; - this.бланкиToolStripMenuItem.Size = new System.Drawing.Size(137, 22); - this.бланкиToolStripMenuItem.Text = "Бланки"; - this.бланкиToolStripMenuItem.Click += new System.EventHandler(this.BlanksToolStripMenuItem_Click); - // - // документыToolStripMenuItem - // - this.документыToolStripMenuItem.Name = "документыToolStripMenuItem"; - this.документыToolStripMenuItem.Size = new System.Drawing.Size(137, 22); - this.документыToolStripMenuItem.Text = "Документы"; - this.документыToolStripMenuItem.Click += new System.EventHandler(this.DocumentsToolStripMenuItem_Click); - // - // отчетыToolStripMenuItem - // - this.отчетыToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.списокКомпонентовToolStripMenuItem, - this.компонентыПоИзделиямToolStripMenuItem, - this.списокЗаказовToolStripMenuItem}); - this.отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem"; - this.отчетыToolStripMenuItem.Size = new System.Drawing.Size(60, 20); - this.отчетыToolStripMenuItem.Text = "Отчеты"; - // - // списокКомпонентовToolStripMenuItem - // - this.списокКомпонентовToolStripMenuItem.Name = "списокКомпонентовToolStripMenuItem"; - this.списокКомпонентовToolStripMenuItem.Size = new System.Drawing.Size(218, 22); - this.списокКомпонентовToolStripMenuItem.Text = "Список компонентов"; - this.списокКомпонентовToolStripMenuItem.Click += new System.EventHandler(this.DocumentsReportToolStripMenuItem_Click); - // - // компонентыПоИзделиямToolStripMenuItem - // - this.компонентыПоИзделиямToolStripMenuItem.Name = "компонентыПоИзделиямToolStripMenuItem"; - this.компонентыПоИзделиямToolStripMenuItem.Size = new System.Drawing.Size(218, 22); - this.компонентыПоИзделиямToolStripMenuItem.Text = "Компоненты по изделиям"; - this.компонентыПоИзделиямToolStripMenuItem.Click += new System.EventHandler(this.DocumentBlanksReportToolStripMenuItem_Click); - // - // списокЗаказовToolStripMenuItem - // - this.списокЗаказовToolStripMenuItem.Name = "списокЗаказовToolStripMenuItem"; - this.списокЗаказовToolStripMenuItem.Size = new System.Drawing.Size(218, 22); - this.списокЗаказовToolStripMenuItem.Text = "Список заказов"; - this.списокЗаказовToolStripMenuItem.Click += new System.EventHandler(this.OrdersReportToolStripMenuItem_Click); - // - // dataGridView - // - this.dataGridView.AllowUserToAddRows = false; - this.dataGridView.AllowUserToDeleteRows = false; - this.dataGridView.BackgroundColor = System.Drawing.Color.White; - this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; - this.dataGridView.Location = new System.Drawing.Point(12, 27); - this.dataGridView.Name = "dataGridView"; - this.dataGridView.ReadOnly = true; - this.dataGridView.RowTemplate.Height = 25; - this.dataGridView.Size = new System.Drawing.Size(566, 411); - this.dataGridView.TabIndex = 1; - // - // buttonCreateOrder - // - this.buttonCreateOrder.Location = new System.Drawing.Point(605, 27); - this.buttonCreateOrder.Name = "buttonCreateOrder"; - this.buttonCreateOrder.Size = new System.Drawing.Size(168, 23); - this.buttonCreateOrder.TabIndex = 2; - this.buttonCreateOrder.Text = "Создать заказ"; - this.buttonCreateOrder.UseVisualStyleBackColor = true; - this.buttonCreateOrder.Click += new System.EventHandler(this.ButtonCreateOrder_Click); - // - // buttonTakeOrderInWork - // - this.buttonTakeOrderInWork.Location = new System.Drawing.Point(605, 56); - this.buttonTakeOrderInWork.Name = "buttonTakeOrderInWork"; - this.buttonTakeOrderInWork.Size = new System.Drawing.Size(168, 23); - this.buttonTakeOrderInWork.TabIndex = 3; - this.buttonTakeOrderInWork.Text = "Отдать на выполнение"; - this.buttonTakeOrderInWork.UseVisualStyleBackColor = true; - this.buttonTakeOrderInWork.Click += new System.EventHandler(this.ButtonTakeOrderInWork_Click); - // - // buttonOrderReady - // - this.buttonOrderReady.Location = new System.Drawing.Point(605, 85); - this.buttonOrderReady.Name = "buttonOrderReady"; - this.buttonOrderReady.Size = new System.Drawing.Size(168, 23); - this.buttonOrderReady.TabIndex = 4; - this.buttonOrderReady.Text = "Заказ готов"; - this.buttonOrderReady.UseVisualStyleBackColor = true; - this.buttonOrderReady.Click += new System.EventHandler(this.ButtonOrderReady_Click); - // - // buttonIssuedOrder - // - this.buttonIssuedOrder.Location = new System.Drawing.Point(605, 114); - this.buttonIssuedOrder.Name = "buttonIssuedOrder"; - this.buttonIssuedOrder.Size = new System.Drawing.Size(168, 23); - this.buttonIssuedOrder.TabIndex = 5; - this.buttonIssuedOrder.Text = "Заказ выдан"; - this.buttonIssuedOrder.UseVisualStyleBackColor = true; - this.buttonIssuedOrder.Click += new System.EventHandler(this.ButtonIssuedOrder_Click); - // - // buttonUpdate - // - this.buttonUpdate.Location = new System.Drawing.Point(605, 143); - this.buttonUpdate.Name = "buttonUpdate"; - this.buttonUpdate.Size = new System.Drawing.Size(168, 23); - this.buttonUpdate.TabIndex = 6; - this.buttonUpdate.Text = "Обновить список"; - this.buttonUpdate.UseVisualStyleBackColor = true; - this.buttonUpdate.Click += new System.EventHandler(this.ButtonRef_Click); - // - // FormMain - // - this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(800, 450); - this.Controls.Add(this.buttonUpdate); - this.Controls.Add(this.buttonIssuedOrder); - this.Controls.Add(this.buttonOrderReady); - this.Controls.Add(this.buttonTakeOrderInWork); - this.Controls.Add(this.buttonCreateOrder); - this.Controls.Add(this.dataGridView); - this.Controls.Add(this.menuStrip1); - this.MainMenuStrip = this.menuStrip1; - this.Name = "FormMain"; - this.Text = "Юридическая фирма"; - this.Load += new System.EventHandler(this.FormMain_Load); - this.menuStrip1.ResumeLayout(false); - this.menuStrip1.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); - this.ResumeLayout(false); - this.PerformLayout(); + this.menuStrip1.Location = new System.Drawing.Point(0, 0); + this.menuStrip1.Name = "menuStrip1"; + this.menuStrip1.Padding = new System.Windows.Forms.Padding(5, 2, 0, 2); + this.menuStrip1.Size = new System.Drawing.Size(1015, 24); + this.menuStrip1.TabIndex = 5; + this.menuStrip1.Text = "menuStrip1"; + // + // ToolStripMenuItem + // + this.ToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.ДеталиToolStripMenuItem, + this.ДокументыToolStripMenuItem, + this.магазинToolStripMenuItem}); + this.ToolStripMenuItem.Name = "ToolStripMenuItem"; + this.ToolStripMenuItem.Size = new System.Drawing.Size(94, 20); + this.ToolStripMenuItem.Text = "Справочники"; + // + // ДеталиToolStripMenuItem + // + this.ДеталиToolStripMenuItem.Name = "ДеталиToolStripMenuItem"; + this.ДеталиToolStripMenuItem.Size = new System.Drawing.Size(130, 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(130, 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(130, 22); + this.магазинToolStripMenuItem.Text = "Магазины"; + this.магазинToolStripMenuItem.Click += new System.EventHandler(this.МагазиныToolStripMenuItem_Click); + // + // отчетыToolStripMenuItem + // + this.отчетыToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.DocumentsToolStripMenuItem, + this.documentsBlanksToolStripMenuItem, + this.ordersToolStripMenuItem, + this.загруженностьМагазиновToolStripMenuItem, + this.заказыПоДатеToolStripMenuItem, + this.списокМагазиновToolStripMenuItem}); + this.отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem"; + this.отчетыToolStripMenuItem.Size = new System.Drawing.Size(60, 20); + this.отчетыToolStripMenuItem.Text = "Отчеты"; + // + // DocumentsToolStripMenuItem + // + this.DocumentsToolStripMenuItem.Name = "DocumentsToolStripMenuItem"; + this.DocumentsToolStripMenuItem.Size = new System.Drawing.Size(219, 22); + this.DocumentsToolStripMenuItem.Text = "Список документов"; + this.DocumentsToolStripMenuItem.Click += new System.EventHandler(this.DocumentsToolStripMenuItem_Click); + // + // documentsBlanksToolStripMenuItem + // + this.documentsBlanksToolStripMenuItem.Name = "documentsBlanksToolStripMenuItem"; + this.documentsBlanksToolStripMenuItem.Size = new System.Drawing.Size(219, 22); + this.documentsBlanksToolStripMenuItem.Text = "Изделия по деталям"; + this.documentsBlanksToolStripMenuItem.Click += new System.EventHandler(this.documentBlanksToolStripMenuItem_Click); + // + // ordersToolStripMenuItem + // + this.ordersToolStripMenuItem.Name = "ordersToolStripMenuItem"; + this.ordersToolStripMenuItem.Size = new System.Drawing.Size(219, 22); + this.ordersToolStripMenuItem.Text = "Список заказов"; + this.ordersToolStripMenuItem.Click += new System.EventHandler(this.ordersToolStripMenuItem_Click); + // + // загруженностьМагазиновToolStripMenuItem + // + this.загруженностьМагазиновToolStripMenuItem.Name = "загруженностьМагазиновToolStripMenuItem"; + this.загруженностьМагазиновToolStripMenuItem.Size = new System.Drawing.Size(219, 22); + this.загруженностьМагазиновToolStripMenuItem.Text = "Загруженность магазинов"; + this.загруженностьМагазиновToolStripMenuItem.Click += new System.EventHandler(this.ShopLoadToolStripMenuItem_Click); + // + // заказыПоДатеToolStripMenuItem + // + this.заказыПоДатеToolStripMenuItem.Name = "заказыПоДатеToolStripMenuItem"; + this.заказыПоДатеToolStripMenuItem.Size = new System.Drawing.Size(219, 22); + this.заказыПоДатеToolStripMenuItem.Text = "Заказы по дате"; + this.заказыПоДатеToolStripMenuItem.Click += new System.EventHandler(this.OrdersByDateToolStripMenuItem_Click); + // + // списокМагазиновToolStripMenuItem + // + this.списокМагазиновToolStripMenuItem.Name = "списокМагазиновToolStripMenuItem"; + this.списокМагазиновToolStripMenuItem.Size = new System.Drawing.Size(219, 22); + this.списокМагазиновToolStripMenuItem.Text = "Список магазинов"; + this.списокМагазиновToolStripMenuItem.Click += new System.EventHandler(this.ListOfShopsToolStripMenuItem_Click); + // + // dataGridView + // + this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView.Dock = System.Windows.Forms.DockStyle.Left; + this.dataGridView.Location = new System.Drawing.Point(0, 24); + this.dataGridView.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.dataGridView.Name = "dataGridView"; + this.dataGridView.RowHeadersWidth = 51; + this.dataGridView.RowTemplate.Height = 29; + this.dataGridView.Size = new System.Drawing.Size(816, 332); + this.dataGridView.TabIndex = 6; + // + // ButtonAddDocument + // + this.ButtonAddDocument.Location = new System.Drawing.Point(841, 284); + this.ButtonAddDocument.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.ButtonAddDocument.Name = "ButtonAddDocument"; + this.ButtonAddDocument.Size = new System.Drawing.Size(164, 25); + this.ButtonAddDocument.TabIndex = 7; + this.ButtonAddDocument.Text = "Добавить документ"; + this.ButtonAddDocument.UseVisualStyleBackColor = true; + this.ButtonAddDocument.Click += new System.EventHandler(this.ButtonAddDocument_Click); + // + // ButtonSellDocument + // + this.ButtonSellDocument.Location = new System.Drawing.Point(841, 325); + this.ButtonSellDocument.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.ButtonSellDocument.Name = "ButtonSellDocument"; + this.ButtonSellDocument.Size = new System.Drawing.Size(164, 22); + this.ButtonSellDocument.TabIndex = 8; + this.ButtonSellDocument.Text = "Продать документ"; + this.ButtonSellDocument.UseVisualStyleBackColor = true; + this.ButtonSellDocument.Click += new System.EventHandler(this.ButtonSellDocument_Click); + // + // FormMain + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(1015, 356); + this.Controls.Add(this.ButtonSellDocument); + this.Controls.Add(this.ButtonAddDocument); + this.Controls.Add(this.dataGridView); + this.Controls.Add(this.ButtonRef); + this.Controls.Add(this.ButtonIssuedOrder); + this.Controls.Add(this.ButtonOrderReady); + this.Controls.Add(this.ButtonTakeOrderInWork); + this.Controls.Add(this.ButtonCreateOrder); + this.Controls.Add(this.menuStrip1); + this.MainMenuStrip = this.menuStrip1; + this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.Name = "FormMain"; + this.Text = "LawFirm"; + this.Load += new System.EventHandler(this.FormMain_Load); + this.menuStrip1.ResumeLayout(false); + this.menuStrip1.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); } #endregion + private Button ButtonCreateOrder; + private Button ButtonTakeOrderInWork; + private Button ButtonOrderReady; + private Button ButtonIssuedOrder; + private Button ButtonRef; private MenuStrip menuStrip1; - private ToolStripMenuItem справочникиToolStripMenuItem; + private ToolStripMenuItem ToolStripMenuItem; + private ToolStripMenuItem ДеталиToolStripMenuItem; + private ToolStripMenuItem ДокументыToolStripMenuItem; private DataGridView dataGridView; - private Button buttonCreateOrder; - private Button buttonTakeOrderInWork; - private Button buttonOrderReady; - private Button buttonIssuedOrder; - private Button buttonUpdate; - private ToolStripMenuItem бланкиToolStripMenuItem; - private ToolStripMenuItem документыToolStripMenuItem; - private ToolStripMenuItem магазиныToolStripMenuItem; - private Button buttonAddDocument; - private Button buttonSellDocument; - } private ToolStripMenuItem отчетыToolStripMenuItem; - private ToolStripMenuItem списокКомпонентовToolStripMenuItem; - private ToolStripMenuItem компонентыПоИзделиямToolStripMenuItem; - private ToolStripMenuItem списокЗаказовToolStripMenuItem; + private ToolStripMenuItem DocumentsToolStripMenuItem; + private ToolStripMenuItem documentsBlanksToolStripMenuItem; + private ToolStripMenuItem ordersToolStripMenuItem; + private ToolStripMenuItem магазинToolStripMenuItem; + private Button ButtonAddDocument; + private Button ButtonSellDocument; + 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 580683c..bd6bff7 100644 --- a/LawFirm/LawFirmView/FormMain.cs +++ b/LawFirm/LawFirmView/FormMain.cs @@ -1,8 +1,15 @@ -using LawFirmBusinessLogic.BusinessLogics; +using Microsoft.Extensions.Logging; using LawFirmContracts.BindingModels; using LawFirmContracts.BusinessLogicsContracts; using LawFirmDataModels.Enums; -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 @@ -12,14 +19,15 @@ namespace LawFirmView private readonly ILogger _logger; private readonly IOrderLogic _orderLogic; private readonly IReportLogic _reportLogic; - - public FormMain(ILogger logger, IOrderLogic orderLogic, IReportLogic reportLogic) + public FormMain(ILogger logger, IOrderLogic orderLogic,IReportLogic reportlogic) { InitializeComponent(); _logger = logger; _orderLogic = orderLogic; - _reportLogic = reportLogic; + _reportLogic = reportlogic; + } + private void FormMain_Load(object sender, EventArgs e) { LoadData(); @@ -35,7 +43,7 @@ namespace LawFirmView dataGridView.DataSource = list; dataGridView.Columns["DocumentId"].Visible = false; } - _logger.LogInformation("Загрузка прошла успешно"); + _logger.LogInformation("Загрузка заказов"); } catch (Exception ex) { @@ -43,6 +51,25 @@ namespace LawFirmView MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } + + private void ДеталиToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormBlanks)); + if (service is FormBlanks form) + { + form.ShowDialog(); + } + } + + private void ДокументыToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormDocuments)); + if (service is FormDocuments form) + { + form.ShowDialog(); + } + } + private void ButtonCreateOrder_Click(object sender, EventArgs e) { var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder)); @@ -52,6 +79,7 @@ namespace LawFirmView LoadData(); } } + private void ButtonTakeOrderInWork_Click(object sender, EventArgs e) { if (dataGridView.SelectedRows.Count == 1) @@ -60,9 +88,7 @@ namespace LawFirmView _logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id); try { - var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel{ - Id = id, - }); + var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel { Id = id}); if (!operationResult) { throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); @@ -72,11 +98,12 @@ namespace LawFirmView catch (Exception ex) { _logger.LogError(ex, "Ошибка передачи заказа в работу"); - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, - MessageBoxIcon.Error); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } + } + private void ButtonOrderReady_Click(object sender, EventArgs e) { if (dataGridView.SelectedRows.Count == 1) @@ -85,13 +112,10 @@ namespace LawFirmView _logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'", id); try { - var operationResult = _orderLogic.FinishOrder(new OrderBindingModel - { - Id = id - }); + var operationResult = _orderLogic.FinishOrder(new OrderBindingModel { Id = id }); if (!operationResult) { - throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); + throw new Exception("Ошибка при сохранении.Дополнительная информация в логах."); } LoadData(); } @@ -102,20 +126,16 @@ namespace LawFirmView } } } + private void ButtonIssuedOrder_Click(object sender, EventArgs e) { if (dataGridView.SelectedRows.Count == 1) { - int id = - Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); _logger.LogInformation("Заказ №{id}. Меняется статус на 'Выдан'", id); try { - var operationResult = _orderLogic.DeliveryOrder(new - OrderBindingModel - { - Id = id - }); + var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel { Id = id}); if (!operationResult) { throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); @@ -126,70 +146,46 @@ namespace LawFirmView catch (Exception ex) { _logger.LogError(ex, "Ошибка отметки о выдачи заказа"); - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, - MessageBoxIcon.Error); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } + } + private void ButtonRef_Click(object sender, EventArgs e) { LoadData(); } - private void BlanksToolStripMenuItem_Click(object sender, EventArgs e) - { - var service = Program.ServiceProvider?.GetService(typeof(FormBlanks)); - if (service is FormBlanks form) - { - form.ShowDialog(); - } - } - private void DocumentsToolStripMenuItem_Click(object sender, EventArgs e) - { - var service = Program.ServiceProvider?.GetService(typeof(FormDocuments)); - if (service is FormDocuments form) - { - form.ShowDialog(); - } - } - private void DocumentsReportToolStripMenuItem_Click(object sender, EventArgs -e) + private void DocumentsToolStripMenuItem_Click(object sender, EventArgs e) { using var dialog = new SaveFileDialog { Filter = "docx|*.docx" }; if (dialog.ShowDialog() == DialogResult.OK) { - _reportLogic.SaveBlanksToWordFile(new ReportBindingModel - { - FileName = dialog.FileName - }); - MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, - MessageBoxIcon.Information); + _reportLogic.SaveBlanksToWordFile(new ReportBindingModel { FileName = dialog.FileName }); + MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information); } } - private void DocumentBlanksReportToolStripMenuItem_Click(object sender, - EventArgs e) + + private void documentBlanksToolStripMenuItem_Click(object sender, EventArgs e) { - var service = - Program.ServiceProvider?.GetService(typeof(FormReportDocumentBlanks)); + var service = Program.ServiceProvider?.GetService(typeof(FormReportDocumentBlanks)); if (service is FormReportDocumentBlanks form) { form.ShowDialog(); } } - private void OrdersReportToolStripMenuItem_Click(object sender, EventArgs e) + + private void ordersToolStripMenuItem_Click(object sender, EventArgs e) { - var service = - Program.ServiceProvider?.GetService(typeof(FormReportOrders)); + var service = Program.ServiceProvider?.GetService(typeof(FormReportOrders)); if (service is FormReportOrders form) { form.ShowDialog(); } } - } - } - } - private void ShopToolStripMenuItem_Click(object sender, EventArgs e) + private void МагазиныToolStripMenuItem_Click(object sender, EventArgs e) { var service = Program.ServiceProvider?.GetService(typeof(FormShops)); if (service is FormShops form) @@ -208,14 +204,42 @@ e) } } - private void ButtonSellDocument_Click(object sender, EventArgs e) - { - var service = Program.ServiceProvider?.GetService(typeof(FormSellDocuments)); - if (service is FormSellDocuments form) - { - form.ShowDialog(); - LoadData(); - } - } - } + private void ButtonSellDocument_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormSellDocuments)); + if (service is FormSellDocuments form) + { + form.ShowDialog(); + LoadData(); + } + } + + private void ShopLoadToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormReportShopDocuments)); + if (service is FormReportShopDocuments form) + { + form.ShowDialog(); + } + } + + private void OrdersByDateToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormReportGroupedOrders)); + if (service is FormReportGroupedOrders form) + { + form.ShowDialog(); + } + } + + private void ListOfShopsToolStripMenuItem_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); + } + } + } } diff --git a/LawFirm/LawFirmView/FormReportGroupedOrders.Designer.cs b/LawFirm/LawFirmView/FormReportGroupedOrders.Designer.cs new file mode 100644 index 0000000..cbccadd --- /dev/null +++ b/LawFirm/LawFirmView/FormReportGroupedOrders.Designer.cs @@ -0,0 +1,86 @@ +namespace LawFirmView +{ + partial class FormReportGroupedOrders + { + /// + /// 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.buttonToPdf = new System.Windows.Forms.Button(); + this.buttonMake = new System.Windows.Forms.Button(); + this.panel.SuspendLayout(); + this.SuspendLayout(); + // + // panel + // + this.panel.Controls.Add(this.buttonToPdf); + 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, 44); + this.panel.TabIndex = 0; + // + // buttonToPdf + // + this.buttonToPdf.Location = new System.Drawing.Point(171, 12); + this.buttonToPdf.Name = "buttonToPdf"; + this.buttonToPdf.Size = new System.Drawing.Size(160, 29); + this.buttonToPdf.TabIndex = 1; + this.buttonToPdf.Text = "Сохранить в pdf"; + this.buttonToPdf.UseVisualStyleBackColor = true; + this.buttonToPdf.Click += new System.EventHandler(this.ButtonToPdf_Click); + // + // buttonMake + // + this.buttonMake.Location = new System.Drawing.Point(12, 12); + this.buttonMake.Name = "buttonMake"; + this.buttonMake.Size = new System.Drawing.Size(141, 29); + this.buttonMake.TabIndex = 0; + this.buttonMake.Text = "Сформировать"; + this.buttonMake.UseVisualStyleBackColor = true; + this.buttonMake.Click += new System.EventHandler(this.ButtonMake_Click); + // + // FormReportGroupedOrders + // + 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.panel); + this.Name = "FormReportGroupedOrders"; + this.Text = "Заказы по дате"; + this.panel.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + + private Panel panel; + private Button buttonMake; + private Button buttonToPdf; + } +} \ No newline at end of file diff --git a/LawFirm/LawFirmView/FormReportGroupedOrders.cs b/LawFirm/LawFirmView/FormReportGroupedOrders.cs new file mode 100644 index 0000000..bbce8cd --- /dev/null +++ b/LawFirm/LawFirmView/FormReportGroupedOrders.cs @@ -0,0 +1,81 @@ +using Microsoft.Extensions.Logging; +using Microsoft.Reporting.WinForms; +using LawFirmContracts.BindingModels; +using LawFirmContracts.BusinessLogicsContracts; +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 FormReportGroupedOrders : Form + { + private readonly ReportViewer reportViewer; + + private readonly ILogger _logger; + + private readonly IReportLogic _logic; + + public FormReportGroupedOrders(ILogger logger, IReportLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + reportViewer = new ReportViewer + { + Dock = DockStyle.Fill + }; + reportViewer.LocalReport.LoadReportDefinition(new FileStream("ReportGroupedOrders.rdlc", FileMode.Open)); + Controls.Clear(); + Controls.Add(reportViewer); + Controls.Add(panel); + } + + private void ButtonMake_Click(object sender, EventArgs e) + { + try + { + var dataSource = _logic.GetGroupedByDateOrders(); + 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 ButtonToPdf_Click(object sender, EventArgs e) + { + using var dialog = new SaveFileDialog { Filter = "pdf|*.pdf" }; + if (dialog.ShowDialog() == DialogResult.OK) + { + try + { + _logic.SaveGroupedByDateOrders(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/FormReportGroupedOrders.resx b/LawFirm/LawFirmView/FormReportGroupedOrders.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/LawFirm/LawFirmView/FormReportGroupedOrders.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..5864870 --- /dev/null +++ b/LawFirm/LawFirmView/FormReportShopDocuments.Designer.cs @@ -0,0 +1,108 @@ +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.ButtonSaveToExcel = new System.Windows.Forms.Button(); + this.dataGridView = new System.Windows.Forms.DataGridView(); + this.ShopColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.DocumentColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.CountColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); + this.SuspendLayout(); + // + // ButtonSaveToExcel + // + this.ButtonSaveToExcel.Location = new System.Drawing.Point(12, 12); + this.ButtonSaveToExcel.Name = "ButtonSaveToExcel"; + this.ButtonSaveToExcel.Size = new System.Drawing.Size(145, 29); + this.ButtonSaveToExcel.TabIndex = 0; + this.ButtonSaveToExcel.Text = "Сохранить в excel"; + this.ButtonSaveToExcel.UseVisualStyleBackColor = true; + this.ButtonSaveToExcel.Click += new System.EventHandler(this.ButtonSaveToExcel_Click); + // + // dataGridView + // + this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.ShopColumn, + this.DocumentColumn, + this.CountColumn}); + this.dataGridView.Dock = System.Windows.Forms.DockStyle.Bottom; + this.dataGridView.Location = new System.Drawing.Point(0, 64); + this.dataGridView.Name = "dataGridView"; + this.dataGridView.RowHeadersWidth = 51; + this.dataGridView.RowTemplate.Height = 29; + this.dataGridView.Size = new System.Drawing.Size(504, 417); + this.dataGridView.TabIndex = 1; + // + // ShopColumn + // + this.ShopColumn.HeaderText = "Магазин"; + this.ShopColumn.MinimumWidth = 6; + this.ShopColumn.Name = "ShopColumn"; + this.ShopColumn.Width = 125; + // + // DocumentColumn + // + this.DocumentColumn.HeaderText = "Документ"; + this.DocumentColumn.MinimumWidth = 6; + this.DocumentColumn.Name = "DocumentColumn"; + this.DocumentColumn.Width = 125; + // + // CountColumn + // + this.CountColumn.HeaderText = "Количество"; + this.CountColumn.MinimumWidth = 6; + this.CountColumn.Name = "CountColumn"; + this.CountColumn.Width = 125; + // + // FormReportShopDocuments + // + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(504, 481); + this.Controls.Add(this.dataGridView); + this.Controls.Add(this.ButtonSaveToExcel); + this.Name = "FormReportShopDocuments"; + this.Text = "Магазины и документы"; + this.Load += new System.EventHandler(this.FormReportShopDocuments_Load); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private Button ButtonSaveToExcel; + private DataGridView dataGridView; + private DataGridViewTextBoxColumn ShopColumn; + private DataGridViewTextBoxColumn DocumentColumn; + private DataGridViewTextBoxColumn CountColumn; + } +} \ No newline at end of file diff --git a/LawFirm/LawFirmView/FormReportShopDocuments.cs b/LawFirm/LawFirmView/FormReportShopDocuments.cs new file mode 100644 index 0000000..25a5c58 --- /dev/null +++ b/LawFirm/LawFirmView/FormReportShopDocuments.cs @@ -0,0 +1,79 @@ +using Microsoft.Extensions.Logging; +using LawFirmContracts.BindingModels; +using LawFirmContracts.BusinessLogicsContracts; +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 logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + } + + 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.TotalCount }); + 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.SaveShopDocumentToExcelFile(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..8c7ffcf --- /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 5904c43..099e484 100644 --- a/LawFirm/LawFirmView/LawFirmView.csproj +++ b/LawFirm/LawFirmView/LawFirmView.csproj @@ -28,6 +28,9 @@ + + Always + Always diff --git a/LawFirm/LawFirmView/Program.cs b/LawFirm/LawFirmView/Program.cs index d1602ad..4adb0da 100644 --- a/LawFirm/LawFirmView/Program.cs +++ b/LawFirm/LawFirmView/Program.cs @@ -60,10 +60,11 @@ namespace LawFirmView services.AddTransient(); services.AddTransient(); services.AddTransient(); - services.AddTransient(); - } + services.AddTransient(); services.AddTransient(); services.AddTransient(); - } + services.AddTransient(); + services.AddTransient(); + } } } \ No newline at end of file diff --git a/LawFirm/LawFirmView/ReportGroupedOrders.rdlc b/LawFirm/LawFirmView/ReportGroupedOrders.rdlc new file mode 100644 index 0000000..494a170 --- /dev/null +++ b/LawFirm/LawFirmView/ReportGroupedOrders.rdlc @@ -0,0 +1,411 @@ + + + 0 + + + + System.Data.DataSet + /* Local Connection */ + + 10791c83-cee8-4a38-bbd0-245fc17cefb3 + + + + + + LawFirmContractsViewModels + /* Local Query */ + + + + Date + System.DateTime + + + Count + System.Int32 + + + Sum + System.Decimal + + + + LawFirmContracts.ViewModels + ReportOrdersGroupedByDateViewModel + LawFirmContracts.ViewModels.ReportOrdersGroupedByDateViewModel, LawFirmContracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + + + + + + + + + true + true + + + + + Заказы + + + + + + + Textbox1 + 0.70583cm + 19.67885cm + + + 2pt + 2pt + 2pt + 2pt + + + + + + + 4.56494cm + + + 4.56494cm + + + 2.5cm + + + + + 0.74083cm + + + + + true + true + + + + + Date + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Count + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Sum + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + 0.74083cm + + + + + true + true + + + + + =Fields!Date.Value + + + + + + 2pt + 2pt + 2pt + 2pt + + + true + + + + + + true + true + + + + + =Fields!Count.Value + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!Sum.Value + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + + + + + + + + + + + + After + + + + + + + DataSetOrders + 1.87537cm + 4.83399cm + 1.48166cm + 11.62988cm + 1 + + + + + + true + true + + + + + Итого: + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + =Sum(Fields!Sum.Value, "DataSetOrders") + + + 2pt + 2pt + 2pt + 2pt + + + + 2in +