| | |
| | | private bool UpdateData(SqlSugarScope db, SalesReturnNotice mesSalesReturn, |
| | | List<SalesReturnNoticeDetail> mesSalesReturnDatas) |
| | | { |
| | | var decimals = mesSalesReturnDatas.Select(s => s.Id).ToArray(); |
| | | var update = base.DeleteById(mesSalesReturn.Id); |
| | | var insertOrUpdate = db |
| | | .Deleteable<SalesReturnNoticeDetail>().In(decimals) |
| | | .ExecuteCommand() > 0; |
| | | // var decimals = mesSalesReturnDatas.Select(s => s.Id).ToArray(); |
| | | var decimals = mesSalesReturnDatas |
| | | ?.Where(x => x.Id.HasValue) |
| | | .Select(x => x.Id.Value) |
| | | .ToArray() ?? new decimal[0]; |
| | | //扫码不允许删除 |
| | | var hasMaterialOut = db.Queryable<MesInvItemIns>() |
| | | .Any(x => x.CbillNo == mesSalesReturn.BillNo); |
| | | |
| | | if (update && insertOrUpdate) return true; |
| | | if (hasMaterialOut) |
| | | { |
| | | throw new Exception($"MES有领料记录,单号:{mesSalesReturn.BillNo},不能删除!"); |
| | | } |
| | | var update = true; |
| | | if (mesSalesReturn != null) |
| | | { |
| | | if (mesSalesReturn.Id != null) |
| | | { |
| | | update = base.DeleteById(mesSalesReturn.Id); |
| | | } |
| | | } |
| | | var insertOrUpdate = true; |
| | | if (decimals != null || decimals.Length > 0) |
| | | { |
| | | insertOrUpdate = db.Deleteable<SalesReturnNoticeDetail>().In(decimals).ExecuteCommand() > 0; |
| | | } |
| | | |
| | | if (update && insertOrUpdate) |
| | | { |
| | | return true; |
| | | } |
| | | throw new NotImplementedException("更新失败"); |
| | | } |
| | | |