From 936cc0929321ce495f3a2096c127aecc7ee42b64 Mon Sep 17 00:00:00 2001 From: vladimir_zinovev Date: Sat, 4 May 2024 20:17:10 +0400 Subject: [PATCH] lab is done --- .../FurnitureAssembly/FormMain.Designer.cs | 250 ++++---- .../FurnitureAssembly/FormMain.cs | 112 +++- .../FurnitureAssembly/FormMain.resx | 62 +- .../FormReportFurnitureWorkpieces.Designer.cs | 118 ++++ .../FormReportFurnitureWorkpieces.cs | 94 +++ .../FormReportFurnitureWorkpieces.resx | 69 ++ .../FormReportOrders.Designer.cs | 129 ++++ .../FurnitureAssembly/FormReportOrders.cs | 123 ++++ .../FurnitureAssembly/FormReportOrders.resx | 120 ++++ .../FormWorkpiece.Designer.cs | 135 ++-- .../FurnitureAssembly/FormWorkpiece.resx | 62 +- .../FurnitureAssemblyView.csproj | 10 +- .../FurnitureAssembly/Program.cs | 13 +- .../FurnitureAssembly/ReportOrders.rdlc | 600 ++++++++++++++++++ .../BusinessLogic/FurnitureLogic.cs | 147 +++++ .../BusinessLogic/OrderLogic.cs | 158 +++++ .../BusinessLogic/ReportLogic.cs | 118 ++++ .../BusinessLogic/WorkpieceLogic.cs | 111 ++++ .../FurnitureAssemblyBusinessLogic.csproj | 2 + .../OfficePackage/AbstractSaveToExcel.cs | 102 +++ .../OfficePackage/AbstractSaveToPdf.cs | 81 +++ .../OfficePackage/AbstractSaveToWord.cs | 59 ++ .../HelperEnums/ExcelStyleInfoType.cs | 15 + .../HelperEnums/PdfParagraphAlignmentType.cs | 15 + .../HelperEnums/WordJustificationType.cs | 14 + .../HelperModels/ExcelCellParameters.cs | 18 + .../OfficePackage/HelperModels/ExcelInfo.cs | 20 + .../HelperModels/ExcelMergeParameters.cs | 15 + .../OfficePackage/HelperModels/PdfInfo.cs | 18 + .../HelperModels/PdfParagraph.cs | 16 + .../HelperModels/PdfRowParameters.cs | 16 + .../OfficePackage/HelperModels/WordInfo.cs | 19 + .../HelperModels/WordParagraph.cs | 14 + .../HelperModels/WordTextProperties.cs | 16 + .../OfficePackage/Implements/SaveToExcel.cs | 376 +++++++++++ .../OfficePackage/Implements/SaveToPdf.cs | 131 ++++ .../OfficePackage/Implements/SaveToWord.cs | 137 ++++ .../BindingModels/ReportBindingModel.cs | 15 + .../BusinessLogicsContracts/IReportLogic.cs | 40 ++ .../SearchModels/OrderSearchModel.cs | 3 + .../ViewModels/OrderViewModel.cs | 2 +- .../ReportFurnitureWorkpieceViewModel.cs | 15 + .../ViewModels/ReportOrdersViewModel.cs | 17 + .../FurnitureAssemblyDatabase.cs | 1 - .../FurnitureAssemblyDatabaseImplement.csproj | 7 +- .../Implements/OrderStorage.cs | 19 +- .../Models/Order.cs | 2 +- .../Models/Order.cs | 2 +- 48 files changed, 3414 insertions(+), 224 deletions(-) create mode 100644 FurnitureAssembly/FurnitureAssembly/FormReportFurnitureWorkpieces.Designer.cs create mode 100644 FurnitureAssembly/FurnitureAssembly/FormReportFurnitureWorkpieces.cs create mode 100644 FurnitureAssembly/FurnitureAssembly/FormReportFurnitureWorkpieces.resx create mode 100644 FurnitureAssembly/FurnitureAssembly/FormReportOrders.Designer.cs create mode 100644 FurnitureAssembly/FurnitureAssembly/FormReportOrders.cs create mode 100644 FurnitureAssembly/FurnitureAssembly/FormReportOrders.resx create mode 100644 FurnitureAssembly/FurnitureAssembly/ReportOrders.rdlc create mode 100644 FurnitureAssembly/FurnitureAssemblyBusinessLogic/BusinessLogic/FurnitureLogic.cs create mode 100644 FurnitureAssembly/FurnitureAssemblyBusinessLogic/BusinessLogic/OrderLogic.cs create mode 100644 FurnitureAssembly/FurnitureAssemblyBusinessLogic/BusinessLogic/ReportLogic.cs create mode 100644 FurnitureAssembly/FurnitureAssemblyBusinessLogic/BusinessLogic/WorkpieceLogic.cs create mode 100644 FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/AbstractSaveToExcel.cs create mode 100644 FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/AbstractSaveToPdf.cs create mode 100644 FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/AbstractSaveToWord.cs create mode 100644 FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/HelperEnums/ExcelStyleInfoType.cs create mode 100644 FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/HelperEnums/PdfParagraphAlignmentType.cs create mode 100644 FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/HelperEnums/WordJustificationType.cs create mode 100644 FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/HelperModels/ExcelCellParameters.cs create mode 100644 FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs create mode 100644 FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/HelperModels/ExcelMergeParameters.cs create mode 100644 FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs create mode 100644 FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/HelperModels/PdfParagraph.cs create mode 100644 FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/HelperModels/PdfRowParameters.cs create mode 100644 FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/HelperModels/WordInfo.cs create mode 100644 FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/HelperModels/WordParagraph.cs create mode 100644 FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/HelperModels/WordTextProperties.cs create mode 100644 FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/Implements/SaveToExcel.cs create mode 100644 FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/Implements/SaveToPdf.cs create mode 100644 FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/Implements/SaveToWord.cs create mode 100644 FurnitureAssembly/FurnitureAssemblyContracts/BindingModels/ReportBindingModel.cs create mode 100644 FurnitureAssembly/FurnitureAssemblyContracts/BusinessLogicsContracts/IReportLogic.cs create mode 100644 FurnitureAssembly/FurnitureAssemblyContracts/ViewModels/ReportFurnitureWorkpieceViewModel.cs create mode 100644 FurnitureAssembly/FurnitureAssemblyContracts/ViewModels/ReportOrdersViewModel.cs diff --git a/FurnitureAssembly/FurnitureAssembly/FormMain.Designer.cs b/FurnitureAssembly/FurnitureAssembly/FormMain.Designer.cs index 7ceebba..64fae1d 100644 --- a/FurnitureAssembly/FurnitureAssembly/FormMain.Designer.cs +++ b/FurnitureAssembly/FurnitureAssembly/FormMain.Designer.cs @@ -28,149 +28,175 @@ /// private void InitializeComponent() { - this.menuStrip1 = new System.Windows.Forms.MenuStrip(); - this.справочникиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.заготовкиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.мебельToolStripMenuItem = 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(); - this.ButtonOrderReady = new System.Windows.Forms.Button(); - this.ButtonIssuedOrder = new System.Windows.Forms.Button(); - this.ButtonRef = new System.Windows.Forms.Button(); - this.menuStrip1.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); - this.SuspendLayout(); + menuStrip1 = new MenuStrip(); + справочники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(); + ButtonOrderReady = new Button(); + ButtonIssuedOrder = new Button(); + ButtonRef = new Button(); + menuStrip1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + SuspendLayout(); // // menuStrip1 // - this.menuStrip1.ImageScalingSize = new System.Drawing.Size(32, 32); - this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.справочникиToolStripMenuItem}); - this.menuStrip1.Location = new System.Drawing.Point(0, 0); - this.menuStrip1.Name = "menuStrip1"; - this.menuStrip1.Size = new System.Drawing.Size(1631, 40); - this.menuStrip1.TabIndex = 0; - this.menuStrip1.Text = "menuStrip1"; + menuStrip1.ImageScalingSize = new Size(32, 32); + menuStrip1.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, отчетыToolStripMenuItem }); + menuStrip1.Location = new Point(0, 0); + menuStrip1.Name = "menuStrip1"; + menuStrip1.Size = new Size(1631, 40); + menuStrip1.TabIndex = 0; + menuStrip1.Text = "menuStrip1"; // // справочникиToolStripMenuItem // - this.справочникиToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.заготовкиToolStripMenuItem, - this.мебельToolStripMenuItem}); - this.справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem"; - this.справочникиToolStripMenuItem.Size = new System.Drawing.Size(184, 36); - this.справочникиToolStripMenuItem.Text = "Справочники"; + справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { заготовкиToolStripMenuItem, мебельToolStripMenuItem }); + справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem"; + справочникиToolStripMenuItem.Size = new Size(184, 38); + справочникиToolStripMenuItem.Text = "Справочники"; // // заготовкиToolStripMenuItem // - this.заготовкиToolStripMenuItem.Name = "заготовкиToolStripMenuItem"; - this.заготовкиToolStripMenuItem.Size = new System.Drawing.Size(258, 44); - this.заготовкиToolStripMenuItem.Text = "Заготовки"; - this.заготовкиToolStripMenuItem.Click += new System.EventHandler(this.ЗаготовкиToolStripMenuItem_Click); + заготовкиToolStripMenuItem.Name = "заготовкиToolStripMenuItem"; + заготовкиToolStripMenuItem.Size = new Size(258, 44); + заготовкиToolStripMenuItem.Text = "Заготовки"; + заготовкиToolStripMenuItem.Click += заготовкиToolStripMenuItem_Click; // // мебельToolStripMenuItem // - this.мебельToolStripMenuItem.Name = "мебельToolStripMenuItem"; - this.мебельToolStripMenuItem.Size = new System.Drawing.Size(258, 44); - this.мебельToolStripMenuItem.Text = "Мебель"; - this.мебельToolStripMenuItem.Click += new System.EventHandler(this.МебельToolStripMenuItem_Click); + мебельToolStripMenuItem.Name = "мебельToolStripMenuItem"; + мебельToolStripMenuItem.Size = new Size(258, 44); + мебельToolStripMenuItem.Text = "Мебель"; + мебельToolStripMenuItem.Click += мебельToolStripMenuItem_Click; + // + // отчетыToolStripMenuItem + // + отчетыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { списокМебелиToolStripMenuItem, компонентыПоИзделиямToolStripMenuItem, списокЗаказовToolStripMenuItem }); + отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem"; + отчетыToolStripMenuItem.Size = new Size(116, 36); + отчетыToolStripMenuItem.Text = "Отчеты"; + // + // списокМебелиToolStripMenuItem + // + списокМебелиToolStripMenuItem.Name = "списокМебелиToolStripMenuItem"; + списокМебелиToolStripMenuItem.Size = new Size(437, 44); + списокМебелиToolStripMenuItem.Text = "Список мебели"; + списокМебелиToolStripMenuItem.Click += FurnituresToolStripMenuItem_Click; + // + // компонентыПоИзделиямToolStripMenuItem + // + компонентыПоИзделиямToolStripMenuItem.Name = "компонентыПоИзделиямToolStripMenuItem"; + компонентыПоИзделиямToolStripMenuItem.Size = new Size(437, 44); + компонентыПоИзделиямToolStripMenuItem.Text = "Компоненты по изделиям"; + компонентыПоИзделиямToolStripMenuItem.Click += FurnituresComponentsToolStripMenuItem_Click; + // + // списокЗаказовToolStripMenuItem + // + списокЗаказовToolStripMenuItem.Name = "списокЗаказовToolStripMenuItem"; + списокЗаказовToolStripMenuItem.Size = new Size(437, 44); + списокЗаказовToolStripMenuItem.Text = "Список заказов"; + списокЗаказовToolStripMenuItem.Click += OrdersToolStripMenuItem_Click; // // dataGridView // - this.dataGridView.AllowUserToAddRows = false; - this.dataGridView.AllowUserToDeleteRows = false; - this.dataGridView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.dataGridView.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; - this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; - this.dataGridView.Location = new System.Drawing.Point(0, 65); - this.dataGridView.Name = "dataGridView"; - this.dataGridView.RowHeadersVisible = false; - this.dataGridView.RowHeadersWidth = 82; - this.dataGridView.RowTemplate.Height = 41; - this.dataGridView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; - this.dataGridView.Size = new System.Drawing.Size(1237, 528); - this.dataGridView.TabIndex = 1; + dataGridView.AllowUserToAddRows = false; + dataGridView.AllowUserToDeleteRows = false; + dataGridView.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; + dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Location = new Point(0, 65); + dataGridView.Name = "dataGridView"; + dataGridView.RowHeadersVisible = false; + dataGridView.RowHeadersWidth = 82; + dataGridView.RowTemplate.Height = 41; + dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridView.Size = new Size(1237, 528); + dataGridView.TabIndex = 1; // // ButtonCreateOrder // - this.ButtonCreateOrder.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.ButtonCreateOrder.Location = new System.Drawing.Point(1266, 65); - this.ButtonCreateOrder.Name = "ButtonCreateOrder"; - this.ButtonCreateOrder.Size = new System.Drawing.Size(334, 46); - this.ButtonCreateOrder.TabIndex = 2; - this.ButtonCreateOrder.Text = "Создать заказ"; - this.ButtonCreateOrder.UseVisualStyleBackColor = true; - this.ButtonCreateOrder.Click += new System.EventHandler(this.ButtonCreateOrder_Click); + ButtonCreateOrder.Anchor = AnchorStyles.Top | AnchorStyles.Right; + ButtonCreateOrder.Location = new Point(1266, 65); + ButtonCreateOrder.Name = "ButtonCreateOrder"; + ButtonCreateOrder.Size = new Size(334, 46); + ButtonCreateOrder.TabIndex = 2; + ButtonCreateOrder.Text = "Создать заказ"; + ButtonCreateOrder.UseVisualStyleBackColor = true; + ButtonCreateOrder.Click += ButtonCreateOrder_Click; // // ButtonTakeOrderInWork // - this.ButtonTakeOrderInWork.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.ButtonTakeOrderInWork.Location = new System.Drawing.Point(1266, 119); - this.ButtonTakeOrderInWork.Name = "ButtonTakeOrderInWork"; - this.ButtonTakeOrderInWork.Size = new System.Drawing.Size(334, 46); - this.ButtonTakeOrderInWork.TabIndex = 3; - this.ButtonTakeOrderInWork.Text = "Отдать на выполнение"; - this.ButtonTakeOrderInWork.UseVisualStyleBackColor = true; - this.ButtonTakeOrderInWork.Click += new System.EventHandler(this.ButtonTakeOrderInWork_Click); + ButtonTakeOrderInWork.Anchor = AnchorStyles.Top | AnchorStyles.Right; + ButtonTakeOrderInWork.Location = new Point(1266, 119); + ButtonTakeOrderInWork.Name = "ButtonTakeOrderInWork"; + ButtonTakeOrderInWork.Size = new Size(334, 46); + ButtonTakeOrderInWork.TabIndex = 3; + ButtonTakeOrderInWork.Text = "Отдать на выполнение"; + ButtonTakeOrderInWork.UseVisualStyleBackColor = true; + ButtonTakeOrderInWork.Click += ButtonTakeOrderInWork_Click; // // ButtonOrderReady // - this.ButtonOrderReady.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.ButtonOrderReady.Location = new System.Drawing.Point(1266, 196); - this.ButtonOrderReady.Name = "ButtonOrderReady"; - this.ButtonOrderReady.Size = new System.Drawing.Size(334, 46); - this.ButtonOrderReady.TabIndex = 4; - this.ButtonOrderReady.Text = "Заказ готов"; - this.ButtonOrderReady.UseVisualStyleBackColor = true; - this.ButtonOrderReady.Click += new System.EventHandler(this.ButtonOrderReady_Click); + ButtonOrderReady.Anchor = AnchorStyles.Top | AnchorStyles.Right; + ButtonOrderReady.Location = new Point(1266, 196); + ButtonOrderReady.Name = "ButtonOrderReady"; + ButtonOrderReady.Size = new Size(334, 46); + ButtonOrderReady.TabIndex = 4; + ButtonOrderReady.Text = "Заказ готов"; + ButtonOrderReady.UseVisualStyleBackColor = true; + ButtonOrderReady.Click += ButtonOrderReady_Click; // // ButtonIssuedOrder // - this.ButtonIssuedOrder.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.ButtonIssuedOrder.Location = new System.Drawing.Point(1266, 252); - this.ButtonIssuedOrder.Name = "ButtonIssuedOrder"; - this.ButtonIssuedOrder.Size = new System.Drawing.Size(334, 46); - this.ButtonIssuedOrder.TabIndex = 5; - this.ButtonIssuedOrder.Text = "Заказ выдан"; - this.ButtonIssuedOrder.UseVisualStyleBackColor = true; - this.ButtonIssuedOrder.Click += new System.EventHandler(this.ButtonIssuedOrder_Click); + ButtonIssuedOrder.Anchor = AnchorStyles.Top | AnchorStyles.Right; + ButtonIssuedOrder.Location = new Point(1266, 252); + ButtonIssuedOrder.Name = "ButtonIssuedOrder"; + ButtonIssuedOrder.Size = new Size(334, 46); + ButtonIssuedOrder.TabIndex = 5; + ButtonIssuedOrder.Text = "Заказ выдан"; + ButtonIssuedOrder.UseVisualStyleBackColor = true; + ButtonIssuedOrder.Click += ButtonIssuedOrder_Click; // // ButtonRef // - this.ButtonRef.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.ButtonRef.Location = new System.Drawing.Point(1266, 336); - this.ButtonRef.Name = "ButtonRef"; - this.ButtonRef.Size = new System.Drawing.Size(334, 46); - this.ButtonRef.TabIndex = 6; - this.ButtonRef.Text = "Обновить список"; - this.ButtonRef.UseVisualStyleBackColor = true; - this.ButtonRef.Click += new System.EventHandler(this.ButtonRef_Click); + ButtonRef.Anchor = AnchorStyles.Top | AnchorStyles.Right; + ButtonRef.Location = new Point(1266, 336); + ButtonRef.Name = "ButtonRef"; + ButtonRef.Size = new Size(334, 46); + ButtonRef.TabIndex = 6; + ButtonRef.Text = "Обновить список"; + ButtonRef.UseVisualStyleBackColor = true; + ButtonRef.Click += ButtonRef_Click; // // FormMain // - this.AutoScaleDimensions = new System.Drawing.SizeF(13F, 32F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(1631, 594); - this.Controls.Add(this.ButtonRef); - this.Controls.Add(this.ButtonIssuedOrder); - this.Controls.Add(this.ButtonOrderReady); - this.Controls.Add(this.ButtonTakeOrderInWork); - this.Controls.Add(this.ButtonCreateOrder); - this.Controls.Add(this.dataGridView); - this.Controls.Add(this.menuStrip1); - this.MainMenuStrip = this.menuStrip1; - this.Name = "FormMain"; - this.Text = "Сборка мебели"; - this.Load += new System.EventHandler(this.FormMain_Load); - this.menuStrip1.ResumeLayout(false); - this.menuStrip1.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); - this.ResumeLayout(false); - this.PerformLayout(); - + AutoScaleDimensions = new SizeF(13F, 32F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(1631, 594); + Controls.Add(ButtonRef); + Controls.Add(ButtonIssuedOrder); + Controls.Add(ButtonOrderReady); + Controls.Add(ButtonTakeOrderInWork); + Controls.Add(ButtonCreateOrder); + Controls.Add(dataGridView); + Controls.Add(menuStrip1); + MainMenuStrip = menuStrip1; + Name = "FormMain"; + Text = "Сборка мебели"; + Load += MainForm_Load; + menuStrip1.ResumeLayout(false); + menuStrip1.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + PerformLayout(); } #endregion @@ -185,5 +211,9 @@ private Button ButtonOrderReady; private Button ButtonIssuedOrder; private Button ButtonRef; + private ToolStripMenuItem отчетыToolStripMenuItem; + private ToolStripMenuItem списокМебелиToolStripMenuItem; + private ToolStripMenuItem компонентыПоИзделиямToolStripMenuItem; + private ToolStripMenuItem списокЗаказовToolStripMenuItem; } } \ No newline at end of file diff --git a/FurnitureAssembly/FurnitureAssembly/FormMain.cs b/FurnitureAssembly/FurnitureAssembly/FormMain.cs index 0d5c3ee..8e16764 100644 --- a/FurnitureAssembly/FurnitureAssembly/FormMain.cs +++ b/FurnitureAssembly/FurnitureAssembly/FormMain.cs @@ -1,6 +1,8 @@ -using FurnitureAssembly; +using DocumentFormat.OpenXml.Office2010.ExcelAc; +using FurnitureAssembly; using FurnitureAssemblyContracts.BindingModels; using FurnitureAssemblyContracts.BusinessLogicsContracts; +using FurnitureAssemblyDataModels.Enums; using Microsoft.Extensions.Logging; using System; using System.Collections.Generic; @@ -17,26 +19,23 @@ namespace FurnitureAssemblyView public partial class FormMain : Form { 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) + private void MainForm_Load(object sender, EventArgs e) { LoadData(); } - private void LoadData() { _logger.LogInformation("Загрузка заказов"); - try { var list = _orderLogic.ReadList(null); @@ -56,17 +55,16 @@ namespace FurnitureAssemblyView } } - private void ЗаготовкиToolStripMenuItem_Click(object sender, EventArgs e) + private void заготовкиToolStripMenuItem_Click(object sender, EventArgs e) { var service = Program.ServiceProvider?.GetService(typeof(FormWorkpieces)); - if (service is FormWorkpieces form) { form.ShowDialog(); } } - private void МебельToolStripMenuItem_Click(object sender, EventArgs e) + private void мебельToolStripMenuItem_Click(object sender, EventArgs e) { var service = Program.ServiceProvider?.GetService(typeof(FormFurnitures)); @@ -79,7 +77,6 @@ namespace FurnitureAssemblyView private void ButtonCreateOrder_Click(object sender, EventArgs e) { var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder)); - if (service is FormCreateOrder form) { form.ShowDialog(); @@ -94,44 +91,59 @@ namespace FurnitureAssemblyView { int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); _logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id); - try { - var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel{Id = id}); - + var resStatus = Enum.TryParse(Convert.ToString(dataGridView.SelectedRows[0].Cells["Status"].Value), true, out OrderStatus status); + if (!resStatus) + { + throw new Exception("Неверный формат статуса"); + } + var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel + { + Id = id, + FurnitureId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["FurnitureId"].Value), + Status = status, + Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value), + Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()), + DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()), + }); if (!operationResult) { throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); } - LoadData(); } catch (Exception ex) { _logger.LogError(ex, "Ошибка передачи заказа в работу"); - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); } } + } + private void ButtonOrderReady_Click(object sender, EventArgs e) { if (dataGridView.SelectedRows.Count == 1) { int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); _logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'", id); - try { var operationResult = _orderLogic.FinishOrder(new OrderBindingModel { - Id = id + Id = id, + FurnitureId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["FurnitureId"].Value), + Status = Enum.Parse(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()), + Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value), + Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()), + DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()), }); - if (!operationResult) { - throw new Exception("Заказ не отправлен в сборку. Дополнительная информация в логах."); + throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); } - LoadData(); } catch (Exception ex) @@ -140,6 +152,7 @@ namespace FurnitureAssemblyView MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } + } private void ButtonIssuedOrder_Click(object sender, EventArgs e) @@ -148,34 +161,73 @@ namespace FurnitureAssemblyView { int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); _logger.LogInformation("Заказ №{id}. Меняется статус на 'Выдан'", id); - try { - var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel + var operationResult = _orderLogic.DeliveryOrder(new + OrderBindingModel { - Id = id + Id = id, + FurnitureId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["FurnitureId"].Value), + Status = Enum.Parse(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()), + Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value), + Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()), + DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()), }); - if (!operationResult) { - throw new Exception("Заказ не в статусе готовности. Дополнительная информация в логах."); + throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); } - _logger.LogInformation("Заказ №{id} выдан", id); - LoadData(); } catch (Exception ex) { _logger.LogError(ex, "Ошибка отметки о выдачи заказа"); - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); } } + } private void ButtonRef_Click(object sender, EventArgs e) { LoadData(); } + + private void FurnituresToolStripMenuItem_Click(object sender, EventArgs e) + { + using var dialog = new SaveFileDialog { Filter = "docx|*.docx" }; + if (dialog.ShowDialog() == DialogResult.OK) + { + _reportLogic.SaveFurnituresToWordFile(new ReportBindingModel + { + FileName = dialog.FileName + }); + MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, + MessageBoxIcon.Information); + } + } + + private void FurnituresComponentsToolStripMenuItem_Click(object sender, EventArgs e) + { + + var service = + Program.ServiceProvider?.GetService(typeof(FormReportFurnitureWorkpieces)); + if (service is FormReportFurnitureWorkpieces form) + { + form.ShowDialog(); + } + } + + private void OrdersToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = + Program.ServiceProvider?.GetService(typeof(FormReportOrders)); + if (service is FormReportOrders form) + { + form.ShowDialog(); + } + } } } diff --git a/FurnitureAssembly/FurnitureAssembly/FormMain.resx b/FurnitureAssembly/FurnitureAssembly/FormMain.resx index 938108a..a0623c8 100644 --- a/FurnitureAssembly/FurnitureAssembly/FormMain.resx +++ b/FurnitureAssembly/FurnitureAssembly/FormMain.resx @@ -1,4 +1,64 @@ - + + + diff --git a/FurnitureAssembly/FurnitureAssembly/FormReportFurnitureWorkpieces.Designer.cs b/FurnitureAssembly/FurnitureAssembly/FormReportFurnitureWorkpieces.Designer.cs new file mode 100644 index 0000000..3e4b205 --- /dev/null +++ b/FurnitureAssembly/FurnitureAssembly/FormReportFurnitureWorkpieces.Designer.cs @@ -0,0 +1,118 @@ +namespace FurnitureAssemblyView +{ + partial class FormReportFurnitureWorkpieces + { + /// + /// 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.buttonSaveToExcel = new System.Windows.Forms.Button(); + this.dataGridView = new System.Windows.Forms.DataGridView(); + this.ColumnWorkpiece = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.ColumnFurniture = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.ColumnCount = new System.Windows.Forms.DataGridViewTextBoxColumn(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); + this.SuspendLayout(); + // + // buttonSaveToExcel + // + this.buttonSaveToExcel.Location = new System.Drawing.Point(12, 12); + this.buttonSaveToExcel.Name = "buttonSaveToExcel"; + this.buttonSaveToExcel.Size = new System.Drawing.Size(456, 46); + this.buttonSaveToExcel.TabIndex = 0; + this.buttonSaveToExcel.Text = "Сохранить в Excel"; + this.buttonSaveToExcel.UseVisualStyleBackColor = true; + this.buttonSaveToExcel.Click += new System.EventHandler(this.ButtonSaveToExcel_Click); + // + // dataGridView + // + this.dataGridView.AllowUserToAddRows = false; + this.dataGridView.AllowUserToDeleteRows = false; + this.dataGridView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.ColumnWorkpiece, + this.ColumnFurniture, + this.ColumnCount}); + this.dataGridView.Location = new System.Drawing.Point(12, 64); + this.dataGridView.MultiSelect = false; + this.dataGridView.Name = "dataGridView"; + this.dataGridView.ReadOnly = true; + this.dataGridView.RowHeadersWidth = 82; + this.dataGridView.RowTemplate.Height = 41; + this.dataGridView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; + this.dataGridView.Size = new System.Drawing.Size(1059, 826); + this.dataGridView.TabIndex = 1; + // + // ColumnWorkpiece + // + this.ColumnWorkpiece.HeaderText = "Компонент"; + this.ColumnWorkpiece.MinimumWidth = 10; + this.ColumnWorkpiece.Name = "ColumnWorkpiece"; + this.ColumnWorkpiece.ReadOnly = true; + this.ColumnWorkpiece.Width = 200; + // + // ColumnFurniture + // + this.ColumnFurniture.HeaderText = "Изделие"; + this.ColumnFurniture.MinimumWidth = 10; + this.ColumnFurniture.Name = "ColumnFurniture"; + this.ColumnFurniture.ReadOnly = true; + this.ColumnFurniture.Width = 200; + // + // ColumnCount + // + this.ColumnCount.HeaderText = "Количество"; + this.ColumnCount.MinimumWidth = 10; + this.ColumnCount.Name = "ColumnCount"; + this.ColumnCount.ReadOnly = true; + this.ColumnCount.Width = 200; + // + // FormReportFurnitureWorkpieces + // + this.AutoScaleDimensions = new System.Drawing.SizeF(13F, 32F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(1083, 902); + this.Controls.Add(this.dataGridView); + this.Controls.Add(this.buttonSaveToExcel); + this.Name = "FormReportFurnitureWorkpieces"; + this.Text = "Компоненты по изделиям"; + this.Load += new System.EventHandler(this.FormReportFurnitureWorkpieces_Load); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private Button buttonSaveToExcel; + private DataGridView dataGridView; + private DataGridViewTextBoxColumn ColumnWorkpiece; + private DataGridViewTextBoxColumn ColumnFurniture; + private DataGridViewTextBoxColumn ColumnCount; + } +} \ No newline at end of file diff --git a/FurnitureAssembly/FurnitureAssembly/FormReportFurnitureWorkpieces.cs b/FurnitureAssembly/FurnitureAssembly/FormReportFurnitureWorkpieces.cs new file mode 100644 index 0000000..c73cd24 --- /dev/null +++ b/FurnitureAssembly/FurnitureAssembly/FormReportFurnitureWorkpieces.cs @@ -0,0 +1,94 @@ +using FurnitureAssemblyContracts.BindingModels; +using FurnitureAssemblyContracts.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 FurnitureAssemblyView +{ + public partial class FormReportFurnitureWorkpieces : Form + { + private readonly ILogger _logger; + + private readonly IReportLogic _logic; + + public FormReportFurnitureWorkpieces(ILogger logger, IReportLogic logic) + { + InitializeComponent(); + + _logger = logger; + _logic = logic; + } + + private void FormReportFurnitureWorkpieces_Load(object sender, EventArgs e) + { + try + { + var dict = _logic.GetFurnitureWorkpiece(); + + if (dict != null) + { + dataGridView.Rows.Clear(); + + foreach (var elem in dict) + { + dataGridView.Rows.Add(new object[] { elem.FurnitureName, "", "" }); + + foreach (var listElem in elem.Workpieces) + { + 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.SaveFurnitureWorkpieceToExcelFile(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/FurnitureAssembly/FurnitureAssembly/FormReportFurnitureWorkpieces.resx b/FurnitureAssembly/FurnitureAssembly/FormReportFurnitureWorkpieces.resx new file mode 100644 index 0000000..ae6f831 --- /dev/null +++ b/FurnitureAssembly/FurnitureAssembly/FormReportFurnitureWorkpieces.resx @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + True + + + True + + + True + + \ No newline at end of file diff --git a/FurnitureAssembly/FurnitureAssembly/FormReportOrders.Designer.cs b/FurnitureAssembly/FurnitureAssembly/FormReportOrders.Designer.cs new file mode 100644 index 0000000..3a22e36 --- /dev/null +++ b/FurnitureAssembly/FurnitureAssembly/FormReportOrders.Designer.cs @@ -0,0 +1,129 @@ +namespace FurnitureAssemblyView +{ + 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(); + ButtonMakeReport = new Button(); + label2 = new Label(); + label1 = new Label(); + dateTimePickerTo = new DateTimePicker(); + dateTimePickerFrom = new DateTimePicker(); + panel.SuspendLayout(); + SuspendLayout(); + // + // panel + // + panel.Controls.Add(ButtonToPdf); + panel.Controls.Add(ButtonMakeReport); + panel.Controls.Add(label2); + panel.Controls.Add(label1); + panel.Controls.Add(dateTimePickerTo); + panel.Controls.Add(dateTimePickerFrom); + panel.Location = new Point(0, 0); + panel.Name = "panel"; + panel.Size = new Size(1918, 67); + panel.TabIndex = 0; + // + // ButtonToPdf + // + ButtonToPdf.Location = new Point(1523, 10); + ButtonToPdf.Name = "ButtonToPdf"; + ButtonToPdf.Size = new Size(333, 46); + ButtonToPdf.TabIndex = 5; + ButtonToPdf.Text = "В Pdf"; + ButtonToPdf.UseVisualStyleBackColor = true; + ButtonToPdf.Click += ButtonToPdf_Click; + // + // ButtonMakeReport + // + ButtonMakeReport.Location = new Point(983, 10); + ButtonMakeReport.Name = "ButtonMakeReport"; + ButtonMakeReport.Size = new Size(333, 46); + ButtonMakeReport.TabIndex = 4; + ButtonMakeReport.Text = "Сформировать"; + ButtonMakeReport.UseVisualStyleBackColor = true; + ButtonMakeReport.Click += ButtonMakeReport_Click; + // + // label2 + // + label2.AutoSize = true; + label2.Location = new Point(486, 10); + label2.Name = "label2"; + label2.Size = new Size(45, 32); + label2.TabIndex = 3; + label2.Text = "По"; + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(14, 10); + label1.Name = "label1"; + label1.Size = new Size(29, 32); + label1.TabIndex = 2; + label1.Text = "С"; + // + // dateTimePickerTo + // + dateTimePickerTo.Location = new Point(537, 12); + dateTimePickerTo.Name = "dateTimePickerTo"; + dateTimePickerTo.Size = new Size(400, 39); + dateTimePickerTo.TabIndex = 1; + // + // dateTimePickerFrom + // + dateTimePickerFrom.Location = new Point(49, 12); + dateTimePickerFrom.Name = "dateTimePickerFrom"; + dateTimePickerFrom.Size = new Size(400, 39); + dateTimePickerFrom.TabIndex = 0; + // + // FormReportOrders + // + AutoScaleDimensions = new SizeF(13F, 32F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(1919, 918); + Controls.Add(panel); + Name = "FormReportOrders"; + Text = "Заказы"; + panel.ResumeLayout(false); + panel.PerformLayout(); + ResumeLayout(false); + } + + #endregion + + private Panel panel; + private Label label1; + private DateTimePicker dateTimePickerTo; + private DateTimePicker dateTimePickerFrom; + private Button ButtonToPdf; + private Button ButtonMakeReport; + private Label label2; + } +} \ No newline at end of file diff --git a/FurnitureAssembly/FurnitureAssembly/FormReportOrders.cs b/FurnitureAssembly/FurnitureAssembly/FormReportOrders.cs new file mode 100644 index 0000000..c42c1d1 --- /dev/null +++ b/FurnitureAssembly/FurnitureAssembly/FormReportOrders.cs @@ -0,0 +1,123 @@ +using FurnitureAssemblyContracts.BindingModels; +using FurnitureAssemblyContracts.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 FurnitureAssemblyView +{ + public partial class FormReportOrders : Form + { + private readonly ReportViewer reportViewer; + + private readonly ILogger _logger; + + private readonly IReportLogic _logic; + + public FormReportOrders(ILogger logger, IReportLogic logic) + { + Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); + 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); + panel.BringToFront(); + } + + private void ButtonMakeReport_Click(object sender, EventArgs e) + { + if (dateTimePickerFrom.Value.ToUniversalTime().Date >= dateTimePickerTo.Value.ToUniversalTime().Date) + { + MessageBox.Show("Дата начала должна быть меньше даты окончания", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + + return; + } + try + { + var dataSource = _logic.GetOrders(new ReportBindingModel + { + DateFrom = dateTimePickerFrom.Value.ToUniversalTime(), + DateTo = dateTimePickerTo.Value.ToUniversalTime() + }); + + 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.ToUniversalTime(), + DateTo = dateTimePickerTo.Value.ToUniversalTime() + }); + + _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/FurnitureAssembly/FurnitureAssembly/FormReportOrders.resx b/FurnitureAssembly/FurnitureAssembly/FormReportOrders.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/FurnitureAssembly/FurnitureAssembly/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/FurnitureAssembly/FurnitureAssembly/FormWorkpiece.Designer.cs b/FurnitureAssembly/FurnitureAssembly/FormWorkpiece.Designer.cs index e1b6498..f26c76a 100644 --- a/FurnitureAssembly/FurnitureAssembly/FormWorkpiece.Designer.cs +++ b/FurnitureAssembly/FurnitureAssembly/FormWorkpiece.Designer.cs @@ -28,102 +28,97 @@ /// private void InitializeComponent() { - this.button1 = new System.Windows.Forms.Button(); - this.label1 = new System.Windows.Forms.Label(); - this.textBoxName = new System.Windows.Forms.TextBox(); - this.textBoxCost = new System.Windows.Forms.TextBox(); - this.label2 = new System.Windows.Forms.Label(); - this.button2 = new System.Windows.Forms.Button(); - this.SuspendLayout(); + ButtonSave = new Button(); + label1 = new Label(); + textBoxName = new TextBox(); + textBoxCost = new TextBox(); + label2 = new Label(); + ButtonCancel = new Button(); + SuspendLayout(); // - // button1 + // ButtonSave // - this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.button1.Location = new System.Drawing.Point(335, 208); - this.button1.Name = "button1"; - this.button1.Size = new System.Drawing.Size(150, 46); - this.button1.TabIndex = 0; - this.button1.Text = "Сохранить"; - this.button1.UseVisualStyleBackColor = true; - this.button1.Click += new System.EventHandler(this.ButtonSave_Click); + ButtonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + ButtonSave.Location = new Point(335, 208); + ButtonSave.Name = "ButtonSave"; + ButtonSave.Size = new Size(150, 46); + ButtonSave.TabIndex = 0; + ButtonSave.Text = "Сохранить"; + ButtonSave.UseVisualStyleBackColor = true; + ButtonSave.Click += ButtonSave_Click; // // label1 // - this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(26, 43); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(125, 32); - this.label1.TabIndex = 1; - this.label1.Text = "Название:"; + label1.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + label1.AutoSize = true; + label1.Location = new Point(26, 43); + label1.Name = "label1"; + label1.Size = new Size(125, 32); + label1.TabIndex = 1; + label1.Text = "Название:"; // // textBoxName // - this.textBoxName.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.textBoxName.Location = new System.Drawing.Point(165, 40); - this.textBoxName.Name = "textBoxName"; - this.textBoxName.Size = new System.Drawing.Size(496, 39); - this.textBoxName.TabIndex = 2; + textBoxName.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + textBoxName.Location = new Point(165, 40); + textBoxName.Name = "textBoxName"; + textBoxName.Size = new Size(496, 39); + textBoxName.TabIndex = 2; // // textBoxCost // - this.textBoxCost.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.textBoxCost.Location = new System.Drawing.Point(165, 105); - this.textBoxCost.Name = "textBoxCost"; - this.textBoxCost.Size = new System.Drawing.Size(245, 39); - this.textBoxCost.TabIndex = 4; + textBoxCost.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + textBoxCost.Location = new Point(165, 105); + textBoxCost.Name = "textBoxCost"; + textBoxCost.Size = new Size(245, 39); + textBoxCost.TabIndex = 4; // // label2 // - this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(26, 108); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(76, 32); - this.label2.TabIndex = 3; - this.label2.Text = "Цена:"; + label2.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + label2.AutoSize = true; + label2.Location = new Point(26, 108); + label2.Name = "label2"; + label2.Size = new Size(76, 32); + label2.TabIndex = 3; + label2.Text = "Цена:"; // - // button2 + // ButtonCancel // - this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.button2.Location = new System.Drawing.Point(511, 208); - this.button2.Name = "button2"; - this.button2.Size = new System.Drawing.Size(150, 46); - this.button2.TabIndex = 5; - this.button2.Text = "Отмена"; - this.button2.UseVisualStyleBackColor = true; - this.button2.Click += new System.EventHandler(this.ButtonCancel_Click); + ButtonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + ButtonCancel.Location = new Point(511, 208); + ButtonCancel.Name = "ButtonCancel"; + ButtonCancel.Size = new Size(150, 46); + ButtonCancel.TabIndex = 5; + ButtonCancel.Text = "Отмена"; + ButtonCancel.UseVisualStyleBackColor = true; + ButtonCancel.Click += ButtonCancel_Click; // // FormWorkpiece // - this.AutoScaleDimensions = new System.Drawing.SizeF(13F, 32F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(686, 280); - this.Controls.Add(this.button2); - this.Controls.Add(this.textBoxCost); - this.Controls.Add(this.label2); - this.Controls.Add(this.textBoxName); - this.Controls.Add(this.label1); - this.Controls.Add(this.button1); - this.Name = "FormWorkpiece"; - this.Text = "Заготовка"; - this.Load += new System.EventHandler(this.FormComponent_Load); - this.ResumeLayout(false); - this.PerformLayout(); - + AutoScaleDimensions = new SizeF(13F, 32F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(686, 280); + Controls.Add(ButtonCancel); + Controls.Add(textBoxCost); + Controls.Add(label2); + Controls.Add(textBoxName); + Controls.Add(label1); + Controls.Add(ButtonSave); + Name = "FormWorkpiece"; + Text = "Заготовка"; + Load += FormComponent_Load; + ResumeLayout(false); + PerformLayout(); } #endregion - private Button button1; + private Button ButtonSave; private Label label1; private TextBox textBoxName; private TextBox textBoxCost; private Label label2; - private Button button2; + private Button ButtonCancel; } } \ No newline at end of file diff --git a/FurnitureAssembly/FurnitureAssembly/FormWorkpiece.resx b/FurnitureAssembly/FurnitureAssembly/FormWorkpiece.resx index f298a7b..af32865 100644 --- a/FurnitureAssembly/FurnitureAssembly/FormWorkpiece.resx +++ b/FurnitureAssembly/FurnitureAssembly/FormWorkpiece.resx @@ -1,4 +1,64 @@ - + + + diff --git a/FurnitureAssembly/FurnitureAssembly/FurnitureAssemblyView.csproj b/FurnitureAssembly/FurnitureAssembly/FurnitureAssemblyView.csproj index bf7b9ef..c426ea7 100644 --- a/FurnitureAssembly/FurnitureAssembly/FurnitureAssemblyView.csproj +++ b/FurnitureAssembly/FurnitureAssembly/FurnitureAssemblyView.csproj @@ -10,6 +10,7 @@ + @@ -18,6 +19,12 @@ + + + Never + + + all @@ -27,14 +34,13 @@ + - - \ No newline at end of file diff --git a/FurnitureAssembly/FurnitureAssembly/Program.cs b/FurnitureAssembly/FurnitureAssembly/Program.cs index 9d25fa9..1ac7636 100644 --- a/FurnitureAssembly/FurnitureAssembly/Program.cs +++ b/FurnitureAssembly/FurnitureAssembly/Program.cs @@ -1,5 +1,6 @@ -using FurnitureAssemblyBusinessLogic; -using FurnitureAssemblyBusinessLogic.BusinessLogics; +using FurnitureAssemblyBusinessLogic.BusinessLogic; +using FurnitureAssemblyBusinessLogic.OfficePackage.Implements; +using FurnitureAssemblyBusinessLogic.OfficePackage; using FurnitureAssemblyContracts.BusinessLogicsContracts; using FurnitureAssemblyContracts.StoragesContracts; using FurnitureAssemblyDatabaseImplement.Implements; @@ -44,6 +45,11 @@ namespace FurnitureAssembly services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); + + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); @@ -52,6 +58,9 @@ namespace FurnitureAssembly services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); } } } \ No newline at end of file diff --git a/FurnitureAssembly/FurnitureAssembly/ReportOrders.rdlc b/FurnitureAssembly/FurnitureAssembly/ReportOrders.rdlc new file mode 100644 index 0000000..29dd1f4 --- /dev/null +++ b/FurnitureAssembly/FurnitureAssembly/ReportOrders.rdlc @@ -0,0 +1,600 @@ + + + 0 + + + + System.Data.DataSet + /* Local Connection */ + + 10791c83-cee8-4a38-bbd0-245fc17cefb3 + + + + + + FurnitureAssemblyContractsViewModels + /* Local Query */ + + + + Id + System.Int32 + + + DateCreate + System.DateTime + + + FurnitureName + System.String + + + Sum + System.Decimal + + + OrderStatus + FurnitureAssemblyDataModels.OrderStatus + + + + FurnitureAssemblyContracts.ViewModels + ReportOrdersViewModel + FurnitureAssemblyContracts.ViewModels.ReportOrdersViewModel, ConfectioneryContracts, 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 + + + 3.02917cm + + + 2.87042cm + + + + + 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!FurnitureName.Value + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!OrderStatus.Value + + + 2pt + 2pt + 2pt + 2pt + + + true + + + + + + true + true + + + + + =Fields!Sum.Value + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + + + + + + + + + + + + + + After + + + + + + + DataSetOrders + 2.48391cm + 0.55245cm + 1.2cm + 19.84713cm + 2 + + + + + + true + true + + + + + Итого: + + + + + + + 4cm + 15.39958cm + 0.6cm + 2.5cm + 3 + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + =Sum(Fields!Sum.Value, "DataSetOrders") + + + + + + + 4cm + 17.89958cm + 0.6cm + 2.5cm + 4 + + + 2pt + 2pt + 2pt + 2pt + + + + 5.72875cm +