From e05df9849afacc0308c15fabccad5de39bec3adf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9A=D0=B0=D1=88=D0=B8=D0=BD=20=D0=9C=D0=B0=D0=BA=D1=81?= =?UTF-8?q?=D0=B8=D0=BC?= Date: Tue, 14 Mar 2023 00:13:38 +0400 Subject: [PATCH] =?UTF-8?q?=D0=A8=D0=B0=D0=B3=204.2=20=D0=9D=D0=B5=20?= =?UTF-8?q?=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=D0=B5=D1=82=20=D0=BE=D1=82?= =?UTF-8?q?=D1=87=D0=B5=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...FormReportReinforcedComponents.Designer.cs | 110 ++++ .../FormReportReinforcedComponents.cs | 85 +++ .../FormReportReinforcedComponents.resx | 78 +++ .../PrecastConcretePlant/Program.cs | 6 + .../Properties/Resources.Designer.cs | 63 -- .../Properties/Resources.resx | 120 ---- .../Properties/launchSettings.json | 7 - .../PrecastConcretePlant/ReportOrders.rdlc | 599 ++++++++++++++++++ .../BusinessLogic/ReportLogic.cs | 110 ++++ .../OfficePackage/AbstractSaveToExcel.cs | 8 +- .../OfficePackage/AbstractSaveToPdf.cs | 2 +- .../OfficePackage/AbstractSaveToWord.cs | 6 +- .../OfficePackage/HelperModels/ExcelInfo.cs | 2 +- .../OfficePackage/HelperModels/WordInfo.cs | 2 +- .../OfficePackage/Implements/SaveToExcel.cs | 312 +++++++++ .../OfficePackage/Implements/SaveToPdf.cs | 103 +++ .../OfficePackage/Implements/SaveToWord.cs | 122 ++++ .../PrecastConcretePlantBusinessLogic.csproj | 6 +- .../BusinessLogicsContracts/IReportLogic.cs | 6 +- .../ReportComponentBlankViewModel.cs | 6 +- .../ViewModels/ReportOrdersViewModel.cs | 2 +- 21 files changed, 1544 insertions(+), 211 deletions(-) create mode 100644 PrecastConcretePlant/PrecastConcretePlant/FormReportReinforcedComponents.Designer.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlant/FormReportReinforcedComponents.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlant/FormReportReinforcedComponents.resx delete mode 100644 PrecastConcretePlant/PrecastConcretePlant/Properties/Resources.Designer.cs delete mode 100644 PrecastConcretePlant/PrecastConcretePlant/Properties/Resources.resx delete mode 100644 PrecastConcretePlant/PrecastConcretePlant/Properties/launchSettings.json create mode 100644 PrecastConcretePlant/PrecastConcretePlant/ReportOrders.rdlc create mode 100644 PrecastConcretePlant/PrecastConcretePlantBusinessLogic/BusinessLogic/ReportLogic.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantBusinessLogic/OfficePackage/Implements/SaveToExcel.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantBusinessLogic/OfficePackage/Implements/SaveToPdf.cs create mode 100644 PrecastConcretePlant/PrecastConcretePlantBusinessLogic/OfficePackage/Implements/SaveToWord.cs diff --git a/PrecastConcretePlant/PrecastConcretePlant/FormReportReinforcedComponents.Designer.cs b/PrecastConcretePlant/PrecastConcretePlant/FormReportReinforcedComponents.Designer.cs new file mode 100644 index 0000000..b7104b9 --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlant/FormReportReinforcedComponents.Designer.cs @@ -0,0 +1,110 @@ +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.dataGridView = new System.Windows.Forms.DataGridView(); + this.Blank = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Document = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Count = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.buttonSaveToExcel = new System.Windows.Forms.Button(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); + this.SuspendLayout(); + // + // dataGridView + // + this.dataGridView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.Blank, + this.Document, + this.Count}); + this.dataGridView.Location = new System.Drawing.Point(12, 37); + this.dataGridView.Name = "dataGridView"; + this.dataGridView.RowHeadersWidth = 51; + this.dataGridView.RowTemplate.Height = 29; + this.dataGridView.Size = new System.Drawing.Size(776, 401); + this.dataGridView.TabIndex = 0; + // + // Blank + // + this.Blank.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.Blank.HeaderText = "Бланк"; + this.Blank.MinimumWidth = 6; + this.Blank.Name = "Blank"; + // + // Document + // + this.Document.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.Document.HeaderText = "Документ"; + this.Document.MinimumWidth = 6; + this.Document.Name = "Document"; + // + // Count + // + this.Count.HeaderText = "Количество"; + this.Count.MinimumWidth = 6; + this.Count.Name = "Count"; + this.Count.Width = 125; + // + // buttonSaveToExcel + // + this.buttonSaveToExcel.Location = new System.Drawing.Point(12, 2); + this.buttonSaveToExcel.Name = "buttonSaveToExcel"; + this.buttonSaveToExcel.Size = new System.Drawing.Size(220, 29); + this.buttonSaveToExcel.TabIndex = 1; + this.buttonSaveToExcel.Text = "Сохранить в Excel"; + this.buttonSaveToExcel.UseVisualStyleBackColor = true; + this.buttonSaveToExcel.Click += new System.EventHandler(this.buttonSaveToExcel_Click); + // + // FormReportReinforcedComponents + // + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(800, 450); + this.Controls.Add(this.buttonSaveToExcel); + this.Controls.Add(this.dataGridView); + this.Name = "FormReportReinforcedComponents"; + this.Text = "Бланки по документам"; + this.Load += new System.EventHandler(this.FormReportDocumentBlanks_Load); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private DataGridView dataGridView; + private DataGridViewTextBoxColumn Blank; + private DataGridViewTextBoxColumn Document; + private DataGridViewTextBoxColumn Count; + private Button buttonSaveToExcel; + } +} \ No newline at end of file diff --git a/PrecastConcretePlant/PrecastConcretePlant/FormReportReinforcedComponents.cs b/PrecastConcretePlant/PrecastConcretePlant/FormReportReinforcedComponents.cs new file mode 100644 index 0000000..5711c76 --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlant/FormReportReinforcedComponents.cs @@ -0,0 +1,85 @@ +using PrecastConcretePlantContracts.BindingModels; +using PrecastConcretePlantContracts.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 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 FormReportDocumentBlanks_Load(object sender, EventArgs e) + { + try + { + var dict = _logic.GetReinforcedComponents(); + 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..0908e41 --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlant/FormReportReinforcedComponents.resx @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + True + + + True + + + True + + \ No newline at end of file diff --git a/PrecastConcretePlant/PrecastConcretePlant/Program.cs b/PrecastConcretePlant/PrecastConcretePlant/Program.cs index c7ef8f3..bb82627 100644 --- a/PrecastConcretePlant/PrecastConcretePlant/Program.cs +++ b/PrecastConcretePlant/PrecastConcretePlant/Program.cs @@ -6,6 +6,8 @@ using Microsoft.Extensions.Logging; using NLog.Extensions.Logging; using PrecastConcretePlantBusinessLogic.PrecastConcretePlantBusinessLogic.BusinessLogic; using PrecastConcretePlantDatabaseImplement.Implements; +using PrecastConcretePlantBusinessLogic.OfficePackage.Implements; +using PrecastConcretePlantBusinessLogic.OfficePackage; namespace PrecastConcretePlantView { @@ -37,6 +39,10 @@ namespace PrecastConcretePlantView services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); diff --git a/PrecastConcretePlant/PrecastConcretePlant/Properties/Resources.Designer.cs b/PrecastConcretePlant/PrecastConcretePlant/Properties/Resources.Designer.cs deleted file mode 100644 index 5110396..0000000 --- a/PrecastConcretePlant/PrecastConcretePlant/Properties/Resources.Designer.cs +++ /dev/null @@ -1,63 +0,0 @@ -//------------------------------------------------------------------------------ -// -// Этот код создан программой. -// Исполняемая версия:4.0.30319.42000 -// -// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае -// повторной генерации кода. -// -//------------------------------------------------------------------------------ - -namespace PrecastConcretePlantView.Properties { - using System; - - - /// - /// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д. - /// - // Этот класс создан автоматически классом StronglyTypedResourceBuilder - // с помощью такого средства, как ResGen или Visual Studio. - // Чтобы добавить или удалить член, измените файл .ResX и снова запустите ResGen - // с параметром /str или перестройте свой проект VS. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Resources { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Resources() { - } - - /// - /// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("PrecastConcretePlantView.Properties.Resources", typeof(Resources).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Перезаписывает свойство CurrentUICulture текущего потока для всех - /// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - } -} diff --git a/PrecastConcretePlant/PrecastConcretePlant/Properties/Resources.resx b/PrecastConcretePlant/PrecastConcretePlant/Properties/Resources.resx deleted file mode 100644 index 1af7de1..0000000 --- a/PrecastConcretePlant/PrecastConcretePlant/Properties/Resources.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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/Properties/launchSettings.json b/PrecastConcretePlant/PrecastConcretePlant/Properties/launchSettings.json deleted file mode 100644 index 8a978ef..0000000 --- a/PrecastConcretePlant/PrecastConcretePlant/Properties/launchSettings.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "profiles": { - "SoftwareInstallationView": { - "commandName": "Project" - } - } -} \ No newline at end of file diff --git a/PrecastConcretePlant/PrecastConcretePlant/ReportOrders.rdlc b/PrecastConcretePlant/PrecastConcretePlant/ReportOrders.rdlc new file mode 100644 index 0000000..23d27f7 --- /dev/null +++ b/PrecastConcretePlant/PrecastConcretePlant/ReportOrders.rdlc @@ -0,0 +1,599 @@ + + + 0 + + + + System.Data.DataSet + /* Local Connection */ + + 10791c83-cee8-4a38-bbd0-245fc17cefb3 + + + + + + LawFirmContractsViewModels + /* Local Query */ + + + + Id + System.Int32 + + + DateCreate + System.DateTime + + + DocumentName + System.String + + + Sum + System.Decimal + + + Status + System.String + + + + LawFirmContracts.ViewModels + ReportOrdersViewModel + LawFirmContracts.ViewModels.ReportOrdersViewModel, LawFirmContracts, 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 + + + 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!DocumentName.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 + + + 2pt + 2pt + 2pt + 2pt + + + + 5.72875cm +