From 2e91117b6733145d6a6c6b97e695025748e91c78 Mon Sep 17 00:00:00 2001 From: dimazhelovanov Date: Mon, 13 Mar 2023 08:21:48 +0300 Subject: [PATCH 1/3] =?UTF-8?q?=D0=9A=D0=BE=D0=BC=D0=BC=D0=B8=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BlacksmithWorkshop.csproj | 2 + .../BlacksmithWorkshop/FormMain.Designer.cs | 42 ++- .../BlacksmithWorkshop/FormMain.cs | 44 ++- ...ormReportManufactureComponents.Designer.cs | 105 ++++++ .../FormReportManufactureComponents.cs | 96 +++++ .../FormReportManufactureComponents.resx | 69 ++++ .../FormReportOrders.Designer.cs | 130 +++++++ .../BlacksmithWorkshop/FormReportOrders.cs | 110 ++++++ .../BlacksmithWorkshop/FormReportOrders.resx | 60 +++ .../BlacksmithWorkshop/Program.cs | 11 + ...LogicsContracts.IComponentLogic.datasource | 10 + ...gicsContracts.IManufactureLogic.datasource | 10 + ...nessLogicsContracts.IOrderLogic.datasource | 10 + ...essLogicsContracts.IReportLogic.datasource | 10 + ...agesContracts.IComponentStorage.datasource | 10 + ...esContracts.IManufactureStorage.datasource | 10 + ...StoragesContracts.IOrderStorage.datasource | 10 + ...BlacksmithWorkshopDataModel.IId.datasource | 10 + ...ataModel.Models.IComponentModel.datasource | 10 + .../BlacksmithWorkshop/ReportOrders.rdlc | 111 ++++++ .../BlacksmithWorkshopBusinessLogic.csproj | 2 + .../BusinessLogics/ReportLogic.cs | 131 +++++++ .../OfficePackage/AbstractSaveToExcel.cs | 103 +++++ .../OfficePackage/AbstractSaveToPdf.cs | 84 +++++ .../OfficePackage/AbstractSaveToWord.cs | 72 ++++ .../HelperEnums/ExcelStyleInfoType.cs | 16 + .../HelperEnums/PdfParagraphAlignmentType.cs | 16 + .../HelperEnums/PdfRowParameters.cs | 15 + .../HelperEnums/WordJustificationType.cs | 15 + .../HelperModels/ExcelCellParameters.cs | 18 + .../OfficePackage/HelperModels/ExcelInfo.cs | 21 ++ .../HelperModels/ExcelMergeParameters.cs | 15 + .../OfficePackage/HelperModels/PdfInfo.cs | 18 + .../HelperModels/PdfParagraph.cs | 16 + .../OfficePackage/HelperModels/WordInfo.cs | 17 + .../HelperModels/WordParagraph.cs | 14 + .../HelperModels/WordTextProperties.cs | 16 + .../OfficePackage/Implements/SaveToExcel.cs | 356 ++++++++++++++++++ .../OfficePackage/Implements/SaveToPdf.cs | 108 ++++++ .../OfficePackage/Implements/SaveToWord.cs | 132 +++++++ .../BindingModels/ReportBindingModel.cs | 16 + .../BlacksmithWorkshopContracts.csproj | 4 + .../BusinessLogicsContracts/IReportLogic.cs | 40 ++ ...essLogicsContracts.IReportLogic.datasource | 10 + .../SearchModels/OrderSearchModel.cs | 2 + .../ReportManufactureComponentViewModel.cs | 15 + .../ViewModels/ReportOrdersViewModel.cs | 17 + .../BlacksmithWorkshopDataModel.csproj | 2 +- .../Implements/OrderStorage.cs | 9 + .../Implements/OrderStorage.cs | 13 + .../Implements/OrderStorage.cs | 12 + 51 files changed, 2189 insertions(+), 6 deletions(-) create mode 100644 BlacksmithWorkshop/BlacksmithWorkshop/FormReportManufactureComponents.Designer.cs create mode 100644 BlacksmithWorkshop/BlacksmithWorkshop/FormReportManufactureComponents.cs create mode 100644 BlacksmithWorkshop/BlacksmithWorkshop/FormReportManufactureComponents.resx create mode 100644 BlacksmithWorkshop/BlacksmithWorkshop/FormReportOrders.Designer.cs create mode 100644 BlacksmithWorkshop/BlacksmithWorkshop/FormReportOrders.cs create mode 100644 BlacksmithWorkshop/BlacksmithWorkshop/FormReportOrders.resx create mode 100644 BlacksmithWorkshop/BlacksmithWorkshop/Properties/DataSources/BlacksmithWorkshopContracts.BusinessLogicsContracts.IComponentLogic.datasource create mode 100644 BlacksmithWorkshop/BlacksmithWorkshop/Properties/DataSources/BlacksmithWorkshopContracts.BusinessLogicsContracts.IManufactureLogic.datasource create mode 100644 BlacksmithWorkshop/BlacksmithWorkshop/Properties/DataSources/BlacksmithWorkshopContracts.BusinessLogicsContracts.IOrderLogic.datasource create mode 100644 BlacksmithWorkshop/BlacksmithWorkshop/Properties/DataSources/BlacksmithWorkshopContracts.BusinessLogicsContracts.IReportLogic.datasource create mode 100644 BlacksmithWorkshop/BlacksmithWorkshop/Properties/DataSources/BlacksmithWorkshopContracts.StoragesContracts.IComponentStorage.datasource create mode 100644 BlacksmithWorkshop/BlacksmithWorkshop/Properties/DataSources/BlacksmithWorkshopContracts.StoragesContracts.IManufactureStorage.datasource create mode 100644 BlacksmithWorkshop/BlacksmithWorkshop/Properties/DataSources/BlacksmithWorkshopContracts.StoragesContracts.IOrderStorage.datasource create mode 100644 BlacksmithWorkshop/BlacksmithWorkshop/Properties/DataSources/BlacksmithWorkshopDataModel.IId.datasource create mode 100644 BlacksmithWorkshop/BlacksmithWorkshop/Properties/DataSources/BlacksmithWorkshopDataModel.Models.IComponentModel.datasource create mode 100644 BlacksmithWorkshop/BlacksmithWorkshop/ReportOrders.rdlc create mode 100644 BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogics/ReportLogic.cs create mode 100644 BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/OfficePackage/AbstractSaveToExcel.cs create mode 100644 BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/OfficePackage/AbstractSaveToPdf.cs create mode 100644 BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/OfficePackage/AbstractSaveToWord.cs create mode 100644 BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/OfficePackage/HelperEnums/ExcelStyleInfoType.cs create mode 100644 BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/OfficePackage/HelperEnums/PdfParagraphAlignmentType.cs create mode 100644 BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/OfficePackage/HelperEnums/PdfRowParameters.cs create mode 100644 BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/OfficePackage/HelperEnums/WordJustificationType.cs create mode 100644 BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/OfficePackage/HelperModels/ExcelCellParameters.cs create mode 100644 BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs create mode 100644 BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/OfficePackage/HelperModels/ExcelMergeParameters.cs create mode 100644 BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs create mode 100644 BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/OfficePackage/HelperModels/PdfParagraph.cs create mode 100644 BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/OfficePackage/HelperModels/WordInfo.cs create mode 100644 BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/OfficePackage/HelperModels/WordParagraph.cs create mode 100644 BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/OfficePackage/HelperModels/WordTextProperties.cs create mode 100644 BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/OfficePackage/Implements/SaveToExcel.cs create mode 100644 BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/OfficePackage/Implements/SaveToPdf.cs create mode 100644 BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/OfficePackage/Implements/SaveToWord.cs create mode 100644 BlacksmithWorkshop/BlacksmithWorkshopContracts/BindingModels/ReportBindingModel.cs create mode 100644 BlacksmithWorkshop/BlacksmithWorkshopContracts/BusinessLogicsContracts/IReportLogic.cs create mode 100644 BlacksmithWorkshop/BlacksmithWorkshopContracts/DataSources/BlacksmithWorkshopContracts.BusinessLogicsContracts.IReportLogic.datasource create mode 100644 BlacksmithWorkshop/BlacksmithWorkshopContracts/ViewModels/ReportManufactureComponentViewModel.cs create mode 100644 BlacksmithWorkshop/BlacksmithWorkshopContracts/ViewModels/ReportOrdersViewModel.cs diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/BlacksmithWorkshop.csproj b/BlacksmithWorkshop/BlacksmithWorkshop/BlacksmithWorkshop.csproj index 21732a7..faeeef0 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/BlacksmithWorkshop.csproj +++ b/BlacksmithWorkshop/BlacksmithWorkshop/BlacksmithWorkshop.csproj @@ -21,10 +21,12 @@ + + diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.Designer.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.Designer.cs index 4889d10..cb3c202 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.Designer.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.Designer.cs @@ -32,6 +32,10 @@ this.справочникиToolStripMenuItem1 = 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.ComponentsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.ComponentsManufactueToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.OrdersToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.dataGridView = new System.Windows.Forms.DataGridView(); this.buttonCreateOrder = new System.Windows.Forms.Button(); this.buttonnTakeOrderInWork = new System.Windows.Forms.Button(); @@ -46,7 +50,8 @@ // this.menuStrip1.ImageScalingSize = new System.Drawing.Size(20, 20); this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.справочникиToolStripMenuItem1}); + this.справочникиToolStripMenuItem1, + this.отчётыToolStripMenuItem}); this.menuStrip1.Location = new System.Drawing.Point(0, 0); this.menuStrip1.Name = "menuStrip1"; this.menuStrip1.Size = new System.Drawing.Size(920, 28); @@ -76,6 +81,37 @@ this.кузнечныеИзделияToolStripMenuItem.Text = "КузнечныеИзделия"; this.кузнечныеИзделияToolStripMenuItem.Click += new System.EventHandler(this.КузнечныеИзделияToolStripMenuItem_Click); // + // отчётыToolStripMenuItem + // + this.отчётыToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.ComponentsToolStripMenuItem, + this.ComponentsManufactueToolStripMenuItem, + this.OrdersToolStripMenuItem}); + this.отчётыToolStripMenuItem.Name = "отчётыToolStripMenuItem"; + this.отчётыToolStripMenuItem.Size = new System.Drawing.Size(73, 24); + this.отчётыToolStripMenuItem.Text = "Отчёты"; + // + // ComponentsToolStripMenuItem + // + this.ComponentsToolStripMenuItem.Name = "ComponentsToolStripMenuItem"; + this.ComponentsToolStripMenuItem.Size = new System.Drawing.Size(276, 26); + this.ComponentsToolStripMenuItem.Text = "Список компонентов"; + this.ComponentsToolStripMenuItem.Click += new System.EventHandler(this.ComponentsToolStripMenuItem_Click); + // + // ComponentsManufactueToolStripMenuItem + // + this.ComponentsManufactueToolStripMenuItem.Name = "ComponentsManufactueToolStripMenuItem"; + this.ComponentsManufactueToolStripMenuItem.Size = new System.Drawing.Size(276, 26); + this.ComponentsManufactueToolStripMenuItem.Text = "Компоненты по изделиям"; + this.ComponentsManufactueToolStripMenuItem.Click += new System.EventHandler(this.ComponentsManufactueToolStripMenuItem_Click); + // + // OrdersToolStripMenuItem + // + this.OrdersToolStripMenuItem.Name = "OrdersToolStripMenuItem"; + this.OrdersToolStripMenuItem.Size = new System.Drawing.Size(276, 26); + this.OrdersToolStripMenuItem.Text = "Список заказов"; + this.OrdersToolStripMenuItem.Click += new System.EventHandler(this.OrdersToolStripMenuItem_Click); + // // dataGridView // this.dataGridView.BackgroundColor = System.Drawing.SystemColors.ButtonHighlight; @@ -172,5 +208,9 @@ private Button buttonRef; private ToolStripMenuItem компонентыToolStripMenuItem; private ToolStripMenuItem кузнечныеИзделияToolStripMenuItem; + private ToolStripMenuItem отчётыToolStripMenuItem; + private ToolStripMenuItem ComponentsToolStripMenuItem; + private ToolStripMenuItem ComponentsManufactueToolStripMenuItem; + private ToolStripMenuItem OrdersToolStripMenuItem; } } \ No newline at end of file diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.cs index 5665d5a..089135f 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.cs @@ -1,4 +1,5 @@ -using BlacksmithWorkshopContracts.BindingModels; +using BlacksmithWorkshopBusinessLogic.BusinessLogics; +using BlacksmithWorkshopContracts.BindingModels; using BlacksmithWorkshopContracts.BusinessLogicsContracts; using BlacksmithWorkshopDataModel.Enums; using Microsoft.Extensions.Logging; @@ -19,13 +20,14 @@ namespace BlacksmithWorkshop private readonly ILogger _logger; private readonly IOrderLogic _orderLogic; - public FormMain(ILogger logger, IOrderLogic orderLogic) + IReportLogic _reportLogic; + public FormMain(ILogger logger, IOrderLogic orderLogic, IReportLogic reportLogic) { InitializeComponent(); _logger = logger; _orderLogic = orderLogic; LoadData(); - + _reportLogic = reportLogic; } private void FormMain_Load(object sender, EventArgs e) @@ -200,6 +202,40 @@ namespace BlacksmithWorkshop LoadData(); } - + + private void ComponentsToolStripMenuItem_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 ComponentsManufactueToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = +Program.ServiceProvider?.GetService(typeof(FormReportManufactureComponents)); + if (service is FormReportManufactureComponents 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/BlacksmithWorkshop/BlacksmithWorkshop/FormReportManufactureComponents.Designer.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormReportManufactureComponents.Designer.cs new file mode 100644 index 0000000..3884194 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormReportManufactureComponents.Designer.cs @@ -0,0 +1,105 @@ +namespace BlacksmithWorkshop +{ + partial class FormReportManufactureComponents + { + /// + /// 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(); + buttonSaveToExcel = new Button(); + ColumnManufacture = new DataGridViewTextBoxColumn(); + ColumnComponent = new DataGridViewTextBoxColumn(); + ColumnCount = new DataGridViewTextBoxColumn(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + SuspendLayout(); + // + // dataGridView + // + dataGridView.BackgroundColor = SystemColors.ButtonFace; + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Columns.AddRange(new DataGridViewColumn[] { ColumnManufacture, ColumnComponent, ColumnCount }); + dataGridView.Dock = DockStyle.Bottom; + dataGridView.Location = new Point(0, 76); + dataGridView.Name = "dataGridView"; + dataGridView.RowHeadersWidth = 51; + dataGridView.RowTemplate.Height = 29; + dataGridView.Size = new Size(564, 437); + dataGridView.TabIndex = 0; + // + // buttonSaveToExcel + // + buttonSaveToExcel.Location = new Point(23, 23); + buttonSaveToExcel.Name = "buttonSaveToExcel"; + buttonSaveToExcel.Size = new Size(166, 29); + buttonSaveToExcel.TabIndex = 1; + buttonSaveToExcel.Text = "Сохранить в Excel"; + buttonSaveToExcel.UseVisualStyleBackColor = true; + buttonSaveToExcel.Click += ButtonSaveToExcel_Click; + // + // ColumnManufacture + // + ColumnManufacture.HeaderText = "Изделие"; + ColumnManufacture.MinimumWidth = 6; + ColumnManufacture.Name = "ColumnManufacture"; + ColumnManufacture.Width = 125; + // + // ColumnComponent + // + ColumnComponent.HeaderText = "Компонент"; + ColumnComponent.MinimumWidth = 6; + ColumnComponent.Name = "ColumnComponent"; + ColumnComponent.Width = 125; + // + // ColumnCount + // + ColumnCount.HeaderText = "Количество"; + ColumnCount.MinimumWidth = 6; + ColumnCount.Name = "ColumnCount"; + ColumnCount.Width = 125; + // + // FormReportManufactureComponents + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(564, 513); + Controls.Add(buttonSaveToExcel); + Controls.Add(dataGridView); + Name = "FormReportManufactureComponents"; + Text = "FormReportManufactureComponents"; + Load += FormReportManufactureComponents_Load; + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + } + + #endregion + + private DataGridView dataGridView; + private Button buttonSaveToExcel; + private DataGridViewTextBoxColumn ColumnManufacture; + private DataGridViewTextBoxColumn ColumnComponent; + private DataGridViewTextBoxColumn ColumnCount; + } +} \ No newline at end of file diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormReportManufactureComponents.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormReportManufactureComponents.cs new file mode 100644 index 0000000..e519cbf --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormReportManufactureComponents.cs @@ -0,0 +1,96 @@ +using BlacksmithWorkshopContracts.BindingModels; +using BlacksmithWorkshopContracts.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 BlacksmithWorkshop +{ + public partial class FormReportManufactureComponents : Form + { + + private readonly ILogger _logger; + private readonly IReportLogic _logic; + public FormReportManufactureComponents(ILogger + logger, IReportLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + + } + private void FormReportManufactureComponents_Load(object sender, EventArgs e) + { + try + { + var dict = _logic.GetManufactureComponent(); + if (dict != null) + { + dataGridView.Rows.Clear(); + foreach (var elem in dict) + { + dataGridView.Rows.Add(new object[] { elem.ManufactureName, +"", "" }); + 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.SaveManufactureComponentToExcelFile(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/BlacksmithWorkshop/BlacksmithWorkshop/FormReportManufactureComponents.resx b/BlacksmithWorkshop/BlacksmithWorkshop/FormReportManufactureComponents.resx new file mode 100644 index 0000000..b2a3f9d --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormReportManufactureComponents.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/BlacksmithWorkshop/BlacksmithWorkshop/FormReportOrders.Designer.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormReportOrders.Designer.cs new file mode 100644 index 0000000..a788b8b --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormReportOrders.Designer.cs @@ -0,0 +1,130 @@ +namespace BlacksmithWorkshop +{ + 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.ButtonToPdf = new System.Windows.Forms.Button(); + this.ButtonMake = new System.Windows.Forms.Button(); + this.dateTimePickerTo = new System.Windows.Forms.DateTimePicker(); + this.label2 = new System.Windows.Forms.Label(); + this.dateTimePickerFrom = new System.Windows.Forms.DateTimePicker(); + this.label1 = new System.Windows.Forms.Label(); + this.panel.SuspendLayout(); + this.SuspendLayout(); + // + // panel + // + this.panel.Controls.Add(this.ButtonToPdf); + this.panel.Controls.Add(this.ButtonMake); + this.panel.Controls.Add(this.dateTimePickerTo); + this.panel.Controls.Add(this.label2); + this.panel.Controls.Add(this.dateTimePickerFrom); + this.panel.Controls.Add(this.label1); + this.panel.Location = new System.Drawing.Point(0, 2); + this.panel.Name = "panel"; + this.panel.Size = new System.Drawing.Size(932, 42); + this.panel.TabIndex = 0; + // + // ButtonToPdf + // + this.ButtonToPdf.Location = new System.Drawing.Point(829, 8); + this.ButtonToPdf.Name = "ButtonToPdf"; + this.ButtonToPdf.Size = new System.Drawing.Size(94, 29); + this.ButtonToPdf.TabIndex = 5; + this.ButtonToPdf.Text = "в PDF"; + this.ButtonToPdf.UseVisualStyleBackColor = true; + this.ButtonToPdf.Click += new System.EventHandler(this.ButtonToPdf_Click); + // + // ButtonMake + // + this.ButtonMake.Location = new System.Drawing.Point(550, 8); + this.ButtonMake.Name = "ButtonMake"; + this.ButtonMake.Size = new System.Drawing.Size(128, 29); + 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(269, 10); + this.dateTimePickerTo.Name = "dateTimePickerTo"; + this.dateTimePickerTo.Size = new System.Drawing.Size(250, 27); + this.dateTimePickerTo.TabIndex = 3; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(236, 12); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(27, 20); + this.label2.TabIndex = 2; + this.label2.Text = "по"; + // + // dateTimePickerFrom + // + this.dateTimePickerFrom.Location = new System.Drawing.Point(42, 10); + this.dateTimePickerFrom.Name = "dateTimePickerFrom"; + this.dateTimePickerFrom.Size = new System.Drawing.Size(188, 27); + this.dateTimePickerFrom.TabIndex = 1; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(20, 12); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(16, 20); + this.label1.TabIndex = 0; + this.label1.Text = "с"; + // + // FormReportOrders + // + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(935, 450); + this.Controls.Add(this.panel); + this.Name = "FormReportOrders"; + this.Text = "FormReportOrders"; + this.panel.ResumeLayout(false); + this.panel.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private Panel panel; + private Label label2; + private DateTimePicker dateTimePickerFrom; + private Label label1; + private Button ButtonToPdf; + private Button ButtonMake; + private DateTimePicker dateTimePickerTo; + } +} \ No newline at end of file diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormReportOrders.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormReportOrders.cs new file mode 100644 index 0000000..fd7ffda --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormReportOrders.cs @@ -0,0 +1,110 @@ +using BlacksmithWorkshopContracts.BindingModels; +using BlacksmithWorkshopContracts.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 BlacksmithWorkshop +{ + 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("C:\\Users\\User\\source\\repos\\BlacksmithWorkshop\\BlacksmithWorkshop\\BlacksmithWorkshop\\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/BlacksmithWorkshop/BlacksmithWorkshop/FormReportOrders.resx b/BlacksmithWorkshop/BlacksmithWorkshop/FormReportOrders.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshop/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/BlacksmithWorkshop/BlacksmithWorkshop/Program.cs b/BlacksmithWorkshop/BlacksmithWorkshop/Program.cs index c641ef7..8414299 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/Program.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshop/Program.cs @@ -1,4 +1,6 @@ using BlacksmithWorkshopBusinessLogic.BusinessLogics; +using BlacksmithWorkshopBusinessLogic.OfficePackage; +using BlacksmithWorkshopBusinessLogic.OfficePackage.Implements; using BlacksmithWorkshopContracts.BusinessLogicsContracts; using BlacksmithWorkshopContracts.StoragesContracts; using BlacksmithWorkshopDatabaseImplement.Implements; @@ -39,6 +41,13 @@ namespace BlacksmithWorkshop services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); + + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + + services.AddTransient(); services.AddTransient(); services.AddTransient(); @@ -46,6 +55,8 @@ namespace BlacksmithWorkshop services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); + services.AddTransient(); } } } \ No newline at end of file diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/Properties/DataSources/BlacksmithWorkshopContracts.BusinessLogicsContracts.IComponentLogic.datasource b/BlacksmithWorkshop/BlacksmithWorkshop/Properties/DataSources/BlacksmithWorkshopContracts.BusinessLogicsContracts.IComponentLogic.datasource new file mode 100644 index 0000000..e6e1a26 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshop/Properties/DataSources/BlacksmithWorkshopContracts.BusinessLogicsContracts.IComponentLogic.datasource @@ -0,0 +1,10 @@ + + + + BlacksmithWorkshopContracts.BusinessLogicsContracts.IComponentLogic, BlacksmithWorkshopContracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + \ No newline at end of file diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/Properties/DataSources/BlacksmithWorkshopContracts.BusinessLogicsContracts.IManufactureLogic.datasource b/BlacksmithWorkshop/BlacksmithWorkshop/Properties/DataSources/BlacksmithWorkshopContracts.BusinessLogicsContracts.IManufactureLogic.datasource new file mode 100644 index 0000000..ed3589b --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshop/Properties/DataSources/BlacksmithWorkshopContracts.BusinessLogicsContracts.IManufactureLogic.datasource @@ -0,0 +1,10 @@ + + + + BlacksmithWorkshopContracts.BusinessLogicsContracts.IManufactureLogic, BlacksmithWorkshopContracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + \ No newline at end of file diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/Properties/DataSources/BlacksmithWorkshopContracts.BusinessLogicsContracts.IOrderLogic.datasource b/BlacksmithWorkshop/BlacksmithWorkshop/Properties/DataSources/BlacksmithWorkshopContracts.BusinessLogicsContracts.IOrderLogic.datasource new file mode 100644 index 0000000..c5feb50 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshop/Properties/DataSources/BlacksmithWorkshopContracts.BusinessLogicsContracts.IOrderLogic.datasource @@ -0,0 +1,10 @@ + + + + BlacksmithWorkshopContracts.BusinessLogicsContracts.IOrderLogic, BlacksmithWorkshopContracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + \ No newline at end of file diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/Properties/DataSources/BlacksmithWorkshopContracts.BusinessLogicsContracts.IReportLogic.datasource b/BlacksmithWorkshop/BlacksmithWorkshop/Properties/DataSources/BlacksmithWorkshopContracts.BusinessLogicsContracts.IReportLogic.datasource new file mode 100644 index 0000000..74859dd --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshop/Properties/DataSources/BlacksmithWorkshopContracts.BusinessLogicsContracts.IReportLogic.datasource @@ -0,0 +1,10 @@ + + + + BlacksmithWorkshopContracts.BusinessLogicsContracts.IReportLogic, BlacksmithWorkshopContracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + \ No newline at end of file diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/Properties/DataSources/BlacksmithWorkshopContracts.StoragesContracts.IComponentStorage.datasource b/BlacksmithWorkshop/BlacksmithWorkshop/Properties/DataSources/BlacksmithWorkshopContracts.StoragesContracts.IComponentStorage.datasource new file mode 100644 index 0000000..ac1e522 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshop/Properties/DataSources/BlacksmithWorkshopContracts.StoragesContracts.IComponentStorage.datasource @@ -0,0 +1,10 @@ + + + + BlacksmithWorkshopContracts.StoragesContracts.IComponentStorage, BlacksmithWorkshopContracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + \ No newline at end of file diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/Properties/DataSources/BlacksmithWorkshopContracts.StoragesContracts.IManufactureStorage.datasource b/BlacksmithWorkshop/BlacksmithWorkshop/Properties/DataSources/BlacksmithWorkshopContracts.StoragesContracts.IManufactureStorage.datasource new file mode 100644 index 0000000..23ffd15 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshop/Properties/DataSources/BlacksmithWorkshopContracts.StoragesContracts.IManufactureStorage.datasource @@ -0,0 +1,10 @@ + + + + BlacksmithWorkshopContracts.StoragesContracts.IManufactureStorage, BlacksmithWorkshopContracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + \ No newline at end of file diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/Properties/DataSources/BlacksmithWorkshopContracts.StoragesContracts.IOrderStorage.datasource b/BlacksmithWorkshop/BlacksmithWorkshop/Properties/DataSources/BlacksmithWorkshopContracts.StoragesContracts.IOrderStorage.datasource new file mode 100644 index 0000000..41448a7 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshop/Properties/DataSources/BlacksmithWorkshopContracts.StoragesContracts.IOrderStorage.datasource @@ -0,0 +1,10 @@ + + + + BlacksmithWorkshopContracts.StoragesContracts.IOrderStorage, BlacksmithWorkshopContracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + \ No newline at end of file diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/Properties/DataSources/BlacksmithWorkshopDataModel.IId.datasource b/BlacksmithWorkshop/BlacksmithWorkshop/Properties/DataSources/BlacksmithWorkshopDataModel.IId.datasource new file mode 100644 index 0000000..d0cda50 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshop/Properties/DataSources/BlacksmithWorkshopDataModel.IId.datasource @@ -0,0 +1,10 @@ + + + + BlacksmithWorkshopDataModel.IId, BlacksmithWorkshopDataModel, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + \ No newline at end of file diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/Properties/DataSources/BlacksmithWorkshopDataModel.Models.IComponentModel.datasource b/BlacksmithWorkshop/BlacksmithWorkshop/Properties/DataSources/BlacksmithWorkshopDataModel.Models.IComponentModel.datasource new file mode 100644 index 0000000..8be7998 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshop/Properties/DataSources/BlacksmithWorkshopDataModel.Models.IComponentModel.datasource @@ -0,0 +1,10 @@ + + + + BlacksmithWorkshopDataModel.Models.IComponentModel, BlacksmithWorkshopDataModel, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + \ No newline at end of file diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/ReportOrders.rdlc b/BlacksmithWorkshop/BlacksmithWorkshop/ReportOrders.rdlc new file mode 100644 index 0000000..3093666 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshop/ReportOrders.rdlc @@ -0,0 +1,111 @@ + + + 0 + + + + + + true + true + + + + + Заказ + + + + + + + Textbox1 + 0.84553cm + 16.51cm + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + =Parameters!ReportParameterPeriod.Value + + + + ReportParameterPeriod + 0.91609cm + 0.77611cm + 16.51cm + 1 + + + 2pt + 2pt + 2pt + 2pt + + + + 2in + @@ -26,7 +69,8 @@ Textbox1 - 0.84553cm + 0.61383cm + 1.03603cm 16.51cm + + + + + + 1.73518cm + + + 3.66134cm + + + 3.87301cm + + + 2.5cm + + + 2.5cm + + + + + 0.76214cm + + + + + 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.76214cm + + + + + true + true + + + + + =Fields!Id.Value + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!DateCreate.Value + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!ManufactureName.Value + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!Sum.Value + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!OrderStatus.Value + + + 2pt + 2pt + 2pt + 2pt + + + true + + + + + + + + + + + + + + + + + + + After + + + + + + + DataSetOrders + 2.86342cm + 2.26483cm + 1.52428cm + 14.26953cm + 2 + + + + + + true + true + + + + + Итого + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + =Sum(Fields!Sum.Value, "DataSetOrders") + + + 2pt + 2pt + 2pt + 2pt + + - 2in + 2.75in