From 11ed1b1c7c732522846b81a960de465fa0bdf6eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9F=D0=B0=D0=B2=D0=B5=D0=BB=20=D0=9F=D1=83=D1=82=D0=B8?= =?UTF-8?q?=D0=BB=D0=B8=D0=BD?= Date: Mon, 20 Mar 2023 21:27:43 +0400 Subject: [PATCH] lab4Complete --- .../PrecastConcretePlant/FormMain.Designer.cs | 42 +- .../PrecastConcretePlant/FormMain.cs | 34 +- .../FormReportOrders.Designer.cs | 153 +++++ .../PrecastConcretePlant/FormReportOrders.cs | 100 +++ .../FormReportOrders.resx | 60 ++ ...FormReportReinforcedComponents.Designer.cs | 116 ++++ .../FormReportReinforcedComponents.cs | 78 +++ .../FormReportReinforcedComponents.resx | 60 ++ .../PrecastConcretePlantView.csproj | 7 + .../PrecastConcretePlant/Program.cs | 11 + .../PrecastConcretePlant/ReportOrders.rdlc | 600 ++++++++++++++++++ .../OfficePackage/AbstractSaveToExcel.cs | 112 ++++ .../OfficePackage/AbstractSaveToPdf.cs | 79 +++ .../OfficePackage/AbstractSaveToWord.cs | 66 ++ .../HelperEnums/ExcelStyleInfoType.cs | 15 + .../HelperEnums/PdfParagraphAlignmentType.cs | 15 + .../HelperEnums/WordJustificationType.cs | 14 + .../HelperModels/ExcelCellParameters.cs | 18 + .../OfficePackage/HelperModels/ExcelInfo.cs | 20 + .../HelperModels/ExcelMergeParameters.cs | 15 + .../OfficePackage/HelperModels/PdfInfo.cs | 18 + .../HelperModels/PdfParagraph.cs | 16 + .../HelperModels/PdfRowParameters.cs | 16 + .../OfficePackage/HelperModels/WordInfo.cs | 16 + .../HelperModels/WordParagraph.cs | 14 + .../HelperModels/WordTextProperties.cs | 16 + .../OfficePackage/Implement/SaveToExcel.cs | 297 +++++++++ .../OfficePackage/Implement/SaveToPdf.cs | 119 ++++ .../OfficePackage/Implement/SaveToWord.cs | 135 ++++ .../PrecastConcretePlantBusinessLogic.csproj | 2 + .../ReportLogic.cs | 126 ++++ .../BindingModels/ReportBindingModel.cs | 15 + .../BusinessLogicsContracts/IReportLogic.cs | 40 ++ .../SearchModels/OrderSearchModel.cs | 2 + .../ViewModels/ReportOrdersViewModel.cs | 17 + .../ReportReinforcedComponentViewModel.cs | 15 + .../OrderStorage.cs | 8 + .../OrderStorage.cs | 7 + .../ReinforcedStorage.cs | 8 +- .../OrderStorage.cs | 12 +- 40 files changed, 2504 insertions(+), 10 deletions(-) create mode 100644 PrecastConcretePlant/PrecastConcretePlant/FormReportOrders.Designer.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlant/FormReportOrders.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlant/FormReportOrders.resx create mode 100644 PrecastConcretePlant/PrecastConcretePlant/FormReportReinforcedComponents.Designer.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlant/FormReportReinforcedComponents.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlant/FormReportReinforcedComponents.resx create mode 100644 PrecastConcretePlant/PrecastConcretePlant/ReportOrders.rdlc create mode 100644 PrecastConcretePlant/PrecastConcretePlantBusinessLogic/OfficePackage/AbstractSaveToExcel.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantBusinessLogic/OfficePackage/AbstractSaveToPdf.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantBusinessLogic/OfficePackage/AbstractSaveToWord.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantBusinessLogic/OfficePackage/HelperEnums/ExcelStyleInfoType.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantBusinessLogic/OfficePackage/HelperEnums/PdfParagraphAlignmentType.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantBusinessLogic/OfficePackage/HelperEnums/WordJustificationType.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantBusinessLogic/OfficePackage/HelperModels/ExcelCellParameters.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantBusinessLogic/OfficePackage/HelperModels/ExcelMergeParameters.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantBusinessLogic/OfficePackage/HelperModels/PdfParagraph.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantBusinessLogic/OfficePackage/HelperModels/PdfRowParameters.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantBusinessLogic/OfficePackage/HelperModels/WordInfo.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantBusinessLogic/OfficePackage/HelperModels/WordParagraph.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantBusinessLogic/OfficePackage/HelperModels/WordTextProperties.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantBusinessLogic/OfficePackage/Implement/SaveToExcel.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantBusinessLogic/OfficePackage/Implement/SaveToPdf.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantBusinessLogic/OfficePackage/Implement/SaveToWord.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantBusinessLogic/ReportLogic.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantContracts/BindingModels/ReportBindingModel.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantContracts/BusinessLogicsContracts/IReportLogic.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantContracts/ViewModels/ReportOrdersViewModel.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantContracts/ViewModels/ReportReinforcedComponentViewModel.cs diff --git a/PrecastConcretePlant/PrecastConcretePlant/FormMain.Designer.cs b/PrecastConcretePlant/PrecastConcretePlant/FormMain.Designer.cs index 36fff37..7525c24 100644 --- a/PrecastConcretePlant/PrecastConcretePlant/FormMain.Designer.cs +++ b/PrecastConcretePlant/PrecastConcretePlant/FormMain.Designer.cs @@ -38,6 +38,10 @@ this.справочникиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.reinforcedToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.componentToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.reportsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.pastriesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.pastryComponentsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.ordersToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); this.menuStrip1.SuspendLayout(); this.SuspendLayout(); @@ -112,7 +116,8 @@ // menuStrip1 // this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.справочникиToolStripMenuItem}); + this.справочникиToolStripMenuItem, + this.reportsToolStripMenuItem}); this.menuStrip1.Location = new System.Drawing.Point(0, 0); this.menuStrip1.Name = "menuStrip1"; this.menuStrip1.Size = new System.Drawing.Size(999, 24); @@ -142,6 +147,37 @@ this.componentToolStripMenuItem.Text = "Компоненты"; this.componentToolStripMenuItem.Click += new System.EventHandler(this.ComponentsToolStripMenuItem_Click); // + // reportsToolStripMenuItem + // + this.reportsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.pastriesToolStripMenuItem, + this.pastryComponentsToolStripMenuItem, + this.ordersToolStripMenuItem}); + this.reportsToolStripMenuItem.Name = "reportsToolStripMenuItem"; + this.reportsToolStripMenuItem.Size = new System.Drawing.Size(60, 20); + this.reportsToolStripMenuItem.Text = "Отчеты"; + // + // pastriesToolStripMenuItem + // + this.pastriesToolStripMenuItem.Name = "pastriesToolStripMenuItem"; + this.pastriesToolStripMenuItem.Size = new System.Drawing.Size(215, 22); + this.pastriesToolStripMenuItem.Text = "Список изделий"; + this.pastriesToolStripMenuItem.Click += new System.EventHandler(this.ReinforcedsToolStripMenuItem_Click_1); + // + // pastryComponentsToolStripMenuItem + // + this.pastryComponentsToolStripMenuItem.Name = "pastryComponentsToolStripMenuItem"; + this.pastryComponentsToolStripMenuItem.Size = new System.Drawing.Size(215, 22); + this.pastryComponentsToolStripMenuItem.Text = "Изделия с компонентами"; + this.pastryComponentsToolStripMenuItem.Click += new System.EventHandler(this.ReinforcedComponentsToolStripMenuItem_Click); + // + // ordersToolStripMenuItem + // + this.ordersToolStripMenuItem.Name = "ordersToolStripMenuItem"; + this.ordersToolStripMenuItem.Size = new System.Drawing.Size(215, 22); + this.ordersToolStripMenuItem.Text = "Список заказов"; + this.ordersToolStripMenuItem.Click += new System.EventHandler(this.OrdersToolStripMenuItem_Click); + // // FormMain // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); @@ -177,5 +213,9 @@ private ToolStripMenuItem справочникиToolStripMenuItem; private ToolStripMenuItem reinforcedToolStripMenuItem; private ToolStripMenuItem componentToolStripMenuItem; + private ToolStripMenuItem reportsToolStripMenuItem; + private ToolStripMenuItem pastriesToolStripMenuItem; + private ToolStripMenuItem pastryComponentsToolStripMenuItem; + private ToolStripMenuItem ordersToolStripMenuItem; } } \ No newline at end of file diff --git a/PrecastConcretePlant/PrecastConcretePlant/FormMain.cs b/PrecastConcretePlant/PrecastConcretePlant/FormMain.cs index 6961b10..e1869de 100644 --- a/PrecastConcretePlant/PrecastConcretePlant/FormMain.cs +++ b/PrecastConcretePlant/PrecastConcretePlant/FormMain.cs @@ -1,5 +1,6 @@ using Microsoft.Extensions.Logging; using PrecastConcretePlant; +using PrecastConcretePlantBusinessLogic; using PrecastConcretePlantContracts.BindingModels; using PrecastConcretePlantContracts.BusinessLogicsContracts; using PrecastConcretePlantDataModels.Enums; @@ -11,11 +12,14 @@ namespace PrecastConcretePlantView { 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; + _reportLogic = reportLogic; } private void FormMain_Load(object sender, EventArgs e) { @@ -152,5 +156,33 @@ namespace PrecastConcretePlantView { LoadData(); } + + private void ReinforcedsToolStripMenuItem_Click_1(object sender, EventArgs e) + { + using var dialog = new SaveFileDialog { Filter = "docx|*.docx" }; + if (dialog.ShowDialog() == DialogResult.OK) + { + _reportLogic.SaveReinforcedsToWordFile(new ReportBindingModel { FileName = dialog.FileName }); + MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + } + + private void ReinforcedComponentsToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormReportReinforcedComponents)); + if (service is FormReportReinforcedComponents 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/PrecastConcretePlant/PrecastConcretePlant/FormReportOrders.Designer.cs b/PrecastConcretePlant/PrecastConcretePlant/FormReportOrders.Designer.cs new file mode 100644 index 0000000..c8be4f2 --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlant/FormReportOrders.Designer.cs @@ -0,0 +1,153 @@ +namespace PrecastConcretePlantView +{ + 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.panel = new System.Windows.Forms.Panel(); + 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(); + // + // panel + // + 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); + this.panel.Name = "panel"; + this.panel.Size = new System.Drawing.Size(1046, 40); + this.panel.TabIndex = 1; + // + // button1 + // + this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.button1.Location = new System.Drawing.Point(894, 8); + this.button1.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(139, 27); + this.button1.TabIndex = 6; + this.button1.Text = "В Pdf"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.ButtonToPdf_Click); + // + // buttonToPdf + // + this.buttonToPdf.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.buttonToPdf.Location = new System.Drawing.Point(1724, 8); + this.buttonToPdf.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.buttonToPdf.Name = "buttonToPdf"; + this.buttonToPdf.Size = new System.Drawing.Size(139, 27); + this.buttonToPdf.TabIndex = 5; + this.buttonToPdf.Text = "В Pdf"; + this.buttonToPdf.UseVisualStyleBackColor = true; + // + // buttonMake + // + this.buttonMake.Location = new System.Drawing.Point(476, 8); + this.buttonMake.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.buttonMake.Name = "buttonMake"; + this.buttonMake.Size = new System.Drawing.Size(139, 27); + this.buttonMake.TabIndex = 4; + this.buttonMake.Text = "Сформировать"; + 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 = "С"; + // + // FormReportOrders + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(1046, 470); + this.Controls.Add(this.panel); + this.Name = "FormReportOrders"; + this.Text = "Заказы"; + this.panel.ResumeLayout(false); + this.panel.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private Panel panel; + private Button buttonToPdf; + private Button buttonMake; + private DateTimePicker dateTimePickerTo; + private Label labelTo; + private DateTimePicker dateTimePickerFrom; + private Label labelFrom; + private Button button1; + } +} \ No newline at end of file diff --git a/PrecastConcretePlant/PrecastConcretePlant/FormReportOrders.cs b/PrecastConcretePlant/PrecastConcretePlant/FormReportOrders.cs new file mode 100644 index 0000000..45c809d --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlant/FormReportOrders.cs @@ -0,0 +1,100 @@ +using Microsoft.Extensions.Logging; +using Microsoft.Reporting.WinForms; +using PrecastConcretePlantContracts.BindingModels; +using PrecastConcretePlantContracts.BusinessLogicsContracts; +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 PrecastConcretePlantView +{ + 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/PrecastConcretePlant/PrecastConcretePlant/FormReportOrders.resx b/PrecastConcretePlant/PrecastConcretePlant/FormReportOrders.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlant/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/PrecastConcretePlant/PrecastConcretePlant/FormReportReinforcedComponents.Designer.cs b/PrecastConcretePlant/PrecastConcretePlant/FormReportReinforcedComponents.Designer.cs new file mode 100644 index 0000000..f3474ce --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlant/FormReportReinforcedComponents.Designer.cs @@ -0,0 +1,116 @@ +namespace PrecastConcretePlantView +{ + partial class FormReportReinforcedComponents + { + /// + /// 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.buttonSaveToExcel = new System.Windows.Forms.Button(); + this.dataGridView = new System.Windows.Forms.DataGridView(); + this.ColumnPastry = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.ColumnComponent = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.ColumnCount = new System.Windows.Forms.DataGridViewTextBoxColumn(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); + this.SuspendLayout(); + // + // buttonSaveToExcel + // + this.buttonSaveToExcel.Location = new System.Drawing.Point(39, 12); + this.buttonSaveToExcel.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.buttonSaveToExcel.Name = "buttonSaveToExcel"; + this.buttonSaveToExcel.Size = new System.Drawing.Size(186, 27); + this.buttonSaveToExcel.TabIndex = 2; + this.buttonSaveToExcel.Text = "Сохранить в Excel"; + this.buttonSaveToExcel.UseVisualStyleBackColor = true; + this.buttonSaveToExcel.Click += new System.EventHandler(this.ButtonSaveToExcel_Click); + // + // dataGridView + // + this.dataGridView.AllowUserToAddRows = false; + this.dataGridView.AllowUserToDeleteRows = false; + this.dataGridView.AllowUserToOrderColumns = true; + this.dataGridView.AllowUserToResizeColumns = false; + this.dataGridView.AllowUserToResizeRows = false; + this.dataGridView.BackgroundColor = System.Drawing.SystemColors.ControlLightLight; + this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.ColumnPastry, + this.ColumnComponent, + this.ColumnCount}); + this.dataGridView.Dock = System.Windows.Forms.DockStyle.Bottom; + this.dataGridView.Location = new System.Drawing.Point(0, 72); + this.dataGridView.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.dataGridView.MultiSelect = false; + this.dataGridView.Name = "dataGridView"; + this.dataGridView.ReadOnly = true; + this.dataGridView.RowHeadersVisible = false; + this.dataGridView.Size = new System.Drawing.Size(666, 510); + this.dataGridView.TabIndex = 3; + // + // ColumnPastry + // + this.ColumnPastry.HeaderText = "Изделие"; + this.ColumnPastry.Name = "ColumnPastry"; + this.ColumnPastry.ReadOnly = true; + this.ColumnPastry.Width = 200; + // + // ColumnComponent + // + this.ColumnComponent.HeaderText = "Компонент"; + this.ColumnComponent.Name = "ColumnComponent"; + this.ColumnComponent.ReadOnly = true; + this.ColumnComponent.Width = 200; + // + // ColumnCount + // + this.ColumnCount.HeaderText = "Количество"; + this.ColumnCount.Name = "ColumnCount"; + this.ColumnCount.ReadOnly = true; + // + // FormReportReinforcedComponents + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(666, 582); + this.Controls.Add(this.dataGridView); + this.Controls.Add(this.buttonSaveToExcel); + this.Name = "FormReportReinforcedComponents"; + this.Text = "Изделия с компонентами"; + this.Load += new System.EventHandler(this.FormReportPastryComponents_Load); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private Button buttonSaveToExcel; + private DataGridView dataGridView; + private DataGridViewTextBoxColumn ColumnPastry; + private DataGridViewTextBoxColumn ColumnComponent; + private DataGridViewTextBoxColumn ColumnCount; + } +} \ No newline at end of file diff --git a/PrecastConcretePlant/PrecastConcretePlant/FormReportReinforcedComponents.cs b/PrecastConcretePlant/PrecastConcretePlant/FormReportReinforcedComponents.cs new file mode 100644 index 0000000..af9e05b --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlant/FormReportReinforcedComponents.cs @@ -0,0 +1,78 @@ +using Microsoft.Extensions.Logging; +using PrecastConcretePlantContracts.BindingModels; +using PrecastConcretePlantContracts.BusinessLogicsContracts; +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 PrecastConcretePlantView +{ + public partial class FormReportReinforcedComponents : Form + { + private readonly ILogger _logger; + + private readonly IReportLogic _logic; + public FormReportReinforcedComponents(ILogger logger, IReportLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + } + + private void FormReportPastryComponents_Load(object sender, EventArgs e) + { + try + { + var dict = _logic.GetReinforcedComponent(); + if (dict != null) + { + dataGridView.Rows.Clear(); + foreach (var elem in dict) + { + dataGridView.Rows.Add(new object[] { elem.ReinforcedName, "", "" }); + foreach (var listElem in elem.Components) + { + 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.SaveReinforcedComponentToExcelFile(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/PrecastConcretePlant/PrecastConcretePlant/FormReportReinforcedComponents.resx b/PrecastConcretePlant/PrecastConcretePlant/FormReportReinforcedComponents.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlant/FormReportReinforcedComponents.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/PrecastConcretePlant/PrecastConcretePlant/PrecastConcretePlantView.csproj b/PrecastConcretePlant/PrecastConcretePlant/PrecastConcretePlantView.csproj index 6ed204a..3652882 100644 --- a/PrecastConcretePlant/PrecastConcretePlant/PrecastConcretePlantView.csproj +++ b/PrecastConcretePlant/PrecastConcretePlant/PrecastConcretePlantView.csproj @@ -15,6 +15,7 @@ + @@ -25,4 +26,10 @@ + + + Always + + + \ No newline at end of file diff --git a/PrecastConcretePlant/PrecastConcretePlant/Program.cs b/PrecastConcretePlant/PrecastConcretePlant/Program.cs index ecc282a..326a72d 100644 --- a/PrecastConcretePlant/PrecastConcretePlant/Program.cs +++ b/PrecastConcretePlant/PrecastConcretePlant/Program.cs @@ -7,6 +7,9 @@ using PrecastConcretePlantView; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using NLog.Extensions.Logging; +using PrecastConcretePlantBusinessLogic.OfficePackage.Implement; +using PrecastConcretePlantBusinessLogic.OfficePackage; +using PrecastConcretePlantBusinessLogic; namespace PrecastConcretePlant @@ -43,6 +46,12 @@ namespace PrecastConcretePlant services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); + + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); @@ -50,6 +59,8 @@ namespace PrecastConcretePlant services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); + services.AddTransient(); } } } \ No newline at end of file diff --git a/PrecastConcretePlant/PrecastConcretePlant/ReportOrders.rdlc b/PrecastConcretePlant/PrecastConcretePlant/ReportOrders.rdlc new file mode 100644 index 0000000..12043ea --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlant/ReportOrders.rdlc @@ -0,0 +1,600 @@ + + + 0 + + + + System.Data.DataSet + /* Local Connection */ + + 10791c83-cee8-4a38-bbd0-245fc17cefb3 + + + + + + PrecastConcretePlantContractsViewModels + /* Local Query */ + + + + Id + System.Int32 + + + DateCreate + System.DateTime + + + ReinforcedName + System.String + + + Sum + System.Decimal + + + OrderStatus + PrecastConcretePlantDataModels.OrderStatus + + + + PrecastConcretePlantContracts.ViewModels + ReportOrdersViewModel + PrecastConcretePlantContracts.ViewModels.ReportOrdersViewModel, PrecastConcretePlantContracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + + + + + + + + + true + true + + + + + =Parameters!ReportParameterPeriod.Value + + + + + + + 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 + + + 3.02917cm + + + 2.87042cm + + + + + 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!ReinforcedName.Value + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!OrderStatus.Value + + + 2pt + 2pt + 2pt + 2pt + + + true + + + + + + true + true + + + + + =Fields!Sum.Value + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + + + + + + + + + + + + + + After + + + + + + + DataSetOrders + 2.48391cm + 0.55245cm + 1.2cm + 19.84713cm + 2 + + + + + + true + true + + + + + Итого: + + + + + + + 4cm + 15.39958cm + 0.6cm + 2.5cm + 3 + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + =Sum(Fields!Sum.Value, "DataSetOrders") + + + + + + + 4cm + 17.89958cm + 0.6cm + 2.5cm + 4 + + + 2pt + 2pt + 2pt + 2pt + + + + 5.72875cm +