/// <summary> /// 修改送货单数据 /// </summary> /// <param name="nId"></param> /// <param name="decTransportCharges">运费</param> /// <param name="listGoods"></param> /// <param name="nOpStaffId"></param> /// <param name="strOpStaffName"></param> /// <param name="strErrText"></param> /// <returns></returns> public bool UpdateDeliverBill(long nId, decimal decTransportCharges, List <DeliverBillGoods> listGoods, long nOpStaffId, string strOpStaffName, out string strErrText) { try { strErrText = string.Empty; long nDispatchBillId = 0; long nPlanId = 0; using (TransactionScope transScope = new TransactionScope(TransactionScopeOption.Required, new TimeSpan(2, 0, 0))) { using (DeliverDAO dao = new DeliverDAO()) { //读取送货单数据 DeliverBill bill = dao.LoadDeliverBill(nId, nOpStaffId, strOpStaffName, out strErrText); if (bill == null) { return(false); } nDispatchBillId = bill.DispatchBillId; nPlanId = bill.PlanId; //修改货物数据 foreach (DeliverBillGoods goods in listGoods) { if (!dao.UpdateDeliverBillGoods(goods, nOpStaffId, strOpStaffName, out strErrText)) { return(false); } } } using (DispatchDAO dao = new DispatchDAO()) { //读取调度单计划数据 DispatchBillDeliverPlan plan = dao.LoadDispatchBillDeliverPlan(nDispatchBillId, nPlanId, nOpStaffId, strOpStaffName, out strErrText); if (plan == null) { return(false); } decimal decOldTransportCharges = plan.TransportCharges; //修改调度单计划数据 plan.TransportCharges = decTransportCharges; if (!dao.UpdateDispatchBillDeliverPlan(plan, nOpStaffId, strOpStaffName, out strErrText)) { return(false); } //读取调度单数据 DispatchBill bill = dao.LoadDispatchBill(nDispatchBillId, nOpStaffId, strOpStaffName, out strErrText); if (bill == null) { return(false); } //修改调度单数据 bill.TotalTransportCharges = bill.TotalTransportCharges - decOldTransportCharges + decTransportCharges; if (!dao.UpdateDispatchBill(bill, nOpStaffId, strOpStaffName, out strErrText)) { return(false); } //校验调度单数据 if (!dao.CheckDispatchBill(nDispatchBillId, nOpStaffId, strOpStaffName, out strErrText)) { return(false); } } transScope.Complete(); } return(true); } catch (Exception e) { strErrText = e.Message; return(false); } }