public bool CreateDnDetail(long id, TOutDnD[] details) { var o = wmsoutbound.TOutDns.Where(x => x.Id == id).FirstOrDefault(); if (o == null) { return(false); } o.Qty = details.Sum(x => x.Qty); foreach (var d in details) { var n = new TOutDnD { HId = id, Sku = d.Sku, Barcode = d.Barcode, Qty = d.Qty, //IsDeleted = false, CreatedBy = "rickli", CreatedTime = DateTime.UtcNow, }; wmsoutbound.TOutDnDs.Add(n); } return(wmsoutbound.SaveChanges() > 0); }
public bool Upload(IFormFile file, long id, string code) { ioService.basePath = this.Root; //保存文件 DataTable dataTable = ioService.Import(file, "DN", code); var details = new List <TOutDnD>(); //写入到数据库 for (int i = 0; i < dataTable.Rows.Count; i++) { TOutDnD d = new TOutDnD(); d.HId = id; d.Barcode = dataTable.Rows[i]["barcode"].ToString(); d.Sku = dataTable.Rows[i]["sku"].ToString(); d.Qty = Convert.ToInt32(dataTable.Rows[i]["qty"].ToString()); d.CreatedBy = "rickli"; d.CreatedTime = DateTime.UtcNow; details.Add(d); } var r = CreateDnDetail(id, details.ToArray()); return(r); }