/// <summary> /// 更新其他入库 /// </summary> /// <param name="otherIn"></param> /// <returns></returns> public ResultData <string> UpdateOtherIn(WOtherIn otherIn) { ResultData <string> rData = CheckValid(otherIn); if (rData.status != 0) { return(rData); } if (otherIn.StockStatus != StockStatusEnum.New) { rData.status = -1; rData.message = "单据已经审核,不能编辑."; return(rData); } DatabaseContext db = oiRepository.DbCondext; try { db.BeginTransaction(); otherIn.UpdateDate = DateTime.Now; oiRepository.Update(otherIn); foreach (var line in otherIn.Lines) { switch (line.CURD) { case CurdEnum.Add: line.ParentID = otherIn.ID; line.CreateBy = otherIn.CreateBy; line.CreateDate = DateTime.Now; line.Batch = string.IsNullOrEmpty(line.Batch) ? "" : line.Batch; oilRepository.Insert(line); break; case CurdEnum.Delete: oilRepository.Delete(line); break; case CurdEnum.Update: line.UpdateBy = otherIn.UpdateBy; line.UpdateDate = DateTime.Now; line.Batch = string.IsNullOrEmpty(line.Batch) ? "" : line.Batch; oilRepository.Update(line); break; } } db.CompleteTransaction(); } catch (Exception ex) { db.AbortTransaction(); throw ex; } return(rData); }