From 47bb5e41567aad456b4c79336da79c4f9ff23e1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=93=D0=B0=D0=BB=D0=B8=D0=BD=D0=B0=20=D0=A4=D0=B5=D0=B4?= =?UTF-8?q?=D0=BE=D1=80=D0=B5=D0=BD=D0=BA=D0=BE?= Date: Wed, 10 Apr 2024 09:09:17 +0400 Subject: [PATCH] =?UTF-8?q?=D0=B2=D0=B0=D1=83,=20=D1=8D=D1=82=D0=BE=20?= =?UTF-8?q?=D1=87=D1=82=D0=BE,=20=D1=80=D0=B0=D0=B1=D0=BE=D1=87=D0=B0?= =?UTF-8?q?=D1=8F=204=20=D0=BB=D0=B0=D0=B1=D0=B0=3F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CarpentryWorkshopView.csproj | 24 + .../CarpentryWorkshop/FormMain.Designer.cs | 42 +- .../CarpentryWorkshop/FormMain.cs | 38 +- .../FormReportOrders.Designer.cs | 133 ++++ .../CarpentryWorkshop/FormReportOrders.cs | 96 +++ .../CarpentryWorkshop/FormReportOrders.resx | 120 ++++ .../FormReportWoodComponents.Designer.cs | 106 ++++ .../FormReportWoodComponents.cs | 88 +++ .../FormReportWoodComponents.resx | 120 ++++ .../CarpentryWorkshop/Program.cs | 9 + .../CarpentryWorkshop/ReportOrders.rdlc | 600 ++++++++++++++++++ .../BusinessLogics/ReportLogic.cs | 121 ++++ .../CarpentryWorkshopBusinessLogic.csproj | 4 +- .../OfficePackage/AbstractSaveToExcel.cs | 98 +++ .../OfficePackage/AbstractSaveToPdf.cs | 75 +++ .../OfficePackage/AbstractSaveToWord.cs | 58 ++ .../HelperEnums/ExcelStyleInfoType.cs | 9 + .../HelperEnums/PdfParagraphAlignmentType.cs | 9 + .../HelperEnums/WordJustificationType.cs | 8 + .../HelperModels/ExcelCellParameters.cs | 13 + .../OfficePackage/HelperModels/ExcelInfo.cs | 11 + .../HelperModels/ExcelMergeParameters.cs | 9 + .../OfficePackage/HelperModels/PdfInfo.cs | 15 + .../HelperModels/PdfParagraph.cs | 11 + .../HelperModels/PdfRowParameters.cs | 11 + .../OfficePackage/HelperModels/WordInfo.cs | 11 + .../HelperModels/WordParagraph.cs | 8 + .../HelperModels/WordTextProperties.cs | 11 + .../OfficePackage/Implements/SaveToExcel.cs | 350 ++++++++++ .../OfficePackage/Implements/SaveToPdf.cs | 99 +++ .../OfficePackage/Implements/SaveToWord.cs | 125 ++++ .../BindingModels/ReportBindingModel.cs | 12 + .../BusinessLogicsContracts/IReportLogic.cs | 35 + .../SearchModels/OrderSearchModel.cs | 2 + .../ViewModels/ReportOrdersViewModel.cs | 11 + .../ReportWoodComponentViewModel.cs | 9 + .../Implements/OrderStorage.cs | 4 +- .../Implements/OrderStorage.cs | 4 +- .../Implements/OrderStorage.cs | 2 +- 39 files changed, 2501 insertions(+), 10 deletions(-) create mode 100644 CarpentryWorkshop/CarpentryWorkshop/FormReportOrders.Designer.cs create mode 100644 CarpentryWorkshop/CarpentryWorkshop/FormReportOrders.cs create mode 100644 CarpentryWorkshop/CarpentryWorkshop/FormReportOrders.resx create mode 100644 CarpentryWorkshop/CarpentryWorkshop/FormReportWoodComponents.Designer.cs create mode 100644 CarpentryWorkshop/CarpentryWorkshop/FormReportWoodComponents.cs create mode 100644 CarpentryWorkshop/CarpentryWorkshop/FormReportWoodComponents.resx create mode 100644 CarpentryWorkshop/CarpentryWorkshop/ReportOrders.rdlc create mode 100644 CarpentryWorkshop/CarpentryWorkshopBusinessLogic/BusinessLogics/ReportLogic.cs create mode 100644 CarpentryWorkshop/CarpentryWorkshopBusinessLogic/OfficePackage/AbstractSaveToExcel.cs create mode 100644 CarpentryWorkshop/CarpentryWorkshopBusinessLogic/OfficePackage/AbstractSaveToPdf.cs create mode 100644 CarpentryWorkshop/CarpentryWorkshopBusinessLogic/OfficePackage/AbstractSaveToWord.cs create mode 100644 CarpentryWorkshop/CarpentryWorkshopBusinessLogic/OfficePackage/HelperEnums/ExcelStyleInfoType.cs create mode 100644 CarpentryWorkshop/CarpentryWorkshopBusinessLogic/OfficePackage/HelperEnums/PdfParagraphAlignmentType.cs create mode 100644 CarpentryWorkshop/CarpentryWorkshopBusinessLogic/OfficePackage/HelperEnums/WordJustificationType.cs create mode 100644 CarpentryWorkshop/CarpentryWorkshopBusinessLogic/OfficePackage/HelperModels/ExcelCellParameters.cs create mode 100644 CarpentryWorkshop/CarpentryWorkshopBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs create mode 100644 CarpentryWorkshop/CarpentryWorkshopBusinessLogic/OfficePackage/HelperModels/ExcelMergeParameters.cs create mode 100644 CarpentryWorkshop/CarpentryWorkshopBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs create mode 100644 CarpentryWorkshop/CarpentryWorkshopBusinessLogic/OfficePackage/HelperModels/PdfParagraph.cs create mode 100644 CarpentryWorkshop/CarpentryWorkshopBusinessLogic/OfficePackage/HelperModels/PdfRowParameters.cs create mode 100644 CarpentryWorkshop/CarpentryWorkshopBusinessLogic/OfficePackage/HelperModels/WordInfo.cs create mode 100644 CarpentryWorkshop/CarpentryWorkshopBusinessLogic/OfficePackage/HelperModels/WordParagraph.cs create mode 100644 CarpentryWorkshop/CarpentryWorkshopBusinessLogic/OfficePackage/HelperModels/WordTextProperties.cs create mode 100644 CarpentryWorkshop/CarpentryWorkshopBusinessLogic/OfficePackage/Implements/SaveToExcel.cs create mode 100644 CarpentryWorkshop/CarpentryWorkshopBusinessLogic/OfficePackage/Implements/SaveToPdf.cs create mode 100644 CarpentryWorkshop/CarpentryWorkshopBusinessLogic/OfficePackage/Implements/SaveToWord.cs create mode 100644 CarpentryWorkshop/CarpentryWorkshopContracts/BindingModels/ReportBindingModel.cs create mode 100644 CarpentryWorkshop/CarpentryWorkshopContracts/BusinessLogicsContracts/IReportLogic.cs create mode 100644 CarpentryWorkshop/CarpentryWorkshopContracts/ViewModels/ReportOrdersViewModel.cs create mode 100644 CarpentryWorkshop/CarpentryWorkshopContracts/ViewModels/ReportWoodComponentViewModel.cs diff --git a/CarpentryWorkshop/CarpentryWorkshop/CarpentryWorkshopView.csproj b/CarpentryWorkshop/CarpentryWorkshop/CarpentryWorkshopView.csproj index f9f9743..1f871b3 100644 --- a/CarpentryWorkshop/CarpentryWorkshop/CarpentryWorkshopView.csproj +++ b/CarpentryWorkshop/CarpentryWorkshop/CarpentryWorkshopView.csproj @@ -12,6 +12,10 @@ + + + + Always @@ -25,6 +29,7 @@ + @@ -36,4 +41,23 @@ + + + + + + + True + True + Resources.resx + + + + + + ResXFileCodeGenerator + Resources.Designer.cs + + + \ No newline at end of file diff --git a/CarpentryWorkshop/CarpentryWorkshop/FormMain.Designer.cs b/CarpentryWorkshop/CarpentryWorkshop/FormMain.Designer.cs index 08dbbfe..865c038 100644 --- a/CarpentryWorkshop/CarpentryWorkshop/FormMain.Designer.cs +++ b/CarpentryWorkshop/CarpentryWorkshop/FormMain.Designer.cs @@ -32,6 +32,10 @@ справочникиToolStripMenuItem = new ToolStripMenuItem(); КомпонентыToolStripMenuItem = new ToolStripMenuItem(); ИзделияToolStripMenuItem = new ToolStripMenuItem(); + отчётыToolStripMenuItem = new ToolStripMenuItem(); + списокИзделийToolStripMenuItem = new ToolStripMenuItem(); + компонентыПоИзделиямToolStripMenuItem = new ToolStripMenuItem(); + списокЗаказовToolStripMenuItem = new ToolStripMenuItem(); dataGridView = new DataGridView(); ButtonCreateOrder = new Button(); ButtonTakeOrderInWork = new Button(); @@ -44,7 +48,7 @@ // // menuStrip1 // - 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(896, 24); @@ -61,17 +65,45 @@ // КомпонентыToolStripMenuItem // КомпонентыToolStripMenuItem.Name = "КомпонентыToolStripMenuItem"; - КомпонентыToolStripMenuItem.Size = new Size(180, 22); + КомпонентыToolStripMenuItem.Size = new Size(145, 22); КомпонентыToolStripMenuItem.Text = "Компоненты"; КомпонентыToolStripMenuItem.Click += КомпонентыToolStripMenuItem_Click; // // ИзделияToolStripMenuItem // ИзделияToolStripMenuItem.Name = "ИзделияToolStripMenuItem"; - ИзделияToolStripMenuItem.Size = new Size(180, 22); + ИзделияToolStripMenuItem.Size = new Size(145, 22); ИзделияToolStripMenuItem.Text = "Изделия"; ИзделияToolStripMenuItem.Click += ИзделияToolStripMenuItem_Click; // + // отчётыToolStripMenuItem + // + отчётыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { списокИзделийToolStripMenuItem, компонентыПоИзделиямToolStripMenuItem, списокЗаказовToolStripMenuItem }); + отчётыToolStripMenuItem.Name = "отчётыToolStripMenuItem"; + отчётыToolStripMenuItem.Size = new Size(60, 20); + отчётыToolStripMenuItem.Text = "Отчёты"; + // + // списокИзделийToolStripMenuItem + // + списокИзделийToolStripMenuItem.Name = "списокИзделийToolStripMenuItem"; + списокИзделийToolStripMenuItem.Size = new Size(218, 22); + списокИзделийToolStripMenuItem.Text = "Список изделий"; + списокИзделийToolStripMenuItem.Click += списокИзделийToolStripMenuItem_Click; + // + // компонентыПоИзделиямToolStripMenuItem + // + компонентыПоИзделиямToolStripMenuItem.Name = "компонентыПоИзделиямToolStripMenuItem"; + компонентыПоИзделиямToolStripMenuItem.Size = new Size(218, 22); + компонентыПоИзделиямToolStripMenuItem.Text = "Компоненты по изделиям"; + компонентыПоИзделиямToolStripMenuItem.Click += компонентыПоИзделиямToolStripMenuItem_Click; + // + // списокЗаказовToolStripMenuItem + // + списокЗаказовToolStripMenuItem.Name = "списокЗаказовToolStripMenuItem"; + списокЗаказовToolStripMenuItem.Size = new Size(218, 22); + списокЗаказовToolStripMenuItem.Text = "Список заказов"; + списокЗаказовToolStripMenuItem.Click += списокЗаказовToolStripMenuItem_Click; + // // dataGridView // dataGridView.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; @@ -174,5 +206,9 @@ private Button ButtonRef; private ToolStripMenuItem КомпонентыToolStripMenuItem; private ToolStripMenuItem ИзделияToolStripMenuItem; + private ToolStripMenuItem отчётыToolStripMenuItem; + private ToolStripMenuItem списокИзделийToolStripMenuItem; + private ToolStripMenuItem компонентыПоИзделиямToolStripMenuItem; + private ToolStripMenuItem списокЗаказовToolStripMenuItem; } } \ No newline at end of file diff --git a/CarpentryWorkshop/CarpentryWorkshop/FormMain.cs b/CarpentryWorkshop/CarpentryWorkshop/FormMain.cs index 73d980e..c283592 100644 --- a/CarpentryWorkshop/CarpentryWorkshop/FormMain.cs +++ b/CarpentryWorkshop/CarpentryWorkshop/FormMain.cs @@ -10,11 +10,13 @@ namespace CarpentryWorkshopView { 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 FormMain_Load(object sender, EventArgs e) { @@ -147,6 +149,40 @@ namespace CarpentryWorkshopView } } } + + private void списокИзделийToolStripMenuItem_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 компонентыПоИзделиямToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormReportWoodComponents)); + if (service is FormReportWoodComponents form) + { + form.ShowDialog(); + } + + } + + private void списокЗаказовToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormReportOrders)); + if (service is FormReportOrders form) + { + form.ShowDialog(); + } + + } private void ButtonRef_Click(object sender, EventArgs e) { LoadData(); diff --git a/CarpentryWorkshop/CarpentryWorkshop/FormReportOrders.Designer.cs b/CarpentryWorkshop/CarpentryWorkshop/FormReportOrders.Designer.cs new file mode 100644 index 0000000..e29ba57 --- /dev/null +++ b/CarpentryWorkshop/CarpentryWorkshop/FormReportOrders.Designer.cs @@ -0,0 +1,133 @@ +using static System.Windows.Forms.VisualStyles.VisualStyleElement.Window; +using System.Windows.Forms; + +namespace CarpentryWorkshopView +{ + 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(); + labelFrom = new Label(); + buttonToPdf = new Button(); + dateTimePickerDateFrom = new DateTimePicker(); + labelTo = new Label(); + dateTimePickerDateTo = new DateTimePicker(); + buttonMake = new Button(); + panel.SuspendLayout(); + SuspendLayout(); + // + // panel + // + panel.Controls.Add(labelFrom); + panel.Controls.Add(buttonToPdf); + panel.Controls.Add(dateTimePickerDateFrom); + panel.Controls.Add(labelTo); + panel.Controls.Add(dateTimePickerDateTo); + panel.Controls.Add(buttonMake); + panel.Dock = DockStyle.Top; + panel.Location = new Point(0, 0); + panel.Name = "panel"; + panel.Size = new Size(1321, 71); + panel.TabIndex = 3; + // + // labelFrom + // + labelFrom.AutoSize = true; + labelFrom.Location = new Point(16, 31); + labelFrom.Name = "labelFrom"; + labelFrom.Size = new Size(18, 20); + labelFrom.TabIndex = 3; + labelFrom.Text = "С"; + // + // buttonToPdf + // + buttonToPdf.Location = new Point(1200, 27); + buttonToPdf.Name = "buttonToPdf"; + buttonToPdf.Size = new Size(94, 29); + buttonToPdf.TabIndex = 4; + buttonToPdf.Text = "В PDF"; + buttonToPdf.UseVisualStyleBackColor = true; + buttonToPdf.Click += ButtonToPdf_Click; + // + // dateTimePickerDateFrom + // + dateTimePickerDateFrom.Location = new Point(51, 27); + dateTimePickerDateFrom.Name = "dateTimePickerDateFrom"; + dateTimePickerDateFrom.Size = new Size(250, 27); + dateTimePickerDateFrom.TabIndex = 0; + // + // labelTo + // + labelTo.AutoSize = true; + labelTo.Location = new Point(317, 31); + labelTo.Name = "labelTo"; + labelTo.Size = new Size(29, 20); + labelTo.TabIndex = 4; + labelTo.Text = "По"; + // + // dateTimePickerDateTo + // + dateTimePickerDateTo.Location = new Point(365, 27); + dateTimePickerDateTo.Name = "dateTimePickerDateTo"; + dateTimePickerDateTo.Size = new Size(250, 27); + dateTimePickerDateTo.TabIndex = 1; + // + // buttonMake + // + buttonMake.Location = new Point(677, 27); + buttonMake.Name = "buttonMake"; + buttonMake.Size = new Size(132, 29); + buttonMake.TabIndex = 3; + buttonMake.Text = "Сформировать"; + buttonMake.UseVisualStyleBackColor = true; + buttonMake.Click += ButtonMake_Click; + // + // FormReportOrders + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(1321, 450); + Controls.Add(panel); + Name = "FormReportOrders"; + Text = "FormReportOrders"; + panel.ResumeLayout(false); + panel.PerformLayout(); + ResumeLayout(false); + } + + #endregion + + private Panel panel; + private DateTimePicker dateTimePickerDateTo; + private DateTimePicker dateTimePickerDateFrom; + private Button buttonMake; + private Button buttonToPdf; + private Label labelTo; + private Label labelFrom; + } +} \ No newline at end of file diff --git a/CarpentryWorkshop/CarpentryWorkshop/FormReportOrders.cs b/CarpentryWorkshop/CarpentryWorkshop/FormReportOrders.cs new file mode 100644 index 0000000..549c278 --- /dev/null +++ b/CarpentryWorkshop/CarpentryWorkshop/FormReportOrders.cs @@ -0,0 +1,96 @@ +using CarpentryWorkshopContracts.BindingModels; +using CarpentryWorkshopContracts.BusinessLogicsContracts; +using Microsoft.Extensions.Logging; +using Microsoft.Reporting.WinForms; +using System.IO; + +namespace CarpentryWorkshopView +{ + 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 + }; + var path = Directory.GetParent(Directory.GetCurrentDirectory())?.Parent?.Parent?.ToString() + "\\ReportOrders.rdlc"; + reportViewer.LocalReport.LoadReportDefinition(new FileStream(path, FileMode.Open)); + //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 (dateTimePickerDateFrom.Value.Date >= dateTimePickerDateTo.Value.Date) + { + MessageBox.Show("Дата начала должна быть меньше даты окончания", + "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + try + { + var dataSource = _logic.GetOrders(new ReportBindingModel + { + DateFrom = dateTimePickerDateFrom.Value, + DateTo = dateTimePickerDateTo.Value + }); + var source = new ReportDataSource("DataSetOrders", dataSource); + reportViewer.LocalReport.DataSources.Clear(); + reportViewer.LocalReport.DataSources.Add(source); + var parameters = new[] { new ReportParameter("ReportParameterPeriod", $"c {dateTimePickerDateFrom.Value.ToShortDateString()} по {dateTimePickerDateTo.Value.ToShortDateString()}") }; + + // ЗДЕСЬ ПРОИСХОДИТ ОШИБКА И ВЫБРАСЫВАЕТСЯ ИСКЛЮЧЕНИЕ + reportViewer.LocalReport.SetParameters(parameters); + reportViewer.RefreshReport(); + _logger.LogInformation("Загрузка списка заказов на период {From}-{To}", + dateTimePickerDateFrom.Value.ToShortDateString(), dateTimePickerDateTo.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 (dateTimePickerDateFrom.Value.Date >= dateTimePickerDateTo.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 = dateTimePickerDateFrom.Value, + DateTo = dateTimePickerDateTo.Value + }); + _logger.LogInformation("Сохранение списка заказов на период {From}-{To} ", + dateTimePickerDateFrom.Value.ToShortDateString(), dateTimePickerDateTo.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/CarpentryWorkshop/CarpentryWorkshop/FormReportOrders.resx b/CarpentryWorkshop/CarpentryWorkshop/FormReportOrders.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/CarpentryWorkshop/CarpentryWorkshop/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/CarpentryWorkshop/CarpentryWorkshop/FormReportWoodComponents.Designer.cs b/CarpentryWorkshop/CarpentryWorkshop/FormReportWoodComponents.Designer.cs new file mode 100644 index 0000000..0e2656d --- /dev/null +++ b/CarpentryWorkshop/CarpentryWorkshop/FormReportWoodComponents.Designer.cs @@ -0,0 +1,106 @@ +namespace CarpentryWorkshopView +{ + partial class FormReportWoodComponents + { + /// + /// 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(); + SaveButton = new Button(); + ComponentColumn = new DataGridViewTextBoxColumn(); + WoodColumn = new DataGridViewTextBoxColumn(); + CountColumn = new DataGridViewTextBoxColumn(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + SuspendLayout(); + // + // dataGridView + // + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Columns.AddRange(new DataGridViewColumn[] { ComponentColumn, WoodColumn, CountColumn }); + dataGridView.Location = new Point(14, 61); + dataGridView.Margin = new Padding(3, 4, 3, 4); + dataGridView.Name = "dataGridView"; + dataGridView.RowHeadersWidth = 51; + dataGridView.RowTemplate.Height = 25; + dataGridView.Size = new Size(651, 523); + dataGridView.TabIndex = 0; + // + // SaveButton + // + SaveButton.Location = new Point(14, 23); + SaveButton.Margin = new Padding(3, 4, 3, 4); + SaveButton.Name = "SaveButton"; + SaveButton.Size = new Size(193, 31); + SaveButton.TabIndex = 1; + SaveButton.Text = "Сохранить в Excel"; + SaveButton.UseVisualStyleBackColor = true; + SaveButton.Click += SaveButton_Click; + // + // ComponentColumn + // + ComponentColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + ComponentColumn.HeaderText = "Компонент"; + ComponentColumn.MinimumWidth = 6; + ComponentColumn.Name = "ComponentColumn"; + // + // WoodColumn + // + WoodColumn.HeaderText = "Изделие"; + WoodColumn.MinimumWidth = 6; + WoodColumn.Name = "WoodColumn"; + WoodColumn.Width = 200; + // + // CountColumn + // + CountColumn.HeaderText = "Количество"; + CountColumn.MinimumWidth = 6; + CountColumn.Name = "CountColumn"; + CountColumn.Width = 130; + // + // FormReportWoodComponents + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(679, 600); + Controls.Add(SaveButton); + Controls.Add(dataGridView); + Margin = new Padding(3, 4, 3, 4); + Name = "FormReportWoodComponents"; + Text = "Компоненты по изделиям"; + Load += FormReportWoodComponents_Load; + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + } + + #endregion + + private DataGridView dataGridView; + private Button SaveButton; + private DataGridViewTextBoxColumn ComponentColumn; + private DataGridViewTextBoxColumn WoodColumn; + private DataGridViewTextBoxColumn CountColumn; + } +} \ No newline at end of file diff --git a/CarpentryWorkshop/CarpentryWorkshop/FormReportWoodComponents.cs b/CarpentryWorkshop/CarpentryWorkshop/FormReportWoodComponents.cs new file mode 100644 index 0000000..a4d2aa0 --- /dev/null +++ b/CarpentryWorkshop/CarpentryWorkshop/FormReportWoodComponents.cs @@ -0,0 +1,88 @@ +using CarpentryWorkshopContracts.BindingModels; +using CarpentryWorkshopContracts.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 CarpentryWorkshopView +{ + public partial class FormReportWoodComponents : Form + { + private readonly ILogger _logger; + private readonly IReportLogic _logic; + + public FormReportWoodComponents(ILogger logger, IReportLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + } + + private void FormReportWoodComponents_Load(object sender, EventArgs e) + { + try + { + var dict = _logic.GetWoodComponent(); + if (dict != null) + { + dataGridView.Rows.Clear(); + foreach (var elem in dict) + { + dataGridView.Rows.Add(new object[] { elem.WoodName, "", "" }); + 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 SaveButton_Click(object sender, EventArgs e) + { + using var dialog = new SaveFileDialog + { + Filter = "xlsx|*.xlsx" + }; + if (dialog.ShowDialog() == DialogResult.OK) + { + try + { + _logic.SaveWoodComponentToExcelFile(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/CarpentryWorkshop/CarpentryWorkshop/FormReportWoodComponents.resx b/CarpentryWorkshop/CarpentryWorkshop/FormReportWoodComponents.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/CarpentryWorkshop/CarpentryWorkshop/FormReportWoodComponents.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/CarpentryWorkshop/CarpentryWorkshop/Program.cs b/CarpentryWorkshop/CarpentryWorkshop/Program.cs index 8759e1b..462ded6 100644 --- a/CarpentryWorkshop/CarpentryWorkshop/Program.cs +++ b/CarpentryWorkshop/CarpentryWorkshop/Program.cs @@ -1,4 +1,6 @@ using CarpentryWorkshopBusinessLogic.BusinessLogics; +using CarpentryWorkshopBusinessLogic.OfficePackage; +using CarpentryWorkshopBusinessLogic.OfficePackage.Implements; using CarpentryWorkshopContracts.BusinessLogicsContracts; using CarpentryWorkshopContracts.StoragesContracts; using CarpentryWorkshopDatabaseImplement.Implements; @@ -42,6 +44,7 @@ namespace CarpentryWorkshop services.AddTransient(); services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); @@ -51,6 +54,12 @@ namespace CarpentryWorkshop services.AddTransient(); services.AddTransient(); services.AddTransient(); + + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); } } } \ No newline at end of file diff --git a/CarpentryWorkshop/CarpentryWorkshop/ReportOrders.rdlc b/CarpentryWorkshop/CarpentryWorkshop/ReportOrders.rdlc new file mode 100644 index 0000000..4205fe8 --- /dev/null +++ b/CarpentryWorkshop/CarpentryWorkshop/ReportOrders.rdlc @@ -0,0 +1,600 @@ + + + 0 + + + + System.Data.DataSet + /* Local Connection */ + + 10791c83-cee8-4a38-bbd0-245fc17cefb3 + + + + + + CarpentryWorkshopContractsViewModels + /* Local Query */ + + + + Id + System.Int32 + + + DateCreate + System.DateTime + + + WoodName + System.String + + + Sum + System.Decimal + + + Status + System.String + + + + CarpentryWorkshopContracts.ViewModels + ReportOrderViewModel + CarpentryWorkshopContracts.ViewModels.ReportOrderViewModel, CarpentryWorkshopContracts, 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!WoodName.Value + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!Status.Value + + + 2pt + 2pt + 2pt + 2pt + + + true + + + + + + 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 +