예제 #1
0
        /// <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 long InsertDispatchBill(DispatchBill bill, List <DispatchBillDeliverPlan> listDeliverPlan, List <DispatchBillGoods> listGoods, long nOpStaffId, string strOpStaffName, out string strErrText)
        {
            long nDispatchBillId = 0;

            try
            {
                using (TransactionScope transScope = new TransactionScope(TransactionScopeOption.Required, new TimeSpan(2, 0, 0)))
                {
                    using (DispatchDAO dao = new DispatchDAO())
                    {
                        //新增计划数据
                        nDispatchBillId = dao.InsertDispatchBill(bill, nOpStaffId, strOpStaffName, out strErrText);
                        if (nDispatchBillId <= 0)
                        {
                            return(0);
                        }

                        //新增计划数据
                        foreach (DispatchBillDeliverPlan deliverPlan in listDeliverPlan)
                        {
                            deliverPlan.DispatchBillId = nDispatchBillId;

                            if (!dao.InsertDispatchBillDeliverPlan(deliverPlan, nOpStaffId, strOpStaffName, out strErrText))
                            {
                                return(0);
                            }
                        }

                        //新增货物数据
                        foreach (DispatchBillGoods goods in listGoods)
                        {
                            goods.DispatchBillId = nDispatchBillId;

                            if (!dao.InsertDispatchBillGoods(goods, nOpStaffId, strOpStaffName, out strErrText))
                            {
                                return(0);
                            }
                        }

                        //校验调度单数据
                        if (!dao.CheckDispatchBill(nDispatchBillId, nOpStaffId, strOpStaffName, out strErrText))
                        {
                            return(0);
                        }
                    }
                    transScope.Complete();
                }
                return(nDispatchBillId);
            }
            catch (Exception e)
            {
                strErrText = e.Message;
                return(0);
            }
        }
예제 #2
0
        /// <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);
            }
        }
예제 #3
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);
            }
        }