public ActionResult OutWarehouse(OutWarehouseBillViewModel model) { if (ModelState.IsValid) { //检查承运单位 if (model.OutType == InnoSoft.LS.Resources.Options.DeliverGoods) { if (model.CarrierId == 0 || model.CarrierName == string.Empty) { return Json(InnoSoft.LS.Resources.Strings.NotEnterCarrierInfoWhenDeliverGoods); } } //创建数据 OutWarehouseBill bill = new OutWarehouseBill(); bill.Id = model.Id; bill.BillNo = model.BillNo; bill.PlanId = model.PlanId; bill.CustomerId = model.CustomerId; bill.CustomerName = model.CustomerName; bill.DeliveryNo = model.DeliveryNo; bill.OutType = model.OutType; bill.ReceiverName = model.ReceiverName; bill.ReceiverCountry = model.ReceiverCountry; bill.ReceiverProvince = model.ReceiverProvince; bill.ReceiverCity = model.ReceiverCity; bill.ReceiverAddress = model.ReceiverAddress; bill.ReceiverContact = model.ReceiverContact; bill.ReceiverContactTel = model.ReceiverContactTel; bill.ReceiveType = model.ReceiveType; bill.CarNo = model.CarNo; bill.TrailerNo = model.TrailerNo; bill.CarrierId = model.CarrierId; bill.CarrierName = model.CarrierName; bill.PayerId = model.PayerId; bill.PayerName = model.PayerName; bill.IsConsigning = model.IsConsigning; bill.ConsignedDeliveryNo = model.ConsignedDeliveryNo; bill.Warehouse = model.Warehouse; bill.LoadingForceFeePrice = model.LoadingForceFeePrice; bill.ForceFee = model.ForceFee; bill.Remark = model.Remark; bill.CreateTime = DateTime.Parse(model.CreateTime); List<OutWarehouseBillGoods> listGoods = new List<OutWarehouseBillGoods>(); foreach (OutWarehouseBillGoodsViewModel m in model.Goods) { OutWarehouseBillGoods g = new OutWarehouseBillGoods(); g.Id = m.Id; g.OutWarehouseBillId = m.OutWarehouseBillId; g.GoodsId = m.GoodsId; g.GoodsName = m.GoodsName; g.GoodsNo = m.GoodsNo; g.Brand = m.Brand; g.SpecModel = m.SpecModel; g.GWeight = m.GWeight; g.Grade = m.Grade; g.PieceWeight = m.PieceWeight; g.Packing = m.Packing; g.BatchNo = m.BatchNo; g.Location = m.Location; g.Packages = m.Packages; g.Tunnages = m.Tunnages; g.Piles = m.Piles; g.TenThousands = m.TenThousands; g.ProductionDate = m.ProductionDate; g.EnterWarehouseBillId = m.EnterWarehouseBillId; listGoods.Add(g); } string strErrText; StockSystem stock = new StockSystem(); if (bill.Id > 0) { if (stock.UpdateOutWarehouseBill(bill, listGoods, LoginAccountId, LoginStaffName, out strErrText)) { return Json(string.Empty); } else { return Json(strErrText); } } else { if (stock.InsertOutWarehouseBill(bill, listGoods, LoginAccountId, LoginStaffName, out strErrText) > 0) { return Json(string.Empty); } else { return Json(strErrText); } } } return View(model); }