From d25f62c217c821e07767b8ce80f93a5b9f2f816e Mon Sep 17 00:00:00 2001 From: Sergey Kozyrev Date: Fri, 19 Apr 2024 14:35:49 +0400 Subject: [PATCH] SOMEBADCODE --- .../BusinessLogic/ReportLogic.cs | 33 +- .../OfficePackage/AbstractSaveToExcel.cs | 6 +- .../OfficePackage/AbstractSaveToPdf.cs | 4 +- .../BusinessLogicsContracts/IReportLogic.cs | 3 +- .../SewingDressesView/MainForm.Designer.cs | 24 +- SewingDresses/SewingDressesView/MainForm.cs | 23 +- SewingDresses/SewingDressesView/Program.cs | 3 +- .../SewingDressesView/ReportOrders.rdlc | 444 +++++++++++++----- .../SewingDressesView/ReportOrdersByDate.rdlc | 425 +++++++++++++++++ .../ReportOrdersByDateForm.Designer.cs | 84 ++++ .../ReportOrdersByDateForm.cs | 74 +++ .../ReportOrdersByDateForm.resx | 120 +++++ .../ReportOrdersForm.Designer.cs | 47 +- .../SewingDressesView/ReportOrdersForm.cs | 26 +- .../ReportShopsDressesForm.cs | 8 +- 15 files changed, 1179 insertions(+), 145 deletions(-) create mode 100644 SewingDresses/SewingDressesView/ReportOrdersByDate.rdlc create mode 100644 SewingDresses/SewingDressesView/ReportOrdersByDateForm.Designer.cs create mode 100644 SewingDresses/SewingDressesView/ReportOrdersByDateForm.cs create mode 100644 SewingDresses/SewingDressesView/ReportOrdersByDateForm.resx diff --git a/SewingDresses/SewingDressesBusinessLogic/BusinessLogic/ReportLogic.cs b/SewingDresses/SewingDressesBusinessLogic/BusinessLogic/ReportLogic.cs index dc2ae4e..feb0144 100644 --- a/SewingDresses/SewingDressesBusinessLogic/BusinessLogic/ReportLogic.cs +++ b/SewingDresses/SewingDressesBusinessLogic/BusinessLogic/ReportLogic.cs @@ -53,7 +53,17 @@ namespace SewingDressesBusinessLogic.BusinessLogic } return list; } - public List GetOrders(ReportBindingModel model) + public List GetDatesOrders() + { + var a = _orderStorage.GetFullList(); + return a.GroupBy(x => x.DateCreate.Date).Select(x => new ReportDateOrdersViewModel + { + DateOfOrders = x.Key, + Count = x.Count(), + Sum = x.Sum(y => y.Sum) + }).ToList(); + } + public List GetOrders(ReportBindingModel model) { return _orderStorage.GetFilteredList(new OrderSearchModel { @@ -88,17 +98,26 @@ namespace SewingDressesBusinessLogic.BusinessLogic DressComponents = GetDressComponent() }) ; } - public void SaveOrdersToPdfFile(ReportBindingModel model) + public void SaveOrdersByDateToPdfFile(ReportBindingModel model) { - _saveToPdf.CreateDoc(new PdfInfo + _saveToPdf.CreateReportDateDoc(new PdfInfo { FileName = model.FileName, Title = "Список заказов", - DateFrom = model.DateFrom!.Value, - DateTo = model.DateTo!.Value, - Orders = GetOrders(model) - }); + DateOrders = GetDatesOrders(), + }); } + public void SaveOrdersToPdfFile(ReportBindingModel model) + { + _saveToPdf.CreateDoc(new PdfInfo + { + FileName = model.FileName, + Title = "Список заказов", + DateFrom = model.DateFrom!.Value, + DateTo = model.DateTo!.Value, + Orders = GetOrders(model) + }); + } public List GetShopsDresses() { var shops = _shopStorage.GetFullList(); diff --git a/SewingDresses/SewingDressesBusinessLogic/OfficePackage/AbstractSaveToExcel.cs b/SewingDresses/SewingDressesBusinessLogic/OfficePackage/AbstractSaveToExcel.cs index 6d36b06..91a1091 100644 --- a/SewingDresses/SewingDressesBusinessLogic/OfficePackage/AbstractSaveToExcel.cs +++ b/SewingDresses/SewingDressesBusinessLogic/OfficePackage/AbstractSaveToExcel.cs @@ -101,13 +101,13 @@ namespace SewingDressesBusinessLogic.OfficePackage StyleInfo = ExcelStyleInfoType.Text }); rowIndex++; - foreach (var iceCream in pc.Dresses) + foreach (var dress in pc.Dresses) { InsertCellInWorksheet(new ExcelCellParameters { ColumnName = "B", RowIndex = rowIndex, - Text = iceCream.Item1, + Text = dress.Item1, StyleInfo = ExcelStyleInfoType.TextWithBorder }); @@ -115,7 +115,7 @@ namespace SewingDressesBusinessLogic.OfficePackage { ColumnName = "C", RowIndex = rowIndex, - Text = iceCream.Item2.ToString(), + Text = dress.Item2.ToString(), StyleInfo = ExcelStyleInfoType.TextWithBorder }); diff --git a/SewingDresses/SewingDressesBusinessLogic/OfficePackage/AbstractSaveToPdf.cs b/SewingDresses/SewingDressesBusinessLogic/OfficePackage/AbstractSaveToPdf.cs index 30b01ce..e1ad133 100644 --- a/SewingDresses/SewingDressesBusinessLogic/OfficePackage/AbstractSaveToPdf.cs +++ b/SewingDresses/SewingDressesBusinessLogic/OfficePackage/AbstractSaveToPdf.cs @@ -11,8 +11,8 @@ namespace SewingDressesBusinessLogic.OfficePackage { CreatePdf(info); CreateParagraph(new PdfParagraph { Text = info.Title, Style = "NormalTitle", ParagraphAlignment = PdfParagraphAlignmentType.Center }); - CreateParagraph(new PdfParagraph { Text = $"с {info.DateFrom.ToShortDateString()} по {info.DateTo.ToShortDateString()}", Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Center }); - + CreateParagraph(new PdfParagraph { Text = $"с {info.DateFrom.ToShortDateString()} по {info.DateTo.ToShortDateString()}", Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Center }); + CreateTable(new List { "2cm", "3cm", "6cm", "4cm", "3cm" }); CreateRow(new PdfRowParameters diff --git a/SewingDresses/SewingDressesContracts/BusinessLogicsContracts/IReportLogic.cs b/SewingDresses/SewingDressesContracts/BusinessLogicsContracts/IReportLogic.cs index 0f4fde7..57f7721 100644 --- a/SewingDresses/SewingDressesContracts/BusinessLogicsContracts/IReportLogic.cs +++ b/SewingDresses/SewingDressesContracts/BusinessLogicsContracts/IReportLogic.cs @@ -13,7 +13,8 @@ namespace SewingDressesContracts.BusinessLogicsContracts void SaveComponentsToWordFile(ReportBindingModel model); void SaveDressComponentToExcelFile(ReportBindingModel model); void SaveOrdersToPdfFile(ReportBindingModel model); - void SaveShopsToWordFile(ReportBindingModel model); + void SaveOrdersByDateToPdfFile(ReportBindingModel model); + void SaveShopsToWordFile(ReportBindingModel model); void SaveShopsDressesToExcelFile(ReportBindingModel model); void SaveDatesOrdersToPdfFile(ReportBindingModel model); } diff --git a/SewingDresses/SewingDressesView/MainForm.Designer.cs b/SewingDresses/SewingDressesView/MainForm.Designer.cs index 4df7d11..5b65744 100644 --- a/SewingDresses/SewingDressesView/MainForm.Designer.cs +++ b/SewingDresses/SewingDressesView/MainForm.Designer.cs @@ -46,6 +46,8 @@ компонентыПоИзделиямToolStripMenuItem = new ToolStripMenuItem(); списокЗаказовToolStripMenuItem = new ToolStripMenuItem(); списокПлатьевПоМагазинамToolStripMenuItem = new ToolStripMenuItem(); + списокЗаказовПоДатамToolStripMenuItem = new ToolStripMenuItem(); + списокПлатьевToolStripMenuItem = new ToolStripMenuItem(); ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); menuStrip1.SuspendLayout(); SuspendLayout(); @@ -164,7 +166,7 @@ // // отчетыToolStripMenuItem // - отчетыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { DressesReportToolStripMenuItem, компонентыПоИзделиямToolStripMenuItem, списокЗаказовToolStripMenuItem, списокПлатьевПоМагазинамToolStripMenuItem }); + отчетыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { DressesReportToolStripMenuItem, компонентыПоИзделиямToolStripMenuItem, списокЗаказовToolStripMenuItem, списокПлатьевПоМагазинамToolStripMenuItem, списокЗаказовПоДатамToolStripMenuItem, списокПлатьевToolStripMenuItem }); отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem"; отчетыToolStripMenuItem.Size = new Size(73, 24); отчетыToolStripMenuItem.Text = "Отчеты"; @@ -173,8 +175,8 @@ // DressesReportToolStripMenuItem.Name = "DressesReportToolStripMenuItem"; DressesReportToolStripMenuItem.Size = new Size(304, 26); - DressesReportToolStripMenuItem.Text = "Список платьев"; - DressesReportToolStripMenuItem.Click += DressesToolStripMenuItemReport_Click; + DressesReportToolStripMenuItem.Text = "Список магазинов"; + DressesReportToolStripMenuItem.Click += ShopsToolStripMenuItemReport_Click; // // компонентыПоИзделиямToolStripMenuItem // @@ -197,6 +199,20 @@ списокПлатьевПоМагазинамToolStripMenuItem.Text = "Список платьев по магазинам"; списокПлатьевПоМагазинамToolStripMenuItem.Click += DressesToShopStripMenuItem_Click; // + // списокЗаказовПоДатамToolStripMenuItem + // + списокЗаказовПоДатамToolStripMenuItem.Name = "списокЗаказовПоДатамToolStripMenuItem"; + списокЗаказовПоДатамToolStripMenuItem.Size = new Size(304, 26); + списокЗаказовПоДатамToolStripMenuItem.Text = "Список заказов по датам"; + списокЗаказовПоДатамToolStripMenuItem.Click += OrdersByDateToolStripMenuItemReport_Click; + // + // списокПлатьевToolStripMenuItem + // + списокПлатьевToolStripMenuItem.Name = "списокПлатьевToolStripMenuItem"; + списокПлатьевToolStripMenuItem.Size = new Size(304, 26); + списокПлатьевToolStripMenuItem.Text = "Список платьев"; + списокПлатьевToolStripMenuItem.Click += DressesToolStripMenuItemReport_Click; + // // MainForm // AutoScaleDimensions = new SizeF(8F, 20F); @@ -240,5 +256,7 @@ private ToolStripMenuItem поставкиToolStripMenuItem; private ToolStripMenuItem продажаToolStripMenuItem; private ToolStripMenuItem списокПлатьевПоМагазинамToolStripMenuItem; + private ToolStripMenuItem списокЗаказовПоДатамToolStripMenuItem; + private ToolStripMenuItem списокПлатьевToolStripMenuItem; } } \ No newline at end of file diff --git a/SewingDresses/SewingDressesView/MainForm.cs b/SewingDresses/SewingDressesView/MainForm.cs index 9ba3c84..6e6dcaf 100644 --- a/SewingDresses/SewingDressesView/MainForm.cs +++ b/SewingDresses/SewingDressesView/MainForm.cs @@ -182,8 +182,16 @@ namespace SewingDressesView form.ShowDialog(); } } + private void OrdersByDateToolStripMenuItemReport_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(ReportOrdersByDateForm)); + if (service is ReportOrdersByDateForm form) + { + form.ShowDialog(); + } + } - private void DressesToolStripMenuItemReport_Click(object sender, EventArgs e) + private void ShopsToolStripMenuItemReport_Click(object sender, EventArgs e) { using var dialog = new SaveFileDialog { Filter = "docx|*.docx" }; if (dialog.ShowDialog() == DialogResult.OK) @@ -213,5 +221,18 @@ namespace SewingDressesView form.ShowDialog(); } } + + private void DressesToolStripMenuItemReport_Click(object sender, EventArgs e) + { + using var dialog = new SaveFileDialog { Filter = "docx|*.docx" }; + if (dialog.ShowDialog() == DialogResult.OK) + { + _reportLogic.SaveComponentsToWordFile(new ReportBindingModel + { + FileName = dialog.FileName + }); + MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + } } } diff --git a/SewingDresses/SewingDressesView/Program.cs b/SewingDresses/SewingDressesView/Program.cs index 49530c6..474b787 100644 --- a/SewingDresses/SewingDressesView/Program.cs +++ b/SewingDresses/SewingDressesView/Program.cs @@ -51,8 +51,9 @@ namespace SewingDressesView services.AddTransient(); services.AddTransient(); services.AddTransient(); - services.AddTransient(); + services.AddTransient(); services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); diff --git a/SewingDresses/SewingDressesView/ReportOrders.rdlc b/SewingDresses/SewingDressesView/ReportOrders.rdlc index 77fd621..12d2edf 100644 --- a/SewingDresses/SewingDressesView/ReportOrders.rdlc +++ b/SewingDresses/SewingDressesView/ReportOrders.rdlc @@ -17,17 +17,25 @@ /* Local Query */ - - DateOfOrders + + Id + System.Int32 + + + DateCreate System.DateTime - - Count - System.Decimal + + DressName + System.String + + + Status + System.String Sum - System.Double + System.Decimal @@ -41,7 +49,7 @@ - + true true @@ -49,48 +57,175 @@ Заказы - + + + + + + - Middle 2pt 2pt 2pt 2pt - + - 3cm + 5.50333cm - 3cm + 5.50333cm - 7cm + 4.62938cm + + + 2.90217cm + + + 6.1195cm - 0.6cm + 1.235cm + + + + true + true + + + + + Номер + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Дата создания + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Изделие + + + 2pt + 2pt + 2pt + 2pt + + + + @@ -100,10 +235,17 @@ - Дата - + Статус + - - - - - 2pt - 2pt - 2pt - 2pt - - - - - - - + true true @@ -165,15 +275,22 @@ Сумма - + + =Fields!Id.Value + - - 2pt - 2pt - 2pt - 2pt - - - - - - - - true - true - - =Fields!Count.Value + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!DressName.Value + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!Status.Value + + + 2pt + 2pt + 2pt + 2pt + + + + + + + true true @@ -270,7 +454,7 @@ + - + true true - Всего: - + =Parameters!ReportParameterPeriod.Value + - 4.24cm - 8.55245cm - 0.6cm - 2.5cm + 0.77639cm + 0.70583cm + 25.53401cm 2 - + true true - =Sum(Fields!Sum.Value, "DataSetOrders") - + Итого: + + + + true + true + + + + + =Sum(Fields!Sum.Value, "DataSetOrders") + + + 2pt + 2pt + 2pt + 2pt + + - 2in + 2.81911in + + + + + + 0.24cm + 1cm + 21cm + + + Middle + 2pt + 2pt + 2pt + 2pt + + + + + + + 3cm + + + 3cm + + + 7cm + + + + + 0.6cm + + + + + true + true + + + + + Дата + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Количество + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Сумма + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + 0.6cm + + + + + true + true + + + + + =Fields!DateOfOrders.Value + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!Count.Value + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!Sum.Value + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + + + + + + + + + + + + After + + + + + + + DataSetOrders + 2.72391cm + 0.55245cm + 1.2cm + 13cm + 1 + + + + + + true + true + + + + + Всего: + + + + + + + 4.24cm + 8.55245cm + 0.6cm + 2.5cm + 2 + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + =Sum(Fields!Sum.Value, "DataSetOrders") + + + + + + + 4.24cm + 11.05245cm + 0.6cm + 2.5cm + 3 + + + 2pt + 2pt + 2pt + 2pt + + + + 2in +