ИСЭбд-21.Васильева.С.В. 4 лабораторная работа #4

Closed
SVETLANA_8 wants to merge 7 commits from LabWork_4 into LabWork_3
5 changed files with 18 additions and 10 deletions
Showing only changes of commit c5759f33e9 - Show all commits

View File

@ -25,8 +25,11 @@ public class Order
[Browsable(false)] [Browsable(false)]
public IEnumerable<OrderProduct> OrderProduct { get; private set; } = []; public IEnumerable<OrderProduct> OrderProduct { get; private set; } = [];
[DisplayName("Номер(id) клиента")]
[Browsable(false)]
public int IdClient { get; private set; } public int IdClient { get; private set; }
[DisplayName("Имя клиента")]
public string NameClient { get; private set; } = string.Empty;
public static Order CreateOperation(int id, OrderStatus status, string characteristic, IEnumerable<OrderProduct> orderProduct, int idClient, DateTime dateTime) public static Order CreateOperation(int id, OrderStatus status, string characteristic, IEnumerable<OrderProduct> orderProduct, int idClient, DateTime dateTime)
{ {

View File

@ -66,10 +66,10 @@ public class MaterialReplenishmentRepository : IMaterialReplenishmentRepository
} }
public IEnumerable<MaterialReplenishment> ReadMaterialsSpent(DateTime? dateForm = null, DateTime? dateTo = null, string? materialName = null) public IEnumerable<MaterialReplenishment> ReadMaterialsSpent(DateTime? dateForm = null, DateTime? dateTo = null, string? materialName = null)
{ {
var builder = new QueryBuilder(); var builder = new QueryBuilder();
if (dateForm.HasValue) if (dateForm.HasValue)
{ {
builder.AddCondition("DataTime >= @dateForm"); builder.AddCondition("DataTime >= @dateForm");
} }
if (dateTo.HasValue) if (dateTo.HasValue)
{ {

View File

@ -34,14 +34,15 @@ internal class ExcelBuilder
_rowIndex = 1; _rowIndex = 1;
} }
public ExcelBuilder AddHeader(string header, int startIndex, int count) public ExcelBuilder AddHeader(string headerPrefix, string materialName, int startIndex, int count)
{ {
string header = $"{headerPrefix}{materialName}";
CreateCell(startIndex, _rowIndex, header, StyleIndex.BoldTextWithoutBorder); CreateCell(startIndex, _rowIndex, header, StyleIndex.BoldTextWithoutBorder);
for (int i = startIndex + 1; i < startIndex + count; ++i) for (int i = startIndex + 1; i < startIndex + count; ++i)
{ {
CreateCell(i, _rowIndex, "", StyleIndex.SimpleTextWithoutBorder); CreateCell(i, _rowIndex, "", StyleIndex.SimpleTextWithoutBorder);
} }
_mergeCells.Append(new MergeCell() _mergeCells.Append(new MergeCell()
{ {
Reference = new StringValue($"{GetExcelColumnName(startIndex)}{_rowIndex}:{GetExcelColumnName(startIndex + count - 1)}{_rowIndex}") Reference = new StringValue($"{GetExcelColumnName(startIndex)}{_rowIndex}:{GetExcelColumnName(startIndex + count - 1)}{_rowIndex}")

View File

@ -30,9 +30,10 @@ internal class TableReport
{ {
try try
{ {
var materialName = _materialRepository.ReadMaterialById(materialId).Name;
new ExcelBuilder(filePath) new ExcelBuilder(filePath)
.AddHeader("Сводка по движению материала", 0, 3) .AddHeader("Сводка по движению материала- ", materialName, 0, 3)
.AddParagraph($"за период c {startDate:dd.MM.yyyy} по {endDate:dd.MM.yyyy}", 0) .AddParagraph($"за период c {startDate:dd.MM.yyyy} по {endDate:dd.MM.yyyy}", 0)
.AddTable([10, 15, 15], GetData(materialId, startDate, endDate)) .AddTable([10, 15, 15], GetData(materialId, startDate, endDate))
.Build(); .Build();
return true; return true;

View File

@ -1,4 +1,5 @@
using Dapper; using Dapper;
using DocumentFormat.OpenXml.Drawing;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Newtonsoft.Json; using Newtonsoft.Json;
using Npgsql; using Npgsql;
@ -82,10 +83,12 @@ public class OrderRepository : IOrderRepository
{ {
using var connection = new NpgsqlConnection(_connectionString.ConnectionString); using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var querySelect = @" var querySelect = @"
SELECT orders.*, products.id AS productid, products.name AS productname, op.count AS count SELECT orders.*, clients.name AS NameClient, products.id AS productid, products.name AS productname, op.count AS count
FROM orders FROM orders
INNER JOIN order_products AS op ON orders.id = op.orderid INNER JOIN order_products AS op ON orders.id = op.orderid
INNER JOIN products ON op.productid = products.id"; INNER JOIN products ON op.productid = products.id
INNER JOIN clients ON orders.idclient = clients.id";
var productsDict = new Dictionary<int, List<OrderProduct>>(); var productsDict = new Dictionary<int, List<OrderProduct>>();