From 1e3d3e0e32ba5bc9a67a07dc9ea03eb8d636f4b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=BA=20=D0=98=D0=B3=D0=BE=D1=80=D1=8C?= Date: Sun, 26 Mar 2023 19:27:00 +0400 Subject: [PATCH] =?UTF-8?q?=D0=BB=D0=B0=D0=B1=204=20=D0=B1=D0=B5=D0=B7=20?= =?UTF-8?q?=D0=B4=D0=BE=D0=B4=D0=B5=D0=BB=D0=BE=D0=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BlacksmithWorkshopView.csproj | 5 + .../BlacksmithWorkshop/FormMain.Designer.cs | 44 +- .../BlacksmithWorkshop/FormMain.cs | 32 +- ...ormReportManufactureComponents.Designer.cs | 103 ++++ .../FormReportManufactureComponents.cs | 71 +++ .../FormReportManufactureComponents.resx | 78 +++ .../BlacksmithWorkshop/FormReportOrders.cs | 90 +++ .../FormReportOrders.designer.cs | 141 +++++ .../BlacksmithWorkshop/FormReportOrders.resx | 120 ++++ .../BlacksmithWorkshop/Program.cs | 9 + .../BlacksmithWorkshop/ReportOrders.rdlc | 527 ++++++++++++++++++ .../BlacksmithWorkshopBusinessLogic.csproj | 2 + .../BusinessLogics/ReportLogic.cs | 124 +++++ .../OfficePackage/AbstractSaveToExcel.cs | 97 ++++ .../OfficePackage/AbstractSaveToPdf.cs | 74 +++ .../OfficePackage/AbstractSaveToWord.cs | 58 ++ .../HelperEnums/ExcelStyleInfoType.cs | 9 + .../HelperEnums/PdfParagraphAlignmentType.cs | 9 + .../HelperEnums/WordJustificationType.cs | 8 + .../HelperModels/ExcelCellParameters.cs | 12 + .../OfficePackage/HelperModels/ExcelInfo.cs | 11 + .../HelperModels/ExcelMergeParameters.cs | 9 + .../OfficePackage/HelperModels/PdfInfo.cs | 14 + .../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 | 321 +++++++++++ .../OfficePackage/Implements/SaveToPdf.cs | 100 ++++ .../OfficePackage/Implements/SaveToWord.cs | 121 ++++ .../BindingModels/ReportBindingModel.cs | 9 + .../BusinessLogicsContracts/IReportLogic.cs | 35 ++ .../SearchModels/OrderSearchModel.cs | 2 + .../ReportManufactureComponentViewModel.cs | 9 + .../ViewModels/ReportOrdersViewModel.cs | 10 + .../Implements/OrderStorage.cs | 4 +- 37 files changed, 2305 insertions(+), 5 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.cs create mode 100644 BlacksmithWorkshop/BlacksmithWorkshop/FormReportOrders.designer.cs create mode 100644 BlacksmithWorkshop/BlacksmithWorkshop/FormReportOrders.resx 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/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/PdfRowParameters.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/ViewModels/ReportManufactureComponentViewModel.cs create mode 100644 BlacksmithWorkshop/BlacksmithWorkshopContracts/ViewModels/ReportOrdersViewModel.cs diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/BlacksmithWorkshopView.csproj b/BlacksmithWorkshop/BlacksmithWorkshop/BlacksmithWorkshopView.csproj index ae37a5d..fe9d4c2 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/BlacksmithWorkshopView.csproj +++ b/BlacksmithWorkshop/BlacksmithWorkshop/BlacksmithWorkshopView.csproj @@ -10,12 +10,16 @@ + Always + + Always + @@ -25,6 +29,7 @@ + diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.Designer.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.Designer.cs index 747545a..47781ff 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.Designer.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.Designer.cs @@ -32,6 +32,10 @@ this.refbooksToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.componentsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.manufacturesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.reportsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.reportComponentsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.reportManufactureComponentsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.reportOrdersToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.dataGridView = new System.Windows.Forms.DataGridView(); this.buttonCreateOrder = new System.Windows.Forms.Button(); this.buttonTakeOrderInWork = new System.Windows.Forms.Button(); @@ -41,12 +45,12 @@ this.menuStrip.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); this.SuspendLayout(); - this.Load += new System.EventHandler(this.FormMain_Load); // // menuStrip // this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.refbooksToolStripMenuItem}); + this.refbooksToolStripMenuItem, + this.reportsToolStripMenuItem}); this.menuStrip.Location = new System.Drawing.Point(0, 0); this.menuStrip.Name = "menuStrip"; this.menuStrip.Size = new System.Drawing.Size(1108, 24); @@ -76,6 +80,37 @@ this.manufacturesToolStripMenuItem.Text = "Изделия"; this.manufacturesToolStripMenuItem.Click += new System.EventHandler(this.ManufacturesToolStripMenuItem_Click); // + // reportsToolStripMenuItem + // + this.reportsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.reportComponentsToolStripMenuItem, + this.reportManufactureComponentsToolStripMenuItem, + this.reportOrdersToolStripMenuItem}); + this.reportsToolStripMenuItem.Name = "reportsToolStripMenuItem"; + this.reportsToolStripMenuItem.Size = new System.Drawing.Size(60, 20); + this.reportsToolStripMenuItem.Text = "Отчеты"; + // + // reportComponentsToolStripMenuItem + // + this.reportComponentsToolStripMenuItem.Name = "reportComponentsToolStripMenuItem"; + this.reportComponentsToolStripMenuItem.Size = new System.Drawing.Size(218, 22); + this.reportComponentsToolStripMenuItem.Text = "Список компонентов"; + this.reportComponentsToolStripMenuItem.Click += new System.EventHandler(this.ReportComponentsToolStripMenuItem_Click); + // + // reportManufactureComponentsToolStripMenuItem + // + this.reportManufactureComponentsToolStripMenuItem.Name = "reportManufactureComponentsToolStripMenuItem"; + this.reportManufactureComponentsToolStripMenuItem.Size = new System.Drawing.Size(218, 22); + this.reportManufactureComponentsToolStripMenuItem.Text = "Компоненты по изделиям"; + this.reportManufactureComponentsToolStripMenuItem.Click += new System.EventHandler(this.ReportManufactureComponentsToolStripMenuItem_Click); + // + // reportOrdersToolStripMenuItem + // + this.reportOrdersToolStripMenuItem.Name = "reportOrdersToolStripMenuItem"; + this.reportOrdersToolStripMenuItem.Size = new System.Drawing.Size(218, 22); + this.reportOrdersToolStripMenuItem.Text = "Список заказов"; + this.reportOrdersToolStripMenuItem.Click += new System.EventHandler(this.ReportOrdersToolStripMenuItem_Click); + // // dataGridView // this.dataGridView.BackgroundColor = System.Drawing.SystemColors.ControlLightLight; @@ -156,6 +191,7 @@ this.MainMenuStrip = this.menuStrip; this.Name = "FormMain"; this.Text = "Кузнечная мастерская"; + this.Load += new System.EventHandler(this.FormMain_Load); this.menuStrip.ResumeLayout(false); this.menuStrip.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); @@ -176,5 +212,9 @@ private Button buttonOrderReady; private Button buttonIssuedOrder; private Button buttonRef; + private ToolStripMenuItem reportsToolStripMenuItem; + private ToolStripMenuItem reportComponentsToolStripMenuItem; + private ToolStripMenuItem reportManufactureComponentsToolStripMenuItem; + private ToolStripMenuItem reportOrdersToolStripMenuItem; } } \ No newline at end of file diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.cs index ad836a4..d7c5f4d 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.cs @@ -1,5 +1,6 @@ using BlacksmithWorkshopContracts.BindingModels; using BlacksmithWorkshopContracts.BusinessLogicContracts; +using BlacksmithWorkshopContracts.BusinessLogicsContracts; using Microsoft.Extensions.Logging; namespace BlacksmithWorkshopView @@ -9,11 +10,13 @@ namespace BlacksmithWorkshopView 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) { @@ -146,5 +149,32 @@ namespace BlacksmithWorkshopView { LoadData(); } + private void ReportComponentsToolStripMenuItem_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 ReportManufactureComponentsToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormReportManufactureComponents)); + if (service is FormReportManufactureComponents form) + { + form.ShowDialog(); + LoadData(); + } + } + private void ReportOrdersToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormReportOrders)); + if (service is FormReportOrders form) + { + form.ShowDialog(); + LoadData(); + } + } } } \ No newline at end of file diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormReportManufactureComponents.Designer.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormReportManufactureComponents.Designer.cs new file mode 100644 index 0000000..277bc75 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormReportManufactureComponents.Designer.cs @@ -0,0 +1,103 @@ +namespace BlacksmithWorkshopView +{ + 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() + { + this.dataGridView = new System.Windows.Forms.DataGridView(); + this.ColumnComponent = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.ColumnManufacture = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.ColumnCount = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.buttonSaveToExcel = new System.Windows.Forms.Button(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); + this.SuspendLayout(); + this.Load += new System.EventHandler(this.FormReportManufactureComponents_Load); + // + // dataGridView + // + this.dataGridView.AllowUserToAddRows = false; + this.dataGridView.BackgroundColor = System.Drawing.SystemColors.ControlLightLight; + this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.ColumnComponent, + this.ColumnManufacture, + this.ColumnCount}); + this.dataGridView.Dock = System.Windows.Forms.DockStyle.Bottom; + this.dataGridView.Location = new System.Drawing.Point(0, 45); + this.dataGridView.Name = "dataGridView"; + this.dataGridView.RowTemplate.Height = 25; + this.dataGridView.Size = new System.Drawing.Size(610, 405); + this.dataGridView.TabIndex = 0; + // + // ColumnComponent + // + this.ColumnComponent.HeaderText = "Компонент"; + this.ColumnComponent.Name = "ColumnComponent"; + // + // ColumnManufacture + // + this.ColumnManufacture.HeaderText = "Изделие"; + this.ColumnManufacture.Name = "ColumnManufacture"; + // + // ColumnCount + // + this.ColumnCount.HeaderText = "Количество"; + this.ColumnCount.Name = "ColumnCount"; + // + // buttonSaveToExcel + // + this.buttonSaveToExcel.Location = new System.Drawing.Point(12, 12); + this.buttonSaveToExcel.Name = "buttonSaveToExcel"; + this.buttonSaveToExcel.Size = new System.Drawing.Size(188, 23); + this.buttonSaveToExcel.TabIndex = 1; + this.buttonSaveToExcel.Text = "Сохранить в Excel"; + this.buttonSaveToExcel.UseVisualStyleBackColor = true; + this.buttonSaveToExcel.Click += new System.EventHandler(this.ButtonSaveToExcel_Click); + // + // FormReportManufactureComponents + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(610, 450); + this.Controls.Add(this.buttonSaveToExcel); + this.Controls.Add(this.dataGridView); + this.Name = "FormReportManufactureComponents"; + this.Text = "FormReportManufactureComponents"; + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private DataGridView dataGridView; + private DataGridViewTextBoxColumn ColumnComponent; + private DataGridViewTextBoxColumn ColumnManufacture; + private DataGridViewTextBoxColumn ColumnCount; + private Button buttonSaveToExcel; + } +} \ No newline at end of file diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormReportManufactureComponents.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormReportManufactureComponents.cs new file mode 100644 index 0000000..980c8b7 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormReportManufactureComponents.cs @@ -0,0 +1,71 @@ +using BlacksmithWorkshopContracts.BindingModels; +using BlacksmithWorkshopContracts.BusinessLogicsContracts; +using Microsoft.Extensions.Logging; + +namespace BlacksmithWorkshopView +{ + 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.ComponentName, "", "" }); + foreach (var listElem in elem.Manufactures) + { + 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); + } + } + } + + } +} \ No newline at end of file diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormReportManufactureComponents.resx b/BlacksmithWorkshop/BlacksmithWorkshop/FormReportManufactureComponents.resx new file mode 100644 index 0000000..bd4b7f6 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormReportManufactureComponents.resx @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + True + + + True + + + True + + + True + + + True + + + True + + \ No newline at end of file diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormReportOrders.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormReportOrders.cs new file mode 100644 index 0000000..89c6808 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormReportOrders.cs @@ -0,0 +1,90 @@ +using BlacksmithWorkshopContracts.BindingModels; +using BlacksmithWorkshopContracts.BusinessLogicsContracts; +using Microsoft.Extensions.Logging; +using Microsoft.Reporting.WinForms; + +namespace BlacksmithWorkshopView +{ + 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); + } + } + } + } +} \ 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..e776ede --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormReportOrders.designer.cs @@ -0,0 +1,141 @@ +namespace BlacksmithWorkshopView +{ + 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.labelTo = new System.Windows.Forms.Label(); + this.dateTimePickerFrom = new System.Windows.Forms.DateTimePicker(); + this.labelFrom = new System.Windows.Forms.Label(); + this.panel.SuspendLayout(); + this.SuspendLayout(); + // + // panel + // + this.panel.Controls.Add(this.buttonToPdf); + this.panel.Controls.Add(this.buttonMake); + this.panel.Controls.Add(this.dateTimePickerTo); + this.panel.Controls.Add(this.labelTo); + this.panel.Controls.Add(this.dateTimePickerFrom); + this.panel.Controls.Add(this.labelFrom); + this.panel.Dock = System.Windows.Forms.DockStyle.Top; + this.panel.Location = new System.Drawing.Point(0, 0); + this.panel.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.panel.Name = "panel"; + this.panel.Size = new System.Drawing.Size(1031, 40); + this.panel.TabIndex = 0; + // + // buttonToPdf + // + this.buttonToPdf.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.buttonToPdf.Location = new System.Drawing.Point(878, 8); + this.buttonToPdf.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.buttonToPdf.Name = "buttonToPdf"; + this.buttonToPdf.Size = new System.Drawing.Size(139, 27); + this.buttonToPdf.TabIndex = 5; + this.buttonToPdf.Text = "В Pdf"; + this.buttonToPdf.UseVisualStyleBackColor = true; + this.buttonToPdf.Click += new System.EventHandler(this.ButtonToPdf_Click); + // + // buttonMake + // + this.buttonMake.Location = new System.Drawing.Point(476, 8); + this.buttonMake.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.buttonMake.Name = "buttonMake"; + this.buttonMake.Size = new System.Drawing.Size(139, 27); + this.buttonMake.TabIndex = 4; + this.buttonMake.Text = "Сформировать"; + this.buttonMake.UseVisualStyleBackColor = true; + this.buttonMake.Click += new System.EventHandler(this.ButtonMake_Click); + // + // dateTimePickerTo + // + this.dateTimePickerTo.Location = new System.Drawing.Point(237, 7); + this.dateTimePickerTo.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.dateTimePickerTo.Name = "dateTimePickerTo"; + this.dateTimePickerTo.Size = new System.Drawing.Size(163, 23); + this.dateTimePickerTo.TabIndex = 3; + // + // labelTo + // + this.labelTo.AutoSize = true; + this.labelTo.Location = new System.Drawing.Point(208, 10); + this.labelTo.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.labelTo.Name = "labelTo"; + this.labelTo.Size = new System.Drawing.Size(21, 15); + this.labelTo.TabIndex = 2; + this.labelTo.Text = "по"; + // + // dateTimePickerFrom + // + this.dateTimePickerFrom.Location = new System.Drawing.Point(37, 7); + this.dateTimePickerFrom.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.dateTimePickerFrom.Name = "dateTimePickerFrom"; + this.dateTimePickerFrom.Size = new System.Drawing.Size(163, 23); + this.dateTimePickerFrom.TabIndex = 1; + // + // labelFrom + // + this.labelFrom.AutoSize = true; + this.labelFrom.Location = new System.Drawing.Point(14, 10); + this.labelFrom.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.labelFrom.Name = "labelFrom"; + this.labelFrom.Size = new System.Drawing.Size(15, 15); + this.labelFrom.TabIndex = 0; + this.labelFrom.Text = "С"; + // + // FormReportOrders + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(1031, 647); + this.Controls.Add(this.panel); + this.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.Name = "FormReportOrders"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "Заказы"; + this.panel.ResumeLayout(false); + this.panel.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Panel panel; + private System.Windows.Forms.Button buttonToPdf; + private System.Windows.Forms.Button buttonMake; + private System.Windows.Forms.DateTimePicker dateTimePickerTo; + private System.Windows.Forms.Label labelTo; + private System.Windows.Forms.DateTimePicker dateTimePickerFrom; + private System.Windows.Forms.Label labelFrom; + } +} \ No newline at end of file diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormReportOrders.resx b/BlacksmithWorkshop/BlacksmithWorkshop/FormReportOrders.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshop/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/BlacksmithWorkshop/BlacksmithWorkshop/Program.cs b/BlacksmithWorkshop/BlacksmithWorkshop/Program.cs index 643d0f9..4fd9534 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/Program.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshop/Program.cs @@ -1,5 +1,8 @@ +using BlacksmithWorkshopBusinessLogic.OfficePackage; +using BlacksmithWorkshopBusinessLogic.OfficePackage.Implements; using BlacksmithWorkShopBusinessLogic.BusinessLogics; using BlacksmithWorkshopContracts.BusinessLogicContracts; +using BlacksmithWorkshopContracts.BusinessLogicsContracts; using BlacksmithWorkshopContracts.StoragesContracts; using BlacksmithWorkshopDatabaseImplement.Implements; using Microsoft.Extensions.DependencyInjection; @@ -36,6 +39,10 @@ namespace BlacksmithWorkshopView services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); @@ -43,6 +50,8 @@ namespace BlacksmithWorkshopView services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); + services.AddTransient(); } } } \ No newline at end of file diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/ReportOrders.rdlc b/BlacksmithWorkshop/BlacksmithWorkshop/ReportOrders.rdlc new file mode 100644 index 0000000..70caca1 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshop/ReportOrders.rdlc @@ -0,0 +1,527 @@ + + + 0 + + + + System.Data.DataSet + /* Local Connection */ + + 10791c83-cee8-4a38-bbd0-245fc17cefb3 + + + + + + BlacksmithWorkshopContractsViewModels + /* Local Query */ + + + + Id + System.Int32 + + + DateCreate + System.DateTime + + + ManufactureName + System.String + + + Sum + System.Decimal + + + + BlacksmithWorkshopContracts.ViewModels + ReportOrdersViewModel + BlacksmithWorkshopContracts.ViewModels.ReportOrdersViewModel, BlacksmithWorkshopContracts, 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 + + + + + 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 + + + + + + + + 0.6cm + + + + + 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 + + + + + + + + + + + + + + + + + + + + After + + + + + + + DataSetOrders + 2.48391cm + 0.55245cm + 1.2cm + 16.44755cm + 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 +