From b98d113c8f8a4ffb951ccc2ac6e73d773665f101 Mon Sep 17 00:00:00 2001 From: goldfest Date: Fri, 22 Mar 2024 01:29:50 +0400 Subject: [PATCH 1/5] =?UTF-8?q?=D0=BB=D0=B0=D0=B14?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TravelCompany/FormMain.Designer.cs | 38 +- TravelCompany/TravelCompany/FormMain.cs | 39 +- .../FormReportOrders.Designer.cs | 128 +++++++ .../TravelCompany/FormReportOrders.cs | 109 ++++++ .../TravelCompany/FormReportOrders.resx | 120 +++++++ .../FormReportTravelComponents.Designer.cs | 99 +++++ .../FormReportTravelComponents.cs | 95 +++++ .../FormReportTravelComponents.resx | 129 +++++++ TravelCompany/TravelCompany/Program.cs | 8 + TravelCompany/TravelCompany/ReportOrders.rdlc | 74 ++++ .../TravelCompany/TravelCompanyView.csproj | 6 +- .../BusinessLogic/ReportLogic.cs | 110 ++++++ .../OfficePackage/AbstractSaveToExcel.cs | 83 +++++ .../OfficePackage/AbstractSaveToPdf.cs | 63 ++++ .../OfficePackage/AbstractSaveToWord.cs | 46 +++ .../HelperEnums/ExcelStyleInfoType.cs | 15 + .../HelperEnums/PdfParagraphAlignmentType.cs | 15 + .../HelperEnums/WordJustificationType.cs | 14 + .../HelperModels/ExcelCellParameters.cs | 18 + .../OfficePackage/HelperModels/ExcelInfo.cs | 21 ++ .../HelperModels/ExcelMergeParameters.cs | 15 + .../OfficePackage/HelperModels/PdfInfo.cs | 18 + .../HelperModels/PdfParagraph.cs | 16 + .../HelperModels/PdfRowParameters.cs | 17 + .../OfficePackage/HelperModels/WordInfo.cs | 16 + .../HelperModels/WordParagraph.cs | 14 + .../HelperModels/WordTextProperties.cs | 16 + .../OfficePackage/Implements/SaveToExcel.cs | 339 ++++++++++++++++++ .../OfficePackage/Implements/SaveToPdf.cs | 107 ++++++ .../OfficePackage/Implements/SaveToWord.cs | 121 +++++++ .../TravelCompanyBusinessLogic.csproj | 3 + .../BindingModels/ReportBindingModel.cs | 16 + .../BusinessLogicsContracts/IReportLogic.cs | 19 + .../SearchModels/OrderSearchModel.cs | 2 + .../ViewModels/ReportOrdersViewModel.cs | 19 + .../ReportTravelComponentViewModel.cs | 16 + 36 files changed, 1981 insertions(+), 3 deletions(-) create mode 100644 TravelCompany/TravelCompany/FormReportOrders.Designer.cs create mode 100644 TravelCompany/TravelCompany/FormReportOrders.cs create mode 100644 TravelCompany/TravelCompany/FormReportOrders.resx create mode 100644 TravelCompany/TravelCompany/FormReportTravelComponents.Designer.cs create mode 100644 TravelCompany/TravelCompany/FormReportTravelComponents.cs create mode 100644 TravelCompany/TravelCompany/FormReportTravelComponents.resx create mode 100644 TravelCompany/TravelCompany/ReportOrders.rdlc create mode 100644 TravelCompany/TravelCompanyBusinessLogic/BusinessLogic/ReportLogic.cs create mode 100644 TravelCompany/TravelCompanyBusinessLogic/OfficePackage/AbstractSaveToExcel.cs create mode 100644 TravelCompany/TravelCompanyBusinessLogic/OfficePackage/AbstractSaveToPdf.cs create mode 100644 TravelCompany/TravelCompanyBusinessLogic/OfficePackage/AbstractSaveToWord.cs create mode 100644 TravelCompany/TravelCompanyBusinessLogic/OfficePackage/HelperEnums/ExcelStyleInfoType.cs create mode 100644 TravelCompany/TravelCompanyBusinessLogic/OfficePackage/HelperEnums/PdfParagraphAlignmentType.cs create mode 100644 TravelCompany/TravelCompanyBusinessLogic/OfficePackage/HelperEnums/WordJustificationType.cs create mode 100644 TravelCompany/TravelCompanyBusinessLogic/OfficePackage/HelperModels/ExcelCellParameters.cs create mode 100644 TravelCompany/TravelCompanyBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs create mode 100644 TravelCompany/TravelCompanyBusinessLogic/OfficePackage/HelperModels/ExcelMergeParameters.cs create mode 100644 TravelCompany/TravelCompanyBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs create mode 100644 TravelCompany/TravelCompanyBusinessLogic/OfficePackage/HelperModels/PdfParagraph.cs create mode 100644 TravelCompany/TravelCompanyBusinessLogic/OfficePackage/HelperModels/PdfRowParameters.cs create mode 100644 TravelCompany/TravelCompanyBusinessLogic/OfficePackage/HelperModels/WordInfo.cs create mode 100644 TravelCompany/TravelCompanyBusinessLogic/OfficePackage/HelperModels/WordParagraph.cs create mode 100644 TravelCompany/TravelCompanyBusinessLogic/OfficePackage/HelperModels/WordTextProperties.cs create mode 100644 TravelCompany/TravelCompanyBusinessLogic/OfficePackage/Implements/SaveToExcel.cs create mode 100644 TravelCompany/TravelCompanyBusinessLogic/OfficePackage/Implements/SaveToPdf.cs create mode 100644 TravelCompany/TravelCompanyBusinessLogic/OfficePackage/Implements/SaveToWord.cs create mode 100644 TravelCompany/TravelCompanyContracts/BindingModels/ReportBindingModel.cs create mode 100644 TravelCompany/TravelCompanyContracts/BusinessLogicsContracts/IReportLogic.cs create mode 100644 TravelCompany/TravelCompanyContracts/ViewModels/ReportOrdersViewModel.cs create mode 100644 TravelCompany/TravelCompanyContracts/ViewModels/ReportTravelComponentViewModel.cs diff --git a/TravelCompany/TravelCompany/FormMain.Designer.cs b/TravelCompany/TravelCompany/FormMain.Designer.cs index e2b8f72..cd45176 100644 --- a/TravelCompany/TravelCompany/FormMain.Designer.cs +++ b/TravelCompany/TravelCompany/FormMain.Designer.cs @@ -39,6 +39,10 @@ buttonIssuedOrder = new Button(); buttonRef = new Button(); dataGridView = new DataGridView(); + отчетыToolStripMenuItem = new ToolStripMenuItem(); + списокКомпонентовToolStripMenuItem = new ToolStripMenuItem(); + компонентыПоПутёвкамToolStripMenuItem = new ToolStripMenuItem(); + списокЗаказовToolStripMenuItem = new ToolStripMenuItem(); toolStrip1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); SuspendLayout(); @@ -46,7 +50,7 @@ // toolStrip1 // toolStrip1.ImageScalingSize = new Size(20, 20); - toolStrip1.Items.AddRange(new ToolStripItem[] { toolStripDropDownButton1 }); + toolStrip1.Items.AddRange(new ToolStripItem[] { toolStripDropDownButton1, отчетыToolStripMenuItem }); toolStrip1.Location = new Point(0, 0); toolStrip1.Name = "toolStrip1"; toolStrip1.Size = new Size(969, 25); @@ -139,6 +143,34 @@ dataGridView.Size = new Size(763, 435); dataGridView.TabIndex = 6; // + // отчетыToolStripMenuItem + // + отчетыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { списокКомпонентовToolStripMenuItem, компонентыПоПутёвкамToolStripMenuItem, списокЗаказовToolStripMenuItem }); + отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem"; + отчетыToolStripMenuItem.Size = new Size(60, 25); + отчетыToolStripMenuItem.Text = "Отчеты"; + // + // списокКомпонентовToolStripMenuItem + // + списокКомпонентовToolStripMenuItem.Name = "списокКомпонентовToolStripMenuItem"; + списокКомпонентовToolStripMenuItem.Size = new Size(216, 22); + списокКомпонентовToolStripMenuItem.Text = "Список компонентов"; + списокКомпонентовToolStripMenuItem.Click += списокКомпонентовToolStripMenuItem_Click; + // + // компонентыПоПутёвкамToolStripMenuItem + // + компонентыПоПутёвкамToolStripMenuItem.Name = "компонентыПоПутёвкамToolStripMenuItem"; + компонентыПоПутёвкамToolStripMenuItem.Size = new Size(216, 22); + компонентыПоПутёвкамToolStripMenuItem.Text = "Компоненты по путёвкам"; + компонентыПоПутёвкамToolStripMenuItem.Click += компонентыПоПутёвкамToolStripMenuItem_Click; + // + // списокЗаказовToolStripMenuItem + // + списокЗаказовToolStripMenuItem.Name = "списокЗаказовToolStripMenuItem"; + списокЗаказовToolStripMenuItem.Size = new Size(216, 22); + списокЗаказовToolStripMenuItem.Text = "Список заказов"; + списокЗаказовToolStripMenuItem.Click += списокЗаказовToolStripMenuItem_Click; + // // FormMain // AutoScaleDimensions = new SizeF(7F, 15F); @@ -173,5 +205,9 @@ private ToolStripDropDownButton toolStripDropDownButton1; private ToolStripMenuItem компонентыToolStripMenuItem; private ToolStripMenuItem ПутёвкиToolStripMenuItem; + private ToolStripMenuItem отчетыToolStripMenuItem; + private ToolStripMenuItem списокКомпонентовToolStripMenuItem; + private ToolStripMenuItem компонентыПоПутёвкамToolStripMenuItem; + private ToolStripMenuItem списокЗаказовToolStripMenuItem; } } \ No newline at end of file diff --git a/TravelCompany/TravelCompany/FormMain.cs b/TravelCompany/TravelCompany/FormMain.cs index d25b396..be59c78 100644 --- a/TravelCompany/TravelCompany/FormMain.cs +++ b/TravelCompany/TravelCompany/FormMain.cs @@ -10,6 +10,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; +using TravelCompanyBusinessLogic.BusinessLogic; namespace TravelCompany.Forms { @@ -17,11 +18,13 @@ namespace TravelCompany.Forms { private readonly ILogger _logger; private readonly IOrderLogic _orderLogic; - public FormMain(ILogger logger, IOrderLogic orderLogic) + private readonly IReportLogic _reportLogic; + public FormMain(ILogger logger, IOrderLogic orderLogic, IReportLogic reportLogic) { InitializeComponent(); _logger = logger; _orderLogic = orderLogic; + _reportLogic = reportLogic; } private void FormMain_Load(object sender, EventArgs e) { @@ -151,5 +154,39 @@ namespace TravelCompany.Forms { LoadData(); } + + private void списокКомпонентовToolStripMenuItem_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); + } + } + + private void компонентыПоПутёвкамToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = +Program.ServiceProvider?.GetService(typeof(FormReportTravelComponents)); + if (service is FormReportTravelComponents form) + { + form.ShowDialog(); + } + } + + private void списокЗаказовToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = +Program.ServiceProvider?.GetService(typeof(FormReportOrders)); + if (service is FormReportOrders form) + { + form.ShowDialog(); + } + } } } diff --git a/TravelCompany/TravelCompany/FormReportOrders.Designer.cs b/TravelCompany/TravelCompany/FormReportOrders.Designer.cs new file mode 100644 index 0000000..cff455b --- /dev/null +++ b/TravelCompany/TravelCompany/FormReportOrders.Designer.cs @@ -0,0 +1,128 @@ +namespace TravelCompany.Forms +{ + partial class FormReportOrders + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + panel = new Panel(); + ToPdfButton = new Button(); + MakeButton = new Button(); + label2 = new Label(); + label1 = new Label(); + dateTimePickerTo = new DateTimePicker(); + dateTimePickerFrom = new DateTimePicker(); + panel.SuspendLayout(); + SuspendLayout(); + // + // panel + // + panel.Controls.Add(ToPdfButton); + panel.Controls.Add(MakeButton); + panel.Controls.Add(label2); + panel.Controls.Add(label1); + panel.Controls.Add(dateTimePickerTo); + panel.Controls.Add(dateTimePickerFrom); + panel.Location = new Point(12, 12); + panel.Name = "panel"; + panel.Size = new Size(776, 43); + panel.TabIndex = 0; + // + // ToPdfButton + // + ToPdfButton.Location = new Point(623, 17); + ToPdfButton.Name = "ToPdfButton"; + ToPdfButton.Size = new Size(150, 23); + ToPdfButton.TabIndex = 5; + ToPdfButton.Text = "В Pdf"; + ToPdfButton.UseVisualStyleBackColor = true; + // + // MakeButton + // + 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; + // + // label2 + // + label2.AutoSize = true; + label2.Location = new Point(235, 23); + label2.Name = "label2"; + label2.Size = new Size(23, 15); + label2.TabIndex = 3; + 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 = "С"; + // + // 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); + dateTimePickerFrom.Name = "dateTimePickerFrom"; + dateTimePickerFrom.Size = new Size(200, 23); + dateTimePickerFrom.TabIndex = 0; + // + // ReportOrdersForm + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(800, 450); + Controls.Add(panel); + Name = "ReportOrdersForm"; + Text = "Заказы"; + panel.ResumeLayout(false); + panel.PerformLayout(); + ResumeLayout(false); + } + + #endregion + + private Panel panel; + private Button ToPdfButton; + private Button MakeButton; + private Label label2; + private Label label1; + private DateTimePicker dateTimePickerTo; + private DateTimePicker dateTimePickerFrom; + } +} \ No newline at end of file diff --git a/TravelCompany/TravelCompany/FormReportOrders.cs b/TravelCompany/TravelCompany/FormReportOrders.cs new file mode 100644 index 0000000..e40fa59 --- /dev/null +++ b/TravelCompany/TravelCompany/FormReportOrders.cs @@ -0,0 +1,109 @@ +using TravelCompanyContracts.BindingModels; +using TravelCompanyContracts.BusinessLogicsContracts; +using Microsoft.Extensions.Logging; +using Microsoft.Reporting.WinForms; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace TravelCompany.Forms +{ + public partial class FormReportOrders : Form + { + private readonly ReportViewer reportViewer; + private readonly ILogger _logger; + private readonly IReportLogic _logic; + public FormReportOrders(ILogger logger, IReportLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + reportViewer = new ReportViewer + { + Dock = DockStyle.Fill + }; + reportViewer.LocalReport.LoadReportDefinition(new + FileStream("ReportOrders.rdlc", FileMode.Open)); + Controls.Clear(); + Controls.Add(reportViewer); + Controls.Add(panel); + } + + private void MakeButton_Click(object sender, EventArgs e) + { + if (dateTimePickerFrom.Value.Date >= dateTimePickerTo.Value.Date) + { + MessageBox.Show("Дата начала должна быть меньше даты окончания", + "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + try + { + var dataSource = _logic.GetOrders(new ReportBindingModel + { + DateFrom = dateTimePickerFrom.Value, + DateTo = dateTimePickerTo.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()}") }; + reportViewer.LocalReport.SetParameters(parameters); + reportViewer.RefreshReport(); + _logger.LogInformation("Загрузка списка заказов на период {From}-{ To}", dateTimePickerFrom.Value.ToShortDateString(), + dateTimePickerTo.Value.ToShortDateString()); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки списка заказов на период"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } + + 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) + { + try + { + _logic.SaveOrdersToPdfFile(new ReportBindingModel + { + FileName = dialog.FileName, + DateFrom = dateTimePickerFrom.Value, + DateTo = dateTimePickerTo.Value + }); + _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); + } + } + } + } +} diff --git a/TravelCompany/TravelCompany/FormReportOrders.resx b/TravelCompany/TravelCompany/FormReportOrders.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/TravelCompany/TravelCompany/FormReportOrders.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/TravelCompany/TravelCompany/FormReportTravelComponents.Designer.cs b/TravelCompany/TravelCompany/FormReportTravelComponents.Designer.cs new file mode 100644 index 0000000..ef17562 --- /dev/null +++ b/TravelCompany/TravelCompany/FormReportTravelComponents.Designer.cs @@ -0,0 +1,99 @@ +namespace TravelCompany.Forms +{ + partial class FormReportTravelComponents + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + dataGridView = new DataGridView(); + ComponentColumn = new DataGridViewTextBoxColumn(); + TravelColumn = new DataGridViewTextBoxColumn(); + CountColumn = new DataGridViewTextBoxColumn(); + SaveButton = new Button(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + SuspendLayout(); + // + // dataGridView + // + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Columns.AddRange(new DataGridViewColumn[] { ComponentColumn, TravelColumn, CountColumn }); + dataGridView.Location = new Point(12, 46); + dataGridView.Name = "dataGridView"; + dataGridView.RowTemplate.Height = 25; + dataGridView.Size = new Size(570, 392); + dataGridView.TabIndex = 0; + // + // ComponentColumn + // + ComponentColumn.HeaderText = "Компонент"; + ComponentColumn.Name = "ComponentColumn"; + ComponentColumn.Width = 200; + // + // TravelColumn + // + TravelColumn.HeaderText = "Мороженное"; + TravelColumn.Name = "TravelColumn"; + TravelColumn.Width = 200; + // + // CountColumn + // + CountColumn.HeaderText = "Количество"; + CountColumn.Name = "CountColumn"; + CountColumn.Width = 130; + // + // SaveButton + // + SaveButton.Location = new Point(12, 17); + SaveButton.Name = "SaveButton"; + SaveButton.Size = new Size(114, 23); + SaveButton.TabIndex = 1; + SaveButton.Text = "Сохранить в Excel"; + SaveButton.UseVisualStyleBackColor = true; + SaveButton.Click += SaveButton_Click; + // + // ReportTravelComponentForm + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(594, 450); + Controls.Add(SaveButton); + Controls.Add(dataGridView); + Name = "ReportTravelComponentForm"; + Text = "Компоненты по мороженным"; + Load += ReportTravelComponentForm_Load; + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + } + + #endregion + + private DataGridView dataGridView; + private Button SaveButton; + private DataGridViewTextBoxColumn ComponentColumn; + private DataGridViewTextBoxColumn TravelColumn; + private DataGridViewTextBoxColumn CountColumn; + } +} \ No newline at end of file diff --git a/TravelCompany/TravelCompany/FormReportTravelComponents.cs b/TravelCompany/TravelCompany/FormReportTravelComponents.cs new file mode 100644 index 0000000..ccffb61 --- /dev/null +++ b/TravelCompany/TravelCompany/FormReportTravelComponents.cs @@ -0,0 +1,95 @@ +using TravelCompanyContracts.BindingModels; +using TravelCompanyContracts.BusinessLogicsContracts; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace TravelCompany.Forms +{ + public partial class FormReportTravelComponents : Form + { + private readonly ILogger _logger; + private readonly IReportLogic _logic; + + public FormReportTravelComponents(ILogger +logger, IReportLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + + } + + private void ReportTravelComponentForm_Load(object sender, EventArgs e) + { + try + { + var dict = _logic.GetTravelComponent(); + 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[] { "", +listElem.Item1, listElem.Item2 }); + } + dataGridView.Rows.Add(new object[] { "Итого", "", +elem.TotalCount }); + dataGridView.Rows.Add(Array.Empty()); + } + } + _logger.LogInformation("Загрузка списка мороженных по компонентам"); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки списка мороженных по компонентам"); + + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + + } + + private void SaveButton_Click(object sender, EventArgs e) + { + using var dialog = new SaveFileDialog + { + Filter = "xlsx|*.xlsx" + }; + if (dialog.ShowDialog() == DialogResult.OK) + { + try + { + _logic.SaveTravelComponentToExcelFile(new + ReportBindingModel + { + FileName = dialog.FileName + }); + _logger.LogInformation("Сохранение списка мороженных по компонентам"); + + MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, + MessageBoxIcon.Information); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка сохранения списка мороженных по компонентам"); + + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } + } + + } +} diff --git a/TravelCompany/TravelCompany/FormReportTravelComponents.resx b/TravelCompany/TravelCompany/FormReportTravelComponents.resx new file mode 100644 index 0000000..3665706 --- /dev/null +++ b/TravelCompany/TravelCompany/FormReportTravelComponents.resx @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + True + + + True + + + True + + \ No newline at end of file diff --git a/TravelCompany/TravelCompany/Program.cs b/TravelCompany/TravelCompany/Program.cs index 3419d03..0603102 100644 --- a/TravelCompany/TravelCompany/Program.cs +++ b/TravelCompany/TravelCompany/Program.cs @@ -5,6 +5,8 @@ using TravelCompanyDatabaseImplement.Implements; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using NLog.Extensions.Logging; +using TravelCompanyBusinessLogic.OfficePackage.Implements; +using TravelCompanyBusinessLogic.OfficePackage; namespace TravelCompany.Forms @@ -42,6 +44,7 @@ namespace TravelCompany.Forms services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); @@ -50,6 +53,11 @@ namespace TravelCompany.Forms services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); } } } \ No newline at end of file diff --git a/TravelCompany/TravelCompany/ReportOrders.rdlc b/TravelCompany/TravelCompany/ReportOrders.rdlc new file mode 100644 index 0000000..7bc7022 --- /dev/null +++ b/TravelCompany/TravelCompany/ReportOrders.rdlc @@ -0,0 +1,74 @@ + + + 0 + + + + + + true + true + + + + + + + + 2pt + 2pt + 2pt + 2pt + + + + 2in + - - 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 @@ -428,7 +428,7 @@ - + true true @@ -442,7 +442,7 @@ + + + 0.6cm + 16.51cm + + + Middle + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + =Parameters!ReportParameterPeriod.Value + + + + + + + ReportParameterPeriod + 0.6cm + 0.6cm + 16.51cm + 1 + + + 2pt + 2pt + 2pt + 2pt + + + + + + + 3.90406cm + + + 3.97461cm + + + 3.65711cm + + + + + 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!Date.Value + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!OrdersCount.Value + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!OrdersSum.Value + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + + + + + + + + + + + + After + + + + + + + DataSetGroupedOrders + 1.88242cm + 2.68676cm + 1.2cm + 11.53578cm + 2 + + + + + + true + true + + + + + Итого: + + + + 3.29409cm + 8.06542cm + 0.6cm + 2.5cm + 3 + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + =Sum(Fields!OrdersSum.Value, "DataSetGroupedOrders") + + + + + + + 3.29409cm + 10.70653cm + 0.6cm + 3.48072cm + 4 + + + 2pt + 2pt + 2pt + 2pt + + + + 2in + + + + 0.6cm + 16.51cm + + + Middle + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + =Parameters!ReportParameterPeriod.Value + + + + ReportParameterPeriod + 0.6cm + 0.6cm + 16.51cm + 1 + + + Middle + 2pt + 2pt + 2pt + 2pt + + + + + + + 2.60583cm + + + 3.262cm + + + 4.8495cm + + + 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!Status.Value + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!Sum.Value + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + + + + + + + + + + + + + + After + + + + + + + DataSetOrders + 1.9177cm + 0.79267cm + 1.2cm + 15.71733cm + 2 + + + + + + true + true + + + + + Итого: + + + + 3.46287cm + 11.51cm + 0.6cm + 2.5cm + 3 + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + =Sum(Fields!Sum.Value, "DataSetOrders") + + + 2pt + 2pt + 2pt + 2pt + + + + 2in + - - - 0.6cm - 16.51cm - - - Middle - 2pt - 2pt - 2pt - 2pt - - - - true - true - - - - - =Parameters!ReportParameterPeriod.Value - - - - ReportParameterPeriod - 0.6cm - 0.6cm - 16.51cm - 1 - - - Middle - 2pt - 2pt - 2pt - 2pt - - - - - - - 2.60583cm - - - 3.262cm - - - 4.8495cm - - - 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!Status.Value - - - 2pt - 2pt - 2pt - 2pt - - - - - - - - true - true - - - - - =Fields!Sum.Value - - - 2pt - 2pt - 2pt - 2pt - - - - - - - - - - - - - - - - - - - - - After - - - - - - - DataSetOrders - 1.9177cm - 0.79267cm - 1.2cm - 15.71733cm - 2 - - - - - - true - true - - - - - Итого: - - - - 3.46287cm - 11.51cm - 0.6cm - 2.5cm - 3 - - - 2pt - 2pt - 2pt - 2pt - - - - true - true - - - - - =Sum(Fields!Sum.Value, "DataSetOrders") - - - 2pt - 2pt - 2pt - 2pt - - - - 2in - @@ -235,6 +235,38 @@ + + + + true + true + + + + + Статус Заказа + + + + + + 2pt + 2pt + 2pt + 2pt + + + + @@ -267,38 +299,6 @@ - - - - true - true - - - - - Статус - - - - - - 2pt - 2pt - 2pt - 2pt - - - - @@ -398,21 +398,21 @@ - + true true - =Fields!Sum.Value + =Fields!OrderStatus.Value