From 3ed7fda20dcbd7958bfbe014f7e02d23164318e5 Mon Sep 17 00:00:00 2001 From: RozhVan Date: Mon, 23 Dec 2024 10:07:41 +0400 Subject: [PATCH] =?UTF-8?q?=D0=B2=D1=81=D1=91=20=D0=B5=D1=89=D1=91=20?= =?UTF-8?q?=D0=BF=D1=80=D0=B8=D1=81=D1=83=D1=82=D1=81=D1=82=D0=B2=D1=83?= =?UTF-8?q?=D1=8E=D1=82=20=D0=BD=D0=B5=D0=B4=D0=BE=D1=80=D0=B0=D0=B1=D0=BE?= =?UTF-8?q?=D1=82=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- GasStation/Forms/FormSellings.cs | 2 +- .../Implementations/SellingRepository.cs | 24 +++++++++---------- .../Implementations/SupplyRepository.cs | 2 +- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/GasStation/Forms/FormSellings.cs b/GasStation/Forms/FormSellings.cs index 2f16909..6846ee6 100644 --- a/GasStation/Forms/FormSellings.cs +++ b/GasStation/Forms/FormSellings.cs @@ -35,7 +35,7 @@ namespace GasStation.Forms { dataGridViewData.DataSource = _sellingRepository.ReadSelling(); 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) diff --git a/GasStation/Repositories/Implementations/SellingRepository.cs b/GasStation/Repositories/Implementations/SellingRepository.cs index 6086640..0429f5c 100644 --- a/GasStation/Repositories/Implementations/SellingRepository.cs +++ b/GasStation/Repositories/Implementations/SellingRepository.cs @@ -58,7 +58,7 @@ VALUES (@Id, @ProductID, @Count)"; var builder = new QueryBuilder(); if (dateTime.HasValue) { - builder.AddCondition("s.SellingDateTime = @sellingDateTime"); + builder.AddCondition("s.SellingDateTime = @dateTime"); } if (count.HasValue) { @@ -70,17 +70,17 @@ VALUES (@Id, @ProductID, @Count)"; } using var connection = new NpgsqlConnection(_connectionString.ConnectionString); - var querySelect = @" + var querySelect = @$" SELECT - fr.*, + s.*, CONCAT(p.ProductType, ' ', p.ProductName) as ProductName, - ps.ProdutId, + ps.ProductId, ps.Count, - g.GasmanName as 'GasmanName' + g.GasmanName FROM Selling s -LEFT JOIN Gasman g on g.Id = s.GasmanId -INNER JOIN Product_Selling ps ON ps.ProductId = s.Id -LEFT JOIN Product p on p.Id = s.ProductId +LEFT JOIN Gasman g on g.ID = s.GasmanID +INNER JOIN Product_Selling ps ON ps.ID = s.ID +LEFT JOIN Product p on p.Id = ps.ProductID {builder.Build()}"; var sellingDict = new Dictionary>(); var selling = connection.Query(querySelect, (sell, sellings) => @@ -92,16 +92,16 @@ LEFT JOIN Product p on p.Id = s.ProductId } ps.Add(sellings); return sell; - }, splitOn: "ProdutcId", param: new + }, splitOn: "ProductId", param: new {dateTime, count, gasmanID}); _logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(selling)); return sellingDict.Select(x => { - var fr = selling.First(y => y.Id == x.Key); - fr.SetProductSelling(x.Value); - return fr; + var s = selling.First(y => y.Id == x.Key); + s.SetProductSelling(x.Value); + return s; }).ToArray(); } diff --git a/GasStation/Repositories/Implementations/SupplyRepository.cs b/GasStation/Repositories/Implementations/SupplyRepository.cs index ce20740..73d191d 100644 --- a/GasStation/Repositories/Implementations/SupplyRepository.cs +++ b/GasStation/Repositories/Implementations/SupplyRepository.cs @@ -83,7 +83,7 @@ WHERE id=@Id"; } using var connection = new NpgsqlConnection(_connectionString.ConnectionString); - var querySelect = @"SELECT + var querySelect = @$"SELECT s.*, CONCAT(p.ProductType, ' ', p.ProductName) as ProductName, sup.SupplierName as SupplierName