From 3cf8dee73318b10165d4b941bb52ef4d250a1e12 Mon Sep 17 00:00:00 2001 From: goldfest Date: Fri, 22 Mar 2024 15:57:40 +0400 Subject: [PATCH] =?UTF-8?q?=D1=87=D1=82=D0=BE=20=D1=82=D0=BE=20=D0=B4?= =?UTF-8?q?=D0=BE=D0=B4=D0=B5=D0=BB=D0=B0=D0=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FormReportOrders.Designer.cs | 69 +-- .../TravelCompany/FormReportOrders.cs | 46 +- TravelCompany/TravelCompany/ReportOrders.rdlc | 541 +++++++++++++++++- .../TravelCompany/TravelCompanyView.csproj | 51 +- .../BusinessLogic/ReportLogic.cs | 15 +- 5 files changed, 628 insertions(+), 94 deletions(-) diff --git a/TravelCompany/TravelCompany/FormReportOrders.Designer.cs b/TravelCompany/TravelCompany/FormReportOrders.Designer.cs index cff455b..181939d 100644 --- a/TravelCompany/TravelCompany/FormReportOrders.Designer.cs +++ b/TravelCompany/TravelCompany/FormReportOrders.Designer.cs @@ -29,46 +29,47 @@ private void InitializeComponent() { panel = new Panel(); - ToPdfButton = new Button(); - MakeButton = new Button(); + buttonCreateToPdf = new Button(); + buttonCreateReport = new Button(); label2 = new Label(); label1 = new Label(); - dateTimePickerTo = new DateTimePicker(); dateTimePickerFrom = new DateTimePicker(); + dateTimePickerTo = new DateTimePicker(); panel.SuspendLayout(); SuspendLayout(); // // panel // - panel.Controls.Add(ToPdfButton); - panel.Controls.Add(MakeButton); + panel.Controls.Add(buttonCreateToPdf); + panel.Controls.Add(buttonCreateReport); panel.Controls.Add(label2); panel.Controls.Add(label1); - panel.Controls.Add(dateTimePickerTo); 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; // - // ToPdfButton + // buttonCreateToPdf // - ToPdfButton.Location = new Point(623, 17); - ToPdfButton.Name = "ToPdfButton"; - ToPdfButton.Size = new Size(150, 23); - ToPdfButton.TabIndex = 5; - ToPdfButton.Text = "В Pdf"; - ToPdfButton.UseVisualStyleBackColor = true; + 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; // - // MakeButton + // buttonCreateReport // - MakeButton.Location = new Point(470, 17); - MakeButton.Name = "MakeButton"; - MakeButton.Size = new Size(147, 23); - MakeButton.TabIndex = 4; - MakeButton.Text = "Сформировать"; - MakeButton.UseVisualStyleBackColor = true; - MakeButton.Click += MakeButton_Click; + 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; // // label2 // @@ -88,13 +89,6 @@ label1.TabIndex = 2; label1.Text = "С"; // - // dateTimePickerTo - // - dateTimePickerTo.Location = new Point(264, 17); - dateTimePickerTo.Name = "dateTimePickerTo"; - dateTimePickerTo.Size = new Size(200, 23); - dateTimePickerTo.TabIndex = 1; - // // dateTimePickerFrom // dateTimePickerFrom.Location = new Point(29, 17); @@ -102,13 +96,20 @@ dateTimePickerFrom.Size = new Size(200, 23); dateTimePickerFrom.TabIndex = 0; // - // ReportOrdersForm + // dateTimePickerTo + // + dateTimePickerTo.Location = new Point(264, 17); + dateTimePickerTo.Name = "dateTimePickerTo"; + dateTimePickerTo.Size = new Size(200, 23); + dateTimePickerTo.TabIndex = 1; + // + // FormReportOrders // AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleMode = AutoScaleMode.Font; ClientSize = new Size(800, 450); Controls.Add(panel); - Name = "ReportOrdersForm"; + Name = "FormReportOrders"; Text = "Заказы"; panel.ResumeLayout(false); panel.PerformLayout(); @@ -118,11 +119,11 @@ #endregion private Panel panel; - private Button ToPdfButton; - private Button MakeButton; + private Button buttonCreateToPdf; + private Button buttonCreateReport; private Label label2; private Label label1; - private DateTimePicker dateTimePickerTo; 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 e40fa59..9b82313 100644 --- a/TravelCompany/TravelCompany/FormReportOrders.cs +++ b/TravelCompany/TravelCompany/FormReportOrders.cs @@ -1,7 +1,7 @@ -using TravelCompanyContracts.BindingModels; -using TravelCompanyContracts.BusinessLogicsContracts; -using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging; using Microsoft.Reporting.WinForms; +using TravelCompanyContracts.BindingModels; +using TravelCompanyContracts.BusinessLogicsContracts; using System; using System.Collections.Generic; using System.ComponentModel; @@ -11,6 +11,8 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; +using TravelCompanyContracts.BindingModels; +using TravelCompanyContracts.BusinessLogicsContracts; namespace TravelCompany.Forms { @@ -19,6 +21,7 @@ namespace TravelCompany.Forms private readonly ReportViewer reportViewer; private readonly ILogger _logger; private readonly IReportLogic _logic; + public FormReportOrders(ILogger logger, IReportLogic logic) { InitializeComponent(); @@ -28,19 +31,20 @@ namespace TravelCompany.Forms { Dock = DockStyle.Fill }; - reportViewer.LocalReport.LoadReportDefinition(new - FileStream("ReportOrders.rdlc", FileMode.Open)); + using (var fileStream = new FileStream("C:\\Users\\goldfest\\Desktop\\RPP\\TravelCompany\\TravelCompany\\ReportOrders.rdlc", FileMode.Open)) + { + reportViewer.LocalReport.LoadReportDefinition(fileStream); + } Controls.Clear(); Controls.Add(reportViewer); Controls.Add(panel); } - private void MakeButton_Click(object sender, EventArgs e) + private void buttonCreateReport_Click(object sender, EventArgs e) { if (dateTimePickerFrom.Value.Date >= dateTimePickerTo.Value.Date) { - MessageBox.Show("Дата начала должна быть меньше даты окончания", - "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show("Дата начала должна быть меньше даты окончания", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } try @@ -53,13 +57,10 @@ namespace TravelCompany.Forms 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); + 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("Загрузка списка заказов на период {From}-{ To}", dateTimePickerFrom.Value.ToShortDateString(), dateTimePickerTo.Value.ToShortDateString()); } catch (Exception ex) { @@ -67,14 +68,14 @@ ReportParameter("ReportParameterPeriod", MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } + } - private void ButtonToPdf_Click(object sender, EventArgs e) + private void buttonCreateToPdf_Click(object sender, EventArgs e) { if (dateTimePickerFrom.Value.Date >= dateTimePickerTo.Value.Date) { - MessageBox.Show("Дата начала должна быть меньше даты окончания", - "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show("Дата начала должна быть меньше даты окончания", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } using var dialog = new SaveFileDialog @@ -91,19 +92,16 @@ ReportParameter("ReportParameterPeriod", DateFrom = dateTimePickerFrom.Value, DateTo = dateTimePickerTo.Value }); - _logger.LogInformation("Сохранение списка заказов на период { From}-{ To}", dateTimePickerFrom.Value.ToShortDateString(), - dateTimePickerTo.Value.ToShortDateString()); - MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, - MessageBoxIcon.Information); + _logger.LogInformation("Сохранение списка заказов на период { From} -{ To}", dateTimePickerFrom.Value.ToShortDateString(), dateTimePickerTo.Value.ToShortDateString()); + MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { _logger.LogError(ex, "Ошибка сохранения списка заказов на период"); - - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, - MessageBoxIcon.Error); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } + } } diff --git a/TravelCompany/TravelCompany/ReportOrders.rdlc b/TravelCompany/TravelCompany/ReportOrders.rdlc index 7bc7022..1da1666 100644 --- a/TravelCompany/TravelCompany/ReportOrders.rdlc +++ b/TravelCompany/TravelCompany/ReportOrders.rdlc @@ -1,27 +1,552 @@ 0 + + + + System.Data.DataSet + /* Local Connection */ + + 10791c83-cee8-4a38-bbd0-245fc17cefb3 + + + + + + TravelCompanyContractsViewModels + /* Local Query */ + + + + Id + System.Int32 + + + DateCreate + System.DateTime + + + TravelName + System.String + + + Sum + System.Decimal + + + Status + System.String + + + + TravelCompanyContracts.ViewModels + ReportOrdersViewModel + TravelCompanyContracts.ViewModels.ReportOrdersViewModel, TravelCompanyContracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + + + - + true true - - - - Textbox1 + ReportParameterPeriod + 1cm + 1cm + 21cm + + + Middle + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + Заказы + + + + + + + 1cm + 21cm + 1 + + + Middle + 2pt + 2pt + 2pt + 2pt + + + + + + + 2.5cm + + + 3.21438cm + + + 8.23317cm + + + 2.5cm + + + 2.5cm + + + + + 0.6cm + + + + + true + true + + + + + Номер + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Дата создания + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Путёвки + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Сумма + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Статус + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + 0.6cm + + + + + true + true + + + + + =Fields!Id.Value + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!DateCreate.Value + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!TravelName.Value + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!Sum.Value + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!Status.Value + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + + + + + + + + + + + + + + After + + + + + + + DataSetOrders + 2.48391cm + 0.55245cm + 1.2cm + 18.94755cm + 2 + + + + + + true + true + + + + + Итого: + + + + + + + 4cm + 12cm 0.6cm 2.5cm + 3 + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + =Sum(Fields!Sum.Value, "DataSetOrders") + + + + + + + 4cm + 14.5cm + 0.6cm + 2.5cm + 4 @@ -33,10 +558,10 @@ - 2in + 5.72875cm