/// <summary> /// 新增调度单货物数据 /// </summary> /// <param name="data"></param> /// <param name="nOpStaffId"></param> /// <param name="strOpStaffName"></param> /// <param name="strErrText"></param> /// <returns></returns> public bool InsertDispatchBillGoods(DispatchBillGoods data, long nOpStaffId, string strOpStaffName, out string strErrText) { //创建存储过程参数 SqlParameter[] Params = { MakeParam(DISPATCHBILLID_PARAM, SqlDbType.BigInt, 8, ParameterDirection.Input, (object)data.DispatchBillId), MakeParam(PLANID_PARAM, SqlDbType.BigInt, 8, ParameterDirection.Input, (object)data.PlanId), MakeParam(GOODSID_PARAM, SqlDbType.BigInt, 8, ParameterDirection.Input, (object)data.GoodsId), MakeParam(BATCHNO_PARAM, SqlDbType.NVarChar, 20, ParameterDirection.Input, (object)data.BatchNo??string.Empty), MakeParam(PACKING_PARAM, SqlDbType.NVarChar, 10, ParameterDirection.Input, (object)data.Packing??string.Empty), MakeParam(LOCATION_PARAM, SqlDbType.NVarChar, 10, ParameterDirection.Input, (object)data.Location??string.Empty), MakeParam(PACKAGES_PARAM, SqlDbType.Int, 4, ParameterDirection.Input, (object)data.Packages), MakeParam(PIECEWEIGHT_PARAM, SqlDbType.Decimal, 13, ParameterDirection.Input, (object)data.PieceWeight), MakeParam(TUNNAGES_PARAM, SqlDbType.Decimal, 13, ParameterDirection.Input, (object)data.Tunnages), MakeParam(PILES_PARAM, SqlDbType.Decimal, 13, ParameterDirection.Input, (object)data.Piles), MakeParam(TENTHOUSANDS_PARAM, SqlDbType.Decimal, 13, ParameterDirection.Input, (object)data.TenThousands), MakeParam(PRODUCTIONDATE_PARAM, SqlDbType.NVarChar, 10, ParameterDirection.Input, (object)data.ProductionDate??string.Empty), MakeParam(ENTERWAREHOUSEBILLID_PARAM, SqlDbType.BigInt, 8, ParameterDirection.Input, (object)data.EnterWarehouseBillId), MakeParam(OPSTAFFID_PARAM, SqlDbType.BigInt, 8, ParameterDirection.Input, (object)nOpStaffId), MakeParam(OPSTAFFNAME_PARAM, SqlDbType.NVarChar, 50, ParameterDirection.Input, (object)strOpStaffName), }; if (Execute("InsertDispatchBillGoods", Params, out strErrText) >= 0) return true; else return false; }
public ActionResult ModifyDispatchedPlan(DispatchBillViewModel model) { if (ModelState.IsValid) { //创建调度计划数据 int nTotalPackages = 0; decimal decTotalTunnages = 0; decimal decTotalPiles = 0; decimal decTotalTenThousands = 0; decimal decTotalTransportCharges = 0; List<DispatchBillDeliverPlan> listDeliverPlan = new List<DispatchBillDeliverPlan>(); if (model.DeliverPlans != null) { foreach (DispatchBillDeliverPlanViewModel m in model.DeliverPlans) { DispatchBillDeliverPlan deliverPlan = new DispatchBillDeliverPlan(); deliverPlan.DispatchBillId = model.Id; deliverPlan.PlanId = m.PlanId; deliverPlan.Packages = m.Packages; deliverPlan.Tunnages = m.Tunnages; deliverPlan.Piles = m.Piles; deliverPlan.TenThousands = m.TenThousands; deliverPlan.TransportChargeExpression = m.TransportChargeExpression; deliverPlan.TransportPriceExpression = m.TransportPriceExpression; deliverPlan.KM = m.KM; deliverPlan.TransportPrice = m.ActualTransportPrice; deliverPlan.TransportCharges = m.TransportCharges; deliverPlan.Remark = m.Remark; listDeliverPlan.Add(deliverPlan); nTotalPackages += m.Packages; decTotalTunnages += m.Tunnages; decTotalPiles += m.Piles; decTotalTenThousands += m.TenThousands; decTotalTransportCharges += m.TransportCharges; } } //创建调度货物数据 List<DispatchBillGoods> listGoods = new List<DispatchBillGoods>(); if (model.Goods != null) { foreach (DispatchBillGoodsViewModel m in model.Goods) { DispatchBillGoods goods = new DispatchBillGoods(); goods.DispatchBillId = model.Id; goods.PlanId = m.PlanId; goods.GoodsId = m.GoodsId; goods.GoodsNo = m.GoodsNo; goods.GoodsName = m.GoodsName; goods.Brand = m.Brand; goods.SpecModel = m.SpecModel; goods.GWeight = m.GWeight; goods.Grade = m.Grade; goods.PieceWeight = m.PieceWeight; goods.Packing = m.Packing; goods.BatchNo = m.BatchNo; goods.Location = m.Location; goods.Packages = m.Packages; goods.Tunnages = m.Tunnages; goods.Piles = m.Piles; goods.TenThousands = m.TenThousands; goods.ProductionDate = m.ProductionDate; goods.EnterWarehouseBillId = m.EnterWarehouseBillId; goods.EnterWarehouseBillNo = m.EnterWarehouseBillNo; listGoods.Add(goods); } } //创建调度单数据 DispatchBill bill = new DispatchBill(); bill.Id = model.Id; bill.CarNo = model.CarNo; bill.TrailerNo = model.TrailerNo; bill.CarType = model.CarType; bill.DriverName = model.DriverName; bill.DriverLicenseNo = model.DriverLicenseNo; bill.DriverMobileTel = model.DriverMobileTel; bill.DriverHomeTel = model.DriverHomeTel; bill.CarrierId = model.CarrierId; bill.CarrierName = model.CarrierName; bill.CarryingCapacity = model.CarryingCapacity; bill.BusinessType = model.BusinessType; bill.PaymentType = model.PaymentType; bill.TotalPackages = nTotalPackages; bill.TotalTunnages = decTotalTunnages; bill.TotalPiles = decTotalPiles; bill.TotalTenThousands = decTotalTenThousands; bill.TotalTransportCharges = decTotalTransportCharges; bill.CreateTime = DateTime.Parse(model.CreateTime); //保存数据 string strErrText; DispatchSystem dispatch = new DispatchSystem(); if (dispatch.UpdateDispatchBill(bill, listDeliverPlan, listGoods, LoginAccountId, LoginStaffName, out strErrText)) { return Json(string.Empty); } else { return Json(strErrText); } } return View(model); }