небольшой фикс

This commit is contained in:
RozhVan 2024-12-14 15:58:17 +04:00
parent c5db05fbb1
commit 1984a205c1
4 changed files with 6 additions and 9 deletions

View File

@ -6,19 +6,16 @@ public class Selling
public int GasmanId { get; private set; }
public int Count { get; private set; }
public IEnumerable<ProductSelling> ProdutcSellings { get; private set; } = [];
public DateTime SellingDateTime { get; private set; }
public static Selling CreateSelling(int id, int gasmanId, int count, IEnumerable<ProductSelling> produtcSellings)
public static Selling CreateSelling(int id, int gasmanId, IEnumerable<ProductSelling> produtcSellings)
{
return new Selling
{
Id = id,
GasmanId = gasmanId,
Count = count,
SellingDateTime = DateTime.Now,
ProdutcSellings = produtcSellings
};

View File

@ -31,7 +31,7 @@ public partial class FormProduct : Form
{
throw new InvalidDataException(nameof(product));
}
numericUpDownCost.Value = product.ProductCost;
comboBoxProduct.SelectedItem = product.ProductType;
_productId = value;
}

View File

@ -33,8 +33,8 @@ namespace GasStation.Forms
throw new Exception("Имеются незаполненые поля");
}
_sellingRepository.CreateSelling(Selling.CreateSelling(0, (int)comboBoxGasman.SelectedValue!,
0, CreateProductSellingsFromDataGrid()));
_sellingRepository.CreateSelling(Selling.CreateSelling(0, (int)comboBoxGasman.SelectedValue!
, CreateProductSellingsFromDataGrid()));
Close();
}

View File

@ -29,8 +29,8 @@ public class SellingRepository : ISellingRepository
connection.Open();
using var transaction = connection.BeginTransaction();
var queryInsert = @"
INSERT INTO selling (sellingDateTime, gasmanId, count)
VALUES (@SellingDateTime, @GasmanId, @Count);
INSERT INTO selling (sellingDateTime, gasmanId)
VALUES (@SellingDateTime, @GasmanId);
SELECT MAX(Id) FROM selling";
var Id = connection.QueryFirst<int>(queryInsert, selling, transaction);
var querySubInsert = @"