| | |
| | | case "6": |
| | | return DeleteData(db, mesDeliveryNoteBarcode) ? 1: 0; |
| | | default: |
| | | throw new ArgumentNullException( |
| | | $"type没有{barcode.Type}这个类型的参数"); |
| | | throw new ArgumentNullException($"type没有{barcode.Type}这个类型的参数"); |
| | | } |
| | | |
| | | throw new NotImplementedException("操作失败"); |
| | | }) > 0; |
| | | } |
| | | |
| | | // 插入数据的方法 |
| | | private bool InsertData(SqlSugarScope db, MesDeliveryNoteBarcode mesDeliveryNoteBarcode) |
| | | { |
| | | |
| | | if (mesDeliveryNoteBarcode.Id != null) base.DeleteById(mesDeliveryNoteBarcode.Id); |
| | | |
| | | var insert = base.Insert(mesDeliveryNoteBarcode); |
| | | |
| | | if (insert) return true; |
| | | throw new NotImplementedException("插入失败"); |
| | | } |
| | | |
| | | // 更新数据的方法 |
| | |
| | | |
| | | if (detect) return true; |
| | | throw new NotImplementedException("更新失败"); |
| | | } |
| | | |
| | | // 删除数据的方法 |
| | | private bool DeleteBarcode(SqlSugarScope db, DelBarcode barcode) |
| | | { |
| | | var del = db.Deleteable<MesDeliveryNoteBarcode>().Where(s => s.SmallBarcode == barcode.SmallBarcode).ExecuteCommand() > 0; |
| | | |
| | | if (del) |
| | | { |
| | | return true; |
| | | } |
| | | throw new NotImplementedException("删除失败"); |
| | | } |
| | | |
| | | public dynamic Delete(DelBarcode barcode) |
| | | { |
| | | return UseTransaction(db => |
| | | { |
| | | return DeleteBarcode(db, barcode) ? 1 : 0; |
| | | }) > 0; |
| | | } |
| | | |
| | | public dynamic DeleteList(List<DelBarcode> barcode) |
| | | { |
| | | var result = barcode.Select(Delete).ToList(); |
| | | return result.All(b => b); |
| | | } |
| | | |
| | | // 插入或更新数据的方法 |
| | |
| | | { |
| | | var result = barcodes.Select(Save).ToList(); |
| | | return result.All(b => b); |
| | | /* var list = barcodes.Select(GetMesDeliveryNoteBarcode).ToList(); |
| | | var groupBy = list.GroupBy(s => s.Type) |
| | | .ToDictionary(g => g.Key, g => g.ToList()); |
| | | |
| | | return UseTransaction(db => |
| | | { |
| | | foreach (var barcodeGroup in groupBy) |
| | | switch (barcodeGroup.Key) |
| | | { |
| | | case "1": |
| | | if (!UpdateItemStatusBatch(db, barcodeGroup.Value, "B")) |
| | | throw new NotImplementedException("禁用失败"); |
| | | break; |
| | | case "2": |
| | | if (!InsertItemBatch(db, barcodeGroup.Value)) |
| | | throw new NotImplementedException("插入失败"); |
| | | break; |
| | | default: |
| | | throw new ArgumentNullException( |
| | | $"type没有{barcodeGroup.Key}这个类型的参数"); |
| | | } |
| | | |
| | | return 1; |
| | | }) > 0; */ |
| | | } |
| | | |
| | | /* private bool InsertItemBatch(SqlSugarScope db, List<MesDeliveryNoteBarcode> barcodeList) |
| | | { |
| | | var insertRange = db.Insertable(barcodeList).ExecuteCommand(); |
| | | if (insertRange > 0) |
| | | return true; |
| | | |
| | | throw new NotImplementedException("插入失败"); |
| | | } |
| | | |
| | | private bool DeleteItemBatch(SqlSugarScope db, List<MesDeliveryNoteBarcode> barcodeList) |
| | | { |
| | | var ids = barcodeList.Select(it => it.Id).ToArray(); |
| | | var deleteByIds = db.Deleteable<MesItems>().In(ids).ExecuteCommand(); |
| | | if (deleteByIds > 0) |
| | | return true; |
| | | |
| | | throw new NotImplementedException("删除失败"); |
| | | } */ |
| | | |
| | | |
| | | public MesDeliveryNoteBarcode GetMesDeliveryNoteBarcode(ErpBarcode barcode) |
| | | { |