public IHttpActionResult AddMoveDetail(List <MoveOrderDetail> moveDetails) { var movedDetailService = new MoveOrderDetailService(); bool isResult = true; try { moveDetails.ForEach(item => { var getMax = movedDetailService.GetAll().LastOrDefault().SnNum; var maxGet = Convert.ToInt32(getMax); maxGet++; var max = maxGet.ToString().PadLeft(6, '0'); item.SnNum = max; item.IsPick = 0; item.RealNum = item.Num; item.CreateTime = DateTime.Now; movedDetailService.Add(item); }); } catch (Exception) { isResult = false; throw; } var result = new { Msg = isResult ? "添加成功" : "添加失败" }; return(Json(result)); }
/// <summary> /// 查看移库主单信息以及详情信息 /// </summary> /// <param name="orderNum"></param> /// <returns></returns> public IHttpActionResult GetByOrderNum(string orderNum) { var moveService = new MoveService(); var moveList = moveService.GetAll().Where(item => item.OrderNum == orderNum); var moveDetailService = new MoveOrderDetailService(); var moveDetailList = moveDetailService.GetAll().Where(item => item.OrderNum == orderNum).OrderByDescending(item => item.CreateTime); var listObj = new List <Object>(); moveDetailList.ToList().ForEach(item => { var locationService = new LocationService(); var Fromlocation = locationService.FindByLocalNum(item.FromLocalNum); var Tolocation = locationService.FindByLocalNum(item.ToLocalNum); var obj = new { ID = item.ID, OrderNum = item.OrderNum, ProductName = item.ProductName, ProductNum = item.ProductNum, BarCode = item.BarCode, BatchNum = item.BatchNum, Num = item.Num, InPrice = item.InPrice, Amout = item.Amout, FromLocalNum = item.FromLocalNum, LocalName = Fromlocation.LocalName, ToLocalNum = item.ToLocalNum, ToLocalName = Tolocation.LocalName }; listObj.Add(obj); }); var result = new { MoveList = moveList, MoveDetailList = listObj }; return(Json(result)); }