/// <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 UpdateShipmentBill(long nId, decimal decTransportCharges, List <ShipmentBillGoods> listGoods, long nOpStaffId, string strOpStaffName, out string strErrText) { try { strErrText = string.Empty; long nDispatchBillId = 0; long nPlanId = 0; string strOutType = string.Empty; using (TransactionScope transScope = new TransactionScope(TransactionScopeOption.Required, new TimeSpan(2, 0, 0))) { //修改出仓单货物数据 using (DeliverDAO dao = new DeliverDAO()) { ShipmentBill bill = dao.LoadShipmentBill(nId, nOpStaffId, strOpStaffName, out strErrText); if (bill == null) { return(false); } nDispatchBillId = bill.DispatchBillId; nPlanId = bill.PlanId; strOutType = bill.OutType; foreach (ShipmentBillGoods goods in listGoods) { if (!dao.UpdateShipmentBillGoods(goods, nOpStaffId, strOpStaffName, out strErrText)) { return(false); } } } //如果是划拨出库,则需要修改入库单 if (strOutType == InnoSoft.LS.Resources.Options.AllocateGoods) { using (StockDAO dao = new StockDAO()) { //读取入库单编码 EnterWarehouseBill bill = dao.LoadEnterWarehouseBillByPlanId(nPlanId, nOpStaffId, strOpStaffName, out strErrText); if (bill == null) { return(false); } long nEnterWarehouseBillId = bill.Id; //读取入库单货物数据 List <EnterWarehouseBillGoods> listEnterWarehouseBillGoods = dao.LoadEnterWarehouseBillAllGoods(nEnterWarehouseBillId, nOpStaffId, strOpStaffName, out strErrText); if (listEnterWarehouseBillGoods == null) { return(false); } foreach (EnterWarehouseBillGoods goods in listEnterWarehouseBillGoods) { int nNewPackages = 0; decimal decNewTunnages = 0; decimal decNewPiles = 0; decimal decNewTenThousands = 0; string[] strShipmentBillGoodsIds = goods.ShipmentBillGoodsIds.Split(','); foreach (string strShipmentBillGoodsId in strShipmentBillGoodsIds) { ShipmentBillGoods goods1 = listGoods.Find(delegate(ShipmentBillGoods g) { return(g.Id == long.Parse(strShipmentBillGoodsId)); }); if (goods1 == null) { strErrText = InnoSoft.LS.Resources.Strings.NotFoundShipmentBillGoodsForEnterWarehouseBill; return(false); } nNewPackages += goods1.Packages; decNewTunnages += goods1.Tunnages; decNewPiles += goods1.Piles; decNewTenThousands += goods1.TenThousands; } goods.Packages = nNewPackages; goods.Tunnages = decNewTunnages; goods.Piles = decNewPiles; goods.TenThousands = decNewTenThousands; if (!dao.UpdateEnterWarehouseBillGoods(goods, nOpStaffId, strOpStaffName, out strErrText)) { return(false); } } } } //如果是发货出库,则需要修改调度记录数据 if (strOutType == InnoSoft.LS.Resources.Options.DeliverGoods) { 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); } }
/// <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); } }
/// <summary> /// 修改调度单 /// </summary> /// <param name="bill"></param> /// <param name="listDeliverPlan"></param> /// <param name="listGoods"></param> /// <param name="nOpStaffId"></param> /// <param name="strOpStaffName"></param> /// <param name="strErrText"></param> /// <returns></returns> public bool UpdateDispatchBill(DispatchBill bill, List <DispatchBillDeliverPlan> listDeliverPlan, List <DispatchBillGoods> listGoods, 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 处理计划和货物数据 int totalOldPackages = 0; decimal totalOldTunnages = 0; decimal totalOldPiles = 0; decimal totalOldTenThousands = 0; decimal totalOldTransportCharges = 0; foreach (DispatchBillDeliverPlan newPlan in listDeliverPlan) { //读取当前调度计划原数据 DispatchBillDeliverPlan oldPlan = dao.LoadDispatchBillDeliverPlan(newPlan.DispatchBillId, newPlan.PlanId, nOpStaffId, strOpStaffName, out strErrText); if (oldPlan == null) { return(false); } totalOldPackages += oldPlan.Packages; totalOldTunnages += oldPlan.Tunnages; totalOldPiles += oldPlan.Piles; totalOldTenThousands += oldPlan.TenThousands; totalOldTransportCharges += oldPlan.TransportCharges; //修改当前调度计划新数据 if (!dao.UpdateDispatchBillDeliverPlan(newPlan, nOpStaffId, strOpStaffName, out strErrText)) { return(false); } //删除当前调度计划原货物数据 if (!dao.DeleteDispatchBillDeliverPlanAllGoods(newPlan.DispatchBillId, newPlan.PlanId, nOpStaffId, strOpStaffName, out strErrText)) { return(false); } //新增当前调度计划货物新数据 foreach (DispatchBillGoods goods in listGoods) { if (goods.DispatchBillId == newPlan.DispatchBillId && goods.PlanId == newPlan.PlanId) { if (!dao.InsertDispatchBillGoods(goods, nOpStaffId, strOpStaffName, out strErrText)) { return(false); } } } } #endregion #region 处理调度单数据 //读取调度单原数据 DispatchBill oldBill = dao.LoadDispatchBill(bill.Id, nOpStaffId, strOpStaffName, out strErrText); if (oldBill == null) { return(false); } bill.TotalPackages = oldBill.TotalPackages - totalOldPackages + bill.TotalPackages; bill.TotalTunnages = oldBill.TotalTunnages - totalOldTunnages + bill.TotalTunnages; bill.TotalPiles = oldBill.TotalPiles - totalOldPiles + bill.TotalPiles; bill.TotalTenThousands = oldBill.TotalTenThousands - totalOldTenThousands + bill.TotalTenThousands; bill.TotalTransportCharges = oldBill.TotalTransportCharges - totalOldTransportCharges + bill.TotalTransportCharges; if (!dao.UpdateDispatchBill(bill, nOpStaffId, strOpStaffName, out strErrText)) { return(false); } #endregion #region 校验调度单数据 if (!dao.CheckDispatchBill(bill.Id, nOpStaffId, strOpStaffName, out strErrText)) { return(false); } #endregion } transScope.Complete(); } return(true); } catch (Exception e) { strErrText = e.Message; return(false); } }