From f0df960fceeca9e4dffee94fab06cd33f5047d13 Mon Sep 17 00:00:00 2001 From: Aleksandr4350 Date: Sat, 21 Dec 2024 19:56:37 +0400 Subject: [PATCH] =?UTF-8?q?=D0=B0=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ProjectLibrary/Entites/Orders.cs | 2 +- ProjectLibrary/Reports/TableReport.cs | 9 +++++---- .../Repositores/Implementations/OrderRepository.cs | 6 ++++-- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/ProjectLibrary/Entites/Orders.cs b/ProjectLibrary/Entites/Orders.cs index 9aae524..c085586 100644 --- a/ProjectLibrary/Entites/Orders.cs +++ b/ProjectLibrary/Entites/Orders.cs @@ -34,7 +34,7 @@ namespace ProjectLibrary.Entites [DisplayName("Отданные книги")] public string BookOrdersing => BookOrders != null ? - string.Join(", ", BookOrders.Select(x => $"{x.BookID}{x.Count}")) : + string.Join(", ", BookOrders.Select(x => $"{x.BookID}({x.Count})")) : string.Empty; public static Orders CreateEntity(int id, DateTime returnDate, int readerID, IEnumerable bookOrders) diff --git a/ProjectLibrary/Reports/TableReport.cs b/ProjectLibrary/Reports/TableReport.cs index 545a174..d1a7624 100644 --- a/ProjectLibrary/Reports/TableReport.cs +++ b/ProjectLibrary/Reports/TableReport.cs @@ -42,8 +42,9 @@ public class TableReport private List GetData(DateTime? startDate = null, DateTime? endDate = null) { - //var s = _orderRepository - // .ReadOrders(StartDate: startDate, EndDate: endDate); + var s = _orderRepository + .ReadOrders(StartDate: startDate, EndDate: endDate); + var data = _orderRepository .ReadOrders(StartDate: startDate, EndDate: endDate) .Select(x => new @@ -51,7 +52,7 @@ public class TableReport x.Id, DateOrder = x.OrderDate, DateReturn = x.ReturnDate, - Book = x.BookOrders.FirstOrDefault(y => y.OrderID == x.Id)?.BookName, + Book = x.BookOrders.FirstOrDefault(y => y.OrderID == x.Id)?.BookID,//вот эти данные не вставляются в эксель Count = x.BookOrders.FirstOrDefault(y => y.OrderID == x.Id)?.Count }) .OrderBy(x => x.Id); @@ -60,7 +61,7 @@ public class TableReport .Union( data .Select(x => new string[] { x.Id.ToString(), x.DateOrder.ToString("dd.MM.yyyy"), x.DateReturn.ToString("dd.MM.yyyy"), - x.Book ?? string.Empty, x.Count?.ToString("N0") ?? string.Empty})) + x.Book?.ToString("N0") ?? string.Empty, x.Count?.ToString("N0") ?? string.Empty})) .Union([["Всего", "", "", "", data.Sum(x => x.Count ?? 0).ToString("N0")]]) .ToList(); //return null; diff --git a/ProjectLibrary/Repositores/Implementations/OrderRepository.cs b/ProjectLibrary/Repositores/Implementations/OrderRepository.cs index 090731f..d8481f2 100644 --- a/ProjectLibrary/Repositores/Implementations/OrderRepository.cs +++ b/ProjectLibrary/Repositores/Implementations/OrderRepository.cs @@ -119,11 +119,13 @@ namespace ProjectLibrary.Repositories.Implementations { builder.AddCollerction("ord.OrderDate >= @StartDate"); } - + /*if (EndDate.HasValue) + { + builder.AddCollerction("ord.ReturnDate < @EndDate"); + }*/ var querySelect = $@"SELECT ord.*, bk.Name as BookName, Obo.bookid as bookid - FROM Orders ord INNER JOIN Book_Orders Obo ON Obo.orderId = ord.Id Inner join book bk on bk.ID = obo.Bookid