Exemplo n.º 1
0
        /// <summary>
        /// 读取指定调度单编码的已调度计划数据
        /// </summary>
        /// <param name="nDispatchBillId"></param>
        /// <param name="nOpStaffId"></param>
        /// <param name="strOpStaffName"></param>
        /// <param name="strErrText"></param>
        /// <returns></returns>
        public List <DispatchBillDeliverPlan> LoadDispatchBillDeliverPlans(long nDispatchBillId, long nOpStaffId, string strOpStaffName, out string strErrText)
        {
            try
            {
                List <DispatchBillDeliverPlan> dataResult = null;
                strErrText = String.Empty;

                using (TransactionScope transScope = new TransactionScope(TransactionScopeOption.Required, new TimeSpan(2, 0, 0)))
                {
                    using (DispatchDAO dao = new DispatchDAO())
                    {
                        dataResult = dao.LoadDispatchBillDeliverPlans(nDispatchBillId, nOpStaffId, strOpStaffName, out strErrText);
                    }
                    transScope.Complete();
                }
                return(dataResult);
            }
            catch (Exception e)
            {
                strErrText = e.Message;
                return(null);
            }
        }
Exemplo n.º 2
0
        /// <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);
            }
        }