public void SaveTransport(Sender sender, SaveTransportArgs args) { try { using (ObjectProxy op = new ObjectProxy(true)) { TransportMain obj = new TransportMain(); obj.TransportID = args.TransportMain.TransportID; if (op.LoadTransportMainByTransportID(obj) == 0) { args.TransportMain.Created = DateTime.Now; args.TransportMain.CreatedBy = sender.UserCode + "." + sender.UserName; op.InsertTransportMain(args.TransportMain); } else { op.UpdateTransportMainByTransportID(args.TransportMain); } if (args.TransportDetails != null) { op.DeleteTransportDetailsByTransportID(args.TransportMain.TransportID); foreach (TransportDetail item in args.TransportDetails) { op.InsertTransportDetail(item); } } op.CommitTransaction(); } } catch (Exception ex) { PLogger.LogError(ex); throw ex; } }
/// <summary> /// 订单出库产品保存 /// </summary> public void SaveTransportMainOut() { try { using (ProxyBE p = new ProxyBE()) { TransportMain tm = new TransportMain(); tm.TransportID = Parm.TransportID; tm.TransportNo = Parm.TransportNo; tm.CarID = Parm.CarID; tm.Source = Parm.Source; tm.Target = Parm.Target; tm.Price = Parm.Price; SaveTransportArgs args = new SaveTransportArgs(); args.TransportMain = tm; //遍历详细页 List <TransportDetail> listdetails = new List <TransportDetail>(); string OutDetail = Request["OutDetail"]; JsonData sj = JsonMapper.ToObject(OutDetail); if (sj.Count > 0) { //遍历对象元素,保存 foreach (JsonData item in sj) { TransportDetail detail = new TransportDetail(); detail.TransportID = Parm.TransportID; detail.OrderID = Guid.Parse(item["OrderID"].ToString()); listdetails.Add(detail); #region 1.改变订单状态 Order order = p.Client.GetOrder(SenderUser, Guid.Parse(item["OrderID"].ToString())); order.Status = "F"; //已完成 SaveOrderArgs sargs = new SaveOrderArgs(); sargs.Order = order; p.Client.SaveOrder(SenderUser, sargs); #endregion #region 2.把存放对应的订单的仓位 设置为不占用、包数设为0、重量设为0 SearchProductWarehouseDetailArgs pargs = new SearchProductWarehouseDetailArgs(); pargs.RowNumberFrom = pagingParm.RowNumberFrom; pargs.RowNumberTo = pagingParm.RowNumberTo; pargs.OrderID = Guid.Parse(item["OrderID"].ToString()); SearchResult sr = p.Client.SearchProductWarehouseDetail(SenderUser, pargs); if (sr.Total > 0) { for (int i = 0; i < sr.DataSet.Tables[0].Rows.Count; i++) { DataRow dr = sr.DataSet.Tables[0].Rows[i]; Location location = p.Client.GetLocation(SenderUser, new Guid(dr["LocationID"].ToString())); location.Flag = false; location.PackageQty = 0; location.Weight = 0; SaveLocationArgs lags = new SaveLocationArgs(); lags.Location = location; p.Client.SaveLocation(SenderUser, lags); } } #endregion } } args.TransportDetails = listdetails; p.Client.SaveTransport(SenderUser, args); } WriteSuccess(); } catch (Exception ex) { WriteError(ex.Message, ex); } }