/// <summary> /// 删除指定的调度单 /// </summary> /// <param name="nId"></param> /// <param name="nOpStaffId"></param> /// <param name="strOpStaffName"></param> /// <param name="strErrText"></param> /// <returns></returns> public bool DeleteDispatchBill(long nId, long nOpStaffId, string strOpStaffName, out string strErrText) { try { using (TransactionScope transScope = new TransactionScope(TransactionScopeOption.Required, new TimeSpan(2, 0, 0))) { using (DispatchDAO dao = new DispatchDAO()) { //删除调度单数据 if (!dao.DeleteDispatchBill(nId, nOpStaffId, strOpStaffName, out strErrText)) { return(false); } //删除调度计划数据 if (!dao.DeleteDispatchBillDeliverPlans(nId, nOpStaffId, strOpStaffName, out strErrText)) { return(false); } //删除调度货物数据 if (!dao.DeleteDispatchBillAllGoods(nId, nOpStaffId, strOpStaffName, out strErrText)) { return(false); } } transScope.Complete(); } return(true); } catch (Exception e) { strErrText = e.Message; return(false); } }
/// <summary> /// 修改调度单 /// </summary> /// <param name="data"></param> /// <param name="listPlan"></param> /// <param name="nOpStaffId"></param> /// <param name="strOpStaffName"></param> /// <param name="strErrText"></param> /// <returns></returns> public bool UpdateDispatchBill(DispatchBill data, List <DispatchBillDeliverPlan> listPlan, long nOpStaffId, string strOpStaffName, out string strErrText) { try { using (TransactionScope transScope = new TransactionScope(TransactionScopeOption.Required, new TimeSpan(2, 0, 0))) { using (DispatchDAO dao = new DispatchDAO()) { #region 修改调度单数据 DispatchBill oldData = dao.LoadDispatchBill(data.Id, nOpStaffId, strOpStaffName, out strErrText); if (oldData == null) { return(false); } data.TotalPackages = oldData.TotalPackages; data.TotalTunnages = oldData.TotalTunnages; data.TotalPiles = oldData.TotalPiles; data.TotalTenThousands = oldData.TotalTenThousands; data.TotalTransportCharges = oldData.TotalTransportCharges; if (!dao.UpdateDispatchBill(data, nOpStaffId, strOpStaffName, out strErrText)) { return(false); } #endregion #region 修改调度计划数据 List <DispatchBillDeliverPlan> listOldPlan = dao.LoadDispatchBillDeliverPlans(data.Id, nOpStaffId, strOpStaffName, out strErrText); if (listOldPlan == null) { return(false); } if (!dao.DeleteDispatchBillDeliverPlans(data.Id, nOpStaffId, strOpStaffName, out strErrText)) { return(false); } foreach (DispatchBillDeliverPlan oldPlan in listOldPlan) { DispatchBillDeliverPlan newPlan = listPlan.Find(delegate(DispatchBillDeliverPlan p) { return(p.PlanId == oldPlan.PlanId); }); if (newPlan != null) { oldPlan.ReceiveType = newPlan.ReceiveType; } if (!dao.InsertDispatchBillDeliverPlan(oldPlan, nOpStaffId, strOpStaffName, out strErrText)) { return(false); } } #endregion #region 修改调度货物数据 List <DispatchBillGoods> listOldGoods = dao.LoadDispatchBillAllGoods(data.Id, nOpStaffId, strOpStaffName, out strErrText); if (listOldGoods == null) { return(false); } if (!dao.DeleteDispatchBillAllGoods(data.Id, nOpStaffId, strOpStaffName, out strErrText)) { return(false); } foreach (DispatchBillGoods goods in listOldGoods) { if (!dao.InsertDispatchBillGoods(goods, nOpStaffId, strOpStaffName, out strErrText)) { return(false); } } #endregion #region 校验调度单数据 if (!dao.CheckDispatchBill(data.Id, nOpStaffId, strOpStaffName, out strErrText)) { return(false); } #endregion } transScope.Complete(); } return(true); } catch (Exception e) { strErrText = e.Message; return(false); } }