From 14a2a0683f827a92e74807fa3e646a284fcc3ccd Mon Sep 17 00:00:00 2001 From: prodigygirl Date: Sat, 8 Apr 2023 17:46:40 +0400 Subject: [PATCH 1/2] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5:=20=D1=83=D0=B1=D1=80=D0=B0=D0=BD=20?= =?UTF-8?q?=D0=BF=D0=B5=D1=80=D0=B8=D0=BE=D0=B4=20=D0=BF=D0=BE=20=D0=BD?= =?UTF-8?q?=D0=BE=D0=B2=D0=BE=D0=BC=D1=83=20=D0=BE=D1=82=D1=87=D0=B5=D1=82?= =?UTF-8?q?=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FormReportCountOrdersByPeriod.Designer.cs | 49 ------------------- .../FormReportCountOrdersByPeriod.cs | 31 +++--------- .../OfficePackage/AbstractSaveToExcel.cs | 47 +----------------- .../OfficePackage/AbstractSaveToPdf.cs | 37 +++----------- .../ReportLogic.cs | 8 ++- .../BusinessLogicsContarcts/IReportLogic.cs | 2 +- 6 files changed, 20 insertions(+), 154 deletions(-) diff --git a/FurnitureAssembly/FurnitureAssembly/FormReportCountOrdersByPeriod.Designer.cs b/FurnitureAssembly/FurnitureAssembly/FormReportCountOrdersByPeriod.Designer.cs index cf6cc18..bbf9bc8 100644 --- a/FurnitureAssembly/FurnitureAssembly/FormReportCountOrdersByPeriod.Designer.cs +++ b/FurnitureAssembly/FurnitureAssembly/FormReportCountOrdersByPeriod.Designer.cs @@ -33,10 +33,6 @@ this.button1 = new System.Windows.Forms.Button(); 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(); // @@ -46,10 +42,6 @@ this.panel.Controls.Add(this.button1); 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.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); @@ -102,42 +94,6 @@ this.buttonMake.UseVisualStyleBackColor = true; this.buttonMake.Click += new System.EventHandler(this.buttonMake_Click); // - // dateTimePickerTo - // - this.dateTimePickerTo.Location = new System.Drawing.Point(237, 7); - this.dateTimePickerTo.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); - this.dateTimePickerTo.Name = "dateTimePickerTo"; - this.dateTimePickerTo.Size = new System.Drawing.Size(163, 23); - this.dateTimePickerTo.TabIndex = 3; - // - // labelTo - // - this.labelTo.AutoSize = true; - this.labelTo.Location = new System.Drawing.Point(208, 10); - this.labelTo.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); - this.labelTo.Name = "labelTo"; - this.labelTo.Size = new System.Drawing.Size(21, 15); - this.labelTo.TabIndex = 2; - this.labelTo.Text = "по"; - // - // dateTimePickerFrom - // - this.dateTimePickerFrom.Location = new System.Drawing.Point(37, 7); - this.dateTimePickerFrom.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); - this.dateTimePickerFrom.Name = "dateTimePickerFrom"; - this.dateTimePickerFrom.Size = new System.Drawing.Size(163, 23); - this.dateTimePickerFrom.TabIndex = 1; - // - // labelFrom - // - this.labelFrom.AutoSize = true; - this.labelFrom.Location = new System.Drawing.Point(14, 10); - this.labelFrom.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); - this.labelFrom.Name = "labelFrom"; - this.labelFrom.Size = new System.Drawing.Size(15, 15); - this.labelFrom.TabIndex = 0; - this.labelFrom.Text = "С"; - // // FormReportCountOrdersByPeriod // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); @@ -147,7 +103,6 @@ this.Name = "FormReportCountOrdersByPeriod"; this.Text = "Заказы по датам"; this.panel.ResumeLayout(false); - this.panel.PerformLayout(); this.ResumeLayout(false); } @@ -158,10 +113,6 @@ private Button button1; private Button buttonToPdf; private Button buttonMake; - private DateTimePicker dateTimePickerTo; - private Label labelTo; - private DateTimePicker dateTimePickerFrom; - private Label labelFrom; private Button buttonMake_Pdf; } } \ No newline at end of file diff --git a/FurnitureAssembly/FurnitureAssembly/FormReportCountOrdersByPeriod.cs b/FurnitureAssembly/FurnitureAssembly/FormReportCountOrdersByPeriod.cs index b432798..20afddd 100644 --- a/FurnitureAssembly/FurnitureAssembly/FormReportCountOrdersByPeriod.cs +++ b/FurnitureAssembly/FurnitureAssembly/FormReportCountOrdersByPeriod.cs @@ -38,28 +38,17 @@ namespace FurnitureAssembly } 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.GetCountOrders(new ReportBindingModel - { - DateFrom = dateTimePickerFrom.Value, - DateTo = dateTimePickerTo.Value - }); + var dataSource = _logic.GetCountOrders(); var source = new ReportDataSource("DataSetOrders", 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) { @@ -70,11 +59,7 @@ namespace FurnitureAssembly 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) { @@ -82,11 +67,9 @@ namespace FurnitureAssembly { _logic.SaveCountOrdersToPdfFile(new ReportBindingModel { - FileName = dialog.FileName, - DateFrom = dateTimePickerFrom.Value, - DateTo = dateTimePickerTo.Value + FileName = dialog.FileName }); - _logger.LogInformation("Сохранение списка заказов на период {From}-{To}", dateTimePickerFrom.Value.ToShortDateString(), dateTimePickerTo.Value.ToShortDateString()); + _logger.LogInformation("Сохранение списка заказов"); MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) diff --git a/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/AbstractSaveToExcel.cs b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/AbstractSaveToExcel.cs index 0acd7c9..57311f3 100644 --- a/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/AbstractSaveToExcel.cs +++ b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/AbstractSaveToExcel.cs @@ -39,52 +39,7 @@ namespace FurnitureAssemblyBusinessLogic.OfficePackage { CreateExcelCellsShops(infoShops, rowIndex); } - /* foreach (var pc in info.FurnitureComponents) - { - InsertCellInWorksheet(new ExcelCellParameters - { - ColumnName = "A", - RowIndex = rowIndex, - Text = pc.FurnitureName, - StyleInfo = ExcelStyleInfoType.Text - }); - rowIndex++; - foreach (var product in pc.Components) - { - InsertCellInWorksheet(new ExcelCellParameters - { - ColumnName = "B", - RowIndex = rowIndex, - Text = product.Item1, - StyleInfo = - ExcelStyleInfoType.TextWithBroder - }); - InsertCellInWorksheet(new ExcelCellParameters - { - ColumnName = "C", - RowIndex = rowIndex, - Text = product.Item2.ToString(), - StyleInfo = - ExcelStyleInfoType.TextWithBroder - }); - rowIndex++; - } - InsertCellInWorksheet(new ExcelCellParameters - { - ColumnName = "A", - RowIndex = rowIndex, - Text = "Итого", - StyleInfo = ExcelStyleInfoType.Text - }); - InsertCellInWorksheet(new ExcelCellParameters - { - ColumnName = "C", - RowIndex = rowIndex, - Text = pc.TotalCount.ToString(), - StyleInfo = ExcelStyleInfoType.Text - }); - rowIndex++; - }*/ + SaveExcel(info); } private void CreateExcelCellsFurnitures(ExcelInfoFurnitures info, uint rowIndex) diff --git a/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/AbstractSaveToPdf.cs b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/AbstractSaveToPdf.cs index 668dca4..1ed861d 100644 --- a/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/AbstractSaveToPdf.cs +++ b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/AbstractSaveToPdf.cs @@ -20,41 +20,20 @@ namespace FurnitureAssemblyBusinessLogic.OfficePackage Style = "NormalTitle", ParagraphAlignment = PdfParagraphAlignmentType.Center }); - CreateParagraph(new PdfParagraph - { - Text = $"с { info.DateFrom.ToShortDateString() } по { info.DateTo.ToShortDateString() }", Style = "Normal", - ParagraphAlignment = PdfParagraphAlignmentType.Center - }); + if (info is PdfInfoOrders infoOrders) { + CreateParagraph(new PdfParagraph + { + Text = $"с { info.DateFrom.ToShortDateString() } по { info.DateTo.ToShortDateString() }", + Style = "Normal", + ParagraphAlignment = PdfParagraphAlignmentType.Center + }); CreateDocOrders(infoOrders); } else if (info is PdfInfoCountOrders countOrders) { CreateDocCountOrders(countOrders); - } - /* CreateTable(new List { "2cm", "3cm", "6cm", "3cm", "3cm" }); - CreateRow(new PdfRowParameters - { - Texts = new List { "Номер", "Дата заказа", "Изделие", "Статус", "Сумма" }, - Style = "NormalTitle", - ParagraphAlignment = PdfParagraphAlignmentType.Center - }); - foreach (var order in info.Orders) - { - CreateRow(new PdfRowParameters - { - Texts = new List { order.Id.ToString(), order.DateCreate.ToShortDateString(), order.FurnitureName, order.OrderStatus, order.Sum.ToString() }, - Style = "Normal", - ParagraphAlignment = PdfParagraphAlignmentType.Left - }); - } - CreateParagraph(new PdfParagraph - { - Text = $"Итого: {info.Orders.Sum(x => x.Sum)}\t", - Style = "Normal", - ParagraphAlignment = - PdfParagraphAlignmentType.Right - });*/ + } SavePdf(info); } diff --git a/FurnitureAssembly/FurnitureAssemblyBusinessLogic/ReportLogic.cs b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/ReportLogic.cs index d70e3f5..e65aa00 100644 --- a/FurnitureAssembly/FurnitureAssemblyBusinessLogic/ReportLogic.cs +++ b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/ReportLogic.cs @@ -165,7 +165,7 @@ namespace FurnitureAssemblyBusinessLogic return list; } - public List GetCountOrders(ReportBindingModel model) + public List GetCountOrders() { return _orderStorage.GetFullList().GroupBy(x => x.DateCreate.Date).Select(x => new ReportCountOrdersViewModel { @@ -179,10 +179,8 @@ namespace FurnitureAssemblyBusinessLogic _saveToPdf.CreateDoc(new PdfInfoCountOrders { FileName = model.FileName, - Title = "Список объединенных по дате заказов", - DateFrom = model.DateFrom!.Value, - DateTo = model.DateTo!.Value, - CountOrders = GetCountOrders(model) + Title = "Список объединенных по дате заказов", + CountOrders = GetCountOrders() }); } } diff --git a/FurnitureAssembly/FurnitureAssemblyContracts/BusinessLogicsContarcts/IReportLogic.cs b/FurnitureAssembly/FurnitureAssemblyContracts/BusinessLogicsContarcts/IReportLogic.cs index ce04cc0..4ba09d0 100644 --- a/FurnitureAssembly/FurnitureAssemblyContracts/BusinessLogicsContarcts/IReportLogic.cs +++ b/FurnitureAssembly/FurnitureAssemblyContracts/BusinessLogicsContarcts/IReportLogic.cs @@ -39,7 +39,7 @@ namespace FurnitureAssemblyContracts.BusinessLogicsContarcts /// /// /// - List GetCountOrders(ReportBindingModel model); + List GetCountOrders(); void SaveCountOrdersToPdfFile(ReportBindingModel model); } } From d3e8f2dd1935d9a00309b3078f9035fc87adc7bd Mon Sep 17 00:00:00 2001 From: pgirl1 Date: Sun, 26 Mar 2023 20:12:34 -0900 Subject: [PATCH 2/2] CommitDelete --- .../FurnitureAssemblyDatabase.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FurnitureAssembly/FurnitureAssemblyDatabaseImplement/FurnitureAssemblyDatabase.cs b/FurnitureAssembly/FurnitureAssemblyDatabaseImplement/FurnitureAssemblyDatabase.cs index 47dd565..16cd67d 100644 --- a/FurnitureAssembly/FurnitureAssemblyDatabaseImplement/FurnitureAssemblyDatabase.cs +++ b/FurnitureAssembly/FurnitureAssemblyDatabaseImplement/FurnitureAssemblyDatabase.cs @@ -14,7 +14,7 @@ namespace FurnitureAssemblyDatabaseImplement { if (optionsBuilder.IsConfigured == false) { - optionsBuilder.UseSqlServer(@"Data Source=zhu\SQLEXPRESS;Initial Catalog=FurnitureAssemblyDatabaseFull;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True"); + optionsBuilder.UseSqlServer(@"Data Source=localhost\SQLEXPRESS;Initial Catalog=FurnitureAssemblyDatabaseFull;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True"); } base.OnConfiguring(optionsBuilder); }