From b630b2bbf00696f49565d5c8217b847c2dd2410f Mon Sep 17 00:00:00 2001 From: goldfest Date: Fri, 22 Mar 2024 19:04:16 +0400 Subject: [PATCH] =?UTF-8?q?=D0=B3=D0=BE=D1=82=D0=BE=D0=B2=D0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TravelCompany/TravelCompany/FormMain.cs | 2 +- .../FormReportOrders.Designer.cs | 142 +++++++++--------- .../TravelCompany/FormReportOrders.cs | 25 ++- .../TravelCompany/FormReportOrders.resx | 62 +------- .../FormReportTravelComponents.Designer.cs | 4 +- .../FormReportTravelComponents.cs | 55 +++---- TravelCompany/TravelCompany/ReportOrders.rdlc | 6 +- .../BusinessLogic/ReportLogic.cs | 57 +++---- .../OfficePackage/AbstractSaveToExcel.cs | 4 +- .../OfficePackage/AbstractSaveToPdf.cs | 20 +-- .../OfficePackage/AbstractSaveToWord.cs | 4 +- .../HelperEnums/PdfParagraphAlignmentType.cs | 2 +- .../OfficePackage/HelperModels/WordInfo.cs | 2 +- .../OfficePackage/Implements/SaveToPdf.cs | 2 +- .../BusinessLogicsContracts/IReportLogic.cs | 4 +- .../ViewModels/ReportOrdersViewModel.cs | 3 +- .../ReportTravelComponentViewModel.cs | 5 +- 17 files changed, 157 insertions(+), 242 deletions(-) diff --git a/TravelCompany/TravelCompany/FormMain.cs b/TravelCompany/TravelCompany/FormMain.cs index be59c78..744ae02 100644 --- a/TravelCompany/TravelCompany/FormMain.cs +++ b/TravelCompany/TravelCompany/FormMain.cs @@ -160,7 +160,7 @@ namespace TravelCompany.Forms using var dialog = new SaveFileDialog { Filter = "docx|*.docx" }; if (dialog.ShowDialog() == DialogResult.OK) { - _reportLogic.SaveComponentsToWordFile(new ReportBindingModel + _reportLogic.SaveTravelsToWordFile(new ReportBindingModel { FileName = dialog.FileName }); diff --git a/TravelCompany/TravelCompany/FormReportOrders.Designer.cs b/TravelCompany/TravelCompany/FormReportOrders.Designer.cs index 181939d..10fe141 100644 --- a/TravelCompany/TravelCompany/FormReportOrders.Designer.cs +++ b/TravelCompany/TravelCompany/FormReportOrders.Designer.cs @@ -28,102 +28,110 @@ /// private void InitializeComponent() { - panel = new Panel(); - buttonCreateToPdf = new Button(); - buttonCreateReport = new Button(); - label2 = new Label(); - label1 = new Label(); - dateTimePickerFrom = new DateTimePicker(); - dateTimePickerTo = new DateTimePicker(); - panel.SuspendLayout(); - SuspendLayout(); + this.panel = new System.Windows.Forms.Panel(); + this.buttonCreateToPdf = new System.Windows.Forms.Button(); + this.buttonCreateReport = new System.Windows.Forms.Button(); + this.label2 = new System.Windows.Forms.Label(); + this.label1 = new System.Windows.Forms.Label(); + this.dateTimePickerEnd = new System.Windows.Forms.DateTimePicker(); + this.dateTimePickerStart = new System.Windows.Forms.DateTimePicker(); + this.panel.SuspendLayout(); + this.SuspendLayout(); // // panel // - panel.Controls.Add(buttonCreateToPdf); - panel.Controls.Add(buttonCreateReport); - panel.Controls.Add(label2); - panel.Controls.Add(label1); - panel.Controls.Add(dateTimePickerFrom); - panel.Controls.Add(dateTimePickerTo); - panel.Location = new Point(12, 12); - panel.Name = "panel"; - panel.Size = new Size(776, 43); - panel.TabIndex = 0; + this.panel.Controls.Add(this.buttonCreateToPdf); + this.panel.Controls.Add(this.buttonCreateReport); + this.panel.Controls.Add(this.label2); + this.panel.Controls.Add(this.label1); + this.panel.Controls.Add(this.dateTimePickerEnd); + this.panel.Controls.Add(this.dateTimePickerStart); + 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(3, 2, 3, 2); + this.panel.Name = "panel"; + this.panel.Size = new System.Drawing.Size(861, 56); + this.panel.TabIndex = 0; // // buttonCreateToPdf // - buttonCreateToPdf.Location = new Point(623, 17); - buttonCreateToPdf.Name = "buttonCreateToPdf"; - buttonCreateToPdf.Size = new Size(150, 23); - buttonCreateToPdf.TabIndex = 5; - buttonCreateToPdf.Text = "В Pdf"; - buttonCreateToPdf.UseVisualStyleBackColor = true; - buttonCreateToPdf.Click += buttonCreateToPdf_Click; + this.buttonCreateToPdf.Location = new System.Drawing.Point(684, 29); + this.buttonCreateToPdf.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.buttonCreateToPdf.Name = "buttonCreateToPdf"; + this.buttonCreateToPdf.Size = new System.Drawing.Size(166, 23); + this.buttonCreateToPdf.TabIndex = 5; + this.buttonCreateToPdf.Text = "PDF"; + this.buttonCreateToPdf.UseVisualStyleBackColor = true; + this.buttonCreateToPdf.Click += new System.EventHandler(this.buttonCreateToPdf_Click); // // buttonCreateReport // - buttonCreateReport.Location = new Point(470, 17); - buttonCreateReport.Name = "buttonCreateReport"; - buttonCreateReport.Size = new Size(147, 23); - buttonCreateReport.TabIndex = 4; - buttonCreateReport.Text = "Сформировать"; - buttonCreateReport.UseVisualStyleBackColor = true; - buttonCreateReport.Click += buttonCreateReport_Click; + this.buttonCreateReport.Location = new System.Drawing.Point(485, 29); + this.buttonCreateReport.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.buttonCreateReport.Name = "buttonCreateReport"; + this.buttonCreateReport.Size = new System.Drawing.Size(166, 23); + this.buttonCreateReport.TabIndex = 4; + this.buttonCreateReport.Text = "Сформировать"; + this.buttonCreateReport.UseVisualStyleBackColor = true; + this.buttonCreateReport.Click += new System.EventHandler(this.buttonCreateReport_Click); // // label2 // - label2.AutoSize = true; - label2.Location = new Point(235, 23); - label2.Name = "label2"; - label2.Size = new Size(23, 15); - label2.TabIndex = 3; - label2.Text = "По"; + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(323, 7); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(44, 15); + this.label2.TabIndex = 3; + this.label2.Text = "Конец:"; // // label1 // - label1.AutoSize = true; - label1.Location = new Point(8, 23); - label1.Name = "label1"; - label1.Size = new Size(15, 15); - label1.TabIndex = 2; - label1.Text = "С"; + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(76, 4); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(52, 15); + this.label1.TabIndex = 2; + this.label1.Text = "Начало:"; // - // dateTimePickerFrom + // dateTimePickerEnd // - dateTimePickerFrom.Location = new Point(29, 17); - dateTimePickerFrom.Name = "dateTimePickerFrom"; - dateTimePickerFrom.Size = new Size(200, 23); - dateTimePickerFrom.TabIndex = 0; + this.dateTimePickerEnd.Location = new System.Drawing.Point(269, 29); + this.dateTimePickerEnd.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.dateTimePickerEnd.Name = "dateTimePickerEnd"; + this.dateTimePickerEnd.Size = new System.Drawing.Size(164, 23); + this.dateTimePickerEnd.TabIndex = 1; // - // dateTimePickerTo + // dateTimePickerStart // - dateTimePickerTo.Location = new Point(264, 17); - dateTimePickerTo.Name = "dateTimePickerTo"; - dateTimePickerTo.Size = new Size(200, 23); - dateTimePickerTo.TabIndex = 1; + this.dateTimePickerStart.Location = new System.Drawing.Point(31, 29); + this.dateTimePickerStart.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.dateTimePickerStart.Name = "dateTimePickerStart"; + this.dateTimePickerStart.Size = new System.Drawing.Size(164, 23); + this.dateTimePickerStart.TabIndex = 0; // // FormReportOrders // - AutoScaleDimensions = new SizeF(7F, 15F); - AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(800, 450); - Controls.Add(panel); - Name = "FormReportOrders"; - Text = "Заказы"; - panel.ResumeLayout(false); - panel.PerformLayout(); - ResumeLayout(false); + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(861, 338); + this.Controls.Add(this.panel); + this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.Name = "FormReportOrders"; + this.Text = "Заказы"; + this.panel.ResumeLayout(false); + this.panel.PerformLayout(); + this.ResumeLayout(false); + } #endregion private Panel panel; + private DateTimePicker dateTimePickerEnd; + private DateTimePicker dateTimePickerStart; private Button buttonCreateToPdf; private Button buttonCreateReport; private Label label2; private Label label1; - private DateTimePicker dateTimePickerFrom; - private DateTimePicker dateTimePickerTo; } -} +} \ No newline at end of file diff --git a/TravelCompany/TravelCompany/FormReportOrders.cs b/TravelCompany/TravelCompany/FormReportOrders.cs index 9b82313..f52301f 100644 --- a/TravelCompany/TravelCompany/FormReportOrders.cs +++ b/TravelCompany/TravelCompany/FormReportOrders.cs @@ -11,8 +11,6 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; -using TravelCompanyContracts.BindingModels; -using TravelCompanyContracts.BusinessLogicsContracts; namespace TravelCompany.Forms { @@ -31,10 +29,7 @@ namespace TravelCompany.Forms { Dock = DockStyle.Fill }; - using (var fileStream = new FileStream("C:\\Users\\goldfest\\Desktop\\RPP\\TravelCompany\\TravelCompany\\ReportOrders.rdlc", FileMode.Open)) - { - reportViewer.LocalReport.LoadReportDefinition(fileStream); - } + reportViewer.LocalReport.LoadReportDefinition(new FileStream("C:\\Users\\goldfest\\Desktop\\TravelCompany\\PrecastConcretePlant\\PrecastConcretePlantView\\ReportOrders.rdlc", FileMode.Open)); Controls.Clear(); Controls.Add(reportViewer); Controls.Add(panel); @@ -42,7 +37,7 @@ namespace TravelCompany.Forms private void buttonCreateReport_Click(object sender, EventArgs e) { - if (dateTimePickerFrom.Value.Date >= dateTimePickerTo.Value.Date) + if (dateTimePickerStart.Value.Date >= dateTimePickerEnd.Value.Date) { MessageBox.Show("Дата начала должна быть меньше даты окончания", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; @@ -51,16 +46,16 @@ namespace TravelCompany.Forms { var dataSource = _logic.GetOrders(new ReportBindingModel { - DateFrom = dateTimePickerFrom.Value, - DateTo = dateTimePickerTo.Value + DateFrom = dateTimePickerStart.Value, + DateTo = dateTimePickerEnd.Value }); 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()}") }; + var parameters = new[] { new ReportParameter("ReportParameterPeriod", $"c{dateTimePickerStart.Value.ToShortDateString()} по {dateTimePickerEnd.Value.ToShortDateString()}") }; reportViewer.LocalReport.SetParameters(parameters); reportViewer.RefreshReport(); - _logger.LogInformation("Загрузка списка заказов на период {From}-{ To}", dateTimePickerFrom.Value.ToShortDateString(), dateTimePickerTo.Value.ToShortDateString()); + _logger.LogInformation("Загрузка списка заказов на период {From}-{ To}", dateTimePickerStart.Value.ToShortDateString(), dateTimePickerEnd.Value.ToShortDateString()); } catch (Exception ex) { @@ -73,7 +68,7 @@ namespace TravelCompany.Forms private void buttonCreateToPdf_Click(object sender, EventArgs e) { - if (dateTimePickerFrom.Value.Date >= dateTimePickerTo.Value.Date) + if (dateTimePickerStart.Value.Date >= dateTimePickerEnd.Value.Date) { MessageBox.Show("Дата начала должна быть меньше даты окончания", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; @@ -89,10 +84,10 @@ namespace TravelCompany.Forms _logic.SaveOrdersToPdfFile(new ReportBindingModel { FileName = dialog.FileName, - DateFrom = dateTimePickerFrom.Value, - DateTo = dateTimePickerTo.Value + DateFrom = dateTimePickerStart.Value, + DateTo = dateTimePickerEnd.Value }); - _logger.LogInformation("Сохранение списка заказов на период { From} -{ To}", dateTimePickerFrom.Value.ToShortDateString(), dateTimePickerTo.Value.ToShortDateString()); + _logger.LogInformation("Сохранение списка заказов на период { From} -{ To}", dateTimePickerStart.Value.ToShortDateString(), dateTimePickerEnd.Value.ToShortDateString()); MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) diff --git a/TravelCompany/TravelCompany/FormReportOrders.resx b/TravelCompany/TravelCompany/FormReportOrders.resx index af32865..f298a7b 100644 --- a/TravelCompany/TravelCompany/FormReportOrders.resx +++ b/TravelCompany/TravelCompany/FormReportOrders.resx @@ -1,64 +1,4 @@ - - - + diff --git a/TravelCompany/TravelCompany/FormReportTravelComponents.Designer.cs b/TravelCompany/TravelCompany/FormReportTravelComponents.Designer.cs index ef17562..eee56c4 100644 --- a/TravelCompany/TravelCompany/FormReportTravelComponents.Designer.cs +++ b/TravelCompany/TravelCompany/FormReportTravelComponents.Designer.cs @@ -72,7 +72,7 @@ SaveButton.TabIndex = 1; SaveButton.Text = "Сохранить в Excel"; SaveButton.UseVisualStyleBackColor = true; - SaveButton.Click += SaveButton_Click; + SaveButton.Click += ButtonSaveToExcel_Click; // // ReportTravelComponentForm // @@ -83,7 +83,7 @@ Controls.Add(dataGridView); Name = "ReportTravelComponentForm"; Text = "Компоненты по мороженным"; - Load += ReportTravelComponentForm_Load; + Load += FormReportTravelComponents_Load; ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); ResumeLayout(false); } diff --git a/TravelCompany/TravelCompany/FormReportTravelComponents.cs b/TravelCompany/TravelCompany/FormReportTravelComponents.cs index ccffb61..e77ccef 100644 --- a/TravelCompany/TravelCompany/FormReportTravelComponents.cs +++ b/TravelCompany/TravelCompany/FormReportTravelComponents.cs @@ -1,6 +1,6 @@ -using TravelCompanyContracts.BindingModels; +using Microsoft.Extensions.Logging; +using TravelCompanyContracts.BindingModels; using TravelCompanyContracts.BusinessLogicsContracts; -using Microsoft.Extensions.Logging; using System; using System.Collections.Generic; using System.ComponentModel; @@ -18,78 +18,61 @@ namespace TravelCompany.Forms private readonly ILogger _logger; private readonly IReportLogic _logic; - public FormReportTravelComponents(ILogger -logger, IReportLogic logic) + public FormReportTravelComponents(ILogger logger, IReportLogic logic) { InitializeComponent(); _logger = logger; _logic = logic; - } - private void ReportTravelComponentForm_Load(object sender, EventArgs e) + private void FormReportTravelComponents_Load(object sender, EventArgs e) { try { - var dict = _logic.GetTravelComponent(); + var dict = _logic.GetTravelComponents(); if (dict != null) { dataGridView.Rows.Clear(); foreach (var elem in dict) { - dataGridView.Rows.Add(new object[] { elem.ComponentName, -"", "" }); - foreach (var listElem in elem.Travels) + dataGridView.Rows.Add(new object[] { elem.TravelName, "", "" }); + foreach (var listElem in elem.Components) { - dataGridView.Rows.Add(new object[] { "", -listElem.Item1, listElem.Item2 }); + dataGridView.Rows.Add(new object[] { "", listElem.Item1, listElem.Item2 }); } - dataGridView.Rows.Add(new object[] { "Итого", "", -elem.TotalCount }); + dataGridView.Rows.Add(new object[] { "Итого", "", elem.TotalCount }); dataGridView.Rows.Add(Array.Empty()); } } - _logger.LogInformation("Загрузка списка мороженных по компонентам"); + _logger.LogInformation("Загрузка списка изделий по компонентам"); } catch (Exception ex) { - _logger.LogError(ex, "Ошибка загрузки списка мороженных по компонентам"); - - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, - MessageBoxIcon.Error); + _logger.LogError(ex, "Ошибка загрузки списка изделий по компонентам"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } - } - private void SaveButton_Click(object sender, EventArgs e) + private void ButtonSaveToExcel_Click(object sender, EventArgs e) { - using var dialog = new SaveFileDialog - { - Filter = "xlsx|*.xlsx" - }; + using var dialog = new SaveFileDialog { Filter = "xlsx|*.xlsx" }; if (dialog.ShowDialog() == DialogResult.OK) { try { - _logic.SaveTravelComponentToExcelFile(new - ReportBindingModel + _logic.SaveTravelComponentToExcelFile(new ReportBindingModel { FileName = dialog.FileName }); - _logger.LogInformation("Сохранение списка мороженных по компонентам"); - - MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, - MessageBoxIcon.Information); + _logger.LogInformation("Сохранение списка изделий по компонентам"); + MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { - _logger.LogError(ex, "Ошибка сохранения списка мороженных по компонентам"); - - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, - MessageBoxIcon.Error); + _logger.LogError(ex, "Ошибка сохранения списка изделий по компонентам"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } - } } diff --git a/TravelCompany/TravelCompany/ReportOrders.rdlc b/TravelCompany/TravelCompany/ReportOrders.rdlc index 1da1666..02e1e80 100644 --- a/TravelCompany/TravelCompany/ReportOrders.rdlc +++ b/TravelCompany/TravelCompany/ReportOrders.rdlc @@ -212,7 +212,7 @@ - Путёвки + Железные изделия @@ -428,7 +428,7 @@ - + true true @@ -442,7 +442,7 @@