From 1bca64b238e38368f3c333087b70afe678b16577 Mon Sep 17 00:00:00 2001 From: grishazagidulin Date: Sun, 15 Dec 2024 22:19:14 +0400 Subject: [PATCH 1/5] =?UTF-8?q?=D0=9A=D0=BE=D0=BC=D0=BC=D0=B8=D1=82,=20?= =?UTF-8?q?=D0=BA=D0=BE=D1=82=D0=BE=D1=80=D0=BE=D0=B3=D0=BE=20=D0=BD=D0=B5?= =?UTF-8?q?=20=D0=B1=D1=83=D0=B4=D0=B5=D1=82=20=D0=B2=20=D1=84=D0=B8=D0=BD?= =?UTF-8?q?=D0=B0=D0=BB=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Workshop/Entities/Master.cs | 6 ++++++ Workshop/Entities/Material.cs | 4 ++++ Workshop/Entities/Product.cs | 6 ++++++ 3 files changed, 16 insertions(+) diff --git a/Workshop/Entities/Master.cs b/Workshop/Entities/Master.cs index e1d13fb..2d8d14c 100644 --- a/Workshop/Entities/Master.cs +++ b/Workshop/Entities/Master.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.ComponentModel; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -10,10 +11,15 @@ namespace Workshop.Entities; public class Master { public int Id { get; private set; } + [DisplayName("Имя")] public string Name { get; private set; } = string.Empty; + [DisplayName("Фамилия")] public string LastName { get; private set; } = string.Empty; + [DisplayName("Возраст")] public int Age { get; private set; } + [DisplayName("Должность")] public MasterPosition Position { get; private set; } + public string fullName => $"{Name} {LastName}"; public static Master CreateEntity(int id, string name, string lastName, int age, MasterPosition position) { diff --git a/Workshop/Entities/Material.cs b/Workshop/Entities/Material.cs index b67a045..c4c7dcc 100644 --- a/Workshop/Entities/Material.cs +++ b/Workshop/Entities/Material.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.ComponentModel; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -9,8 +10,11 @@ namespace Workshop.Entities; public class Material { public int Id { get; private set; } + [DisplayName("Название")] public string Name { get; private set; } = string.Empty; + [DisplayName("Количество на складе")] public int WarehouseAmount { get; private set; } + [DisplayName("Цена")] public double Price { get; private set; } public static Material CreateEntity(int id, string name, int warehouseAmount, double price) { diff --git a/Workshop/Entities/Product.cs b/Workshop/Entities/Product.cs index 2357be0..4f80692 100644 --- a/Workshop/Entities/Product.cs +++ b/Workshop/Entities/Product.cs @@ -1,14 +1,20 @@ using System; +using System.ComponentModel; using Workshop.Entities; using Workshop.Entities.Enums; public class Product { public int Id { get; private set; } + [DisplayName("Название")] public string Name { get; private set; } = string.Empty; + [DisplayName("Цена")] public double Price { get; private set; } + [DisplayName("Количество на складе")] public int WarehouseAmount { get; private set; } + [DisplayName("Категория")] public ProductCategory Category { get; private set; } + [DisplayName("Материалы")] public IEnumerable Materials { get; private set; } = []; public static Product CreateEntity(int id, string name, double price, int warehouseAmount, ProductCategory category, IEnumerable materials) -- 2.25.1 From 117c1df9889572a5999b4d237b9229a78f0da309 Mon Sep 17 00:00:00 2001 From: grishazagidulin Date: Mon, 16 Dec 2024 10:35:55 +0400 Subject: [PATCH 2/5] Lab4 alpha --- Workshop/Entities/Cheque.cs | 13 ++++++ Workshop/Entities/ChequeProduct.cs | 1 + Workshop/Entities/Master.cs | 2 +- Workshop/Entities/ProductCreate.cs | 9 ++++ Workshop/Forms/FormCheques.cs | 8 +++- Workshop/Forms/FormMasters.cs | 9 ++-- Workshop/Forms/FormMaterials.cs | 7 ++- Workshop/Forms/FormProductCreate.cs | 2 +- Workshop/Forms/FormProductCreatings.cs | 7 ++- Workshop/Forms/FormProducts.cs | 7 ++- Workshop/Program.cs | 4 +- Workshop/Reports/ChartReport.cs | 3 +- Workshop/Reports/TableReport.cs | 8 ++-- Workshop/Repositories/IChequeRepository.cs | 2 +- .../Implementations/ChequeRepository.cs | 44 +++++++++++++++---- .../ProductCreateRepository.cs | 21 +++++++-- .../Implementations/QueryBuilder.cs | 33 ++++++++++++++ 17 files changed, 147 insertions(+), 33 deletions(-) create mode 100644 Workshop/Repositories/Implementations/QueryBuilder.cs diff --git a/Workshop/Entities/Cheque.cs b/Workshop/Entities/Cheque.cs index 0ffaf91..02cf418 100644 --- a/Workshop/Entities/Cheque.cs +++ b/Workshop/Entities/Cheque.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.ComponentModel; using System.Diagnostics; using System.Linq; using System.Text; @@ -10,8 +11,13 @@ namespace Workshop.Entities; public class Cheque { public int Id { get; private set; } + [DisplayName("Дата")] public DateTime Date { get; private set; } + [DisplayName("Итоговая сумма")] public double Sum { get; private set; } + public string Product => ChequeProduct != null ? + string.Join(", ", ChequeProduct.Select(x => $"{x.ProductName} {x.Amount}")) : string.Empty; + [Browsable(false)] public IEnumerable ChequeProduct { get; private set; } = []; public static Cheque CreateOperation(int id, int sum, IEnumerable products) @@ -33,4 +39,11 @@ public class Cheque ChequeProduct = chequeProducts }; } + public void SetChequeProduct(IEnumerable chequeProducts) + { + if (chequeProducts != null && chequeProducts.Any()) + { + ChequeProduct = chequeProducts; + } + } } diff --git a/Workshop/Entities/ChequeProduct.cs b/Workshop/Entities/ChequeProduct.cs index 84389fb..596bbb2 100644 --- a/Workshop/Entities/ChequeProduct.cs +++ b/Workshop/Entities/ChequeProduct.cs @@ -10,6 +10,7 @@ public class ChequeProduct public int ProductId { get; private set; } public int ChequeId { get; private set; } public int Amount { get; private set; } + public string ProductName { get; private set; } = string.Empty; public static ChequeProduct CreateEntity(int productid, int chequeid, int amount) { return new ChequeProduct diff --git a/Workshop/Entities/Master.cs b/Workshop/Entities/Master.cs index 2d8d14c..23236ab 100644 --- a/Workshop/Entities/Master.cs +++ b/Workshop/Entities/Master.cs @@ -19,7 +19,7 @@ public class Master public int Age { get; private set; } [DisplayName("Должность")] public MasterPosition Position { get; private set; } - public string fullName => $"{Name} {LastName}"; + public string FullName => $"{Name} {LastName}"; public static Master CreateEntity(int id, string name, string lastName, int age, MasterPosition position) { diff --git a/Workshop/Entities/ProductCreate.cs b/Workshop/Entities/ProductCreate.cs index 26640f7..4c64b2d 100644 --- a/Workshop/Entities/ProductCreate.cs +++ b/Workshop/Entities/ProductCreate.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.ComponentModel; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -10,9 +11,17 @@ namespace Workshop.Entities; public class ProductCreate { public int Id { get; private set; } + [Browsable(false)] public int ProductId { get; private set; } + [Browsable(false)] public int MasterId { get; private set; } + [DisplayName("Дата создания")] public DateTime CreatingDate { get; private set; } + [DisplayName("Изделие")] + public string ProductName { get; private set; } = string.Empty; + [DisplayName("Сотрудник")] + public string MasterName { get; private set; } = string.Empty; + public static ProductCreate CreateOperation(int id, int productid, int masterid) { return new ProductCreate diff --git a/Workshop/Forms/FormCheques.cs b/Workshop/Forms/FormCheques.cs index 896302e..09f6f9e 100644 --- a/Workshop/Forms/FormCheques.cs +++ b/Workshop/Forms/FormCheques.cs @@ -50,6 +50,12 @@ namespace Workshop.Forms MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error); } } - private void LoadList() => dataGridProductCreatings.DataSource = _chequeRepository.ReadCheques(); + private void LoadList() + { + dataGridProductCreatings.DataSource = _chequeRepository.ReadCheques(); + dataGridProductCreatings.Columns["Id"].Visible = false; + //dataGridProductCreatings.Columns["ChequeProduct"].Visible = false; + dataGridProductCreatings.Columns["Date"].DefaultCellStyle.Format = "dd MMMM yyyy hh:mm"; + } } } diff --git a/Workshop/Forms/FormMasters.cs b/Workshop/Forms/FormMasters.cs index b07398e..dc0de05 100644 --- a/Workshop/Forms/FormMasters.cs +++ b/Workshop/Forms/FormMasters.cs @@ -102,8 +102,11 @@ namespace Workshop.Forms id = Convert.ToInt32(dataGridViewMasters.SelectedRows[0].Cells["Id"].Value); return true; } - private void LoadList() => dataGridViewMasters.DataSource = _masterRepository.ReadMasters(); - - + private void LoadList() + { + dataGridViewMasters.DataSource = _masterRepository.ReadMasters(); + dataGridViewMasters.Columns["Id"].Visible = false; + dataGridViewMasters.Columns["FullName"].Visible = false; + } } } diff --git a/Workshop/Forms/FormMaterials.cs b/Workshop/Forms/FormMaterials.cs index 42f5b5b..7efb450 100644 --- a/Workshop/Forms/FormMaterials.cs +++ b/Workshop/Forms/FormMaterials.cs @@ -101,7 +101,10 @@ namespace Workshop.Forms id = Convert.ToInt32(dataGridViewMaterials.SelectedRows[0].Cells["Id"].Value); return true; } - private void LoadList() => dataGridViewMaterials.DataSource = _materialRepository.ReadMaterials(); - + private void LoadList() + { + dataGridViewMaterials.DataSource = _materialRepository.ReadMaterials(); + dataGridViewMaterials.Columns["Id"].Visible = false; + } } } diff --git a/Workshop/Forms/FormProductCreate.cs b/Workshop/Forms/FormProductCreate.cs index 73f3e50..e6d595f 100644 --- a/Workshop/Forms/FormProductCreate.cs +++ b/Workshop/Forms/FormProductCreate.cs @@ -26,7 +26,7 @@ namespace Workshop.Forms comboBoxProduct.ValueMember = "Id"; comboBoxMaster.DataSource = masterRepository.ReadMasters(); - comboBoxMaster.DisplayMember = "LastName"; + comboBoxMaster.DisplayMember = "FullName"; comboBoxMaster.ValueMember = "Id"; } diff --git a/Workshop/Forms/FormProductCreatings.cs b/Workshop/Forms/FormProductCreatings.cs index 9f25875..37abef8 100644 --- a/Workshop/Forms/FormProductCreatings.cs +++ b/Workshop/Forms/FormProductCreatings.cs @@ -68,7 +68,12 @@ namespace Workshop.Forms MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error); } } - private void LoadList() => dataGridProductCreatings.DataSource = _productCreateRepository.ReadProductCreates(); + private void LoadList() + { + dataGridProductCreatings.DataSource = _productCreateRepository.ReadProductCreates(); + dataGridProductCreatings.Columns["Id"].Visible = false; + dataGridProductCreatings.Columns["CreatingDate"].DefaultCellStyle.Format = "dd MMMM yyyy hh:mm"; + } private bool TryGetIdentifierFromSelectedRow(out int id) { id = 0; diff --git a/Workshop/Forms/FormProducts.cs b/Workshop/Forms/FormProducts.cs index d53e9e9..e79d6cc 100644 --- a/Workshop/Forms/FormProducts.cs +++ b/Workshop/Forms/FormProducts.cs @@ -100,6 +100,11 @@ namespace Workshop.Forms id = Convert.ToInt32(dataGridViewProducts.SelectedRows[0].Cells["Id"].Value); return true; } - private void LoadList() => dataGridViewProducts.DataSource = _productRepository.ReadProducts(); + private void LoadList() + { + dataGridViewProducts.DataSource = _productRepository.ReadProducts(); + dataGridViewProducts.Columns["Id"].Visible = false; + dataGridViewProducts.Columns["Materials"].Visible = false; + } } } diff --git a/Workshop/Program.cs b/Workshop/Program.cs index f80a494..afbc268 100644 --- a/Workshop/Program.cs +++ b/Workshop/Program.cs @@ -10,9 +10,7 @@ namespace Workshop { internal static class Program { - //TODO: 1. Update . - //TODO: FormProduct - //TODO: materials + //TODO: chequeId productId TableReport, ChequeRepository, IChequeRepository /// /// The main entry point for the application. /// diff --git a/Workshop/Reports/ChartReport.cs b/Workshop/Reports/ChartReport.cs index d3dc085..8ecbacb 100644 --- a/Workshop/Reports/ChartReport.cs +++ b/Workshop/Reports/ChartReport.cs @@ -43,8 +43,7 @@ internal class ChartReport private List<(string Caption, double Value)> GetData(DateTime dateTimeStart, DateTime dateTimeEnd) { return _creatingRepository - .ReadProductCreates() - .Where(x => x.CreatingDate >= dateTimeStart && x.CreatingDate <= dateTimeEnd) + .ReadProductCreates(dateFrom: dateTimeStart, dateTo: dateTimeEnd) .GroupBy(x => x.ProductId, (key, group) => new { Id = key, diff --git a/Workshop/Reports/TableReport.cs b/Workshop/Reports/TableReport.cs index 5a2a396..dff3759 100644 --- a/Workshop/Reports/TableReport.cs +++ b/Workshop/Reports/TableReport.cs @@ -17,7 +17,7 @@ namespace Workshop.Reports _logger = logger ?? throw new ArgumentNullException(nameof(logger)); } - public bool CreateTable(string filePath, long productId, DateTime startDate, DateTime endDate) + public bool CreateTable(string filePath, int productId, DateTime startDate, DateTime endDate) { try { @@ -35,13 +35,11 @@ namespace Workshop.Reports return false; } } - private List GetData(long productId, DateTime startDate, DateTime + private List GetData(int productId, DateTime startDate, DateTime endDate) { var data = _chequeRepository - .ReadCheques() - .Where(x => x.Date >= startDate && x.Date <= endDate && - x.ChequeProduct.Any(y => y.ProductId == productId)) + .ReadCheques(dateFrom: startDate, dateTo: endDate, productId: productId) .Select(x => new { Date = x.Date, diff --git a/Workshop/Repositories/IChequeRepository.cs b/Workshop/Repositories/IChequeRepository.cs index 6ed982b..6ee68f8 100644 --- a/Workshop/Repositories/IChequeRepository.cs +++ b/Workshop/Repositories/IChequeRepository.cs @@ -9,6 +9,6 @@ namespace Workshop.Repositories; public interface IChequeRepository { - IEnumerable ReadCheques(DateTime? dateFrom = null, DateTime? dateTo = null, int? chequeId = null); + IEnumerable ReadCheques(DateTime? dateFrom = null, DateTime? dateTo = null, int? productId = null); void CreateCheque(Cheque cheque); } diff --git a/Workshop/Repositories/Implementations/ChequeRepository.cs b/Workshop/Repositories/Implementations/ChequeRepository.cs index efcaf9b..c31e074 100644 --- a/Workshop/Repositories/Implementations/ChequeRepository.cs +++ b/Workshop/Repositories/Implementations/ChequeRepository.cs @@ -54,21 +54,47 @@ VALUES (@ProductId, @ChequeID, @Amount)"; } } - public IEnumerable ReadCheques(DateTime? dateFrom = null, DateTime? dateTo = null, int? chequeId = null) + public IEnumerable ReadCheques(DateTime? dateFrom = null, DateTime? dateTo = null, int? productId = null) { _logger.LogInformation("Получение всех объектов"); try { + var builder = new QueryBuilder(); + if (dateFrom.HasValue) + builder.AddCondition("cp.CreatingDate >= @dateFrom"); + if (dateTo.HasValue) + builder.AddCondition("cp.CreatingDate <= @dateTo"); + if (productId.HasValue) + builder.AddCondition("cp.ProductId = @productId"); using var connection = new NpgsqlConnection(_connectionString.ConnectionString); - var querySelect = "SELECT c.*, cp.ProductId, cp.Amount " + "FROM cheque c " + - "INNER JOIN cheque_product cp ON cp.ChequeId = c.Id"; - var cheques = connection.Query(querySelect); + var querySelect = @$"SELECT +c.*, +cp.ProductId, +cp.Amount, +p.Name as ""ProductName"" +FROM Cheque c +INNER JOIN Cheque_Product cp on cp.ChequeId = c.Id +LEFT JOIN Product p on p.Id = cp.ProductId +{builder.Build()}"; + var productDict = new Dictionary>(); + var cheques = connection.Query(querySelect, + (cheque, chequeproduct) => + { + if (!productDict.TryGetValue(cheque.Id, out var cp)) + { + cp = []; + productDict.Add(cheque.Id, cp); + } + cp.Add(chequeproduct); + return cheque; + }, splitOn: "ProductId", param: new { dateFrom, dateTo, productId }); _logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(cheques)); - return cheques.GroupBy(x => x.Id, y => y, - (key, value) => - Cheque.CreateOperation(value.First(), - value.Select(z => - ChequeProduct.CreateEntity(z.ProductId, z.Id, z.Amount)))).ToList(); + return productDict.Select(x => + { + var c = cheques.First(y => y.Id == x.Key); + c.SetChequeProduct(x.Value); + return c; + }).ToArray(); } catch (Exception ex) { diff --git a/Workshop/Repositories/Implementations/ProductCreateRepository.cs b/Workshop/Repositories/Implementations/ProductCreateRepository.cs index 32720a1..f8fa703 100644 --- a/Workshop/Repositories/Implementations/ProductCreateRepository.cs +++ b/Workshop/Repositories/Implementations/ProductCreateRepository.cs @@ -67,9 +67,25 @@ WHERE Id=@id"; _logger.LogInformation("Получение всех объектов"); try { + var builder = new QueryBuilder(); + if (dateFrom.HasValue) + builder.AddCondition("pc.CreatingDate >= @dateFrom"); + if (dateTo.HasValue) + builder.AddCondition("pc.CreatingDate <= @dateTo"); + if (productId.HasValue) + builder.AddCondition("pc.ProductId = @productId"); + if (masterId.HasValue) + builder.AddCondition("pc.MasterId = @masterId"); using var connection = new NpgsqlConnection(_connectionString.ConnectionString); - var querySelect = "SELECT * FROM PRODUCTCREATE"; - var productCreatings = connection.Query(querySelect); + var querySelect = @$"SELECT +pc.*, +p.Name as ""ProductName"", +CONCAT(m.LastName, ' ', m.Name) as MasterName +FROM ProductCreate pc +LEFT JOIN Product p on p.Id = pc.ProductId +LEFT JOIN Master m on m.Id = pc.MasterId +{builder.Build()}"; + var productCreatings = connection.Query(querySelect, new { dateFrom, dateTo, productId, masterId }); _logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(productCreatings)); return productCreatings; } @@ -77,7 +93,6 @@ WHERE Id=@id"; { _logger.LogError(ex, "Ошибка при чтении объектов"); throw; - } } } diff --git a/Workshop/Repositories/Implementations/QueryBuilder.cs b/Workshop/Repositories/Implementations/QueryBuilder.cs new file mode 100644 index 0000000..f161085 --- /dev/null +++ b/Workshop/Repositories/Implementations/QueryBuilder.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Workshop.Repositories.Implementations; + +internal class QueryBuilder +{ + private readonly StringBuilder _builder; + public QueryBuilder() + { + _builder = new(); + } + public QueryBuilder AddCondition(string condition) + { + if (_builder.Length > 0) + { + _builder.Append(" AND "); + } + _builder.Append(condition); + return this; + } + public string Build() + { + if (_builder.Length == 0) + { + return string.Empty; + } + return $"WHERE {_builder}"; + } +} -- 2.25.1 From 9cfe868c17b06e2cefb92bd906f7ad5f85b68771 Mon Sep 17 00:00:00 2001 From: grishazagidulin Date: Mon, 16 Dec 2024 15:02:36 +0400 Subject: [PATCH 3/5] Lab4 Release --- Workshop/Forms/FormCheque.cs | 2 +- Workshop/Reports/ChartReport.cs | 6 +++--- Workshop/Repositories/Implementations/ChequeRepository.cs | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Workshop/Forms/FormCheque.cs b/Workshop/Forms/FormCheque.cs index 1d273f0..24b4db4 100644 --- a/Workshop/Forms/FormCheque.cs +++ b/Workshop/Forms/FormCheque.cs @@ -58,7 +58,7 @@ namespace Workshop.Forms return list.GroupBy( x => x.ProductId, x => x.Amount, - (id, counts) => ChequeProduct.CreateEntity(0, id, counts.Sum())).ToList(); + (id, counts) => ChequeProduct.CreateEntity(id, 0, counts.Sum())).ToList(); } } } diff --git a/Workshop/Reports/ChartReport.cs b/Workshop/Reports/ChartReport.cs index 8ecbacb..482f5f7 100644 --- a/Workshop/Reports/ChartReport.cs +++ b/Workshop/Reports/ChartReport.cs @@ -44,12 +44,12 @@ internal class ChartReport { return _creatingRepository .ReadProductCreates(dateFrom: dateTimeStart, dateTo: dateTimeEnd) - .GroupBy(x => x.ProductId, (key, group) => new + .GroupBy(x => x.ProductName, (key, group) => new { - Id = key, + ProductName = key, Count = group.Count() }) - .Select(x => (x.Id.ToString(), (double)x.Count)) + .Select(x => (x.ProductName.ToString(), (double)x.Count)) .ToList(); } } diff --git a/Workshop/Repositories/Implementations/ChequeRepository.cs b/Workshop/Repositories/Implementations/ChequeRepository.cs index c31e074..216e4ee 100644 --- a/Workshop/Repositories/Implementations/ChequeRepository.cs +++ b/Workshop/Repositories/Implementations/ChequeRepository.cs @@ -43,7 +43,7 @@ INSERT INTO CHEQUE_PRODUCT (ProductID, ChequeID, Amount) VALUES (@ProductId, @ChequeID, @Amount)"; foreach (var elem in cheque.ChequeProduct) { - connection.Execute(querySubInsert, new {chequeId, elem.ProductId, elem.Amount}); + connection.Execute(querySubInsert, new { elem.ProductId, chequeId, elem.Amount}); } transaction.Commit(); } @@ -61,9 +61,9 @@ VALUES (@ProductId, @ChequeID, @Amount)"; { var builder = new QueryBuilder(); if (dateFrom.HasValue) - builder.AddCondition("cp.CreatingDate >= @dateFrom"); + builder.AddCondition("c.Date >= @dateFrom"); if (dateTo.HasValue) - builder.AddCondition("cp.CreatingDate <= @dateTo"); + builder.AddCondition("c.Date <= @dateTo"); if (productId.HasValue) builder.AddCondition("cp.ProductId = @productId"); using var connection = new NpgsqlConnection(_connectionString.ConnectionString); -- 2.25.1 From 258f92d546e2fad95a4df708affdeabbb68bcab4 Mon Sep 17 00:00:00 2001 From: grishazagidulin Date: Mon, 16 Dec 2024 16:57:07 +0400 Subject: [PATCH 4/5] Lab4 done --- Workshop/Program.cs | 1 - Workshop/Reports/ChartReport.cs | 2 +- Workshop/Reports/TableReport.cs | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/Workshop/Program.cs b/Workshop/Program.cs index afbc268..d55b31c 100644 --- a/Workshop/Program.cs +++ b/Workshop/Program.cs @@ -10,7 +10,6 @@ namespace Workshop { internal static class Program { - //TODO: chequeId productId TableReport, ChequeRepository, IChequeRepository /// /// The main entry point for the application. /// diff --git a/Workshop/Reports/ChartReport.cs b/Workshop/Reports/ChartReport.cs index 482f5f7..c497d4c 100644 --- a/Workshop/Reports/ChartReport.cs +++ b/Workshop/Reports/ChartReport.cs @@ -24,7 +24,7 @@ internal class ChartReport { new PDFBuilder(filePath) .AddHeader("Создание изделий") - .AddPieChart("Изделия", GetData(dateTimeStart, dateTimeEnd)) + .AddPieChart($"Созданные изделия за период с {dateTimeStart:dd.MM.yyyy} по {dateTimeEnd:dd.MM.yyyy}", GetData(dateTimeStart, dateTimeEnd)) .Build(); return true; } diff --git a/Workshop/Reports/TableReport.cs b/Workshop/Reports/TableReport.cs index dff3759..cbcd950 100644 --- a/Workshop/Reports/TableReport.cs +++ b/Workshop/Reports/TableReport.cs @@ -23,7 +23,7 @@ namespace Workshop.Reports { new ExcelBuilder(filePath) .AddHeader("Сводка по движению изделия", 0, 3) - .AddParagraph("за период", 0) + .AddParagraph($"за период с {startDate:dd.MM.yyyy} по {endDate:dd.MM.yyyy}", 0) .AddTable([15, 15, 15, 15], GetData(productId, startDate, endDate)) .Build(); -- 2.25.1 From c35e3e38a6a120a3922b418f138b18b6603dfe16 Mon Sep 17 00:00:00 2001 From: grishazagidulin Date: Thu, 19 Dec 2024 13:00:30 +0400 Subject: [PATCH 5/5] =?UTF-8?q?=D0=A4=D0=B8=D0=BA=D1=81=D0=B8=D1=82=20?= =?UTF-8?q?=D0=BA=D0=BE=D0=BD=D1=84=D0=BB=D0=B8=D0=BA=D1=82=20(=D0=9D?= =?UTF-8?q?=D0=B0=D0=B4=D0=B5=D1=8E=D1=81=D1=8C)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Workshop/Reports/DocReport.cs | 6 +++--- Workshop/Reports/WordBuilder.cs | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Workshop/Reports/DocReport.cs b/Workshop/Reports/DocReport.cs index 6a22d82..83777bc 100644 --- a/Workshop/Reports/DocReport.cs +++ b/Workshop/Reports/DocReport.cs @@ -31,17 +31,17 @@ internal class DocReport if (includeMaster) { - builder.AddParagraph("Мастера") + builder.AddHeader("Мастера") .AddTable([2400, 2400, 1200, 2400], GetMasters()); } if (includeMaterial) { - builder.AddParagraph("Материалы") + builder.AddHeader("Материалы") .AddTable([2400, 1200, 1200], GetMaterials()); } if (includeProduct) { - builder.AddParagraph("Изделия") + builder.AddHeader("Изделия") .AddTable([2400, 1200, 1200, 2400], GetProducts()); } builder.Build(); diff --git a/Workshop/Reports/WordBuilder.cs b/Workshop/Reports/WordBuilder.cs index ce43fc4..fefc4df 100644 --- a/Workshop/Reports/WordBuilder.cs +++ b/Workshop/Reports/WordBuilder.cs @@ -27,7 +27,8 @@ internal class WordBuilder { var paragraph = _body.AppendChild(new Paragraph()); var run = paragraph.AppendChild(new Run()); - //TODO прописать настройки под жирный текст + var runProperties = run.AppendChild(new RunProperties()); + runProperties.AppendChild(new Bold()); run.AppendChild(new Text(header)); return this; } -- 2.25.1