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

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

View File

@ -1,12 +1,19 @@
namespace ProjectLibrary.Entities
{
using ProjectLibrary.Entities.Enums;
using System.ComponentModel;
public class Book
{
public int Id { get; private set; }
[DisplayName("Автор")]
public string Author { get; private set; } = string.Empty;
[DisplayName("Назвние книги")]
public string Name { get; private set; } = string.Empty;
[DisplayName("Тип книги")]
public BookType TypeBookID { get; set; } = BookType.None;
public static Book CreateEntity(int id, string author, string name, BookType typeBookID = BookType.None)

View File

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@ -8,8 +9,13 @@ namespace ProjectLibrary.Entites
{
public class Book_Orders
{
[Browsable(false)]
public int BookID { get; private set; }
[Browsable(false)]
public int OrderID { get; private set; }
[DisplayName("Количество")]
public int Count { get; private set; }
public static Book_Orders CreateEntity(int orderID,int bookID, int count )

View File

@ -1,9 +1,15 @@
namespace ProjectLibrary.Entites
using System.ComponentModel;
namespace ProjectLibrary.Entites
{
public class Book_Library
{
[Browsable(false)]
public int BookID { get; private set; }
[Browsable(false)]
public int LibraryID { get; private set; }
[DisplayName("Количество")]
public int Count { get; private set; }
public static Book_Library CreateEntity(int libraryID, int bookID, int count)

View File

@ -1,6 +1,7 @@
using ProjectLibrary.Forms;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@ -10,7 +11,11 @@ namespace ProjectLibrary.Entites
public class Library
{
public int Id { get; private set; }
[DisplayName("Название")]
public string Name { get; private set; } = string.Empty;
[DisplayName("Адрес")]
public string Address { get; private set; } = string.Empty;
public IEnumerable<Book_Library> BookLibrary
{

View File

@ -3,6 +3,7 @@ using Microsoft.VisualBasic;
using ProjectLibrary.Entities;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@ -12,8 +13,14 @@ namespace ProjectLibrary.Entites
public class Orders
{
public int Id { get; private set; }
[DisplayName("Дата с")]
public DateTime OrderDate { get; private set; }
[DisplayName("Дата по")]
public DateTime ReturnDate { get; private set; }
[Browsable(false)]
public int ReaderID { get; private set; }
public IEnumerable<Book_Orders> BookOrders
{

View File

@ -1,10 +1,18 @@
namespace ProjectLibrary.Entities
using System.ComponentModel;
namespace ProjectLibrary.Entities
{
public class Reader
{
public int Id { get; private set; }
[DisplayName("Имя")]
public string Name { get; private set; } = string.Empty;
[DisplayName("Читательский билет")]
public int ReaderTicket { get; private set; }
[DisplayName("Дата регистрации")]
public DateTime RegistrationDateRT { get; private set; } // Изменение на DateTime
public static Reader CreateEntity(int id, string name, int readerTicket)

View File

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@ -9,10 +10,20 @@ 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; }

View File

@ -1,10 +1,18 @@
namespace ProjectLibrary.Entites
using System.ComponentModel;
namespace ProjectLibrary.Entites
{
public class TicketExtensions
{
public int Id { get; private set; }
[Browsable(false)]
public int ReaderID { get; private set; }
[DisplayName("Последняя дата обновления")]
public DateTime LastUpdateDate { get; private set; }
[DisplayName("Следущая дата обновления")]
public DateTime NextUpdateDate { get; private set; }
public static TicketExtensions CreateEntity(int id, int readerID, DateTime lastUpdateDate, DateTime nextUpdateDate)

View File

@ -1,4 +1,5 @@
using Microsoft.Extensions.Logging;
using DocumentFormat.OpenXml.Wordprocessing;
using Microsoft.Extensions.Logging;
using ProjectLibrary.Repositories;
using System;
using System.Collections.Generic;
@ -37,8 +38,7 @@ public class ChartReport
private List<(string Caption, double Value)> GetData(DateTime dateTime)
{
return _orderRepository
.ReadOrders()
.Where(x => x.OrderDate.Date == dateTime.Date)
.ReadOrders(StartDate: startDate, EndDate: endDate)
.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();

View File

@ -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)
@ -28,7 +28,7 @@ public class TableReport
{
new ExcelBuilder(filePath)
.AddHeader("Сводка по движению книг", 0, 5)
.AddParagraph("за период", 0)
.AddParagraph($"За период с {startDate:dd.MM.yyyy} по {endDate:dd.MM.yyyy}",0)
.AddTable([10, 10, 10, 15, 15], GetData(startDate, endDate))
.Build();
return true;
@ -43,8 +43,7 @@ public class TableReport
private List<string[]> GetData(DateTime startDate, DateTime endDate)
{
var data = _orderRepository
.ReadOrders()
.Where(x => x.OrderDate >= startDate && x.OrderDate <= endDate && x.BookOrders.Any(y => y.OrderID == x.Id))
.ReadOrders(StartDate: startDate, EndDate: endDate)
.Select(x => new
{
x.Id,
@ -58,9 +57,10 @@ public class TableReport
new List<string[]>() { item }
.Union(
data
.Select(x => new string[] { x.Id.ToString(), x.DateOrder.ToString(), x.DateReturn.ToString(),
x.Book?.ToString() ?? string.Empty, x.Count?.ToString() ?? string.Empty}))
.Union([["Всего", "", "", "", data.Sum(x => x.Count ?? 0).ToString()]])
.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}))
.Union([["Всего", "", "", "", data.Sum(x => x.Count ?? 0).ToString("N0")]])
.ToList();
//return null;
}
}