From 76993ff3e7cb29d81fdd2af388e2f0ac18d5c55c Mon Sep 17 00:00:00 2001 From: "BB.Wang" Date: Wed, 9 Jul 2025 15:26:03 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AA=BF=E6=95=B4wip=5Fbarcode=E7=9A=84?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/AMES/WipBarcodeController.cs | 61 +++++++++++++------ 1 file changed, 42 insertions(+), 19 deletions(-) diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/WipBarcodeController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/WipBarcodeController.cs index 5cd1a0c..1ea308e 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/WipBarcodeController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/WipBarcodeController.cs @@ -167,30 +167,53 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES public async Task> PutWipBarcode([FromBody] WipBarcode wipBarcode) { ResultModel result = new ResultModel(); - var wipNo = wipBarcode.WipNO; + + //2025-06-19 BB.Wang Modify try { - var result_old = _context.WipBarcodes.Where(w => w.WipNO == wipNo).ToList(); - if (result_old.Count != 0) - { - foreach (var item in result_old) - { - _context.Entry(item).State = EntityState.Modified; - _context.Entry(item).Property("CreateDate").IsModified = false; - _context.Entry(item).Property("CreateUserID").IsModified = false; - item.UpdateDate = DateTime.Now; - item.Remarks = wipBarcode.Remarks; - } - } - else - { - _context.WipBarcodes.Add(wipBarcode); - } - - await _context.SaveChangesAsync(); + wipBarcode.UpdateDate = DateTime.Now; + var sSQL = @" UPDATE JHAMES.WIP_BARCODE SET + START_NO =: StartNO, + END_NO =: EndNO, + REMARKS =: Remarks, + UPDATE_DATE =: UpdateDate + WHERE WIP_NO =: WipNO + "; + await _context.Database.DapperExecuteAsync(sSQL, wipBarcode); result.Success = true; result.Msg = "OK"; } + #region 2025-06-19 BB.Wang remark + //var wipNo = wipBarcode.WipNO; + //try + //{ + // var result_old = _context.WipBarcodes.Where(w => w.WipNO == wipNo).ToList(); + // if (result_old.Count != 0) + // { + // foreach (var item in result_old) + // { + // _context.Entry(item).State = EntityState.Modified; + // _context.Entry(item).Property("CreateDate").IsModified = false; + // _context.Entry(item).Property("CreateUserID").IsModified = false; + + // //2025-06-19 BB.Wang add 增加資料更新時,UPDATE序號起訖 + // item.StartNO = wipBarcode.StartNO; + // item.EndNO = wipBarcode.EndNO; + + // item.UpdateDate = DateTime.Now; + // item.Remarks = wipBarcode.Remarks; + // } + // } + // else + // { + // _context.WipBarcodes.Add(wipBarcode); + // } + + // await _context.SaveChangesAsync(); + // result.Success = true; + // result.Msg = "OK"; + //} + #endregion catch (Exception ex) { result.Success = false;