| | |
| | | }) > 0; |
| | | } |
| | | |
| | | // 插入数据的方法 |
| | | private bool InsertData(SqlSugarScope db, MesRohIn mesRohIn, |
| | | List<MesRohInData> mesRohInDatas, string FBILLTYPE) |
| | | { |
| | | switch (FBILLTYPE) |
| | | { |
| | | case "A": |
| | | { |
| | | var decimals = mesRohInDatas.Select(s => s.Id).ToArray(); |
| | | |
| | | if (mesRohIn.Id != null) base.DeleteById(mesRohIn.Id); |
| | | |
| | | if (decimals.Length > 0) |
| | | db.Deleteable<MesRohInData>().In(decimals).ExecuteCommand(); |
| | | |
| | | var insert = base.Insert(mesRohIn); |
| | | var insertRange = |
| | | rohInDataManager.InsertRange(mesRohInDatas); |
| | | |
| | | if (insert && insertRange) return true; |
| | | throw new NotImplementedException("插入失败"); |
| | | } |
| | | case "B": |
| | | { |
| | | var decimals = mesRohInDatas.Select(s => s.Id).ToArray(); |
| | | if (base.DeleteById(mesRohIn.Id) && db |
| | | .Deleteable<MesRohInData>().In(decimals) |
| | | .ExecuteCommand() > 0) |
| | | { |
| | | var insert = base.Insert(mesRohIn); |
| | | var insertRange = |
| | | rohInDataManager.InsertRange(mesRohInDatas); |
| | | |
| | | if (insert && insertRange) return true; |
| | | throw new NotImplementedException("插入失败"); |
| | | } |
| | | |
| | | break; |
| | | } |
| | | } |
| | | |
| | | throw new NotImplementedException("采购订单类型错误"); |
| | | } |
| | | |
| | | // 更新数据的方法 |
| | | private bool UpdateData(SqlSugarScope db, MesRohIn mesRohIn, |
| | | List<MesRohInData> mesRohInDatas) |
| | | { |
| | | var decimals = mesRohInDatas.Select(s => s.Id).ToArray(); |
| | | var update = base.DeleteById(mesRohIn.Id); |
| | | |
| | | var update = db.Deleteable<MesRohIn>() |
| | | .Where(a => a.Id == mesRohIn.Id) |
| | | .ExecuteCommand() > 0; |
| | | |
| | | var insertOrUpdate = db |
| | | .Deleteable<MesRohInData>().In(decimals) |
| | | .Deleteable<MesRohInData>() |
| | | .Where(s => decimals.Contains(s.Id)) |
| | | .ExecuteCommand() > 0; |
| | | |
| | | if (update && insertOrUpdate) return true; |
| | |
| | | private bool SaveOrUpdateData(SqlSugarScope db, MesRohIn mesRohIn, |
| | | List<MesRohInData> mesRohInDatas) |
| | | { |
| | | if (mesRohIn.Id != null) base.DeleteById(mesRohIn.Id); |
| | | if (mesRohIn.Id != null) |
| | | db.Deleteable<MesRohIn>().Where(s => s.Id == mesRohIn.Id) |
| | | .ExecuteCommand(); |
| | | |
| | | if (mesRohInDatas.Count > 0) |
| | | db.Deleteable<MesRohInData>() |