diff --git a/TypographyBusinessLogic/BusinessLogics/ReportLogic.cs b/TypographyBusinessLogic/BusinessLogics/ReportLogic.cs index 354a2e7..84d0644 100644 --- a/TypographyBusinessLogic/BusinessLogics/ReportLogic.cs +++ b/TypographyBusinessLogic/BusinessLogics/ReportLogic.cs @@ -18,14 +18,16 @@ namespace TypographyBusinessLogic.BusinessLogics private readonly IComponentStorage _componentStorage; private readonly IPrintedStorage _printedStorage; private readonly IOrderStorage _orderStorage; + private readonly IShopStorage _shopStorage; private readonly AbstractSaveToExcel _saveToExcel; private readonly AbstractSaveToWord _saveToWord; private readonly AbstractSaveToPdf _saveToPdf; - public ReportLogic(IPrintedStorage printedStorage, IComponentStorage componentStorage, IOrderStorage orderStorage, AbstractSaveToExcel saveToExcel, AbstractSaveToWord saveToWord, AbstractSaveToPdf saveToPdf) + public ReportLogic(IPrintedStorage printedStorage, IComponentStorage componentStorage, IOrderStorage orderStorage, IShopStorage shopStorage, AbstractSaveToExcel saveToExcel, AbstractSaveToWord saveToWord, AbstractSaveToPdf saveToPdf) { _printedStorage = printedStorage; _componentStorage = componentStorage; _orderStorage = orderStorage; + _shopStorage = shopStorage; _saveToExcel = saveToExcel; _saveToWord = saveToWord; _saveToPdf = saveToPdf; @@ -118,5 +120,62 @@ namespace TypographyBusinessLogic.BusinessLogics Orders = GetOrders(model) }); } + public void SaveShopsToWordFile(ReportBindingModel model) + { + _saveToWord.CreateTableDoc(new WordInfo + { + FileName = model.FileName, + Title = "Список магазинов", + Shops = _shopStorage.GetFullList() + }); + } + public void SaveShopPrintedsToExcelFile(ReportBindingModel model) + { + _saveToExcel.CreateShopReport(new ExcelInfo + { + FileName = model.FileName, + Title = "Загруженность магазинов", + ShopPrinteds = GetShopPrinteds() + }); + } + public List GetShopPrinteds() + { + var shops = _shopStorage.GetFullList(); + var list = new List(); + foreach (var shop in shops) + { + var record = new ReportShopPrintedsViewModel + { + ShopName = shop.ShopName, + Printeds = new List>(), + Count = 0 + }; + foreach (var carCount in shop.ShopPrinteds.Values) + { + record.Printeds.Add(new Tuple(carCount.Item1.PrintedName, carCount.Item2)); + record.Count += carCount.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/TypographyBusinessLogic/ShopLogic.cs b/TypographyBusinessLogic/BusinessLogics/ShopLogic.cs similarity index 97% rename from TypographyBusinessLogic/ShopLogic.cs rename to TypographyBusinessLogic/BusinessLogics/ShopLogic.cs index 1ea282c..08502fc 100644 --- a/TypographyBusinessLogic/ShopLogic.cs +++ b/TypographyBusinessLogic/BusinessLogics/ShopLogic.cs @@ -11,7 +11,7 @@ using TypographyContracts.ViewModels; using TypographyDataModels.Models; using Microsoft.Extensions.Logging; -namespace TypographyBusinessLogic +namespace TypographyBusinessLogic.BusinessLogics { public class ShopLogic : IShopLogic { @@ -49,7 +49,7 @@ namespace TypographyBusinessLogic { _logger.LogInformation("ReadList. Shop Name:{0}, ID:{1} ", model?.ShopName, model?.Id); - var list = (model == null) ? _shopStorage.GetFullList() : _shopStorage.GetFilteredList(model); + var list = model == null ? _shopStorage.GetFullList() : _shopStorage.GetFilteredList(model); if (list == null) { diff --git a/TypographyBusinessLogic/OfficePackage/AbstractSaveToExcel.cs b/TypographyBusinessLogic/OfficePackage/AbstractSaveToExcel.cs index 915219f..72fc2ee 100644 --- a/TypographyBusinessLogic/OfficePackage/AbstractSaveToExcel.cs +++ b/TypographyBusinessLogic/OfficePackage/AbstractSaveToExcel.cs @@ -47,14 +47,14 @@ namespace TypographyBusinessLogic.OfficePackage ColumnName = "B", RowIndex = rowIndex, Text = Component, - StyleInfo = ExcelStyleInfoType.TextWithBroder + StyleInfo = ExcelStyleInfoType.TextWithBorder }); InsertCellInWorksheet(new ExcelCellParameters { ColumnName = "C", RowIndex = rowIndex, Text = Count.ToString(), - StyleInfo = ExcelStyleInfoType.TextWithBroder + StyleInfo = ExcelStyleInfoType.TextWithBorder }); rowIndex++; } @@ -76,6 +76,68 @@ namespace TypographyBusinessLogic.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.ShopPrinteds) + { + InsertCellInWorksheet(new ExcelCellParameters + { + ColumnName = "A", + RowIndex = rowIndex, + Text = pc.ShopName, + StyleInfo = ExcelStyleInfoType.Text + }); + rowIndex++; + foreach (var (PrintedName, Count) in pc.Printeds) + { + InsertCellInWorksheet(new ExcelCellParameters + { + ColumnName = "B", + RowIndex = rowIndex, + Text = PrintedName, + 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/TypographyBusinessLogic/OfficePackage/AbstractSaveToPdf.cs b/TypographyBusinessLogic/OfficePackage/AbstractSaveToPdf.cs index 01a900a..2bed595 100644 --- a/TypographyBusinessLogic/OfficePackage/AbstractSaveToPdf.cs +++ b/TypographyBusinessLogic/OfficePackage/AbstractSaveToPdf.cs @@ -49,6 +49,39 @@ namespace TypographyBusinessLogic.OfficePackage }); 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/TypographyBusinessLogic/OfficePackage/AbstractSaveToWord.cs b/TypographyBusinessLogic/OfficePackage/AbstractSaveToWord.cs index 8d1545b..0580b7c 100644 --- a/TypographyBusinessLogic/OfficePackage/AbstractSaveToWord.cs +++ b/TypographyBusinessLogic/OfficePackage/AbstractSaveToWord.cs @@ -40,6 +40,27 @@ namespace TypographyBusinessLogic.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.DateOpening.ToString()); + } + var wordTable = new WordTable + { + Headers = new List { + "Название", + "Адрес", + "Дата открытия"}, + Texts = list + }; + CreateTable(wordTable); + SaveWord(wordInfo); + } /// /// Создание doc-файла /// @@ -56,6 +77,11 @@ namespace TypographyBusinessLogic.OfficePackage /// /// protected abstract void SaveWord(WordInfo info); + /// + /// создание таблицы + /// + /// + protected abstract void CreateTable(WordTable info); } } diff --git a/TypographyBusinessLogic/OfficePackage/HelperEnums/ExcelStyleInfoType.cs b/TypographyBusinessLogic/OfficePackage/HelperEnums/ExcelStyleInfoType.cs index c82cc16..a915974 100644 --- a/TypographyBusinessLogic/OfficePackage/HelperEnums/ExcelStyleInfoType.cs +++ b/TypographyBusinessLogic/OfficePackage/HelperEnums/ExcelStyleInfoType.cs @@ -10,6 +10,6 @@ namespace TypographyBusinessLogic.OfficePackage.HelperEnums { Title, Text, - TextWithBroder + TextWithBorder } } diff --git a/TypographyBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs b/TypographyBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs index a767d87..9fa363c 100644 --- a/TypographyBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs +++ b/TypographyBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs @@ -17,5 +17,10 @@ namespace TypographyBusinessLogic.OfficePackage.HelperModels get; set; } = new(); + public List ShopPrinteds + { + get; + set; + } = new(); } } diff --git a/TypographyBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs b/TypographyBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs index b7fdf8f..c2ecb4e 100644 --- a/TypographyBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs +++ b/TypographyBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs @@ -14,5 +14,6 @@ namespace TypographyBusinessLogic.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/TypographyBusinessLogic/OfficePackage/HelperModels/WordInfo.cs b/TypographyBusinessLogic/OfficePackage/HelperModels/WordInfo.cs index fdf26b4..9951891 100644 --- a/TypographyBusinessLogic/OfficePackage/HelperModels/WordInfo.cs +++ b/TypographyBusinessLogic/OfficePackage/HelperModels/WordInfo.cs @@ -12,5 +12,6 @@ namespace TypographyBusinessLogic.OfficePackage.HelperModels public string FileName { get; set; } = string.Empty; public string Title { get; set; } = string.Empty; public List Components { get; set; } = new(); + public List Shops { get; set; } = new(); } } diff --git a/TypographyBusinessLogic/OfficePackage/HelperModels/WordTable.cs b/TypographyBusinessLogic/OfficePackage/HelperModels/WordTable.cs new file mode 100644 index 0000000..c030918 --- /dev/null +++ b/TypographyBusinessLogic/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 TypographyBusinessLogic.OfficePackage.HelperModels +{ + public class WordTable + { + public List Headers { get; set; } = new(); + public List Texts { get; set; } = new(); + } +} diff --git a/TypographyBusinessLogic/OfficePackage/Implements/SaveToExcel.cs b/TypographyBusinessLogic/OfficePackage/Implements/SaveToExcel.cs index 5c6ca4b..e899b32 100644 --- a/TypographyBusinessLogic/OfficePackage/Implements/SaveToExcel.cs +++ b/TypographyBusinessLogic/OfficePackage/Implements/SaveToExcel.cs @@ -166,7 +166,7 @@ namespace TypographyBusinessLogic.OfficePackage.Implements return styleInfo switch { ExcelStyleInfoType.Title => 2U, - ExcelStyleInfoType.TextWithBroder => 1U, + ExcelStyleInfoType.TextWithBorder => 1U, ExcelStyleInfoType.Text => 0U, _ => 0U, }; diff --git a/TypographyBusinessLogic/OfficePackage/Implements/SaveToWord.cs b/TypographyBusinessLogic/OfficePackage/Implements/SaveToWord.cs index 5ba6091..fe1ce82 100644 --- a/TypographyBusinessLogic/OfficePackage/Implements/SaveToWord.cs +++ b/TypographyBusinessLogic/OfficePackage/Implements/SaveToWord.cs @@ -126,5 +126,85 @@ namespace TypographyBusinessLogic.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/TypographyContracts/BindingModels/ShopBindingModel.cs b/TypographyContracts/BindingModels/ShopBindingModel.cs index dc46f47..646261a 100644 --- a/TypographyContracts/BindingModels/ShopBindingModel.cs +++ b/TypographyContracts/BindingModels/ShopBindingModel.cs @@ -15,9 +15,9 @@ namespace TypographyContracts.BindingModels public string ShopName { get; set; } = string.Empty; public string Address { get; set; } = string.Empty; - - public DateTime DateOpening { get; set; } = DateTime.Now; public int MaxCountPrinteds { get; set; } + public DateTime DateOpening { get; set; } = DateTime.Now; + public Dictionary ShopPrinteds { get; set; } = new(); } diff --git a/TypographyContracts/BusinessLogicsContracts/IReportLogic.cs b/TypographyContracts/BusinessLogicsContracts/IReportLogic.cs index 3669f68..cf18fd5 100644 --- a/TypographyContracts/BusinessLogicsContracts/IReportLogic.cs +++ b/TypographyContracts/BusinessLogicsContracts/IReportLogic.cs @@ -36,5 +36,30 @@ namespace TypographyContracts.BusinessLogicsContracts /// /// void SaveOrdersToPdfFile(ReportBindingModel model); + /// + /// Сохранение магазинов в файл-Word + /// + /// + void SaveShopsToWordFile(ReportBindingModel model); + /// + /// Сохранение магазинов с указаеним продуктов в файл-Excel + /// + /// + void SaveShopPrintedsToExcelFile(ReportBindingModel model); + /// + /// Получение списка магазинов + /// + /// + List GetShopPrinteds(); + /// + /// Получение списка заказов с группировкой по датам + /// + /// + List GetDateOrders(); + /// + /// Сохранение заказов с группировкой по датам в файл-Pdf + /// + /// + void SaveDateOrdersToPdfFile(ReportBindingModel model); } } diff --git a/TypographyContracts/ViewModels/ReportDateOrdersViewModel.cs b/TypographyContracts/ViewModels/ReportDateOrdersViewModel.cs new file mode 100644 index 0000000..ebdb186 --- /dev/null +++ b/TypographyContracts/ViewModels/ReportDateOrdersViewModel.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace TypographyContracts.ViewModels +{ + public class ReportDateOrdersViewModel + { + public DateTime DateCreate { get; set; } + public int CountOrders { get; set; } + public double SumOrders { get; set; } + } +} diff --git a/TypographyContracts/ViewModels/ReportShopPrintedsViewModel.cs b/TypographyContracts/ViewModels/ReportShopPrintedsViewModel.cs new file mode 100644 index 0000000..8ba61a3 --- /dev/null +++ b/TypographyContracts/ViewModels/ReportShopPrintedsViewModel.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace TypographyContracts.ViewModels +{ + public class ReportShopPrintedsViewModel + { + public string ShopName { get; set; } = string.Empty; + public int Count { get; set; } + public List> Printeds { get; set; } = new(); + } +} diff --git a/TypographyShopDatabaseImplements/TypographyDatabaseImplements.csproj b/TypographyShopDatabaseImplements/TypographyDatabaseImplements.csproj index 30ea109..caf1f43 100644 --- a/TypographyShopDatabaseImplements/TypographyDatabaseImplements.csproj +++ b/TypographyShopDatabaseImplements/TypographyDatabaseImplements.csproj @@ -19,5 +19,4 @@ - diff --git a/TypographyView/FormMain.Designer.cs b/TypographyView/FormMain.Designer.cs index d4dd87c..db15ca9 100644 --- a/TypographyView/FormMain.Designer.cs +++ b/TypographyView/FormMain.Designer.cs @@ -32,6 +32,16 @@ справочникиToolStripMenuItem = new ToolStripMenuItem(); компонентыToolStripMenuItem = new ToolStripMenuItem(); изделиеToolStripMenuItem = new ToolStripMenuItem(); + магазиныToolStripMenuItem = new ToolStripMenuItem(); + пополнениеМагазинаToolStripMenuItem = new ToolStripMenuItem(); + продажаИзделийToolStripMenuItem = new ToolStripMenuItem(); + отчетыToolStripMenuItem = new ToolStripMenuItem(); + списокИзделийToolStripMenuItem = new ToolStripMenuItem(); + компонентыПоИзделиямToolStripMenuItem1 = new ToolStripMenuItem(); + списокЗаказовToolStripMenuItem1 = new ToolStripMenuItem(); + списокМагазиновToolStripMenuItem = new ToolStripMenuItem(); + загруженностьМагазинаToolStripMenuItem = new ToolStripMenuItem(); + списокЗаказовПоДатамToolStripMenuItem = new ToolStripMenuItem(); отчётыToolStripMenuItem = new ToolStripMenuItem(); списокКомпонентовToolStripMenuItem = new ToolStripMenuItem(); компонентыПоИзделиямToolStripMenuItem = new ToolStripMenuItem(); @@ -49,7 +59,7 @@ // menuStrip // menuStrip.ImageScalingSize = new Size(20, 20); - menuStrip.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem }); + menuStrip.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, отчетыToolStripMenuItem }); menuStrip.Location = new Point(0, 0); menuStrip.Name = "menuStrip"; menuStrip.Size = new Size(1146, 28); @@ -58,7 +68,7 @@ // // справочникиToolStripMenuItem // - справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { компонентыToolStripMenuItem, изделиеToolStripMenuItem, магазиныToolStripMenuItem }); + справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { компонентыToolStripMenuItem, изделиеToolStripMenuItem, магазиныToolStripMenuItem, пополнениеМагазинаToolStripMenuItem, продажаИзделийToolStripMenuItem }); справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem"; справочникиToolStripMenuItem.Size = new Size(117, 24); справочникиToolStripMenuItem.Text = "Справочники"; @@ -66,16 +76,86 @@ // компонентыToolStripMenuItem // компонентыToolStripMenuItem.Name = "компонентыToolStripMenuItem"; - компонентыToolStripMenuItem.Size = new Size(182, 26); + компонентыToolStripMenuItem.Size = new Size(251, 26); компонентыToolStripMenuItem.Text = "Компоненты"; - компонентыToolStripMenuItem.Click += КомпонентыToolStripMenuItem_Click; + компонентыToolStripMenuItem.Click += ComponentsToolStripMenuItem_Click; // // изделиеToolStripMenuItem // изделиеToolStripMenuItem.Name = "изделиеToolStripMenuItem"; - изделиеToolStripMenuItem.Size = new Size(182, 26); + изделиеToolStripMenuItem.Size = new Size(251, 26); изделиеToolStripMenuItem.Text = "Изделие"; - изделиеToolStripMenuItem.Click += ЗакускаToolStripMenuItem_Click; + изделиеToolStripMenuItem.Click += PrintedsToolStripMenuItem_Click; + // + // магазиныToolStripMenuItem + // + магазиныToolStripMenuItem.Name = "магазиныToolStripMenuItem"; + магазиныToolStripMenuItem.Size = new Size(251, 26); + магазиныToolStripMenuItem.Text = "Магазины"; + магазиныToolStripMenuItem.Click += shopsToolStripMenuItem_Click; + // + // пополнениеМагазинаToolStripMenuItem + // + пополнениеМагазинаToolStripMenuItem.Name = "пополнениеМагазинаToolStripMenuItem"; + пополнениеМагазинаToolStripMenuItem.Size = new Size(251, 26); + пополнениеМагазинаToolStripMenuItem.Text = "Пополнение магазина"; + пополнениеМагазинаToolStripMenuItem.Click += shopsSupplyToolStripMenuItem_Click; + // + // продажаИзделийToolStripMenuItem + // + продажаИзделийToolStripMenuItem.Name = "продажаИзделийToolStripMenuItem"; + продажаИзделийToolStripMenuItem.Size = new Size(251, 26); + продажаИзделийToolStripMenuItem.Text = "Продажа изделий"; + продажаИзделийToolStripMenuItem.Click += sellPrintedsToolStripMenuItem_Click; + // + // отчетыToolStripMenuItem + // + отчетыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { списокИзделийToolStripMenuItem, компонентыПоИзделиямToolStripMenuItem1, списокЗаказовToolStripMenuItem1, списокМагазиновToolStripMenuItem, загруженностьМагазинаToolStripMenuItem, списокЗаказовПоДатамToolStripMenuItem }); + отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem"; + отчетыToolStripMenuItem.Size = new Size(73, 24); + отчетыToolStripMenuItem.Text = "Отчеты"; + // + // списокИзделийToolStripMenuItem + // + списокИзделийToolStripMenuItem.Name = "списокИзделийToolStripMenuItem"; + списокИзделийToolStripMenuItem.Size = new Size(276, 26); + списокИзделийToolStripMenuItem.Text = "Список изделий"; + списокИзделийToolStripMenuItem.Click += printedsListToolStripMenuItem_Click; + // + // компонентыПоИзделиямToolStripMenuItem1 + // + компонентыПоИзделиямToolStripMenuItem1.Name = "компонентыПоИзделиямToolStripMenuItem1"; + компонентыПоИзделиямToolStripMenuItem1.Size = new Size(276, 26); + компонентыПоИзделиямToolStripMenuItem1.Text = "Компоненты по изделиям"; + компонентыПоИзделиямToolStripMenuItem1.Click += componentsByPrintedsToolStripMenuItem_Click; + // + // списокЗаказовToolStripMenuItem1 + // + списокЗаказовToolStripMenuItem1.Name = "списокЗаказовToolStripMenuItem1"; + списокЗаказовToolStripMenuItem1.Size = new Size(276, 26); + списокЗаказовToolStripMenuItem1.Text = "Список заказов"; + списокЗаказовToolStripMenuItem1.Click += ordersListToolStripMenuItem_Click; + // + // списокМагазиновToolStripMenuItem + // + списокМагазиновToolStripMenuItem.Name = "списокМагазиновToolStripMenuItem"; + списокМагазиновToolStripMenuItem.Size = new Size(276, 26); + списокМагазиновToolStripMenuItem.Text = "Список магазинов"; + списокМагазиновToolStripMenuItem.Click += shopsListToolStripMenuItem_Click; + // + // загруженностьМагазинаToolStripMenuItem + // + загруженностьМагазинаToolStripMenuItem.Name = "загруженностьМагазинаToolStripMenuItem"; + загруженностьМагазинаToolStripMenuItem.Size = new Size(276, 26); + загруженностьМагазинаToolStripMenuItem.Text = "Загруженность магазина"; + загруженностьМагазинаToolStripMenuItem.Click += storeCongestionToolStripMenuItem_Click; + // + // списокЗаказовПоДатамToolStripMenuItem + // + списокЗаказовПоДатамToolStripMenuItem.Name = "списокЗаказовПоДатамToolStripMenuItem"; + списокЗаказовПоДатамToolStripMenuItem.Size = new Size(276, 26); + списокЗаказовПоДатамToolStripMenuItem.Text = "Список заказов по датам"; + списокЗаказовПоДатамToolStripMenuItem.Click += listOdOrdersByDatesToolStripMenuItem_Click; // // отчётыToolStripMenuItem // @@ -96,14 +176,14 @@ компонентыПоИзделиямToolStripMenuItem.Name = "компонентыПоИзделиямToolStripMenuItem"; компонентыПоИзделиямToolStripMenuItem.Size = new Size(276, 26); компонентыПоИзделиямToolStripMenuItem.Text = "Компоненты по изделиям"; - компонентыПоИзделиямToolStripMenuItem.Click += ComponentProductsToolStripMenuItem_Click; + компонентыПоИзделиямToolStripMenuItem.Click += componentsByPrintedsToolStripMenuItem_Click; // // списокЗаказовToolStripMenuItem // списокЗаказовToolStripMenuItem.Name = "списокЗаказовToolStripMenuItem"; списокЗаказовToolStripMenuItem.Size = new Size(276, 26); списокЗаказовToolStripMenuItem.Text = "Список заказов"; - списокЗаказовToolStripMenuItem.Click += OrdersToolStripMenuItem_Click; + списокЗаказовToolStripMenuItem.Click += ordersListToolStripMenuItem_Click; // // dataGridView // @@ -165,7 +245,7 @@ buttonUpd.TabIndex = 6; buttonUpd.Text = "Обновить список"; buttonUpd.UseVisualStyleBackColor = true; - buttonUpd.Click += ButtonUpd_Click; + buttonUpd.Click += ButtonRef_Click; // // FormMain // @@ -206,5 +286,15 @@ private ToolStripMenuItem списокКомпонентовToolStripMenuItem; private ToolStripMenuItem компонентыПоИзделиямToolStripMenuItem; private ToolStripMenuItem списокЗаказовToolStripMenuItem; + private ToolStripMenuItem магазиныToolStripMenuItem; + private ToolStripMenuItem пополнениеМагазинаToolStripMenuItem; + private ToolStripMenuItem продажаИзделийToolStripMenuItem; + private ToolStripMenuItem отчетыToolStripMenuItem; + private ToolStripMenuItem списокИзделийToolStripMenuItem; + private ToolStripMenuItem компонентыПоИзделиямToolStripMenuItem1; + private ToolStripMenuItem списокЗаказовToolStripMenuItem1; + private ToolStripMenuItem списокМагазиновToolStripMenuItem; + private ToolStripMenuItem загруженностьМагазинаToolStripMenuItem; + private ToolStripMenuItem списокЗаказовПоДатамToolStripMenuItem; } } \ No newline at end of file diff --git a/TypographyView/FormMain.cs b/TypographyView/FormMain.cs index af5f693..ca13b92 100644 --- a/TypographyView/FormMain.cs +++ b/TypographyView/FormMain.cs @@ -13,16 +13,16 @@ using Microsoft.Extensions.Logging; using TypographyDataModels.Enums; using AbstractShopView; using TypographyBusinessLogic.BusinessLogics; +using DocumentFormat.OpenXml.Spreadsheet; +using TypographyPlantView; namespace TypographyView { public partial class FormMain : Form { private readonly ILogger _logger; - private readonly IOrderLogic _orderLogic; private readonly IReportLogic _reportLogic; - public FormMain(ILogger logger, IOrderLogic orderLogic, IReportLogic reportLogic) { InitializeComponent(); @@ -30,14 +30,13 @@ namespace TypographyView _orderLogic = orderLogic; _reportLogic = reportLogic; } - private void FormMain_Load(object sender, EventArgs e) { LoadData(); } - private void LoadData() { + _logger.LogInformation("Загрузка заказов"); try { var list = _orderLogic.ReadList(null); @@ -45,16 +44,81 @@ namespace TypographyView { dataGridView.DataSource = list; dataGridView.Columns["PrintedId"].Visible = false; - dataGridView.Columns["PrintedName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; } - _logger.LogInformation("Orders loading"); + _logger.LogInformation("Загрузка заказов"); } catch (Exception ex) { - _logger.LogError(ex, "Orders loading error"); + _logger.LogError(ex, "Ошибка загрузки заказов"); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } + + // управление менюшкой + private void ComponentsToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormComponents)); + if (service is FormComponents form) + { + form.ShowDialog(); + } + } + private void PrintedsToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormPrinteds)); + if (service is FormPrinteds form) + { + form.ShowDialog(); + } + } + private void shopsToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormShops)); + if (service is FormShops form) + { + form.ShowDialog(); + } + } + private void shopsSupplyToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormMakeShipment)); + if (service is FormMakeShipment form) + { + form.ShowDialog(); + } + } + + private void printedsListToolStripMenuItem_Click(object sender, EventArgs e) + { + using var dialog = new SaveFileDialog { Filter = "docx|*.docx" }; + if (dialog.ShowDialog() == DialogResult.OK) + { + _reportLogic.SavePrintedsToWordFile(new ReportBindingModel + { + FileName = dialog.FileName + }); + MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + } + + private void componentsByPrintedsToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormReportPrintedComponents)); + if (service is FormReportPrintedComponents form) + { + form.ShowDialog(); + } + } + + private void ordersListToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormReportOrders)); + if (service is FormReportOrders form) + { + form.ShowDialog(); + } + } + private void sellPrintedsToolStripMenuItem_Click(object sender, EventArgs e) { var service = Program.ServiceProvider?.GetService(typeof(FormShopSell)); @@ -64,41 +128,38 @@ namespace TypographyView } } - private void КомпонентыToolStripMenuItem_Click(object sender, EventArgs e) + private void shopsListToolStripMenuItem_Click(object sender, EventArgs e) { - var service = Program.ServiceProvider?.GetService(typeof(FormComponents)); - if (service is FormComponents form) + 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 storeCongestionToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormReportShopPrinteds)); + if (service is FormReportShopPrinteds form) { form.ShowDialog(); } } - private void ЗакускаToolStripMenuItem_Click(object sender, EventArgs e) + private void listOdOrdersByDatesToolStripMenuItem_Click(object sender, EventArgs e) { - var service = Program.ServiceProvider?.GetService(typeof(FormPrinteds)); - if (service is FormPrinteds form) - { - form.ShowDialog(); - } - } - private void МагазиныToolStripMenuItem_Click(object sender, EventArgs e) - { - var service = Program.ServiceProvider?.GetService(typeof(FormShops)); - if (service is FormShops form) - { - form.ShowDialog(); - } - } - - private void ПополнениеМагазиныToolStripMenuItem_Click(object sender, EventArgs e) - { - var service = Program.ServiceProvider?.GetService(typeof(FormMakeShipment)); - if (service is FormMakeShipment form) + var service = Program.ServiceProvider?.GetService(typeof(FormReportDateOrders)); + if (service is FormReportDateOrders form) { form.ShowDialog(); } } + // управление заказами private void ButtonCreateOrder_Click(object sender, EventArgs e) { var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder)); @@ -108,13 +169,24 @@ namespace TypographyView LoadData(); } } - + private OrderBindingModel CreateBindingModel(int id) + { + return new OrderBindingModel + { + Id = id, + PrintedId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["PrintedId"].Value), + Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value), + DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()), + Status = Enum.Parse(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()), + Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()), + }; + } private void ButtonTakeOrderInWork_Click(object sender, EventArgs e) { if (dataGridView.SelectedRows.Count == 1) { int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); - _logger.LogInformation("Order №{id}. Status changes to 'В работе'", id); + _logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id); try { var operationResult = _orderLogic.TakeOrderInWork(CreateBindingModel(id)); @@ -126,18 +198,18 @@ namespace TypographyView } catch (Exception ex) { - _logger.LogError(ex, "Error taking an order to work"); - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + _logger.LogError(ex, "Ошибка передачи заказа в работу"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); } } } - private void ButtonOrderReady_Click(object sender, EventArgs e) { if (dataGridView.SelectedRows.Count == 1) { int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); - _logger.LogInformation("Order №{id}. Status changes to 'Готов'", id); + _logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'", id); try { var operationResult = _orderLogic.FinishOrder(CreateBindingModel(id)); @@ -149,49 +221,17 @@ namespace TypographyView } catch (Exception ex) { - _logger.LogError(ex, "Order readiness marking error"); + _logger.LogError(ex, "Ошибка отметки о готовности заказа"); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } - private void ComponentsToolStripMenuItem_Click(object sender, EventArgs -e) - { - using var dialog = new SaveFileDialog { Filter = "docx|*.docx" }; - if (dialog.ShowDialog() == DialogResult.OK) - { - _reportLogic.SavePrintedsToWordFile(new ReportBindingModel - { - FileName = dialog.FileName - }); - MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, - MessageBoxIcon.Information); - } - } - private void ComponentProductsToolStripMenuItem_Click(object sender, EventArgs e) - { - var service = Program.ServiceProvider?.GetService(typeof(FormReportPrintedComponents)); - if (service is FormReportPrintedComponents form) - { - form.ShowDialog(); - } - } - private void OrdersToolStripMenuItem_Click(object sender, EventArgs e) - { - var service = Program.ServiceProvider?.GetService(typeof(FormReportOrders)); - if (service is FormReportOrders form) - { - form.ShowDialog(); - } - } - - private void ButtonIssuedOrder_Click(object sender, EventArgs e) { if (dataGridView.SelectedRows.Count == 1) { int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); - _logger.LogInformation("Order №{id}. Status changes to 'Выдан'", id); + _logger.LogInformation("Заказ №{id}. Меняется статус на 'Выдан'", id); try { var operationResult = _orderLogic.DeliveryOrder(CreateBindingModel(id)); @@ -199,32 +239,19 @@ e) { throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); } - _logger.LogInformation("Order №{id} issued", id); + _logger.LogInformation("Заказ №{id} выдан", id); LoadData(); } catch (Exception ex) { - _logger.LogError(ex, "Order issue marking error"); + _logger.LogError(ex, "Ошибка отметки о выдачи заказа"); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } - - private void ButtonUpd_Click(object sender, EventArgs e) + private void ButtonRef_Click(object sender, EventArgs e) { LoadData(); } - private OrderBindingModel CreateBindingModel(int id) - { - return new OrderBindingModel - { - Id = id, - PrintedId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["PrintedId"].Value), - Status = Enum.Parse(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()), - Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value), - Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()), - DateCreate = (System.DateTime)dataGridView.SelectedRows[0].Cells["DateCreate"].Value, - }; - } } } diff --git a/TypographyView/FormMakeShipment.cs b/TypographyView/FormMakeShipment.cs index ff904c1..28db000 100644 --- a/TypographyView/FormMakeShipment.cs +++ b/TypographyView/FormMakeShipment.cs @@ -1,17 +1,6 @@ -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; -using TypographyContracts.BusinessLogicsContracts; +using TypographyContracts.BusinessLogicsContracts; using TypographyContracts.SearchModels; using Microsoft.Extensions.Logging; -using TypographyContracts.BusinessLogicsContracts; -using TypographyContracts.SearchModels; namespace TypographyView { diff --git a/TypographyView/FormReportDateOrders.Designer.cs b/TypographyView/FormReportDateOrders.Designer.cs new file mode 100644 index 0000000..186e89b --- /dev/null +++ b/TypographyView/FormReportDateOrders.Designer.cs @@ -0,0 +1,90 @@ +namespace TypographyView +{ + 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() + { + panel = new Panel(); + ButtonToPdf = new Button(); + buttonMake = new Button(); + panel.SuspendLayout(); + SuspendLayout(); + // + // panel + // + panel.Controls.Add(ButtonToPdf); + panel.Controls.Add(buttonMake); + panel.Dock = DockStyle.Top; + panel.Location = new Point(0, 0); + panel.Margin = new Padding(3, 4, 3, 4); + panel.Name = "panel"; + panel.Size = new Size(914, 61); + panel.TabIndex = 0; + // + // ButtonToPdf + // + ButtonToPdf.Location = new Point(151, 16); + ButtonToPdf.Margin = new Padding(3, 4, 3, 4); + ButtonToPdf.Name = "ButtonToPdf"; + ButtonToPdf.Size = new Size(86, 31); + ButtonToPdf.TabIndex = 7; + ButtonToPdf.Text = "В PDF"; + ButtonToPdf.UseVisualStyleBackColor = true; + ButtonToPdf.Click += buttonToPDF_Click; + // + // buttonMake + // + buttonMake.Location = new Point(14, 16); + buttonMake.Margin = new Padding(3, 4, 3, 4); + buttonMake.Name = "buttonMake"; + buttonMake.Size = new Size(131, 31); + buttonMake.TabIndex = 6; + buttonMake.Text = "Сформировать"; + buttonMake.UseVisualStyleBackColor = true; + buttonMake.Click += buttonMake_Click; + // + // FormReportDateOrders + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(914, 600); + Controls.Add(panel); + Margin = new Padding(3, 4, 3, 4); + Name = "FormReportDateOrders"; + Text = "Отчет по дням заказа"; + FormClosed += FormReportDateOrders_FormClosed; + panel.ResumeLayout(false); + ResumeLayout(false); + } + + #endregion + + private Panel panel; + private Button ButtonToPdf; + private Button buttonMake; + } +} \ No newline at end of file diff --git a/TypographyView/FormReportDateOrders.cs b/TypographyView/FormReportDateOrders.cs new file mode 100644 index 0000000..c2f6b2a --- /dev/null +++ b/TypographyView/FormReportDateOrders.cs @@ -0,0 +1,75 @@ +using TypographyContracts.BindingModels; +using TypographyContracts.BusinessLogicsContracts; +using Microsoft.Extensions.Logging; +using Microsoft.Reporting.WinForms; + +namespace TypographyView +{ + 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 buttonToPDF_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/TypographyView/FormReportDateOrders.resx b/TypographyView/FormReportDateOrders.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/TypographyView/FormReportDateOrders.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/TypographyView/FormReportShopPrinteds.Designer.cs b/TypographyView/FormReportShopPrinteds.Designer.cs new file mode 100644 index 0000000..ad1dc8b --- /dev/null +++ b/TypographyView/FormReportShopPrinteds.Designer.cs @@ -0,0 +1,107 @@ +namespace TypographyPlantView +{ + partial class FormReportShopPrinteds + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + buttonSaveToExcel = new Button(); + dataGridView = new DataGridView(); + Shop = new DataGridViewTextBoxColumn(); + Printed = new DataGridViewTextBoxColumn(); + Count = new DataGridViewTextBoxColumn(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + SuspendLayout(); + // + // buttonSaveToExcel + // + buttonSaveToExcel.Location = new Point(14, 16); + buttonSaveToExcel.Margin = new Padding(3, 4, 3, 4); + buttonSaveToExcel.Name = "buttonSaveToExcel"; + buttonSaveToExcel.Size = new Size(146, 31); + buttonSaveToExcel.TabIndex = 0; + buttonSaveToExcel.Text = "Сохранить в Excel"; + buttonSaveToExcel.UseVisualStyleBackColor = true; + buttonSaveToExcel.Click += buttonSaveToExcel_Click; + // + // dataGridView + // + dataGridView.AllowUserToAddRows = false; + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Columns.AddRange(new DataGridViewColumn[] { Shop, Printed, Count }); + dataGridView.Location = new Point(14, 55); + dataGridView.Margin = new Padding(3, 4, 3, 4); + dataGridView.Name = "dataGridView"; + dataGridView.RowHeadersWidth = 51; + dataGridView.RowTemplate.Height = 25; + dataGridView.Size = new Size(887, 529); + dataGridView.TabIndex = 1; + // + // Shop + // + Shop.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + Shop.HeaderText = "Shop"; + Shop.MinimumWidth = 6; + Shop.Name = "Shop"; + // + // Printed + // + Printed.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + Printed.HeaderText = "Printed"; + Printed.MinimumWidth = 6; + Printed.Name = "Printed"; + // + // Count + // + Count.HeaderText = "Count"; + Count.MinimumWidth = 6; + Count.Name = "Count"; + Count.Width = 125; + // + // FormReportShopPrinteds + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(914, 600); + Controls.Add(dataGridView); + Controls.Add(buttonSaveToExcel); + Margin = new Padding(3, 4, 3, 4); + Name = "FormReportShopPrinteds"; + Text = "Отчет магазинов по изделиям"; + Load += FormReportShopPrinteds_Load; + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + } + + #endregion + + private Button buttonSaveToExcel; + private DataGridView dataGridView; + private DataGridViewTextBoxColumn Shop; + private DataGridViewTextBoxColumn Printed; + private DataGridViewTextBoxColumn Count; + } +} \ No newline at end of file diff --git a/TypographyView/FormReportShopPrinteds.cs b/TypographyView/FormReportShopPrinteds.cs new file mode 100644 index 0000000..9f68afc --- /dev/null +++ b/TypographyView/FormReportShopPrinteds.cs @@ -0,0 +1,72 @@ +using TypographyContracts.BindingModels; +using TypographyContracts.BusinessLogicsContracts; +using Microsoft.Extensions.Logging; + +namespace TypographyPlantView +{ + public partial class FormReportShopPrinteds : Form + { + private readonly ILogger _logger; + private readonly IReportLogic _logic; + + public FormReportShopPrinteds(ILogger logger, IReportLogic reportLogic) + { + InitializeComponent(); + _logger = logger; + _logic = reportLogic; + } + + private void buttonSaveToExcel_Click(object sender, EventArgs e) + { + using var dialog = new SaveFileDialog + { + Filter = "xlsx|*.xlsx" + }; + if (dialog.ShowDialog() == DialogResult.OK) + { + try + { + _logic.SaveShopPrintedsToExcelFile(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 FormReportShopPrinteds_Load(object sender, EventArgs e) + { + try + { + var dict = _logic.GetShopPrinteds(); + if (dict != null) + { + dataGridView.Rows.Clear(); + foreach (var elem in dict) + { + dataGridView.Rows.Add(new object[] { elem.ShopName, "", "" }); + foreach (var listElem in elem.Printeds) + { + 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); + } + } + } +} diff --git a/TypographyView/FormReportShopPrinteds.resx b/TypographyView/FormReportShopPrinteds.resx new file mode 100644 index 0000000..b5224af --- /dev/null +++ b/TypographyView/FormReportShopPrinteds.resx @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + \ No newline at end of file diff --git a/TypographyView/FormShop.cs b/TypographyView/FormShop.cs index f075aa6..0ce2405 100644 --- a/TypographyView/FormShop.cs +++ b/TypographyView/FormShop.cs @@ -3,10 +3,6 @@ using TypographyContracts.BusinessLogicsContracts; using Microsoft.Extensions.Logging; using TypographyContracts.SearchModels; using TypographyDataModels.Models; -using System.Windows.Forms; -using TypographyContracts.BindingModels; -using TypographyContracts.BusinessLogicsContracts; -using TypographyContracts.SearchModels; namespace TypographyView { diff --git a/TypographyView/FormShopSell.Designer.cs b/TypographyView/FormShopSell.Designer.cs index f1ac671..a53b94d 100644 --- a/TypographyView/FormShopSell.Designer.cs +++ b/TypographyView/FormShopSell.Designer.cs @@ -1,4 +1,4 @@ -namespace AutomobilePlantView +namespace TypographyView { partial class FormShopSell { diff --git a/TypographyView/FormShopSell.cs b/TypographyView/FormShopSell.cs index 0c73d6f..6618f04 100644 --- a/TypographyView/FormShopSell.cs +++ b/TypographyView/FormShopSell.cs @@ -11,7 +11,7 @@ using System.Text; using System.Threading.Tasks; using System.Windows.Forms; -namespace AutomobilePlantView +namespace TypographyView { public partial class FormShopSell : Form { diff --git a/TypographyView/FormShops.cs b/TypographyView/FormShops.cs index 2aa8923..d5db4a6 100644 --- a/TypographyView/FormShops.cs +++ b/TypographyView/FormShops.cs @@ -10,8 +10,6 @@ using System.Windows.Forms; using TypographyContracts.BindingModels; using TypographyContracts.BusinessLogicsContracts; using Microsoft.Extensions.Logging; -using TypographyView; - namespace TypographyView { diff --git a/TypographyView/Program.cs b/TypographyView/Program.cs index 19d9819..a325a12 100644 --- a/TypographyView/Program.cs +++ b/TypographyView/Program.cs @@ -8,6 +8,7 @@ using NLog.Extensions.Logging; using TypographyBusinessLogic.OfficePackage.Implements; using TypographyBusinessLogic.OfficePackage; using AbstractShopView; +using TypographyPlantView; namespace TypographyView { @@ -43,6 +44,13 @@ namespace TypographyView services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); services.AddTransient(); @@ -51,6 +59,12 @@ namespace TypographyView 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/TypographyView/ReportOrdersByDate.rdlc b/TypographyView/ReportOrdersByDate.rdlc new file mode 100644 index 0000000..4a037d2 --- /dev/null +++ b/TypographyView/ReportOrdersByDate.rdlc @@ -0,0 +1,424 @@ + + + 0 + + + + System.Data.DataSet + /* Local Connection */ + + 10791c83-cee8-4a38-bbd0-245fc17cefb3 + + + + + + TypographyContractsViewModels + /* Local Query */ + + + + DateCreate + System.DateTime + + + CountOrders + System.Decimal + + + SumOrders + System.Double + + + + TypographyContracts.ViewModels + ReportDateOrdersViewModel + TypographyContracts.ViewModels.ReportDateOrdersViewModel, TypographyContracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + + + + + + + + + true + true + + + + + Заказы + + + + + + + 1cm + 21cm + + + Middle + 2pt + 2pt + 2pt + 2pt + + + + + + + 6.01401cm + + + 6.56042cm + + + 6.12687cm + + + + + 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 + 1.95474cm + 1.16099cm + 1.2cm + 18.7013cm + 1 + + + + + + true + true + + + + + Всего: + + + + + + + 4cm + 11.23542cm + 0.6cm + 2.5cm + 2 + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + =Sum(Fields!SumOrders.Value, "DataSetOrders") + + + + + + + 4cm + 13.73542cm + 0.6cm + 6.12687cm + 3 + + + 2pt + 2pt + 2pt + 2pt + + + + 5.72875cm +