From 5fbaea51ac448e527dbc06762fa5400c166fbf7d Mon Sep 17 00:00:00 2001 From: ujijrujijr Date: Wed, 3 Apr 2024 10:30:37 +0400 Subject: [PATCH 1/6] =?UTF-8?q?=D0=9F=D1=80=D0=B5=D0=B4=D0=B2=D0=B0=D1=80?= =?UTF-8?q?=D0=B8=D1=82=D0=B5=D0=BB=D1=8C=D0=BD=D0=BE=20=D0=B7=D0=B0=D0=BB?= =?UTF-8?q?=D0=B8=D0=BB=20=D0=BB=D0=B0=D0=B1=204?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- GarmentFactory/FormMain.Designer.cs | 38 +- GarmentFactory/FormMain.cs | 35 +- GarmentFactory/FormReportOrders.Designer.cs | 130 ++++ GarmentFactory/FormReportOrders.cs | 98 +++ GarmentFactory/FormReportOrders.resx | 120 ++++ .../FormReportTextileComponents.Designer.cs | 109 ++++ GarmentFactory/FormReportTextileComponents.cs | 74 +++ .../FormReportTextileComponents.resx | 129 ++++ GarmentFactory/FormTextile.Designer.cs | 4 +- GarmentFactory/GarmentFactoryView.csproj | 11 + GarmentFactory/Program.cs | 11 +- ...LogicsContracts.IComponentLogic.datasource | 10 + ...nessLogicsContracts.IOrderLogic.datasource | 10 + ...essLogicsContracts.IReportLogic.datasource | 10 + ...ssLogicsContracts.ITextileLogic.datasource | 10 + ...agesContracts.IComponentStorage.datasource | 10 + ...StoragesContracts.IOrderStorage.datasource | 10 + ...oragesContracts.ITextileStorage.datasource | 10 + GarmentFactory/ReportOrders.rdlc | 599 ++++++++++++++++++ .../{ => BusinessLogics}/ComponentLogic.cs | 4 +- .../{ => BusinessLogics}/OrderLogic.cs | 4 +- .../BusinessLogics/ReportLogic.cs | 110 ++++ .../{ => BusinessLogics}/TextileLogic.cs | 2 +- .../GarmentFactoryBusinessLogic.csproj | 2 + .../OfficePackage/AbstractSaveToExcel.cs | 88 +++ .../OfficePackage/AbstractSaveToPdf.cs | 47 ++ .../OfficePackage/AbstractSaveToWord.cs | 65 ++ .../HelperEnums/ExcelStyleInfoType.cs | 15 + .../HelperEnums/PdfParagraphAlignmentType.cs | 15 + .../HelperEnums/WordJustificationType.cs | 14 + .../HelperModels/ExcelCellParameters.cs | 18 + .../OfficePackage/HelperModels/ExcelInfo.cs | 16 + .../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/Implements/SaveToExcel.cs | 301 +++++++++ .../OfficePackage/Implements/SaveToPdf.cs | 113 ++++ .../OfficePackage/Implements/SaveToWord.cs | 139 ++++ .../BindingModels/ReportBindingModel.cs | 15 + .../BusinessLogicsContracts/IReportLogic.cs | 24 + .../SearchModels/OrderSearchModel.cs | 2 + .../ViewModels/ReportOrdersViewModel.cs | 17 + .../ReportTextileComponentViewModel.cs | 15 + .../Implements/OrderStorage.cs | 11 +- .../Implements/OrderStorage.cs | 8 +- .../Implements/OrderStorage.cs | 12 +- 50 files changed, 2578 insertions(+), 18 deletions(-) create mode 100644 GarmentFactory/FormReportOrders.Designer.cs create mode 100644 GarmentFactory/FormReportOrders.cs create mode 100644 GarmentFactory/FormReportOrders.resx create mode 100644 GarmentFactory/FormReportTextileComponents.Designer.cs create mode 100644 GarmentFactory/FormReportTextileComponents.cs create mode 100644 GarmentFactory/FormReportTextileComponents.resx create mode 100644 GarmentFactory/Properties/DataSources/GarmentFactoryContracts.BusinessLogicsContracts.IComponentLogic.datasource create mode 100644 GarmentFactory/Properties/DataSources/GarmentFactoryContracts.BusinessLogicsContracts.IOrderLogic.datasource create mode 100644 GarmentFactory/Properties/DataSources/GarmentFactoryContracts.BusinessLogicsContracts.IReportLogic.datasource create mode 100644 GarmentFactory/Properties/DataSources/GarmentFactoryContracts.BusinessLogicsContracts.ITextileLogic.datasource create mode 100644 GarmentFactory/Properties/DataSources/GarmentFactoryContracts.StoragesContracts.IComponentStorage.datasource create mode 100644 GarmentFactory/Properties/DataSources/GarmentFactoryContracts.StoragesContracts.IOrderStorage.datasource create mode 100644 GarmentFactory/Properties/DataSources/GarmentFactoryContracts.StoragesContracts.ITextileStorage.datasource create mode 100644 GarmentFactory/ReportOrders.rdlc rename GarmentFactoryBusinessLogic/{ => BusinessLogics}/ComponentLogic.cs (97%) rename GarmentFactoryBusinessLogic/{ => BusinessLogics}/OrderLogic.cs (99%) create mode 100644 GarmentFactoryBusinessLogic/BusinessLogics/ReportLogic.cs rename GarmentFactoryBusinessLogic/{ => BusinessLogics}/TextileLogic.cs (98%) create mode 100644 GarmentFactoryBusinessLogic/OfficePackage/AbstractSaveToExcel.cs create mode 100644 GarmentFactoryBusinessLogic/OfficePackage/AbstractSaveToPdf.cs create mode 100644 GarmentFactoryBusinessLogic/OfficePackage/AbstractSaveToWord.cs create mode 100644 GarmentFactoryBusinessLogic/OfficePackage/HelperEnums/ExcelStyleInfoType.cs create mode 100644 GarmentFactoryBusinessLogic/OfficePackage/HelperEnums/PdfParagraphAlignmentType.cs create mode 100644 GarmentFactoryBusinessLogic/OfficePackage/HelperEnums/WordJustificationType.cs create mode 100644 GarmentFactoryBusinessLogic/OfficePackage/HelperModels/ExcelCellParameters.cs create mode 100644 GarmentFactoryBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs create mode 100644 GarmentFactoryBusinessLogic/OfficePackage/HelperModels/ExcelMergeParameters.cs create mode 100644 GarmentFactoryBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs create mode 100644 GarmentFactoryBusinessLogic/OfficePackage/HelperModels/PdfParagraph.cs create mode 100644 GarmentFactoryBusinessLogic/OfficePackage/HelperModels/PdfRowParameters.cs create mode 100644 GarmentFactoryBusinessLogic/OfficePackage/HelperModels/WordInfo.cs create mode 100644 GarmentFactoryBusinessLogic/OfficePackage/HelperModels/WordParagraph.cs create mode 100644 GarmentFactoryBusinessLogic/OfficePackage/HelperModels/WordTextProperties.cs create mode 100644 GarmentFactoryBusinessLogic/OfficePackage/Implements/SaveToExcel.cs create mode 100644 GarmentFactoryBusinessLogic/OfficePackage/Implements/SaveToPdf.cs create mode 100644 GarmentFactoryBusinessLogic/OfficePackage/Implements/SaveToWord.cs create mode 100644 GarmentFactoryContracts/BindingModels/ReportBindingModel.cs create mode 100644 GarmentFactoryContracts/BusinessLogicsContracts/IReportLogic.cs create mode 100644 GarmentFactoryContracts/ViewModels/ReportOrdersViewModel.cs create mode 100644 GarmentFactoryContracts/ViewModels/ReportTextileComponentViewModel.cs diff --git a/GarmentFactory/FormMain.Designer.cs b/GarmentFactory/FormMain.Designer.cs index 7b3dbfb..e53341c 100644 --- a/GarmentFactory/FormMain.Designer.cs +++ b/GarmentFactory/FormMain.Designer.cs @@ -38,6 +38,10 @@ справочникиToolStripMenuItem = new ToolStripMenuItem(); компонентыToolStripMenuItem = new ToolStripMenuItem(); текстилиToolStripMenuItem = new ToolStripMenuItem(); + отчётыToolStripMenuItem = new ToolStripMenuItem(); + textilesToolStripMenuItem = new ToolStripMenuItem(); + textileComponentsToolStripMenuItem = new ToolStripMenuItem(); + ordersToolStripMenuItem = new ToolStripMenuItem(); ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); menuStrip1.SuspendLayout(); SuspendLayout(); @@ -116,7 +120,7 @@ // menuStrip1 // menuStrip1.ImageScalingSize = new Size(20, 20); - menuStrip1.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem }); + menuStrip1.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, отчётыToolStripMenuItem }); menuStrip1.Location = new Point(0, 0); menuStrip1.Name = "menuStrip1"; menuStrip1.Size = new Size(1169, 28); @@ -144,6 +148,34 @@ текстилиToolStripMenuItem.Text = "Текстили"; текстилиToolStripMenuItem.Click += текстилиToolStripMenuItem_Click; // + // отчётыToolStripMenuItem + // + отчётыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { textilesToolStripMenuItem, textileComponentsToolStripMenuItem, ordersToolStripMenuItem }); + отчётыToolStripMenuItem.Name = "отчётыToolStripMenuItem"; + отчётыToolStripMenuItem.Size = new Size(73, 24); + отчётыToolStripMenuItem.Text = "Отчёты"; + // + // textilesToolStripMenuItem + // + textilesToolStripMenuItem.Name = "textilesToolStripMenuItem"; + textilesToolStripMenuItem.Size = new Size(274, 26); + textilesToolStripMenuItem.Text = "Текстили"; + textilesToolStripMenuItem.Click += TextilesToolStripMenuItem_Click; + // + // textileComponentsToolStripMenuItem + // + textileComponentsToolStripMenuItem.Name = "textileComponentsToolStripMenuItem"; + textileComponentsToolStripMenuItem.Size = new Size(274, 26); + textileComponentsToolStripMenuItem.Text = "Текстили с компонентами"; + textileComponentsToolStripMenuItem.Click += ComponentTextilesToolStripMenuItem_Click; + // + // ordersToolStripMenuItem + // + ordersToolStripMenuItem.Name = "ordersToolStripMenuItem"; + ordersToolStripMenuItem.Size = new Size(274, 26); + ordersToolStripMenuItem.Text = "Заказы"; + ordersToolStripMenuItem.Click += OrdersToolStripMenuItem_Click; + // // FormMain // AutoScaleDimensions = new SizeF(8F, 20F); @@ -179,5 +211,9 @@ private ToolStripMenuItem справочникиToolStripMenuItem; private ToolStripMenuItem компонентыToolStripMenuItem; private ToolStripMenuItem текстилиToolStripMenuItem; + private ToolStripMenuItem отчётыToolStripMenuItem; + private ToolStripMenuItem textilesToolStripMenuItem; + private ToolStripMenuItem textileComponentsToolStripMenuItem; + private ToolStripMenuItem ordersToolStripMenuItem; } } \ No newline at end of file diff --git a/GarmentFactory/FormMain.cs b/GarmentFactory/FormMain.cs index b921a1c..d1969ba 100644 --- a/GarmentFactory/FormMain.cs +++ b/GarmentFactory/FormMain.cs @@ -1,4 +1,5 @@ using GarmentFactory; +using GarmentFactoryBusinessLogic.BusinessLogics; using GarmentFactoryContracts.BindingModels; using GarmentFactoryContracts.BusinessLogicsContracts; using Microsoft.Extensions.Logging; @@ -18,11 +19,13 @@ namespace GarmentFactoryView { private readonly ILogger _logger; private readonly IOrderLogic _orderLogic; - public FormMain(ILogger logger, IOrderLogic orderLogic) + private readonly IReportLogic _reportLogic; + public FormMain(ILogger logger, IOrderLogic orderLogic, IReportLogic reportLogic) { InitializeComponent(); _logger = logger; _orderLogic = orderLogic; + _reportLogic = reportLogic; } private void LoadData() { @@ -68,6 +71,36 @@ namespace GarmentFactoryView } } + private void TextilesToolStripMenuItem_Click(object sender, EventArgs e) + { + using var dialog = new SaveFileDialog { Filter = "docx|*.docx" }; + if (dialog.ShowDialog() == DialogResult.OK) + { + _reportLogic.SaveTextilesToWordFile(new ReportBindingModel + { + FileName = dialog.FileName + }); + MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + } + private void ComponentTextilesToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormReportTextileComponents)); + if (service is FormReportTextileComponents 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(); + } + } + + private void ButtonCreateOrder_Click(object sender, EventArgs e) { var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder)); diff --git a/GarmentFactory/FormReportOrders.Designer.cs b/GarmentFactory/FormReportOrders.Designer.cs new file mode 100644 index 0000000..69aff45 --- /dev/null +++ b/GarmentFactory/FormReportOrders.Designer.cs @@ -0,0 +1,130 @@ +namespace GarmentFactoryView +{ + partial class FormReportOrders + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + panel = new Panel(); + buttonToPDF = new Button(); + buttonMake = new Button(); + dateTimePickerTo = new DateTimePicker(); + dateTimePickerFrom = new DateTimePicker(); + labelTo = new Label(); + labelFrom = new Label(); + panel.SuspendLayout(); + SuspendLayout(); + // + // panel + // + panel.Controls.Add(buttonToPDF); + panel.Controls.Add(buttonMake); + panel.Controls.Add(dateTimePickerTo); + panel.Controls.Add(dateTimePickerFrom); + panel.Controls.Add(labelTo); + panel.Controls.Add(labelFrom); + panel.Dock = DockStyle.Top; + panel.Location = new Point(0, 0); + panel.Name = "panel"; + panel.Size = new Size(800, 55); + panel.TabIndex = 0; + // + // buttonToPDF + // + buttonToPDF.Location = new Point(660, 12); + buttonToPDF.Name = "buttonToPDF"; + buttonToPDF.Size = new Size(107, 29); + buttonToPDF.TabIndex = 5; + buttonToPDF.Text = "В PDF"; + buttonToPDF.UseVisualStyleBackColor = true; + buttonToPDF.Click += ButtonToPdf_Click; + // + // buttonMake + // + buttonMake.Location = new Point(463, 12); + buttonMake.Name = "buttonMake"; + buttonMake.Size = new Size(134, 29); + buttonMake.TabIndex = 4; + buttonMake.Text = "Сформировать"; + buttonMake.UseVisualStyleBackColor = true; + buttonMake.Click += ButtonMake_Click; + // + // dateTimePickerTo + // + dateTimePickerTo.Location = new Point(234, 12); + dateTimePickerTo.Name = "dateTimePickerTo"; + dateTimePickerTo.Size = new Size(160, 27); + dateTimePickerTo.TabIndex = 3; + // + // dateTimePickerFrom + // + dateTimePickerFrom.Location = new Point(35, 12); + dateTimePickerFrom.Name = "dateTimePickerFrom"; + dateTimePickerFrom.Size = new Size(160, 27); + dateTimePickerFrom.TabIndex = 2; + // + // labelTo + // + labelTo.AutoSize = true; + labelTo.Location = new Point(201, 17); + labelTo.Name = "labelTo"; + labelTo.Size = new Size(27, 20); + labelTo.TabIndex = 1; + labelTo.Text = "по"; + // + // labelFrom + // + labelFrom.AutoSize = true; + labelFrom.Location = new Point(11, 17); + labelFrom.Name = "labelFrom"; + labelFrom.Size = new Size(18, 20); + labelFrom.TabIndex = 0; + labelFrom.Text = "С"; + // + // FormReportOrders + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(800, 450); + Controls.Add(panel); + Name = "FormReportOrders"; + Text = "Заказы"; + panel.ResumeLayout(false); + panel.PerformLayout(); + ResumeLayout(false); + } + + #endregion + + private Panel panel; + private DateTimePicker dateTimePickerTo; + private DateTimePicker dateTimePickerFrom; + private Label labelTo; + private Label labelFrom; + private Button buttonToPDF; + private Button buttonMake; + } +} \ No newline at end of file diff --git a/GarmentFactory/FormReportOrders.cs b/GarmentFactory/FormReportOrders.cs new file mode 100644 index 0000000..cd9a1e3 --- /dev/null +++ b/GarmentFactory/FormReportOrders.cs @@ -0,0 +1,98 @@ +using GarmentFactoryContracts.BindingModels; +using GarmentFactoryContracts.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 GarmentFactoryView +{ + 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/GarmentFactory/FormReportOrders.resx b/GarmentFactory/FormReportOrders.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/GarmentFactory/FormReportOrders.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/GarmentFactory/FormReportTextileComponents.Designer.cs b/GarmentFactory/FormReportTextileComponents.Designer.cs new file mode 100644 index 0000000..6e6287d --- /dev/null +++ b/GarmentFactory/FormReportTextileComponents.Designer.cs @@ -0,0 +1,109 @@ +namespace GarmentFactoryView +{ + partial class FormReportTextileComponents + { + /// + /// 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(); + ColumnTextile = new DataGridViewTextBoxColumn(); + ColumnComponent = new DataGridViewTextBoxColumn(); + ColumnCount = new DataGridViewTextBoxColumn(); + buttonSaveToExcel = new Button(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + SuspendLayout(); + // + // dataGridView + // + dataGridView.AllowUserToAddRows = false; + dataGridView.AllowUserToDeleteRows = false; + dataGridView.AllowUserToOrderColumns = true; + dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Columns.AddRange(new DataGridViewColumn[] { ColumnTextile, ColumnComponent, ColumnCount }); + dataGridView.Dock = DockStyle.Bottom; + dataGridView.Location = new Point(0, 55); + dataGridView.Name = "dataGridView"; + dataGridView.ReadOnly = true; + dataGridView.RowHeadersWidth = 51; + dataGridView.RowTemplate.Height = 29; + dataGridView.Size = new Size(578, 405); + dataGridView.TabIndex = 0; + // + // ColumnTextile + // + ColumnTextile.HeaderText = "Текстиль"; + ColumnTextile.MinimumWidth = 6; + ColumnTextile.Name = "ColumnTextile"; + ColumnTextile.ReadOnly = true; + // + // ColumnComponent + // + ColumnComponent.HeaderText = "Компонент"; + ColumnComponent.MinimumWidth = 6; + ColumnComponent.Name = "ColumnComponent"; + ColumnComponent.ReadOnly = true; + // + // ColumnCount + // + ColumnCount.HeaderText = "Количество"; + ColumnCount.MinimumWidth = 6; + ColumnCount.Name = "ColumnCount"; + ColumnCount.ReadOnly = true; + // + // buttonSaveToExcel + // + buttonSaveToExcel.Location = new Point(12, 12); + buttonSaveToExcel.Name = "buttonSaveToExcel"; + buttonSaveToExcel.Size = new Size(183, 29); + buttonSaveToExcel.TabIndex = 1; + buttonSaveToExcel.Text = "Сохранить в Excel"; + buttonSaveToExcel.UseVisualStyleBackColor = true; + buttonSaveToExcel.Click += ButtonSaveToExcel_Click; + // + // FormReportTextileComponents + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(578, 460); + Controls.Add(buttonSaveToExcel); + Controls.Add(dataGridView); + Name = "FormReportTextileComponents"; + Text = "Текстили с компонентами"; + Load += FormReportTextileComponents_Load; + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + } + + #endregion + + private DataGridView dataGridView; + private DataGridViewTextBoxColumn ColumnTextile; + private DataGridViewTextBoxColumn ColumnComponent; + private DataGridViewTextBoxColumn ColumnCount; + private Button buttonSaveToExcel; + } +} \ No newline at end of file diff --git a/GarmentFactory/FormReportTextileComponents.cs b/GarmentFactory/FormReportTextileComponents.cs new file mode 100644 index 0000000..34ef77c --- /dev/null +++ b/GarmentFactory/FormReportTextileComponents.cs @@ -0,0 +1,74 @@ +using GarmentFactoryContracts.BindingModels; +using GarmentFactoryContracts.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 GarmentFactoryView +{ + public partial class FormReportTextileComponents : Form + { + private readonly ILogger _logger; + private readonly IReportLogic _logic; + public FormReportTextileComponents(ILogger logger, IReportLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + } + + private void FormReportTextileComponents_Load(object sender, EventArgs e) + { + try + { + var dict = _logic.GetTextileComponents(); + if (dict != null) + { + dataGridView.Rows.Clear(); + foreach (var elem in dict) + { + dataGridView.Rows.Add(new object[] { elem.TextileName, "", "" }); + 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.SaveTextileComponentToExcelFile(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/GarmentFactory/FormReportTextileComponents.resx b/GarmentFactory/FormReportTextileComponents.resx new file mode 100644 index 0000000..f5f35e0 --- /dev/null +++ b/GarmentFactory/FormReportTextileComponents.resx @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + True + + + True + + + True + + \ No newline at end of file diff --git a/GarmentFactory/FormTextile.Designer.cs b/GarmentFactory/FormTextile.Designer.cs index 5121014..19d22f8 100644 --- a/GarmentFactory/FormTextile.Designer.cs +++ b/GarmentFactory/FormTextile.Designer.cs @@ -138,6 +138,7 @@ // dataGridView.AllowUserToAddRows = false; dataGridView.AllowUserToDeleteRows = false; + dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; dataGridView.Columns.AddRange(new DataGridViewColumn[] { Column1, Column2, Column3 }); dataGridView.Dock = DockStyle.Left; @@ -159,7 +160,6 @@ Column1.Name = "Column1"; Column1.ReadOnly = true; Column1.Visible = false; - Column1.Width = 125; // // Column2 // @@ -167,7 +167,6 @@ Column2.MinimumWidth = 6; Column2.Name = "Column2"; Column2.ReadOnly = true; - Column2.Width = 125; // // Column3 // @@ -175,7 +174,6 @@ Column3.MinimumWidth = 6; Column3.Name = "Column3"; Column3.ReadOnly = true; - Column3.Width = 125; // // buttonSave // diff --git a/GarmentFactory/GarmentFactoryView.csproj b/GarmentFactory/GarmentFactoryView.csproj index 1f48076..6b48d02 100644 --- a/GarmentFactory/GarmentFactoryView.csproj +++ b/GarmentFactory/GarmentFactoryView.csproj @@ -13,11 +13,16 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + @@ -38,4 +43,10 @@ + + + Always + + + \ No newline at end of file diff --git a/GarmentFactory/Program.cs b/GarmentFactory/Program.cs index e086ff8..fb359df 100644 --- a/GarmentFactory/Program.cs +++ b/GarmentFactory/Program.cs @@ -1,4 +1,6 @@ -using GarmentFactoryBusinessLogic; +using GarmentFactoryBusinessLogic.BusinessLogics; +using GarmentFactoryBusinessLogic.OfficePackage.Implements; +using GarmentFactoryBusinessLogic.OfficePackage; using GarmentFactoryContracts.BusinessLogicsContracts; using GarmentFactoryContracts.StoragesContracts; using GarmentFactoryDatabaseImplement.Implements; @@ -42,6 +44,11 @@ namespace GarmentFactory services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); + + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); @@ -50,6 +57,8 @@ namespace GarmentFactory services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); + services.AddTransient(); } } } \ No newline at end of file diff --git a/GarmentFactory/Properties/DataSources/GarmentFactoryContracts.BusinessLogicsContracts.IComponentLogic.datasource b/GarmentFactory/Properties/DataSources/GarmentFactoryContracts.BusinessLogicsContracts.IComponentLogic.datasource new file mode 100644 index 0000000..44f9cbe --- /dev/null +++ b/GarmentFactory/Properties/DataSources/GarmentFactoryContracts.BusinessLogicsContracts.IComponentLogic.datasource @@ -0,0 +1,10 @@ + + + + GarmentFactoryContracts.BusinessLogicsContracts.IComponentLogic, GarmentFactoryContracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + \ No newline at end of file diff --git a/GarmentFactory/Properties/DataSources/GarmentFactoryContracts.BusinessLogicsContracts.IOrderLogic.datasource b/GarmentFactory/Properties/DataSources/GarmentFactoryContracts.BusinessLogicsContracts.IOrderLogic.datasource new file mode 100644 index 0000000..659fdeb --- /dev/null +++ b/GarmentFactory/Properties/DataSources/GarmentFactoryContracts.BusinessLogicsContracts.IOrderLogic.datasource @@ -0,0 +1,10 @@ + + + + GarmentFactoryContracts.BusinessLogicsContracts.IOrderLogic, GarmentFactoryContracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + \ No newline at end of file diff --git a/GarmentFactory/Properties/DataSources/GarmentFactoryContracts.BusinessLogicsContracts.IReportLogic.datasource b/GarmentFactory/Properties/DataSources/GarmentFactoryContracts.BusinessLogicsContracts.IReportLogic.datasource new file mode 100644 index 0000000..d8f129d --- /dev/null +++ b/GarmentFactory/Properties/DataSources/GarmentFactoryContracts.BusinessLogicsContracts.IReportLogic.datasource @@ -0,0 +1,10 @@ + + + + GarmentFactoryContracts.BusinessLogicsContracts.IReportLogic, GarmentFactoryContracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + \ No newline at end of file diff --git a/GarmentFactory/Properties/DataSources/GarmentFactoryContracts.BusinessLogicsContracts.ITextileLogic.datasource b/GarmentFactory/Properties/DataSources/GarmentFactoryContracts.BusinessLogicsContracts.ITextileLogic.datasource new file mode 100644 index 0000000..c52461d --- /dev/null +++ b/GarmentFactory/Properties/DataSources/GarmentFactoryContracts.BusinessLogicsContracts.ITextileLogic.datasource @@ -0,0 +1,10 @@ + + + + GarmentFactoryContracts.BusinessLogicsContracts.ITextileLogic, GarmentFactoryContracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + \ No newline at end of file diff --git a/GarmentFactory/Properties/DataSources/GarmentFactoryContracts.StoragesContracts.IComponentStorage.datasource b/GarmentFactory/Properties/DataSources/GarmentFactoryContracts.StoragesContracts.IComponentStorage.datasource new file mode 100644 index 0000000..63428c6 --- /dev/null +++ b/GarmentFactory/Properties/DataSources/GarmentFactoryContracts.StoragesContracts.IComponentStorage.datasource @@ -0,0 +1,10 @@ + + + + GarmentFactoryContracts.StoragesContracts.IComponentStorage, GarmentFactoryContracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + \ No newline at end of file diff --git a/GarmentFactory/Properties/DataSources/GarmentFactoryContracts.StoragesContracts.IOrderStorage.datasource b/GarmentFactory/Properties/DataSources/GarmentFactoryContracts.StoragesContracts.IOrderStorage.datasource new file mode 100644 index 0000000..8686c61 --- /dev/null +++ b/GarmentFactory/Properties/DataSources/GarmentFactoryContracts.StoragesContracts.IOrderStorage.datasource @@ -0,0 +1,10 @@ + + + + GarmentFactoryContracts.StoragesContracts.IOrderStorage, GarmentFactoryContracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + \ No newline at end of file diff --git a/GarmentFactory/Properties/DataSources/GarmentFactoryContracts.StoragesContracts.ITextileStorage.datasource b/GarmentFactory/Properties/DataSources/GarmentFactoryContracts.StoragesContracts.ITextileStorage.datasource new file mode 100644 index 0000000..537092b --- /dev/null +++ b/GarmentFactory/Properties/DataSources/GarmentFactoryContracts.StoragesContracts.ITextileStorage.datasource @@ -0,0 +1,10 @@ + + + + GarmentFactoryContracts.StoragesContracts.ITextileStorage, GarmentFactoryContracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + \ No newline at end of file diff --git a/GarmentFactory/ReportOrders.rdlc b/GarmentFactory/ReportOrders.rdlc new file mode 100644 index 0000000..ce2047b --- /dev/null +++ b/GarmentFactory/ReportOrders.rdlc @@ -0,0 +1,599 @@ + + + 0 + + + + System.Data.DataSet + /* Local Connection */ + + 47cb53f0-7dde-4717-ba03-866a0bc4f4dd + + + + + + GarmentFactoryContractsViewModels + /* Local Query */ + + + + Id + System.Int32 + + + DateCreate + System.DateTime + + + TextileName + System.String + + + Sum + System.Decimal + + + Status + GarmentFactoryDataModels.Status + + + + GarmentFactoryContracts.ViewModels + ReportOrderViewModel + GarmentFactoryContracts.ViewModels.ReportOrderViewModel, GarmentFactoryContracts, 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!TextileName.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 + 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 + + + + + + + 0.6cm + 16.51cm + + + Middle + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + =Parameters!ReportParameterPeriod.Value + + + + + + + ReportParameterPeriod + 0.6cm + 0.6cm + 16.51cm + 1 + + + 2pt + 2pt + 2pt + 2pt + + + + + + + 3.90406cm + + + 3.97461cm + + + 3.65711cm + + + + + 0.6cm + + + + + true + true + + + + + Дата создания + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Количество заказов + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Общая сумма заказов + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + 0.6cm + + + + + true + true + + + + + =Fields!Date.Value + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!OrdersCount.Value + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!OrdersSum.Value + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + + + + + + + + + + + + After + + + + + + + DataSetGroupedOrders + 1.88242cm + 2.68676cm + 1.2cm + 11.53578cm + 2 + + + + + + true + true + + + + + Итого: + + + + 3.29409cm + 8.06542cm + 0.6cm + 2.5cm + 3 + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + =Sum(Fields!OrdersSum.Value, "DataSetGroupedOrders") + + + + + + + 3.29409cm + 10.70653cm + 0.6cm + 3.48072cm + 4 + + + 2pt + 2pt + 2pt + 2pt + + + + 2in +