фиксес

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) public GeneratedBarcode CreateBarcode(ProductBindingModel model, bool save)
{ {
var barCode = IronBarCode.BarcodeWriter.CreateBarcode(model.Id.ToString(), BarcodeEncoding.Code128); 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; return barCode;
} }
} }

View File

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

View File

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