diff --git a/BusinessLogic/BusinessLogic/BarcodeLogic.cs b/BusinessLogic/BusinessLogic/BarcodeLogic.cs index 375c9ca..7f212f7 100644 --- a/BusinessLogic/BusinessLogic/BarcodeLogic.cs +++ b/BusinessLogic/BusinessLogic/BarcodeLogic.cs @@ -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; } } diff --git a/DatabaseImplement/Implements/ProductStorage.cs b/DatabaseImplement/Implements/ProductStorage.cs index d3de1d9..a0c40ed 100644 --- a/DatabaseImplement/Implements/ProductStorage.cs +++ b/DatabaseImplement/Implements/ProductStorage.cs @@ -114,7 +114,7 @@ namespace DatabaseImplement.Implements product.Update(model); context.SaveChanges(); transaction.Commit(); - return product.GetViewModel; + return new(); } catch { diff --git a/WinFormsApp/FormProducts.cs b/WinFormsApp/FormProducts.cs index ddb366b..9d62565 100644 --- a/WinFormsApp/FormProducts.cs +++ b/WinFormsApp/FormProducts.cs @@ -100,12 +100,16 @@ namespace WinFormsApp IsBeingSold = checkBoxIsSold.Checked, }; var operationResult = _id.HasValue ? _productLogic.Update(model) : _productLogic.Create(model); - var lastProductCreated = _productLogic.ReadList(null).Last(); - _barcodeLogic.CreateBarcode(new ProductBindingModel() + if (!_id.HasValue) { - Id = lastProductCreated.Id, - Name = lastProductCreated.Name, - }, true); + 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) {