это трындец
This commit is contained in:
parent
d42bfcd0a3
commit
fd952b242a
@ -10,12 +10,15 @@
|
||||
[DisplayName("Автор")]
|
||||
public string Author { get; private set; } = string.Empty;
|
||||
|
||||
[DisplayName("Назвние книги")]
|
||||
[Browsable(false)]
|
||||
public string Name { get; private set; } = string.Empty;
|
||||
|
||||
[DisplayName("Тип книги")]
|
||||
[Browsable(false)]
|
||||
public BookType TypeBookID { get; set; } = BookType.None;
|
||||
|
||||
[DisplayName("Название книги (жанр)")]
|
||||
public string NameTypeBookID => $"{Name}({TypeBookID})";
|
||||
|
||||
public static Book CreateEntity(int id, string author, string name, BookType typeBookID = BookType.None)
|
||||
{
|
||||
return new Book
|
||||
|
@ -18,6 +18,8 @@ namespace ProjectLibrary.Entites
|
||||
[DisplayName("Количество")]
|
||||
public int Count { get; private set; }
|
||||
|
||||
public string BookName { get; set; }
|
||||
|
||||
public static Book_Orders CreateEntity(int orderID,int bookID, int count )
|
||||
{
|
||||
return new Book_Orders
|
||||
|
@ -17,12 +17,18 @@ namespace ProjectLibrary.Entites
|
||||
|
||||
[DisplayName("Адрес")]
|
||||
public string Address { get; private set; } = string.Empty;
|
||||
|
||||
[Browsable(false)]
|
||||
public IEnumerable<Book_Library> BookLibrary
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
[DisplayName("Перечень книг в библиотеке")]
|
||||
public string ListBookInLibrary => BookLibrary != null ?
|
||||
string.Join("; ", BookLibrary.Select(x => $"{x.BookID},{x.Count}")): string.Empty;
|
||||
|
||||
public static Library CreateEntity(int id, string name, string address, IEnumerable<Book_Library> bookLibrary)
|
||||
{
|
||||
return new Library
|
||||
@ -33,5 +39,13 @@ namespace ProjectLibrary.Entites
|
||||
BookLibrary = bookLibrary
|
||||
};
|
||||
}
|
||||
|
||||
public void SetLibraryForBook(IEnumerable<Book_Library> book_Library)
|
||||
{
|
||||
if (book_Library != null && book_Library.Any())
|
||||
{
|
||||
BookLibrary = book_Library;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,20 +14,28 @@ namespace ProjectLibrary.Entites
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
|
||||
[DisplayName("Дата с")]
|
||||
[DisplayName("Дата взятия книги")]
|
||||
public DateTime OrderDate { get; private set; }
|
||||
|
||||
[DisplayName("Дата по")]
|
||||
[DisplayName("Дата зврата книги")]
|
||||
public DateTime ReturnDate { get; private set; }
|
||||
|
||||
[Browsable(false)]
|
||||
[DisplayName("Идентификационный номер читателя")]
|
||||
public int ReaderID { get; private set; }
|
||||
|
||||
public string BookName { get; set; }
|
||||
|
||||
[Browsable(false)]
|
||||
public IEnumerable<Book_Orders> BookOrders
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
} = [];
|
||||
|
||||
[DisplayName("Отданные книги")]
|
||||
public string BookOrdersing => BookOrders != null ?
|
||||
string.Join(", ", BookOrders.Select(x => $"{x.BookID}{x.Count}")) :
|
||||
string.Empty;
|
||||
|
||||
public static Orders CreateEntity(int id, DateTime returnDate, int readerID, IEnumerable<Book_Orders> bookOrders)
|
||||
{
|
||||
@ -40,17 +48,12 @@ namespace ProjectLibrary.Entites
|
||||
BookOrders = bookOrders
|
||||
};
|
||||
}
|
||||
|
||||
public static Orders CreateEntity(TempBookOrders tempBookOrders, IEnumerable<Book_Orders> bookOrders)
|
||||
public void SetOrdersOfBooks(IEnumerable<Book_Orders> book_Orders)
|
||||
{
|
||||
return new Orders
|
||||
if (book_Orders != null && book_Orders.Any())
|
||||
{
|
||||
Id = tempBookOrders.Id,
|
||||
OrderDate = tempBookOrders.OrderDate,
|
||||
ReturnDate = tempBookOrders.ReturnDate,
|
||||
ReaderID = tempBookOrders.ReaderID,
|
||||
BookOrders = bookOrders
|
||||
};
|
||||
BookOrders = book_Orders;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
35
ProjectLibrary/Entites/QueryBuilder.cs
Normal file
35
ProjectLibrary/Entites/QueryBuilder.cs
Normal file
@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectLibrary.Entites;
|
||||
|
||||
internal class QueryBuilder
|
||||
{
|
||||
private readonly StringBuilder _builder;
|
||||
public QueryBuilder()
|
||||
{
|
||||
_builder = new();
|
||||
}
|
||||
|
||||
public QueryBuilder AddCollerction(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}";
|
||||
}
|
||||
}
|
@ -6,7 +6,7 @@ namespace ProjectLibrary.Entities
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
|
||||
[DisplayName("Имя")]
|
||||
[DisplayName("ФИО")]
|
||||
public string Name { get; private set; } = string.Empty;
|
||||
|
||||
[DisplayName("Читательский билет")]
|
||||
|
@ -1,30 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectLibrary.Entites;
|
||||
|
||||
public class TempBookOrders
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[DisplayName("Дата заказа???")]
|
||||
public DateTime OrderDate { get; set; }
|
||||
|
||||
[DisplayName("Дата исполнения???")]
|
||||
public DateTime ReturnDate { get; set; }
|
||||
|
||||
[Browsable(false)]
|
||||
public int ReaderID { get; set; }
|
||||
|
||||
[Browsable(false)]
|
||||
public int BookID { get; set; }
|
||||
|
||||
[DisplayName("Количество")]
|
||||
public int Count { get; set; }
|
||||
|
||||
|
||||
}
|
@ -6,7 +6,7 @@ namespace ProjectLibrary.Entites
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
|
||||
[Browsable(false)]
|
||||
[DisplayName("Идентификационный номер читателя")]
|
||||
public int ReaderID { get; private set; }
|
||||
|
||||
[DisplayName("Последняя дата обновления")]
|
||||
|
@ -35,10 +35,10 @@ public class ChartReport
|
||||
}
|
||||
}
|
||||
|
||||
private List<(string Caption, double Value)> GetData(DateTime dateTime)
|
||||
private List<(string Caption, double Value)> GetData(DateTime? dateTime = null)
|
||||
{
|
||||
return _orderRepository
|
||||
.ReadOrders(StartDate: startDate, EndDate: endDate)
|
||||
.ReadOrders()
|
||||
.GroupBy(x => x.BookOrders.First(y => y.OrderID == x.Id).BookID , (key, group) => new { ID = key, Count = group.Sum(y => y.BookOrders.First(z => z.OrderID == y.Id).Count) })
|
||||
.Select(x => (x.ID.ToString(), (double)x.Count))
|
||||
.ToList();
|
||||
|
@ -13,7 +13,7 @@ public class TableReport
|
||||
{
|
||||
private readonly IOrderRepository _orderRepository;
|
||||
private readonly ILogger<TableReport> _logger;
|
||||
internal static readonly string[] item = ["Id заказа", "Книга", "Дата заказа", "Дата возврата", "Количество"];
|
||||
internal static readonly string[] item = ["Id заказа", "Дата заказа", "Дата возврата","Книга", "Количество"];
|
||||
|
||||
|
||||
public TableReport(IOrderRepository orderRepository, ILogger<TableReport> logger)
|
||||
@ -22,7 +22,7 @@ public class TableReport
|
||||
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
||||
}
|
||||
|
||||
public bool CreateTable(string filePath, DateTime startDate, DateTime endDate)
|
||||
public bool CreateTable(string filePath, DateTime? startDate = null, DateTime? endDate = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -40,25 +40,27 @@ public class TableReport
|
||||
}
|
||||
}
|
||||
|
||||
private List<string[]> GetData(DateTime startDate, DateTime endDate)
|
||||
private List<string[]> GetData(DateTime? startDate = null, DateTime? endDate = null)
|
||||
{
|
||||
//var s = _orderRepository
|
||||
// .ReadOrders(StartDate: startDate, EndDate: endDate);
|
||||
var data = _orderRepository
|
||||
.ReadOrders(StartDate: startDate, EndDate: endDate)
|
||||
.Select(x => new
|
||||
{
|
||||
x.Id,
|
||||
DateOrder = x.OrderDate,
|
||||
DateReturn = x.ReturnDate,
|
||||
Book = (int?)x.BookOrders.First(y => y.OrderID == x.Id).BookID,
|
||||
Count = (int?)x.BookOrders.First(y => y.OrderID == x.Id).Count
|
||||
})
|
||||
.OrderBy(x => x.DateOrder);
|
||||
{
|
||||
x.Id,
|
||||
DateOrder = x.OrderDate,
|
||||
DateReturn = x.ReturnDate,
|
||||
Book = x.BookOrders.FirstOrDefault(y => y.OrderID == x.Id)?.BookName,
|
||||
Count = x.BookOrders.FirstOrDefault(y => y.OrderID == x.Id)?.Count
|
||||
})
|
||||
.OrderBy(x => x.Id);
|
||||
return
|
||||
new List<string[]>() { item }
|
||||
.Union(
|
||||
data
|
||||
.Select(x => new string[] { x.Id.ToString(), x.DateOrder.ToString("dd.MM.yyyy"), x.DateReturn.ToString("dd.MM.yyyy"),
|
||||
x.Book?.ToString("N0") ?? string.Empty, x.Count?.ToString("N0") ?? string.Empty}))
|
||||
x.Book ?? string.Empty, x.Count?.ToString("N0") ?? string.Empty}))
|
||||
.Union([["Всего", "", "", "", data.Sum(x => x.Count ?? 0).ToString("N0")]])
|
||||
.ToList();
|
||||
//return null;
|
||||
|
@ -121,9 +121,9 @@ namespace ProjectLibrary.Repositories.Implementations
|
||||
}
|
||||
|
||||
var querySelect = $@"SELECT ord.*,
|
||||
Obo.BookId as bookid,
|
||||
Obo.Count,
|
||||
bk.Name
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user