diff --git a/Pizzeria/Pizzeria/FormReportGroupedOrders.Designer.cs b/Pizzeria/Pizzeria/FormReportGroupedOrders.Designer.cs index ab3b828..f79dd7a 100644 --- a/Pizzeria/Pizzeria/FormReportGroupedOrders.Designer.cs +++ b/Pizzeria/Pizzeria/FormReportGroupedOrders.Designer.cs @@ -31,10 +31,6 @@ this.panel = new System.Windows.Forms.Panel(); this.buttonToPDF = new System.Windows.Forms.Button(); this.buttonMake = new System.Windows.Forms.Button(); - this.dateTimePickerTo = new System.Windows.Forms.DateTimePicker(); - this.labelTo = new System.Windows.Forms.Label(); - this.dateTimePickerFrom = new System.Windows.Forms.DateTimePicker(); - this.labelFrom = new System.Windows.Forms.Label(); this.panel.SuspendLayout(); this.SuspendLayout(); // @@ -42,10 +38,6 @@ // this.panel.Controls.Add(this.buttonToPDF); this.panel.Controls.Add(this.buttonMake); - this.panel.Controls.Add(this.dateTimePickerTo); - this.panel.Controls.Add(this.labelTo); - this.panel.Controls.Add(this.dateTimePickerFrom); - this.panel.Controls.Add(this.labelFrom); this.panel.Dock = System.Windows.Forms.DockStyle.Top; this.panel.Location = new System.Drawing.Point(0, 0); this.panel.Name = "panel"; @@ -54,9 +46,9 @@ // // buttonToPDF // - this.buttonToPDF.Location = new System.Drawing.Point(781, 9); + this.buttonToPDF.Location = new System.Drawing.Point(486, 12); this.buttonToPDF.Name = "buttonToPDF"; - this.buttonToPDF.Size = new System.Drawing.Size(165, 29); + this.buttonToPDF.Size = new System.Drawing.Size(411, 29); this.buttonToPDF.TabIndex = 5; this.buttonToPDF.Text = "В PDF"; this.buttonToPDF.UseVisualStyleBackColor = true; @@ -64,46 +56,14 @@ // // buttonMake // - this.buttonMake.Location = new System.Drawing.Point(542, 10); + this.buttonMake.Location = new System.Drawing.Point(49, 12); this.buttonMake.Name = "buttonMake"; - this.buttonMake.Size = new System.Drawing.Size(165, 29); + this.buttonMake.Size = new System.Drawing.Size(377, 29); this.buttonMake.TabIndex = 4; this.buttonMake.Text = "Сформировать"; this.buttonMake.UseVisualStyleBackColor = true; this.buttonMake.Click += new System.EventHandler(this.ButtonMake_Click); // - // dateTimePickerTo - // - this.dateTimePickerTo.Location = new System.Drawing.Point(300, 9); - this.dateTimePickerTo.Name = "dateTimePickerTo"; - this.dateTimePickerTo.Size = new System.Drawing.Size(199, 27); - this.dateTimePickerTo.TabIndex = 3; - // - // labelTo - // - this.labelTo.AutoSize = true; - this.labelTo.Location = new System.Drawing.Point(254, 14); - this.labelTo.Name = "labelTo"; - this.labelTo.Size = new System.Drawing.Size(27, 20); - this.labelTo.TabIndex = 2; - this.labelTo.Text = "по"; - // - // dateTimePickerFrom - // - this.dateTimePickerFrom.Location = new System.Drawing.Point(36, 9); - this.dateTimePickerFrom.Name = "dateTimePickerFrom"; - this.dateTimePickerFrom.Size = new System.Drawing.Size(199, 27); - this.dateTimePickerFrom.TabIndex = 1; - // - // labelFrom - // - this.labelFrom.AutoSize = true; - this.labelFrom.Location = new System.Drawing.Point(12, 14); - this.labelFrom.Name = "labelFrom"; - this.labelFrom.Size = new System.Drawing.Size(18, 20); - this.labelFrom.TabIndex = 0; - this.labelFrom.Text = "C"; - // // FormReportGroupedOrders // this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); @@ -113,7 +73,6 @@ this.Name = "FormReportGroupedOrders"; this.Text = "Отчёт по группированным заказам "; this.panel.ResumeLayout(false); - this.panel.PerformLayout(); this.ResumeLayout(false); } @@ -123,9 +82,5 @@ private Panel panel; private Button buttonToPDF; private Button buttonMake; - private DateTimePicker dateTimePickerTo; - private Label labelTo; - private DateTimePicker dateTimePickerFrom; - private Label labelFrom; } } \ No newline at end of file diff --git a/Pizzeria/Pizzeria/FormReportGroupedOrders.cs b/Pizzeria/Pizzeria/FormReportGroupedOrders.cs index 5f5cc96..03fd16e 100644 --- a/Pizzeria/Pizzeria/FormReportGroupedOrders.cs +++ b/Pizzeria/Pizzeria/FormReportGroupedOrders.cs @@ -36,27 +36,15 @@ namespace PizzeriaView } private void ButtonMake_Click(object sender, EventArgs e) { - if (dateTimePickerFrom.Value.Date >= dateTimePickerTo.Value.Date) - { - MessageBox.Show("Дата начала должна быть меньше даты окончания", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); - return; - } try { - var dataSource = _logic.GetGroupedOrders(new ReportBindingModel - { - DateFrom = dateTimePickerFrom.Value, - DateTo = dateTimePickerTo.Value - }); + var dataSource = _logic.GetGroupedOrders(); var source = new ReportDataSource("DataSetGroupedOrders", dataSource); reportViewer.LocalReport.DataSources.Clear(); reportViewer.LocalReport.DataSources.Add(source); - var parameters = new[] { new ReportParameter("ReportParameterPeriod", - $"c {dateTimePickerFrom.Value.ToShortDateString()} по {dateTimePickerTo.Value.ToShortDateString()}") }; - reportViewer.LocalReport.SetParameters(parameters); reportViewer.RefreshReport(); - _logger.LogInformation("Загрузка списка группированных заказов на период {From}-{To}", dateTimePickerFrom.Value.ToShortDateString(), dateTimePickerTo.Value.ToShortDateString()); + _logger.LogInformation("Загрузка списка группированных заказов"); } catch (Exception ex) { @@ -67,11 +55,6 @@ namespace PizzeriaView private void buttonToPDF_Click(object sender, EventArgs e) { - if (dateTimePickerFrom.Value.Date >= dateTimePickerTo.Value.Date) - { - MessageBox.Show("Дата начала должна быть меньше даты окончания", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); - return; - } using var dialog = new SaveFileDialog { Filter = "pdf|*.pdf" }; if (dialog.ShowDialog() == DialogResult.OK) { @@ -80,15 +63,13 @@ namespace PizzeriaView _logic.SaveGroupedOrdersToPdfFile(new ReportBindingModel { FileName = dialog.FileName, - DateFrom = dateTimePickerFrom.Value, - DateTo = dateTimePickerTo.Value }); - _logger.LogInformation("Сохранение списка группированных заказов на период {From}-{To}", dateTimePickerFrom.Value.ToShortDateString(), dateTimePickerTo.Value.ToShortDateString()); + _logger.LogInformation("Сохранение списка группированных заказов"); MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { - _logger.LogError(ex, "Ошибка сохранения списка группированных заказов на период"); + _logger.LogError(ex, "Ошибка сохранения списка группированных заказов"); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } diff --git a/Pizzeria/PizzeriaBusinessLogic/BusinessLogics/ReportLogic.cs b/Pizzeria/PizzeriaBusinessLogic/BusinessLogics/ReportLogic.cs index f85e34f..45f5e7a 100644 --- a/Pizzeria/PizzeriaBusinessLogic/BusinessLogics/ReportLogic.cs +++ b/Pizzeria/PizzeriaBusinessLogic/BusinessLogics/ReportLogic.cs @@ -100,13 +100,9 @@ namespace PizzeriaBusinessLogic.BusinessLogics }).ToList(); } - public List GetGroupedOrders(ReportBindingModel model) + public List GetGroupedOrders() { - return _orderStorage.GetFilteredList(new OrderSearchModel - { - DateFrom = model.DateFrom, - DateTo = model.DateTo - }).GroupBy(x => x.DateCreate.Date).Select(x => new ReportGroupOrdersViewModel + return _orderStorage.GetFullList().GroupBy(x => x.DateCreate.Date).Select(x => new ReportGroupOrdersViewModel { Date = x.Key, OrdersCount = x.Count(), @@ -140,9 +136,7 @@ namespace PizzeriaBusinessLogic.BusinessLogics { FileName = model.FileName, Title = "Список заказов сгруппированных по дате заказов", - DateFrom = model.DateFrom!.Value, - DateTo = model.DateTo!.Value, - GroupedOrders = GetGroupedOrders(model) + GroupedOrders = GetGroupedOrders() }); } } diff --git a/Pizzeria/PizzeriaBusinessLogic/Implements/SaveToWord.cs b/Pizzeria/PizzeriaBusinessLogic/Implements/SaveToWord.cs index f906a32..4dea4a6 100644 --- a/Pizzeria/PizzeriaBusinessLogic/Implements/SaveToWord.cs +++ b/Pizzeria/PizzeriaBusinessLogic/Implements/SaveToWord.cs @@ -155,7 +155,6 @@ namespace PizzeriaBusinessLogic.Implements return; TableRow docRow = new TableRow(); - TableCell docCell = new TableCell(); foreach (var column in rowParameters.Texts) { var docParagraph = new Paragraph(); @@ -183,7 +182,8 @@ namespace PizzeriaBusinessLogic.Implements docParagraph.AppendChild(docRun); } - + + TableCell docCell = new TableCell(); docCell.AppendChild(docParagraph); docRow.AppendChild(docCell); } diff --git a/Pizzeria/PizzeriaBusinessLogic/OfficePackage/AbstractSaveToPdf.cs b/Pizzeria/PizzeriaBusinessLogic/OfficePackage/AbstractSaveToPdf.cs index 813f43b..3aa04c4 100644 --- a/Pizzeria/PizzeriaBusinessLogic/OfficePackage/AbstractSaveToPdf.cs +++ b/Pizzeria/PizzeriaBusinessLogic/OfficePackage/AbstractSaveToPdf.cs @@ -44,7 +44,6 @@ namespace PizzeriaBusinessLogic.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 }); CreateTable(new List { "4cm", "3cm", "2cm" }); CreateRow(new PdfRowParameters diff --git a/Pizzeria/PizzeriaContracts/BusinessLogicsContracts/IReportLogic.cs b/Pizzeria/PizzeriaContracts/BusinessLogicsContracts/IReportLogic.cs index dcb8809..ed42df3 100644 --- a/Pizzeria/PizzeriaContracts/BusinessLogicsContracts/IReportLogic.cs +++ b/Pizzeria/PizzeriaContracts/BusinessLogicsContracts/IReportLogic.cs @@ -13,7 +13,7 @@ namespace PizzeriaContracts.BusinessLogicsContracts List GetPizzaComponents(); List GetOrders(ReportBindingModel model); List GetShops(); - List GetGroupedOrders(ReportBindingModel model); + List GetGroupedOrders(); void SavePizzasToWordFile(ReportBindingModel model); void SavePizzaComponentToExcelFile(ReportBindingModel model); void SaveOrdersToPdfFile(ReportBindingModel model);