From dd20fa13a9365b04038b3f3fd7dedb7064522bd6 Mon Sep 17 00:00:00 2001 From: ksenianeva <95441235+ksenianeva@users.noreply.github.com> Date: Thu, 27 Apr 2023 17:25:50 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9B=D0=B0=D0=B1=D0=BE=D1=80=D0=BD=D0=B0?= =?UTF-8?q?=D1=8F=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=204.=20=D0=A1?= =?UTF-8?q?=D0=BE=D1=85=D1=80=D0=B0=D0=BD=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BE?= =?UTF-8?q?=D1=82=D1=87=D0=B5=D1=82=D0=BE=D0=B2=20=D0=B2=20=D0=B4=D0=BE?= =?UTF-8?q?=D0=BA=D1=83=D0=BC=D0=B5=D0=BD=D1=82=D1=8B.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TravelCompany/FormMain.Designer.cs | 42 +- TravelCompany/TravelCompany/FormMain.cs | 36 +- TravelCompany/TravelCompany/FormMain.resx | 3 + .../FormReportOrders.Designer.cs | 131 ++++ .../TravelCompany/FormReportOrders.cs | 102 ++++ .../TravelCompany/FormReportOrders.resx | 60 ++ .../FormReportTravelConditions.Designer.cs | 111 ++++ .../FormReportTravelConditions.cs | 87 +++ .../FormReportTravelConditions.resx | 69 +++ TravelCompany/TravelCompany/Program.cs | 10 + TravelCompany/TravelCompany/ReportOrders.rdlc | 572 ++++++++++++++++++ .../TravelCompany/TravelCompany.csproj | 7 + .../BusinessLogic/ReportLogic.cs | 129 ++++ .../OfficePackage/AbstractSaveToExcel.cs | 104 ++++ .../OfficePackage/AbstractSaveToPdf.cs | 82 +++ .../OfficePackage/AbstractSaveToWord.cs | 57 ++ .../HelperEnums/ExcelStyleInfoType.cs | 15 + .../HelperEnums/PdfParagraphAlignmentType.cs | 15 + .../HelperEnums/WordJustificationType.cs | 14 + .../HelperModels/ExcelCellParameters.cs | 19 + .../OfficePackage/HelperModels/ExcelInfo.cs | 20 + .../HelperModels/ExcelMergeParameters.cs | 15 + .../OfficePackage/HelperModels/PdfInfo.cs | 19 + .../HelperModels/PdfParagraph.cs | 16 + .../HelperModels/PdfRowParameters.cs | 16 + .../OfficePackage/HelperModels/WordInfo.cs | 16 + .../HelperModels/WordParagraph.cs | 17 + .../HelperModels/WordTextProperties.cs | 16 + .../OfficePackage/Implements/SaveToExcel.cs | 347 +++++++++++ .../OfficePackage/Implements/SaveToPdf.cs | 108 ++++ .../OfficePackage/Implements/SaveToWord.cs | 131 ++++ .../TravelCompanyBusinessLogic.csproj | 2 + .../BindingModels/ReportBindingModel.cs | 15 + .../BusinessLogicsContracts/IReportLogic.cs | 41 ++ .../SearchModels/OrderSearchModel.cs | 2 + .../ViewModels/ReportOrdersViewModel.cs | 17 + .../ReportTravelConditionViewModel.cs | 15 + .../Implements/OrderStorage.cs | 24 +- .../Implements/OrderStorage.cs | 21 +- .../Implements/OrderStorage.cs | 21 +- 40 files changed, 2527 insertions(+), 17 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/FormReportTravelConditions.Designer.cs create mode 100644 TravelCompany/TravelCompany/FormReportTravelConditions.cs create mode 100644 TravelCompany/TravelCompany/FormReportTravelConditions.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/ReportTravelConditionViewModel.cs diff --git a/TravelCompany/TravelCompany/FormMain.Designer.cs b/TravelCompany/TravelCompany/FormMain.Designer.cs index b17d4bc..999c272 100644 --- a/TravelCompany/TravelCompany/FormMain.Designer.cs +++ b/TravelCompany/TravelCompany/FormMain.Designer.cs @@ -33,6 +33,10 @@ this.справочникиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.условияToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.путешествияToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.отчетToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.списокУсловийToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.условияПоПоездкамToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.списокЗаказовToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.buttonCreateOrder = new System.Windows.Forms.Button(); this.ButtonTakeOrderInWork = new System.Windows.Forms.Button(); this.ButtonOrderReady = new System.Windows.Forms.Button(); @@ -60,7 +64,8 @@ // this.menuStrip.ImageScalingSize = new System.Drawing.Size(24, 24); this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.справочникиToolStripMenuItem}); + this.справочникиToolStripMenuItem, + this.отчетToolStripMenuItem}); this.menuStrip.Location = new System.Drawing.Point(0, 0); this.menuStrip.Name = "menuStrip"; this.menuStrip.Size = new System.Drawing.Size(1452, 33); @@ -90,6 +95,37 @@ this.путешествияToolStripMenuItem.Text = "Путешествия"; this.путешествияToolStripMenuItem.Click += new System.EventHandler(this.путешествияToolStripMenuItem_Click); // + // отчетToolStripMenuItem + // + this.отчетToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.списокУсловийToolStripMenuItem, + this.условияПоПоездкамToolStripMenuItem, + this.списокЗаказовToolStripMenuItem}); + this.отчетToolStripMenuItem.Name = "отчетToolStripMenuItem"; + this.отчетToolStripMenuItem.Size = new System.Drawing.Size(75, 29); + this.отчетToolStripMenuItem.Text = "Отчет"; + // + // списокУсловийToolStripMenuItem + // + this.списокУсловийToolStripMenuItem.Name = "списокУсловийToolStripMenuItem"; + this.списокУсловийToolStripMenuItem.Size = new System.Drawing.Size(291, 34); + this.списокУсловийToolStripMenuItem.Text = "Список путешествий"; + this.списокУсловийToolStripMenuItem.Click += new System.EventHandler(this.ConditionsToolStripMenuItem_Click); + // + // условияПоПоездкамToolStripMenuItem + // + this.условияПоПоездкамToolStripMenuItem.Name = "условияПоПоездкамToolStripMenuItem"; + this.условияПоПоездкамToolStripMenuItem.Size = new System.Drawing.Size(291, 34); + this.условияПоПоездкамToolStripMenuItem.Text = "Условия по поездкам"; + this.условияПоПоездкамToolStripMenuItem.Click += new System.EventHandler(this.ConditionTravelsToolStripMenuItem_Click); + // + // списокЗаказовToolStripMenuItem + // + this.списокЗаказовToolStripMenuItem.Name = "списокЗаказовToolStripMenuItem"; + this.списокЗаказовToolStripMenuItem.Size = new System.Drawing.Size(291, 34); + this.списокЗаказовToolStripMenuItem.Text = "Список заказов"; + this.списокЗаказовToolStripMenuItem.Click += new System.EventHandler(this.OrdersToolStripMenuItem_Click); + // // buttonCreateOrder // this.buttonCreateOrder.Location = new System.Drawing.Point(1224, 55); @@ -176,5 +212,9 @@ private Button ButtonOrderReady; private Button ButtonIssuedOrder; private Button ButtonRef; + 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 b40f6c6..5d8e3a2 100644 --- a/TravelCompany/TravelCompany/FormMain.cs +++ b/TravelCompany/TravelCompany/FormMain.cs @@ -19,9 +19,11 @@ namespace TravelCompany { 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(); + _reportLogic = reportLogic; _logger = logger; _orderLogic = orderLogic; } @@ -151,5 +153,37 @@ namespace TravelCompany form.ShowDialog(); } } + + private void ConditionsToolStripMenuItem_Click(object sender, EventArgs e) + { + using var dialog = new SaveFileDialog { Filter = "docx|*.docx" }; + if (dialog.ShowDialog() == DialogResult.OK) + { + _reportLogic.SaveTravelsToWordFile(new ReportBindingModel + { + FileName = dialog.FileName + }); + MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, + MessageBoxIcon.Information); + } + } + private void ConditionTravelsToolStripMenuItem_Click(object sender, + EventArgs e) + { + var service = + Program.ServiceProvider?.GetService(typeof(FormReportTravelConditions)); + if (service is FormReportTravelConditions form) + { + form.ShowDialog(); + } + } + private void OrdersToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormReportOrders)); + if (service is FormReportOrders form) + { + form.ShowDialog(); + } + } } } diff --git a/TravelCompany/TravelCompany/FormMain.resx b/TravelCompany/TravelCompany/FormMain.resx index 81a9e3d..076b77c 100644 --- a/TravelCompany/TravelCompany/FormMain.resx +++ b/TravelCompany/TravelCompany/FormMain.resx @@ -60,4 +60,7 @@ 17, 17 + + 25 + \ No newline at end of file diff --git a/TravelCompany/TravelCompany/FormReportOrders.Designer.cs b/TravelCompany/TravelCompany/FormReportOrders.Designer.cs new file mode 100644 index 0000000..b1d0c21 --- /dev/null +++ b/TravelCompany/TravelCompany/FormReportOrders.Designer.cs @@ -0,0 +1,131 @@ +namespace TravelCompany +{ + 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() + { + this.dateTimePickerFrom = new System.Windows.Forms.DateTimePicker(); + this.dateTimePickerTo = new System.Windows.Forms.DateTimePicker(); + this.labelTo = new System.Windows.Forms.Label(); + this.labelFrom = new System.Windows.Forms.Label(); + this.buttonMake = new System.Windows.Forms.Button(); + this.buttonToPdf = new System.Windows.Forms.Button(); + this.panel = new System.Windows.Forms.Panel(); + this.panel.SuspendLayout(); + this.SuspendLayout(); + // + // dateTimePickerFrom + // + this.dateTimePickerFrom.Location = new System.Drawing.Point(33, 10); + this.dateTimePickerFrom.Name = "dateTimePickerFrom"; + this.dateTimePickerFrom.Size = new System.Drawing.Size(300, 31); + this.dateTimePickerFrom.TabIndex = 0; + // + // dateTimePickerTo + // + this.dateTimePickerTo.Location = new System.Drawing.Point(382, 10); + this.dateTimePickerTo.Name = "dateTimePickerTo"; + this.dateTimePickerTo.Size = new System.Drawing.Size(300, 31); + this.dateTimePickerTo.TabIndex = 1; + // + // labelTo + // + this.labelTo.AutoSize = true; + this.labelTo.Location = new System.Drawing.Point(339, 15); + this.labelTo.Name = "labelTo"; + this.labelTo.Size = new System.Drawing.Size(37, 25); + this.labelTo.TabIndex = 2; + this.labelTo.Text = "по:"; + // + // labelFrom + // + this.labelFrom.AutoSize = true; + this.labelFrom.Location = new System.Drawing.Point(3, 15); + this.labelFrom.Name = "labelFrom"; + this.labelFrom.Size = new System.Drawing.Size(24, 25); + this.labelFrom.TabIndex = 3; + this.labelFrom.Text = "с:"; + // + // buttonMake + // + this.buttonMake.Location = new System.Drawing.Point(712, 7); + this.buttonMake.Name = "buttonMake"; + this.buttonMake.Size = new System.Drawing.Size(177, 34); + this.buttonMake.TabIndex = 4; + this.buttonMake.Text = "Сформировать"; + this.buttonMake.UseVisualStyleBackColor = true; + this.buttonMake.Click += new System.EventHandler(this.ButtonMake_Click); + // + // buttonToPdf + // + this.buttonToPdf.Location = new System.Drawing.Point(999, 7); + this.buttonToPdf.Name = "buttonToPdf"; + this.buttonToPdf.Size = new System.Drawing.Size(112, 34); + this.buttonToPdf.TabIndex = 5; + this.buttonToPdf.Text = "В Pdf"; + this.buttonToPdf.UseVisualStyleBackColor = true; + this.buttonToPdf.Click += new System.EventHandler(this.ButtonToPdf_Click); + // + // panel + // + this.panel.Controls.Add(this.labelFrom); + this.panel.Controls.Add(this.buttonToPdf); + this.panel.Controls.Add(this.dateTimePickerFrom); + this.panel.Controls.Add(this.buttonMake); + this.panel.Controls.Add(this.labelTo); + this.panel.Controls.Add(this.dateTimePickerTo); + this.panel.Dock = System.Windows.Forms.DockStyle.Top; + this.panel.Location = new System.Drawing.Point(0, 0); + this.panel.Name = "panel"; + this.panel.Size = new System.Drawing.Size(1132, 53); + this.panel.TabIndex = 6; + // + // FormReportOrders + // + this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(1132, 450); + this.Controls.Add(this.panel); + this.Name = "FormReportOrders"; + this.Text = "Заказы"; + this.panel.ResumeLayout(false); + this.panel.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private DateTimePicker dateTimePickerFrom; + private DateTimePicker dateTimePickerTo; + private Label labelTo; + private Label labelFrom; + private Button buttonMake; + private Button buttonToPdf; + private Panel panel; + } +} \ No newline at end of file diff --git a/TravelCompany/TravelCompany/FormReportOrders.cs b/TravelCompany/TravelCompany/FormReportOrders.cs new file mode 100644 index 0000000..52c4321 --- /dev/null +++ b/TravelCompany/TravelCompany/FormReportOrders.cs @@ -0,0 +1,102 @@ +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; +using TravelCompanyContracts.BindingModels; +using TravelCompanyContracts.BusinessLogicsContracts; +using Microsoft.Reporting.WinForms; + +namespace TravelCompany +{ + 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 ButtonMake_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..f298a7b --- /dev/null +++ b/TravelCompany/TravelCompany/FormReportOrders.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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/FormReportTravelConditions.Designer.cs b/TravelCompany/TravelCompany/FormReportTravelConditions.Designer.cs new file mode 100644 index 0000000..f9b21ea --- /dev/null +++ b/TravelCompany/TravelCompany/FormReportTravelConditions.Designer.cs @@ -0,0 +1,111 @@ +namespace TravelCompany +{ + partial class FormReportTravelConditions + { + /// + /// 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() + { + this.dataGridView = new System.Windows.Forms.DataGridView(); + this.ButtonSaveToExel = new System.Windows.Forms.Button(); + this.Travel = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Condition = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Amount = new System.Windows.Forms.DataGridViewTextBoxColumn(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); + this.SuspendLayout(); + // + // dataGridView + // + this.dataGridView.BackgroundColor = System.Drawing.Color.White; + this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.Travel, + this.Condition, + this.Amount}); + this.dataGridView.Location = new System.Drawing.Point(0, 54); + this.dataGridView.MultiSelect = false; + this.dataGridView.Name = "dataGridView"; + this.dataGridView.RowHeadersVisible = false; + this.dataGridView.RowHeadersWidth = 62; + this.dataGridView.RowTemplate.Height = 33; + this.dataGridView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; + this.dataGridView.Size = new System.Drawing.Size(798, 399); + this.dataGridView.TabIndex = 0; + // + // ButtonSaveToExel + // + this.ButtonSaveToExel.Location = new System.Drawing.Point(15, 7); + this.ButtonSaveToExel.Name = "ButtonSaveToExel"; + this.ButtonSaveToExel.Size = new System.Drawing.Size(257, 34); + this.ButtonSaveToExel.TabIndex = 1; + this.ButtonSaveToExel.Text = "Сохранить в Exel"; + this.ButtonSaveToExel.UseVisualStyleBackColor = true; + this.ButtonSaveToExel.Click += new System.EventHandler(this.ButtonSaveToExcel_Click); + // + // Travel + // + this.Travel.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.Travel.HeaderText = "Путешествие"; + this.Travel.MinimumWidth = 8; + this.Travel.Name = "Travel"; + // + // Condition + // + this.Condition.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.Condition.HeaderText = "Условие"; + this.Condition.MinimumWidth = 8; + this.Condition.Name = "Condition"; + // + // Amount + // + this.Amount.HeaderText = "Количество"; + this.Amount.MinimumWidth = 8; + this.Amount.Name = "Amount"; + this.Amount.Width = 150; + // + // FormReportTravelConditions + // + this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(800, 450); + this.Controls.Add(this.ButtonSaveToExel); + this.Controls.Add(this.dataGridView); + this.Name = "FormReportTravelConditions"; + this.Text = "Отчет условия по путешествиям"; + this.Load += new System.EventHandler(this.FormReportTravelConditions_Load); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private DataGridView dataGridView; + private Button ButtonSaveToExel; + private DataGridViewTextBoxColumn Travel; + private DataGridViewTextBoxColumn Condition; + private DataGridViewTextBoxColumn Amount; + } +} \ No newline at end of file diff --git a/TravelCompany/TravelCompany/FormReportTravelConditions.cs b/TravelCompany/TravelCompany/FormReportTravelConditions.cs new file mode 100644 index 0000000..c99f7ab --- /dev/null +++ b/TravelCompany/TravelCompany/FormReportTravelConditions.cs @@ -0,0 +1,87 @@ +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; +using TravelCompanyContracts.BindingModels; +using TravelCompanyContracts.BusinessLogicsContracts; + +namespace TravelCompany +{ + public partial class FormReportTravelConditions : Form + { + private readonly ILogger _logger; + private readonly IReportLogic _logic; + public FormReportTravelConditions(ILogger logger, IReportLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + } + private void FormReportTravelConditions_Load(object sender, EventArgs e) + { + try + { + var dict = _logic.GetTravelCondition(); + if (dict != null) + { + dataGridView.Rows.Clear(); + foreach (var elem in dict) + { + dataGridView.Rows.Add(new object[] { elem.TravelName, "", "" }); + foreach (var listElem in elem.Conditions) + { + 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 ButtonSaveToExcel_Click(object sender, EventArgs e) + { + using var dialog = new SaveFileDialog + { + Filter = "xlsx|*.xlsx" + }; + if (dialog.ShowDialog() == DialogResult.OK) + { + try + { + _logic.SaveTravelConditionToExcelFile(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/FormReportTravelConditions.resx b/TravelCompany/TravelCompany/FormReportTravelConditions.resx new file mode 100644 index 0000000..db7ace7 --- /dev/null +++ b/TravelCompany/TravelCompany/FormReportTravelConditions.resx @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 aaa5fbd..a973c6b 100644 --- a/TravelCompany/TravelCompany/Program.cs +++ b/TravelCompany/TravelCompany/Program.cs @@ -5,6 +5,8 @@ using TravelCompanyContracts.BusinessLogicsContracts; using TravelCompanyContracts.StoragesContracts; using TravelCompanyDatabaseImplement.Implements; using TravelCompanyBusinessLogic.BusinessLogic; +using TravelCompanyBusinessLogic.OfficePackage.Implements; +using TravelCompanyBusinessLogic.OfficePackage; namespace TravelCompany { @@ -39,6 +41,7 @@ namespace TravelCompany services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); @@ -46,6 +49,13 @@ namespace TravelCompany services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + + } } diff --git a/TravelCompany/TravelCompany/ReportOrders.rdlc b/TravelCompany/TravelCompany/ReportOrders.rdlc new file mode 100644 index 0000000..99e0cfb --- /dev/null +++ b/TravelCompany/TravelCompany/ReportOrders.rdlc @@ -0,0 +1,572 @@ + + + 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 + + + + + Заказы + + + + 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 +