фиксес

This commit is contained in:
the 2024-06-25 16:21:15 +04:00
parent 8bb0d37211
commit 464ab47941
3 changed files with 13 additions and 7 deletions

View File

@ -13,7 +13,8 @@ namespace BusinessLogic.BusinessLogic
public GeneratedBarcode CreateBarcode(ProductBindingModel model, bool save)
{
var barCode = IronBarCode.BarcodeWriter.CreateBarcode(model.Id.ToString(), BarcodeEncoding.Code128);
if (save) return barCode.SaveAsPng($"product{model.Id}.png");
var path = $"product{model.Id}.png";
if (save) return barCode.SaveAsPng(path);
return barCode;
}
}

View File

@ -114,7 +114,7 @@ namespace DatabaseImplement.Implements
product.Update(model);
context.SaveChanges();
transaction.Commit();
return product.GetViewModel;
return new();
}
catch
{

View File

@ -100,12 +100,16 @@ namespace WinFormsApp
IsBeingSold = checkBoxIsSold.Checked,
};
var operationResult = _id.HasValue ? _productLogic.Update(model) : _productLogic.Create(model);
if (!_id.HasValue)
{
var lastProductCreated = _productLogic.ReadList(null).Last();
_barcodeLogic.CreateBarcode(new ProductBindingModel()
{
Id = lastProductCreated.Id,
Name = lastProductCreated.Name,
}, true);
}
_id = null;
if (!operationResult)
{
@ -230,6 +234,7 @@ namespace WinFormsApp
numericUpDownPrice.Value = Convert.ToDecimal(product.Price);
numericUpDownAmount.Value = product.Amount;
checkBoxIsSold.Checked = product.IsBeingSold;
_id = product.Id;
}
catch (Exception ex)
{