diff --git a/LawFirm/AbstractLawFirmBusinessLogic/AbstractLawFirmBusinessLogic.csproj b/LawFirm/AbstractLawFirmBusinessLogic/AbstractLawFirmBusinessLogic.csproj index 6970afc..e013934 100644 --- a/LawFirm/AbstractLawFirmBusinessLogic/AbstractLawFirmBusinessLogic.csproj +++ b/LawFirm/AbstractLawFirmBusinessLogic/AbstractLawFirmBusinessLogic.csproj @@ -9,6 +9,7 @@ + diff --git a/LawFirm/AbstractLawFirmBusinessLogic/OfficePackage/AbstractSaveToExcel.cs b/LawFirm/AbstractLawFirmBusinessLogic/OfficePackage/AbstractSaveToExcel.cs index bf4cfc5..a93401a 100644 --- a/LawFirm/AbstractLawFirmBusinessLogic/OfficePackage/AbstractSaveToExcel.cs +++ b/LawFirm/AbstractLawFirmBusinessLogic/OfficePackage/AbstractSaveToExcel.cs @@ -30,7 +30,7 @@ namespace AbstractLawFirmBusinessLogic.OfficePackage CellToName = "C1" }); uint rowIndex = 2; - foreach (var dc in info.ProductComponents) + foreach (var dc in info.DocumentComponents) { InsertCellInWorksheet(new ExcelCellParameters { diff --git a/LawFirm/AbstractLawFirmBusinessLogic/OfficePackage/AbstractSaveToPdf.cs b/LawFirm/AbstractLawFirmBusinessLogic/OfficePackage/AbstractSaveToPdf.cs new file mode 100644 index 0000000..e80391f --- /dev/null +++ b/LawFirm/AbstractLawFirmBusinessLogic/OfficePackage/AbstractSaveToPdf.cs @@ -0,0 +1,81 @@ +using AbstractLawFirmBusinessLogic.OfficePackage.HelperEnums; +using AbstractLawFirmBusinessLogic.OfficePackage.HelperModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AbstractLawFirmBusinessLogic.OfficePackage +{ + public abstract class AbstractSaveToPdf + { + public void CreateDoc(PdfInfo info) + { + CreatePdf(info); + CreateParagraph(new PdfParagraph + { + Text = info.Title, + Style = + "NormalTitle", + ParagraphAlignment = PdfParagraphAlignmentType.Center + }); + CreateParagraph(new PdfParagraph + { + Text = $"с{ info.DateFrom.ToShortDateString() } по { info.DateTo.ToShortDateString() }", Style= "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Center + }); + CreateTable(new List { "2cm", "3cm", "6cm", "3cm" }); + CreateRow(new PdfRowParameters + { + Texts = new List { "Номер", "Дата заказа", "Изделие", "Сумма" }, + Style = "NormalTitle", + ParagraphAlignment = PdfParagraphAlignmentType.Center + }); + foreach (var order in info.Orders) + { + CreateRow(new PdfRowParameters + { + Texts = new List { order.Id.ToString(), +order.DateCreate.ToShortDateString(), order.ProductName, order.Sum.ToString() }, + Style = "Normal", + ParagraphAlignment = PdfParagraphAlignmentType.Left + }); + } + CreateParagraph(new PdfParagraph + { + Text = $"Итого: {info.Orders.Sum(x => x.Sum)}\t", + Style = "Normal", + ParagraphAlignment = + PdfParagraphAlignmentType.Rigth + }); + SavePdf(info); + } + /// + /// Создание doc-файла + /// + /// + protected abstract void CreatePdf(PdfInfo info); + /// + /// Создание параграфа с текстом + /// + /// + /// + protected abstract void CreateParagraph(PdfParagraph paragraph); + /// + /// Создание таблицы + /// + /// + /// + protected abstract void CreateTable(List columns); + /// + /// Создание и заполнение строки + /// + /// + protected abstract void CreateRow(PdfRowParameters rowParameters); + /// + /// Сохранение файла + /// + /// + protected abstract void SavePdf(PdfInfo info); + } +} diff --git a/LawFirm/AbstractLawFirmBusinessLogic/OfficePackage/HelperEnums/PdfParagraphAlignmentType.cs b/LawFirm/AbstractLawFirmBusinessLogic/OfficePackage/HelperEnums/PdfParagraphAlignmentType.cs new file mode 100644 index 0000000..d527761 --- /dev/null +++ b/LawFirm/AbstractLawFirmBusinessLogic/OfficePackage/HelperEnums/PdfParagraphAlignmentType.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AbstractLawFirmBusinessLogic.OfficePackage.HelperEnums +{ + public enum PdfParagraphAlignmentType + { + Center, + Left, + + Rigth + } + +} diff --git a/LawFirm/AbstractLawFirmBusinessLogic/OfficePackage/HelperModels/ExelInfo.cs b/LawFirm/AbstractLawFirmBusinessLogic/OfficePackage/HelperModels/ExelInfo.cs index e21a81c..9e835f9 100644 --- a/LawFirm/AbstractLawFirmBusinessLogic/OfficePackage/HelperModels/ExelInfo.cs +++ b/LawFirm/AbstractLawFirmBusinessLogic/OfficePackage/HelperModels/ExelInfo.cs @@ -11,7 +11,7 @@ namespace AbstractLawFirmBusinessLogic.OfficePackage.HelperModels { public string FileName { get; set; } = string.Empty; public string Title { get; set; } = string.Empty; - public List ProductComponents + public List DocumentComponents { get; set; diff --git a/LawFirm/AbstractLawFirmBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs b/LawFirm/AbstractLawFirmBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs new file mode 100644 index 0000000..0d16f6f --- /dev/null +++ b/LawFirm/AbstractLawFirmBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs @@ -0,0 +1,18 @@ +using AbstractLawFirmContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AbstractLawFirmBusinessLogic.OfficePackage.HelperModels +{ + public class PdfInfo + { + public string FileName { get; set; } = string.Empty; + public string Title { get; set; } = string.Empty; + public DateTime DateFrom { get; set; } + public DateTime DateTo { get; set; } + public List Orders { get; set; } = new(); + } +} diff --git a/LawFirm/AbstractLawFirmBusinessLogic/OfficePackage/HelperModels/PdfParagraph.cs b/LawFirm/AbstractLawFirmBusinessLogic/OfficePackage/HelperModels/PdfParagraph.cs new file mode 100644 index 0000000..85c57dd --- /dev/null +++ b/LawFirm/AbstractLawFirmBusinessLogic/OfficePackage/HelperModels/PdfParagraph.cs @@ -0,0 +1,16 @@ +using AbstractLawFirmBusinessLogic.OfficePackage.HelperEnums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AbstractLawFirmBusinessLogic.OfficePackage.HelperModels +{ + public class PdfParagraph + { + public string Text { get; set; } = string.Empty; + public string Style { get; set; } = string.Empty; + public PdfParagraphAlignmentType ParagraphAlignment { get; set; } + } +} diff --git a/LawFirm/AbstractLawFirmBusinessLogic/OfficePackage/HelperModels/PdfRowParameters.cs b/LawFirm/AbstractLawFirmBusinessLogic/OfficePackage/HelperModels/PdfRowParameters.cs new file mode 100644 index 0000000..0f76c70 --- /dev/null +++ b/LawFirm/AbstractLawFirmBusinessLogic/OfficePackage/HelperModels/PdfRowParameters.cs @@ -0,0 +1,17 @@ +using AbstractLawFirmBusinessLogic.OfficePackage.HelperEnums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AbstractLawFirmBusinessLogic.OfficePackage.HelperModels +{ + public class PdfRowParameters + { + public List Texts { get; set; } = new(); + public string Style { get; set; } = string.Empty; + public PdfParagraphAlignmentType ParagraphAlignment { get; set; } + } + +} diff --git a/LawFirm/AbstractLawFirmBusinessLogic/OfficePackage/Implements/SaveToPdf.cs b/LawFirm/AbstractLawFirmBusinessLogic/OfficePackage/Implements/SaveToPdf.cs new file mode 100644 index 0000000..efe7ab4 --- /dev/null +++ b/LawFirm/AbstractLawFirmBusinessLogic/OfficePackage/Implements/SaveToPdf.cs @@ -0,0 +1,106 @@ +using AbstractLawFirmBusinessLogic.OfficePackage.HelperEnums; +using AbstractLawFirmBusinessLogic.OfficePackage.HelperModels; +using MigraDoc.DocumentObjectModel; +using MigraDoc.DocumentObjectModel.Tables; +using MigraDoc.Rendering; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AbstractLawFirmBusinessLogic.OfficePackage.Implements +{ + public class SaveToPdf : AbstractSaveToPdf + { + private Document? _document; + private Section? _section; + private Table? _table; + private static ParagraphAlignment + GetParagraphAlignment(PdfParagraphAlignmentType type) + { + return type switch + { + PdfParagraphAlignmentType.Center => ParagraphAlignment.Center, + PdfParagraphAlignmentType.Left => ParagraphAlignment.Left, + PdfParagraphAlignmentType.Rigth => ParagraphAlignment.Right, + _ => ParagraphAlignment.Justify, + }; + } + /// + /// Создание стилей для документа + /// + /// + private static void DefineStyles(Document document) + { + var style = document.Styles["Normal"]; + style.Font.Name = "Times New Roman"; + style.Font.Size = 14; + style = document.Styles.AddStyle("NormalTitle", "Normal"); + style.Font.Bold = true; + } + protected override void CreatePdf(PdfInfo info) + { + _document = new Document(); + DefineStyles(_document); + _section = _document.AddSection(); + } + protected override void CreateParagraph(PdfParagraph pdfParagraph) + { + if (_section == null) + { + return; + } + var paragraph = _section.AddParagraph(pdfParagraph.Text); + paragraph.Format.SpaceAfter = "1cm"; + paragraph.Format.Alignment = + GetParagraphAlignment(pdfParagraph.ParagraphAlignment); + paragraph.Style = pdfParagraph.Style; + } + protected override void CreateTable(List columns) + { + if (_document == null) + { + return; + } + _table = _document.LastSection.AddTable(); + foreach (var elem in columns) + { + _table.AddColumn(elem); + } + } + protected override void CreateRow(PdfRowParameters rowParameters) + { + if (_table == null) + { + return; + } + var row = _table.AddRow(); + for (int i = 0; i < rowParameters.Texts.Count; ++i) + { + row.Cells[i].AddParagraph(rowParameters.Texts[i]); + if (!string.IsNullOrEmpty(rowParameters.Style)) + { + row.Cells[i].Style = rowParameters.Style; + } + Unit borderWidth = 0.5; + row.Cells[i].Borders.Left.Width = borderWidth; + row.Cells[i].Borders.Right.Width = borderWidth; + row.Cells[i].Borders.Top.Width = borderWidth; + row.Cells[i].Borders.Bottom.Width = borderWidth; + row.Cells[i].Format.Alignment = + GetParagraphAlignment(rowParameters.ParagraphAlignment); + row.Cells[i].VerticalAlignment = VerticalAlignment.Center; + } + } + protected override void SavePdf(PdfInfo info) + { + var renderer = new PdfDocumentRenderer(true) + { + Document = _document + }; + renderer.RenderDocument(); + renderer.PdfDocument.Save(info.FileName); + } + } +} diff --git a/LawFirm/AbstractLawFirmBusinessLogic/ReportLogic.cs b/LawFirm/AbstractLawFirmBusinessLogic/ReportLogic.cs new file mode 100644 index 0000000..14a41a4 --- /dev/null +++ b/LawFirm/AbstractLawFirmBusinessLogic/ReportLogic.cs @@ -0,0 +1,130 @@ +using AbstractLawFirmBusinessLogic.OfficePackage.HelperModels; +using AbstractLawFirmBusinessLogic.OfficePackage; +using AbstractLawFirmContracts.BindingModels; +using AbstractLawFirmContracts.BusinessLogicsContracts; +using AbstractLawFirmContracts.SearchModels; +using AbstractLawFirmContracts.StoragesContracts; +using AbstractLawFirmContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AbstractLawFirmBusinessLogic +{ + public class ReportLogic : IReportLogic + { + private readonly IComponentStorage _componentStorage; + private readonly IDocumentStorage _documentStorage; + private readonly IOrderStorage _orderStorage; + private readonly AbstractSaveToExcel _saveToExcel; + private readonly AbstractSaveToWord _saveToWord; + private readonly AbstractSaveToPdf _saveToPdf; + public ReportLogic(IDocumentStorage documentStorage, IComponentStorage + componentStorage, IOrderStorage orderStorage, + AbstractSaveToExcel saveToExcel, AbstractSaveToWord saveToWord, + AbstractSaveToPdf saveToPdf) + { + _documentStorage = documentStorage; + _componentStorage = componentStorage; + _orderStorage = orderStorage; + _saveToExcel = saveToExcel; + _saveToWord = saveToWord; + _saveToPdf = saveToPdf; + } + /// + /// Получение списка компонент с указанием, в каких изделиях используются + /// + /// + public List GetDocumentComponent() + { + var components = _componentStorage.GetFullList(); + var documents = _documentStorage.GetFullList(); + var list = new List(); + foreach (var component in components) + { + var record = new ReportDocumentComponentViewModel + { + ComponentName = component.ComponentName, + Document = new List>(), + TotalCount = 0 + }; + foreach (var document in documents) + { + if (document.DocumentComponents.ContainsKey(component.Id)) + { + record.Document.Add(new Tuple(document.DocumentName, document.DocumentComponents[component.Id].Item2)); + record.TotalCount += document.DocumentComponents[component.Id].Item2; + } + } + list.Add(record); + } + return list; + } + /// + /// Получение списка заказов за определенный период + /// + /// + /// + public List GetOrders(ReportBindingModel model) + { + return _orderStorage.GetFilteredList(new OrderSearchModel + { + DateFrom + = model.DateFrom, + DateTo = model.DateTo + }) + .Select(x => new ReportOrdersViewModel + { + Id = x.Id, + DateCreate = x.DateCreate, + ProductName = x.DocumentName, + Sum = x.Sum + }) + .ToList(); + } + /// + /// Сохранение компонент в файл-Word + /// + /// + public void SaveComponentsToWordFile(ReportBindingModel model) + { + _saveToWord.CreateDoc(new WordInfo + { + FileName = model.FileName, + Title = "Список компонент", + Components = _componentStorage.GetFullList() + }); + } + /// + /// Сохранение компонент с указаеним продуктов в файл-Excel + /// + /// + public void SaveDocumentComponentToExcelFile(ReportBindingModel model) + { + _saveToExcel.CreateReport(new ExcelInfo + { + FileName = model.FileName, + Title = "Список компонент", + DocumentComponents = GetDocumentComponent() + }); + } + /// + /// Сохранение заказов в файл-Pdf + /// + /// + public void SaveOrdersToPdfFile(ReportBindingModel model) + { + _saveToPdf.CreateDoc(new PdfInfo + { + FileName = model.FileName, + Title = "Список заказов", + DateFrom = model.DateFrom!.Value, + DateTo = model.DateTo!.Value, + Orders = GetOrders(model) + }); + } + } + +} diff --git a/LawFirm/AbstractLawFirmContracts/AbstractLawFirmContracts/SearchModels/OrderSearchModel.cs b/LawFirm/AbstractLawFirmContracts/AbstractLawFirmContracts/SearchModels/OrderSearchModel.cs index d568495..02604d4 100644 --- a/LawFirm/AbstractLawFirmContracts/AbstractLawFirmContracts/SearchModels/OrderSearchModel.cs +++ b/LawFirm/AbstractLawFirmContracts/AbstractLawFirmContracts/SearchModels/OrderSearchModel.cs @@ -9,5 +9,7 @@ namespace AbstractLawFirmContracts.SearchModels public class OrderSearchModel { public int? Id { get; set; } + public DateTime? DateFrom { get; set; } + public DateTime? DateTo { get; set; } } } diff --git a/LawFirm/LawFirmView/FormMain.cs b/LawFirm/LawFirmView/FormMain.cs index 134665b..1fc94aa 100644 --- a/LawFirm/LawFirmView/FormMain.cs +++ b/LawFirm/LawFirmView/FormMain.cs @@ -126,7 +126,7 @@ namespace LawFirmView catch (Exception ex) { _logger.LogError(ex, "Ошибка отметки о готовности заказа"); - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } diff --git a/LawFirm/LawFirmView/FormMain.designer.cs b/LawFirm/LawFirmView/FormMain.designer.cs index 6d9d80f..c08ab72 100644 --- a/LawFirm/LawFirmView/FormMain.designer.cs +++ b/LawFirm/LawFirmView/FormMain.designer.cs @@ -28,134 +28,169 @@ /// private void InitializeComponent() { - this.menuStrip1 = new System.Windows.Forms.MenuStrip(); - this.toolStripMenuItemCatalogs = 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(); + toolStripMenuItemCatalogs = 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(); + отчётыToolStripMenuItem = new ToolStripMenuItem(); + списокКомпонентовToolStripMenuItem = new ToolStripMenuItem(); + компонентыПоИзделиямToolStripMenuItem = new ToolStripMenuItem(); + списокЗаказовToolStripMenuItem = new ToolStripMenuItem(); + menuStrip1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + SuspendLayout(); // // menuStrip1 // - this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.toolStripMenuItemCatalogs}); - this.menuStrip1.Location = new System.Drawing.Point(0, 0); - this.menuStrip1.Name = "menuStrip1"; - this.menuStrip1.Size = new System.Drawing.Size(910, 24); - this.menuStrip1.TabIndex = 0; - this.menuStrip1.Text = "Справочники"; + menuStrip1.ImageScalingSize = new Size(20, 20); + menuStrip1.Items.AddRange(new ToolStripItem[] { toolStripMenuItemCatalogs, отчётыToolStripMenuItem }); + menuStrip1.Location = new Point(0, 0); + menuStrip1.Name = "menuStrip1"; + menuStrip1.Padding = new Padding(7, 3, 0, 3); + menuStrip1.Size = new Size(1040, 30); + menuStrip1.TabIndex = 0; + menuStrip1.Text = "Справочники"; // // toolStripMenuItemCatalogs // - this.toolStripMenuItemCatalogs.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.компонентыToolStripMenuItem, - this.пакетыДокументовToolStripMenuItem}); - this.toolStripMenuItemCatalogs.Name = "toolStripMenuItemCatalogs"; - this.toolStripMenuItemCatalogs.Size = new System.Drawing.Size(94, 20); - this.toolStripMenuItemCatalogs.Text = "Справочники"; + toolStripMenuItemCatalogs.DropDownItems.AddRange(new ToolStripItem[] { компонентыToolStripMenuItem, пакетыДокументовToolStripMenuItem }); + toolStripMenuItemCatalogs.Name = "toolStripMenuItemCatalogs"; + toolStripMenuItemCatalogs.Size = new Size(117, 24); + toolStripMenuItemCatalogs.Text = "Справочники"; // // компонентыToolStripMenuItem // - this.компонентыToolStripMenuItem.Name = "компонентыToolStripMenuItem"; - this.компонентыToolStripMenuItem.Size = new System.Drawing.Size(183, 22); - this.компонентыToolStripMenuItem.Text = "Компоненты"; - this.компонентыToolStripMenuItem.Click += new System.EventHandler(this.компонентыToolStripMenuItem_Click); + компонентыToolStripMenuItem.Name = "компонентыToolStripMenuItem"; + компонентыToolStripMenuItem.Size = new Size(229, 26); + компонентыToolStripMenuItem.Text = "Компоненты"; + компонентыToolStripMenuItem.Click += компонентыToolStripMenuItem_Click; // // пакетыДокументовToolStripMenuItem // - this.пакетыДокументовToolStripMenuItem.Name = "пакетыДокументовToolStripMenuItem"; - this.пакетыДокументовToolStripMenuItem.Size = new System.Drawing.Size(183, 22); - this.пакетыДокументовToolStripMenuItem.Text = "Пакеты документов"; - this.пакетыДокументовToolStripMenuItem.Click += new System.EventHandler(this.пакетыДокументовToolStripMenuItem_Click); + пакетыДокументовToolStripMenuItem.Name = "пакетыДокументовToolStripMenuItem"; + пакетыДокументовToolStripMenuItem.Size = new Size(229, 26); + пакетыДокументовToolStripMenuItem.Text = "Пакеты документов"; + пакетыДокументовToolStripMenuItem.Click += пакетыДокументовToolStripMenuItem_Click; // // dataGridView // - this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; - this.dataGridView.Location = new System.Drawing.Point(0, 27); - this.dataGridView.Name = "dataGridView"; - this.dataGridView.RowTemplate.Height = 25; - this.dataGridView.Size = new System.Drawing.Size(736, 411); - this.dataGridView.TabIndex = 1; + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Location = new Point(0, 36); + dataGridView.Margin = new Padding(3, 4, 3, 4); + dataGridView.Name = "dataGridView"; + dataGridView.RowHeadersWidth = 51; + dataGridView.RowTemplate.Height = 25; + dataGridView.Size = new Size(841, 548); + dataGridView.TabIndex = 1; // // buttonCreateOrder // - this.buttonCreateOrder.Location = new System.Drawing.Point(742, 39); - this.buttonCreateOrder.Name = "buttonCreateOrder"; - this.buttonCreateOrder.Size = new System.Drawing.Size(156, 26); - this.buttonCreateOrder.TabIndex = 2; - this.buttonCreateOrder.Text = "Создать заказ"; - this.buttonCreateOrder.UseVisualStyleBackColor = true; - this.buttonCreateOrder.Click += new System.EventHandler(this.buttonCreateOrder_Click); + buttonCreateOrder.Location = new Point(848, 52); + buttonCreateOrder.Margin = new Padding(3, 4, 3, 4); + buttonCreateOrder.Name = "buttonCreateOrder"; + buttonCreateOrder.Size = new Size(178, 35); + buttonCreateOrder.TabIndex = 2; + buttonCreateOrder.Text = "Создать заказ"; + buttonCreateOrder.UseVisualStyleBackColor = true; + buttonCreateOrder.Click += buttonCreateOrder_Click; // // buttonTakeOrderInWork // - this.buttonTakeOrderInWork.Location = new System.Drawing.Point(742, 71); - this.buttonTakeOrderInWork.Name = "buttonTakeOrderInWork"; - this.buttonTakeOrderInWork.Size = new System.Drawing.Size(156, 23); - this.buttonTakeOrderInWork.TabIndex = 3; - this.buttonTakeOrderInWork.Text = "Отдать на выполнение"; - this.buttonTakeOrderInWork.UseVisualStyleBackColor = true; - this.buttonTakeOrderInWork.Click += new System.EventHandler(this.buttonTakeOrderInWork_Click); + buttonTakeOrderInWork.Location = new Point(848, 95); + buttonTakeOrderInWork.Margin = new Padding(3, 4, 3, 4); + buttonTakeOrderInWork.Name = "buttonTakeOrderInWork"; + buttonTakeOrderInWork.Size = new Size(178, 31); + buttonTakeOrderInWork.TabIndex = 3; + buttonTakeOrderInWork.Text = "Отдать на выполнение"; + buttonTakeOrderInWork.UseVisualStyleBackColor = true; + buttonTakeOrderInWork.Click += buttonTakeOrderInWork_Click; // // buttonOrderReady // - this.buttonOrderReady.Location = new System.Drawing.Point(742, 100); - this.buttonOrderReady.Name = "buttonOrderReady"; - this.buttonOrderReady.Size = new System.Drawing.Size(156, 23); - this.buttonOrderReady.TabIndex = 4; - this.buttonOrderReady.Text = "Заказ готов"; - this.buttonOrderReady.UseVisualStyleBackColor = true; - this.buttonOrderReady.Click += new System.EventHandler(this.buttonOrderReady_Click); + buttonOrderReady.Location = new Point(848, 133); + buttonOrderReady.Margin = new Padding(3, 4, 3, 4); + buttonOrderReady.Name = "buttonOrderReady"; + buttonOrderReady.Size = new Size(178, 31); + buttonOrderReady.TabIndex = 4; + buttonOrderReady.Text = "Заказ готов"; + buttonOrderReady.UseVisualStyleBackColor = true; + buttonOrderReady.Click += buttonOrderReady_Click; // // buttonIssuedOrder // - this.buttonIssuedOrder.Location = new System.Drawing.Point(742, 129); - this.buttonIssuedOrder.Name = "buttonIssuedOrder"; - this.buttonIssuedOrder.Size = new System.Drawing.Size(156, 23); - this.buttonIssuedOrder.TabIndex = 5; - this.buttonIssuedOrder.Text = "Заказ выдан"; - this.buttonIssuedOrder.UseVisualStyleBackColor = true; - this.buttonIssuedOrder.Click += new System.EventHandler(this.buttonIssuedOrder_Click); + buttonIssuedOrder.Location = new Point(848, 172); + buttonIssuedOrder.Margin = new Padding(3, 4, 3, 4); + buttonIssuedOrder.Name = "buttonIssuedOrder"; + buttonIssuedOrder.Size = new Size(178, 31); + buttonIssuedOrder.TabIndex = 5; + buttonIssuedOrder.Text = "Заказ выдан"; + buttonIssuedOrder.UseVisualStyleBackColor = true; + buttonIssuedOrder.Click += buttonIssuedOrder_Click; // // buttonRef // - this.buttonRef.Location = new System.Drawing.Point(742, 158); - this.buttonRef.Name = "buttonRef"; - this.buttonRef.Size = new System.Drawing.Size(156, 23); - this.buttonRef.TabIndex = 6; - this.buttonRef.Text = "Обновить список"; - this.buttonRef.UseVisualStyleBackColor = true; - this.buttonRef.Click += new System.EventHandler(this.buttonRef_Click); + buttonRef.Location = new Point(848, 211); + buttonRef.Margin = new Padding(3, 4, 3, 4); + buttonRef.Name = "buttonRef"; + buttonRef.Size = new Size(178, 31); + buttonRef.TabIndex = 6; + buttonRef.Text = "Обновить список"; + buttonRef.UseVisualStyleBackColor = true; + buttonRef.Click += buttonRef_Click; + // + // отчётыToolStripMenuItem + // + отчётыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { списокКомпонентовToolStripMenuItem, компонентыПоИзделиямToolStripMenuItem, списокЗаказовToolStripMenuItem }); + отчётыToolStripMenuItem.Name = "отчётыToolStripMenuItem"; + отчётыToolStripMenuItem.Size = new Size(73, 24); + отчётыToolStripMenuItem.Text = "Отчёты"; + // + // списокКомпонентовToolStripMenuItem + // + списокКомпонентовToolStripMenuItem.Name = "списокКомпонентовToolStripMenuItem"; + списокКомпонентовToolStripMenuItem.Size = new Size(276, 26); + списокКомпонентовToolStripMenuItem.Text = "Список компонентов"; + // + // компонентыПоИзделиямToolStripMenuItem + // + компонентыПоИзделиямToolStripMenuItem.Name = "компонентыПоИзделиямToolStripMenuItem"; + компонентыПоИзделиямToolStripMenuItem.Size = new Size(276, 26); + компонентыПоИзделиямToolStripMenuItem.Text = "Компоненты по изделиям"; + // + // списокЗаказовToolStripMenuItem + // + списокЗаказовToolStripMenuItem.Name = "списокЗаказовToolStripMenuItem"; + списокЗаказовToolStripMenuItem.Size = new Size(276, 26); + списокЗаказовToolStripMenuItem.Text = "Список заказов"; // // FormMain // - this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(910, 477); - 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 = "FormMain"; - 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(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(1040, 636); + Controls.Add(buttonRef); + Controls.Add(buttonIssuedOrder); + Controls.Add(buttonOrderReady); + Controls.Add(buttonTakeOrderInWork); + Controls.Add(buttonCreateOrder); + Controls.Add(dataGridView); + Controls.Add(menuStrip1); + MainMenuStrip = menuStrip1; + Margin = new Padding(3, 4, 3, 4); + Name = "FormMain"; + Text = "FormMain"; + Load += FormMain_Load; + menuStrip1.ResumeLayout(false); + menuStrip1.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + PerformLayout(); } #endregion @@ -170,5 +205,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/LawFirm/LawFirmView/FormMain.resx b/LawFirm/LawFirmView/FormMain.resx index 05252e7..a39c409 100644 --- a/LawFirm/LawFirmView/FormMain.resx +++ b/LawFirm/LawFirmView/FormMain.resx @@ -1,4 +1,64 @@ - + + + diff --git a/LawFirm/LawFirmView/FormReportDocumentComponents.Designer.cs b/LawFirm/LawFirmView/FormReportDocumentComponents.Designer.cs new file mode 100644 index 0000000..94acf3d --- /dev/null +++ b/LawFirm/LawFirmView/FormReportDocumentComponents.Designer.cs @@ -0,0 +1,101 @@ +namespace LawFirmView +{ + partial class FormReportDocumentComponents + { + /// + /// 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(); + Column1 = new DataGridViewTextBoxColumn(); + Column2 = new DataGridViewTextBoxColumn(); + Column3 = new DataGridViewTextBoxColumn(); + button1 = new Button(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + SuspendLayout(); + // + // dataGridView + // + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Columns.AddRange(new DataGridViewColumn[] { Column1, Column2, Column3 }); + dataGridView.Location = new Point(12, 47); + dataGridView.Name = "dataGridView"; + dataGridView.RowHeadersWidth = 51; + dataGridView.RowTemplate.Height = 29; + dataGridView.Size = new Size(430, 542); + dataGridView.TabIndex = 0; + // + // Column1 + // + Column1.HeaderText = "Компонент"; + Column1.MinimumWidth = 6; + Column1.Name = "Column1"; + Column1.Width = 125; + // + // Column2 + // + Column2.HeaderText = "Изделие"; + Column2.MinimumWidth = 6; + Column2.Name = "Column2"; + Column2.Width = 125; + // + // Column3 + // + Column3.HeaderText = "Количество"; + Column3.MinimumWidth = 6; + Column3.Name = "Column3"; + Column3.Width = 125; + // + // button1 + // + button1.Location = new Point(137, 12); + button1.Name = "button1"; + button1.Size = new Size(162, 29); + button1.TabIndex = 1; + button1.Text = "Сохранить exel"; + button1.UseVisualStyleBackColor = true; + // + // FormReportDocumentComponents + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(449, 601); + Controls.Add(button1); + Controls.Add(dataGridView); + Name = "FormReportDocumentComponents"; + Text = "FormReportDocumentComponents"; + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + } + + #endregion + + private DataGridView dataGridView; + private Button button1; + private DataGridViewTextBoxColumn Column1; + private DataGridViewTextBoxColumn Column2; + private DataGridViewTextBoxColumn Column3; + } +} \ No newline at end of file diff --git a/LawFirm/LawFirmView/FormReportDocumentComponents.cs b/LawFirm/LawFirmView/FormReportDocumentComponents.cs new file mode 100644 index 0000000..0103bbd --- /dev/null +++ b/LawFirm/LawFirmView/FormReportDocumentComponents.cs @@ -0,0 +1,86 @@ +using AbstractLawFirmContracts.BindingModels; +using AbstractLawFirmContracts.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 LawFirmView +{ + public partial class FormReportDocumentComponents : Form + { + private readonly ILogger _logger; + private readonly IReportLogic _logic; + public FormReportDocumentComponents(ILogger + logger, IReportLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + } + private void FormReportDocumentComponents_Load(object sender, EventArgs e) + { + try + { + var dict = _logic.GetDocumentComponent(); + if (dict != null) + { + dataGridView.Rows.Clear(); + foreach (var elem in dict) + { + dataGridView.Rows.Add(new object[] { elem.ComponentName, "", "" }); + foreach (var listElem in elem.Document) + { + 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.SaveDocumentComponentToExcelFile(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/LawFirm/LawFirmView/FormReportDocumentComponents.resx b/LawFirm/LawFirmView/FormReportDocumentComponents.resx new file mode 100644 index 0000000..851920e --- /dev/null +++ b/LawFirm/LawFirmView/FormReportDocumentComponents.resx @@ -0,0 +1,138 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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/LawFirm/LawFirmView/LawFirmView.csproj b/LawFirm/LawFirmView/LawFirmView.csproj index 697d6b7..c2052cd 100644 --- a/LawFirm/LawFirmView/LawFirmView.csproj +++ b/LawFirm/LawFirmView/LawFirmView.csproj @@ -15,6 +15,7 @@ +