всё ещё присутствуют недоработки

This commit is contained in:
RozhVan 2024-12-23 10:07:41 +04:00
parent 71a39fa73e
commit 3ed7fda20d
3 changed files with 14 additions and 14 deletions

View File

@ -35,7 +35,7 @@ namespace GasStation.Forms
{ {
dataGridViewData.DataSource = _sellingRepository.ReadSelling(); dataGridViewData.DataSource = _sellingRepository.ReadSelling();
dataGridViewData.Columns["ID"].Visible = false; dataGridViewData.Columns["ID"].Visible = false;
dataGridViewData.Columns["SupplyDate"].DefaultCellStyle.Format = "dd MMMM yyyy hh:mm"; dataGridViewData.Columns["SellingDateTime"].DefaultCellStyle.Format = "dd MMMM yyyy";
} }
private void FormSellings_Load(object sender, EventArgs e) private void FormSellings_Load(object sender, EventArgs e)

View File

@ -58,7 +58,7 @@ VALUES (@Id, @ProductID, @Count)";
var builder = new QueryBuilder(); var builder = new QueryBuilder();
if (dateTime.HasValue) if (dateTime.HasValue)
{ {
builder.AddCondition("s.SellingDateTime = @sellingDateTime"); builder.AddCondition("s.SellingDateTime = @dateTime");
} }
if (count.HasValue) if (count.HasValue)
{ {
@ -70,17 +70,17 @@ VALUES (@Id, @ProductID, @Count)";
} }
using var connection = new NpgsqlConnection(_connectionString.ConnectionString); using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var querySelect = @" var querySelect = @$"
SELECT SELECT
fr.*, s.*,
CONCAT(p.ProductType, ' ', p.ProductName) as ProductName, CONCAT(p.ProductType, ' ', p.ProductName) as ProductName,
ps.ProdutId, ps.ProductId,
ps.Count, ps.Count,
g.GasmanName as 'GasmanName' g.GasmanName
FROM Selling s FROM Selling s
LEFT JOIN Gasman g on g.Id = s.GasmanId LEFT JOIN Gasman g on g.ID = s.GasmanID
INNER JOIN Product_Selling ps ON ps.ProductId = s.Id INNER JOIN Product_Selling ps ON ps.ID = s.ID
LEFT JOIN Product p on p.Id = s.ProductId LEFT JOIN Product p on p.Id = ps.ProductID
{builder.Build()}"; {builder.Build()}";
var sellingDict = new Dictionary<int, List<ProductSelling>>(); var sellingDict = new Dictionary<int, List<ProductSelling>>();
var selling = connection.Query<Selling, ProductSelling, Selling>(querySelect, (sell, sellings) => var selling = connection.Query<Selling, ProductSelling, Selling>(querySelect, (sell, sellings) =>
@ -92,16 +92,16 @@ LEFT JOIN Product p on p.Id = s.ProductId
} }
ps.Add(sellings); ps.Add(sellings);
return sell; return sell;
}, splitOn: "ProdutcId", param: new }, splitOn: "ProductId", param: new
{dateTime, count, gasmanID}); {dateTime, count, gasmanID});
_logger.LogDebug("Полученные объекты: {json}", _logger.LogDebug("Полученные объекты: {json}",
JsonConvert.SerializeObject(selling)); JsonConvert.SerializeObject(selling));
return sellingDict.Select(x => return sellingDict.Select(x =>
{ {
var fr = selling.First(y => y.Id == x.Key); var s = selling.First(y => y.Id == x.Key);
fr.SetProductSelling(x.Value); s.SetProductSelling(x.Value);
return fr; return s;
}).ToArray(); }).ToArray();
} }

View File

@ -83,7 +83,7 @@ WHERE id=@Id";
} }
using var connection = new NpgsqlConnection(_connectionString.ConnectionString); using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var querySelect = @"SELECT var querySelect = @$"SELECT
s.*, s.*,
CONCAT(p.ProductType, ' ', p.ProductName) as ProductName, CONCAT(p.ProductType, ' ', p.ProductName) as ProductName,
sup.SupplierName as SupplierName sup.SupplierName as SupplierName