| | |
| | | { |
| | | public bool SaveList(List<ERPZZCXD> list) |
| | | { |
| | | var result = list.Select(Save).ToList(); |
| | | return result.All(b => b); |
| | | /*var result = list.Select(Save).ToList(); |
| | | return result.All(b => b);*/ |
| | | foreach (var item in list) |
| | | { |
| | | try |
| | | { |
| | | Save(item); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | throw new Exception($"单据 {item.Main.bill_no} 出错: {ex.Message}", ex); |
| | | } |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | public bool Save(ERPZZCXD data) |
| | |
| | | Memo = subDto.memo |
| | | }; |
| | | |
| | | var existingSub = Db.Queryable<ZZCXB>().Where(s => s.Eid == subEntity.Eid).Single(); |
| | | var existingSub = Db.Queryable<ZZCXB>().Where(s => s.Erpid == subEntity.Erpid).Single(); |
| | | if (existingSub != null) subEntity.Id = existingSub.Id; |
| | | |
| | | item.SubItems ??= new List<ZZCXB>(); |
| | |
| | | if (head.Id != null) |
| | | base.DeleteById(head.Id); |
| | | |
| | | |
| | | // 删除孙表 |
| | | db.Deleteable<ZZCXB>().Where(d => d.YdId == head.Erpid).ExecuteCommand(); |
| | | // 删除子表(使用 yd_id 作为关联) |
| | | db.Deleteable<ZZCXA>().Where(d => d.YdId == head.Erpid).ExecuteCommand(); |
| | | db.Deleteable<ZZCXB>().Where(d => d.Erpid == head.Erpid).ExecuteCommand(); |
| | | |
| | | // 删除主表 |
| | | db.Deleteable<ZZCX>().Where(d => d.Erpid == head.Erpid).ExecuteCommand(); |
| | | var insertedHead = db.Insertable(head) |
| | | .IgnoreColumns(true) |
| | | .ExecuteReturnIdentity(); |