ИСЭбд-21 Мосевнин А.М. LabWork_4 #4

Closed
Aleks_andr435 wants to merge 7 commits from Labwork_4 into Labwork_3
3 changed files with 10 additions and 7 deletions
Showing only changes of commit f0df960fce - Show all commits

View File

@ -34,7 +34,7 @@ namespace ProjectLibrary.Entites
[DisplayName("Отданные книги")] [DisplayName("Отданные книги")]
public string BookOrdersing => BookOrders != null ? 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; string.Empty;
public static Orders CreateEntity(int id, DateTime returnDate, int readerID, IEnumerable<Book_Orders> bookOrders) public static Orders CreateEntity(int id, DateTime returnDate, int readerID, IEnumerable<Book_Orders> bookOrders)

View File

@ -42,8 +42,9 @@ public class TableReport
private List<string[]> GetData(DateTime? startDate = null, DateTime? endDate = null) private List<string[]> GetData(DateTime? startDate = null, DateTime? endDate = null)
{ {
//var s = _orderRepository var s = _orderRepository
// .ReadOrders(StartDate: startDate, EndDate: endDate); .ReadOrders(StartDate: startDate, EndDate: endDate);
var data = _orderRepository var data = _orderRepository
.ReadOrders(StartDate: startDate, EndDate: endDate) .ReadOrders(StartDate: startDate, EndDate: endDate)
.Select(x => new .Select(x => new
@ -51,7 +52,7 @@ public class TableReport
x.Id, x.Id,
DateOrder = x.OrderDate, DateOrder = x.OrderDate,
DateReturn = x.ReturnDate, 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 Count = x.BookOrders.FirstOrDefault(y => y.OrderID == x.Id)?.Count
}) })
.OrderBy(x => x.Id); .OrderBy(x => x.Id);
@ -60,7 +61,7 @@ public class TableReport
.Union( .Union(
data data
.Select(x => new string[] { x.Id.ToString(), x.DateOrder.ToString("dd.MM.yyyy"), x.DateReturn.ToString("dd.MM.yyyy"), .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")]]) .Union([["Всего", "", "", "", data.Sum(x => x.Count ?? 0).ToString("N0")]])
.ToList(); .ToList();
//return null; //return null;

View File

@ -119,11 +119,13 @@ namespace ProjectLibrary.Repositories.Implementations
{ {
builder.AddCollerction("ord.OrderDate >= @StartDate"); builder.AddCollerction("ord.OrderDate >= @StartDate");
} }
/*if (EndDate.HasValue)
{
builder.AddCollerction("ord.ReturnDate < @EndDate");
}*/
var querySelect = $@"SELECT ord.*, var querySelect = $@"SELECT ord.*,
bk.Name as BookName, bk.Name as BookName,
Obo.bookid as bookid Obo.bookid as bookid
FROM Orders ord FROM Orders ord
INNER JOIN Book_Orders Obo ON Obo.orderId = ord.Id INNER JOIN Book_Orders Obo ON Obo.orderId = ord.Id
Inner join book bk on bk.ID = obo.Bookid Inner join book bk on bk.ID = obo.Bookid