Example #1
0
        /// <summary>
        /// 合并调度单
        /// </summary>
        /// <param name="strIds"></param>
        /// <param name="nOpStaffId"></param>
        /// <param name="strOpStaffName"></param>
        /// <param name="bShipmentBillMerged"></param>
        /// <param name="bDeliverBillMerged"></param>
        /// <param name="strErrText"></param>
        /// <returns></returns>
        public long MergeDispatchBills(string strIds, long nOpStaffId, string strOpStaffName, out bool bShipmentBillMerged, out bool bDeliverBillMerged, out string strErrText)
        {
            long nNewId = 0;

            try
            {
                using (TransactionScope transScope = new TransactionScope(TransactionScopeOption.Required, new TimeSpan(2, 0, 0)))
                {
                    using (DispatchDAO dao = new DispatchDAO())
                    {
                        nNewId = dao.MergeDispatchBills(strIds, nOpStaffId, strOpStaffName, out bShipmentBillMerged, out bDeliverBillMerged, out strErrText);
                        if (nNewId <= 0)
                        {
                            return(0);
                        }
                    }
                    transScope.Complete();
                }
                return(nNewId);
            }
            catch (Exception e)
            {
                bShipmentBillMerged = false;
                bDeliverBillMerged  = false;
                strErrText          = e.Message;
                return(0);
            }
        }
Example #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 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);
            }
        }
 public ActionResult Edit(int id)
 {
     if (id > 0)
     {
         return(View(DispatchDAO.GetDispatchByID(id)));
     }
     else
     {
         return(RedirectToAction("Index"));
     }
 }
        //
        // GET: /Dispatch/Details/5

        public ActionResult Details(int id)
        {
            DispatchModel dispatch = DispatchDAO.GetDispatchByID(id);

            if (dispatch != null)
            {
                return(View(dispatch));
            }
            else
            {
                return(RedirectToAction("index"));
            }
        }
Example #5
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 long InsertContract(Contract data, List <ContractDeliverPlan> listPlan, long nOpStaffId, string strOpStaffName, out string strErrText)
        {
            long nContractId = 0;

            try
            {
                using (TransactionScope transScope = new TransactionScope(TransactionScopeOption.Required, new TimeSpan(2, 0, 0)))
                {
                    using (ContractDAO dao = new ContractDAO())
                    {
                        //新增合同数据
                        nContractId = dao.InsertContract(data, nOpStaffId, strOpStaffName, out strErrText);
                        if (nContractId <= 0)
                        {
                            return(0);
                        }

                        //新增合同计划数据
                        foreach (ContractDeliverPlan plan in listPlan)
                        {
                            plan.ContractId = nContractId;

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

                    using (DispatchDAO dao = new DispatchDAO())
                    {
                        //检查调度单数据
                        if (!dao.CheckDispatchBill(data.DispatchBillId, nOpStaffId, strOpStaffName, out strErrText))
                        {
                            return(0);
                        }
                    }
                    transScope.Complete();
                }
                return(nContractId);
            }
            catch (Exception e)
            {
                strErrText = e.Message;
                return(0);
            }
        }
        public ActionResult Create(FormCollection collection)
        {
            try
            {
                DispatchModel form = new DispatchModel();

                TryUpdateModel <DispatchModel>(form, collection.ToValueProvider());

                int rowsAffected = DispatchDAO.Insert(form);

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(RedirectToAction("Create"));
            }
        }
Example #7
0
        /// <summary>
        /// 修改合同发货数据
        /// </summary>
        /// <param name="data"></param>
        /// <param name="listGoods"></param>
        /// <param name="nOpStaffId"></param>
        /// <param name="strOpStaffName"></param>
        /// <param name="strErrText"></param>
        /// <returns></returns>
        public bool UpdateContractDeliverPlan(ContractDeliverPlan data, List <ContractGoods> listGoods, long nOpStaffId, string strOpStaffName, out string strErrText)
        {
            try
            {
                using (TransactionScope transScope = new TransactionScope(TransactionScopeOption.Required, new TimeSpan(2, 0, 0)))
                {
                    using (ContractDAO dao = new ContractDAO())
                    {
                        if (!dao.UpdateContractDeliverPlan(data, nOpStaffId, strOpStaffName, out strErrText))
                        {
                            return(false);
                        }

                        foreach (ContractGoods goods in listGoods)
                        {
                            if (!dao.UpdateContractGoods(goods, nOpStaffId, strOpStaffName, out strErrText))
                            {
                                return(false);
                            }
                        }
                    }

                    using (DispatchDAO dao = new DispatchDAO())
                    {
                        //检查调度单数据
                        if (!dao.CheckDispatchBill(data.DispatchBillId, nOpStaffId, strOpStaffName, out strErrText))
                        {
                            return(false);
                        }
                    }
                    transScope.Complete();
                }
                return(true);
            }
            catch (Exception e)
            {
                strErrText = e.Message;
                return(false);
            }
        }
Example #8
0
        /// <summary>
        /// 合同退回修改
        /// </summary>
        /// <param name="nId"></param>
        /// <param name="nOpStaffId"></param>
        /// <param name="strOpStaffName"></param>
        /// <param name="strErrText"></param>
        /// <returns></returns>
        public bool ReturnModifyContract(long nId, long nOpStaffId, string strOpStaffName, out string strErrText)
        {
            try
            {
                using (TransactionScope transScope = new TransactionScope(TransactionScopeOption.Required, new TimeSpan(2, 0, 0)))
                {
                    //修改合同数据
                    Contract data = null;
                    using (ContractDAO dao = new ContractDAO())
                    {
                        data = dao.LoadContract(nId, nOpStaffId, strOpStaffName, out strErrText);
                        if (data == null)
                        {
                            return(false);
                        }

                        if (!dao.ReturnModifyContract(nId, nOpStaffId, strOpStaffName, out strErrText))
                        {
                            return(false);
                        }
                    }

                    //检查调度单数据
                    using (DispatchDAO dao = new DispatchDAO())
                    {
                        if (!dao.CheckDispatchBill(data.DispatchBillId, nOpStaffId, strOpStaffName, out strErrText))
                        {
                            return(false);
                        }
                    }
                    transScope.Complete();
                }
                return(true);
            }
            catch (Exception e)
            {
                strErrText = e.Message;
                return(false);
            }
        }
Example #9
0
        /// <summary>
        /// 根据发货计划编码和货物编码读取货物调度数据
        /// </summary>
        /// <param name="strPlanId"></param>
        /// <param name="strGoodsId"></param>
        /// <param name="strBatchNo"></param>
        /// <param name="strPacking"></param>
        /// <param name="strLocation"></param>
        /// <param name="strProductionDate"></param>
        /// <param name="strEnterWarehouseBillId"></param>
        /// <param name="nOpStaffId"></param>
        /// <param name="strOpStaffName"></param>
        /// <param name="strErrText"></param>
        /// <returns></returns>
        public List <DispatchBillGoods> LoadAllDispatchBillGoodsByConditions(string strPlanId, string strGoodsId, string strBatchNo, string strPacking, string strLocation, string strProductionDate, string strEnterWarehouseBillId, long nOpStaffId, string strOpStaffName, out string strErrText)
        {
            try
            {
                List <DispatchBillGoods> dataResult = null;
                strErrText = String.Empty;

                using (TransactionScope transScope = new TransactionScope(TransactionScopeOption.Required, new TimeSpan(2, 0, 0)))
                {
                    using (DispatchDAO dao = new DispatchDAO())
                    {
                        dataResult = dao.LoadAllDispatchBillGoodsByConditions(strPlanId, strGoodsId, strBatchNo, strPacking, strLocation, strProductionDate, strEnterWarehouseBillId, nOpStaffId, strOpStaffName, out strErrText);
                    }
                    transScope.Complete();
                }
                return(dataResult);
            }
            catch (Exception e)
            {
                strErrText = e.Message;
                return(null);
            }
        }
Example #10
0
 /// <summary>
 /// 取消调度单
 /// </summary>
 /// <param name="nId"></param>
 /// <param name="nOpStaffId"></param>
 /// <param name="strOpStaffName"></param>
 /// <param name="strErrText"></param>
 /// <returns></returns>
 public bool CancelDispatchBill(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.CancelDispatchBill(nId, nOpStaffId, strOpStaffName, out strErrText))
                 {
                     return(false);
                 }
             }
             transScope.Complete();
         }
         return(true);
     }
     catch (Exception e)
     {
         strErrText = e.Message;
         return(false);
     }
 }
Example #11
0
        /// <summary>
        /// 读取指定纸发货计划的待调度货物数据
        /// </summary>
        /// <param name="nPlanId"></param>
        /// <param name="nOpStaffId"></param>
        /// <param name="strOpStaffName"></param>
        /// <param name="strErrText"></param>
        /// <returns></returns>
        public List <DispatchBillGoods> LoadDispatchPaperPlanAllGoods(long nPlanId, long nOpStaffId, string strOpStaffName, out string strErrText)
        {
            try
            {
                List <DispatchBillGoods> dataResult = null;
                strErrText = String.Empty;

                using (TransactionScope transScope = new TransactionScope(TransactionScopeOption.Required, new TimeSpan(2, 0, 0)))
                {
                    using (DispatchDAO dao = new DispatchDAO())
                    {
                        dataResult = dao.LoadDispatchPaperPlanAllGoods(nPlanId, nOpStaffId, strOpStaffName, out strErrText);
                    }
                    transScope.Complete();
                }
                return(dataResult);
            }
            catch (Exception e)
            {
                strErrText = e.Message;
                return(null);
            }
        }
        //
        // GET: /Dispatch/

        public ActionResult Index(int?page)
        {
            if (page.HasValue)
            {
                ViewBag.Page = page;
                return(View(DispatchDAO.List(page.Value)));
            }
            else
            {
                ViewBag.Page = page;
                Boolean disablePaging = false;
                Boolean.TryParse(ConfigurationManager.AppSettings["DisablePaging"].ToString(), out disablePaging);

                if (disablePaging == false)
                {
                    return(RedirectToAction("Index", new { @page = 0 }));
                }
                else
                {
                    return(View(DispatchDAO.List()));
                }
            }
        }
Example #13
0
        /// <summary>
        /// 读取指定车号的待提交调度单数据
        /// </summary>
        /// <param name="strCarNo"></param>
        /// <param name="nOpStaffId"></param>
        /// <param name="strOpStaffName"></param>
        /// <param name="strErrText"></param>
        /// <returns></returns>
        public DispatchBill LoadSubmitDispatchBillByCarNo(string strCarNo, long nOpStaffId, string strOpStaffName, out string strErrText)
        {
            try
            {
                DispatchBill dataResult = null;
                strErrText = String.Empty;

                using (TransactionScope transScope = new TransactionScope(TransactionScopeOption.Required, new TimeSpan(2, 0, 0)))
                {
                    using (DispatchDAO dao = new DispatchDAO())
                    {
                        dataResult = dao.LoadSubmitDispatchBillByCarNo(strCarNo, nOpStaffId, strOpStaffName, out strErrText);
                    }
                    transScope.Complete();
                }
                return(dataResult);
            }
            catch (Exception e)
            {
                strErrText = e.Message;
                return(null);
            }
        }
Example #14
0
        /// <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);
            }
        }
        public ActionResult Edit(int id, FormCollection collection)
        {
            DispatchModel form = new DispatchModel();

            try
            {
                TryUpdateModel <DispatchModel>(form, collection.ToValueProvider());

                int rowsAffected = DispatchDAO.UpdateForm(form);
            }
            catch
            {
                return(View());
            }

            try
            {
                return(RedirectToAction("Edit", new { id = form.FormID }));
            }
            catch
            {
                return(RedirectToAction("Index"));
            }
        }
Example #16
0
        /// <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);
            }
        }
Example #17
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);
            }
        }
Example #18
0
        /// <summary>
        /// 删除指定调度单编码和计划编码的已调度计划数据
        /// </summary>
        /// <param name="nDispatchBillId"></param>
        /// <param name="nPlanId"></param>
        /// <param name="nOpStaffId"></param>
        /// <param name="strOpStaffName"></param>
        /// <param name="strErrText"></param>
        /// <returns></returns>
        public bool DeleteDispatchedPlan(long nDispatchBillId, long nPlanId, 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     totalPackages         = 0;
                        decimal totalTunnages         = 0;
                        decimal totalPiles            = 0;
                        decimal totalTenThousands     = 0;
                        decimal totalTransportCharges = 0;

                        //读取当前调度计划数据
                        DispatchBillDeliverPlan deliverPlan = dao.LoadDispatchBillDeliverPlan(nDispatchBillId, nPlanId, nOpStaffId, strOpStaffName, out strErrText);
                        if (deliverPlan == null)
                        {
                            return(false);
                        }
                        totalPackages         = deliverPlan.Packages;
                        totalTunnages         = deliverPlan.Tunnages;
                        totalPiles            = deliverPlan.Piles;
                        totalTenThousands     = deliverPlan.TenThousands;
                        totalTransportCharges = deliverPlan.TransportCharges;

                        //删除当前调度计划数据
                        if (!dao.DeleteDispatchBillDeliverPlan(nDispatchBillId, nPlanId, nOpStaffId, strOpStaffName, out strErrText))
                        {
                            return(false);
                        }

                        //删除当前调度计划货物数据
                        if (!dao.DeleteDispatchBillDeliverPlanAllGoods(nDispatchBillId, nPlanId, nOpStaffId, strOpStaffName, out strErrText))
                        {
                            return(false);
                        }
                        #endregion

                        #region 修改调度单数据
                        //读取调度单原数据
                        DispatchBill bill = dao.LoadDispatchBill(nDispatchBillId, nOpStaffId, strOpStaffName, out strErrText);
                        if (bill == null)
                        {
                            return(false);
                        }
                        bill.TotalPackages         -= totalPackages;
                        bill.TotalTunnages         -= totalTunnages;
                        bill.TotalPiles            -= totalPiles;
                        bill.TotalTenThousands     -= totalTenThousands;
                        bill.TotalTransportCharges -= totalTransportCharges;

                        //如果调度单为空(即计划已经全部删除了),则同时删除调度单数据
                        if (bill.TotalPackages == 0 && bill.TotalPiles == 0)
                        {
                            if (!dao.DeleteDispatchBill(nDispatchBillId, nOpStaffId, strOpStaffName, out strErrText))
                            {
                                return(false);
                            }
                        }
                        else
                        {
                            if (!dao.UpdateDispatchBill(bill, nOpStaffId, strOpStaffName, out strErrText))
                            {
                                return(false);
                            }

                            if (!dao.CheckDispatchBill(nDispatchBillId, nOpStaffId, strOpStaffName, out strErrText))
                            {
                                return(false);
                            }
                        }
                        #endregion
                    }
                    transScope.Complete();
                }
                return(true);
            }
            catch (Exception e)
            {
                strErrText = e.Message;
                return(false);
            }
        }
Example #19
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);
            }
        }
Example #20
0
        /// <summary>
        /// 审批合同价格数据
        /// </summary>
        /// <param name="nId"></param>
        /// <param name="listPlan"></param>
        /// <param name="nOpStaffId"></param>
        /// <param name="strOpStaffName"></param>
        /// <param name="strMessage"></param>
        /// <returns></returns>
        public bool ApproveContract(long nId, List <ContractDeliverPlan> listPlan, long nOpStaffId, string strOpStaffName, out string strMessage)
        {
            strMessage = string.Empty;
            try
            {
                using (TransactionScope transScope = new TransactionScope(TransactionScopeOption.Required, new TimeSpan(2, 0, 0)))
                {
                    #region 修改审批价格数据

                    Contract data = null;
                    using (ContractDAO dao = new ContractDAO())
                    {
                        //读取合同数据
                        data = dao.LoadContract(nId, nOpStaffId, strOpStaffName, out strMessage);
                        if (data == null)
                        {
                            return(false);
                        }

                        //修改合同计划数据
                        foreach (ContractDeliverPlan plan in listPlan)
                        {
                            if (!dao.UpdateContractDeliverPlanApprovedTransportPrice(plan, nOpStaffId, strOpStaffName, out strMessage))
                            {
                                return(false);
                            }
                        }
                    }

                    using (DispatchDAO dao = new DispatchDAO())
                    {
                        //检查调度单数据
                        if (!dao.CheckDispatchBill(data.DispatchBillId, nOpStaffId, strOpStaffName, out strMessage))
                        {
                            return(false);
                        }
                    }

                    #endregion

                    #region 读取合同价格最大超出比例和超出金额

                    decimal decOverPercentage = 0;
                    decimal decOverAmount     = 0;

                    using (ContractDAO dao = new ContractDAO())
                    {
                        //读取合同价格超出比例
                        decOverPercentage = dao.LoadContractPriceOverPercentage(nId, nOpStaffId, strOpStaffName, out strMessage);

                        //读取合同价格超出金额
                        decOverAmount = dao.LoadContractPriceOverAmount(nId, nOpStaffId, strOpStaffName, out strMessage);
                    }

                    #endregion

                    #region 处理合同价格审批流程

                    int    nCurrentStepNum        = data.ApproveFlowStepNum;
                    int    nApproveFlowStepNum    = 0;
                    string strApproveFlowStepName = string.Empty;
                    long   nApproverId            = 0;
                    string strApproverName        = string.Empty;

                    using (FlowDAO dao = new FlowDAO())
                    {
                        List <ApproveFlowStep> listStep = dao.LoadApproveFlowNextStepsByFlowTypeAndStepNum(InnoSoft.LS.Resources.Options.PriceApproveFlow, nCurrentStepNum, nOpStaffId, strOpStaffName, out strMessage);
                        if (listStep == null)
                        {
                            return(false);
                        }
                        if (listStep.Count > 0)
                        {
                            int nStepIndex = 0;
                            for (nStepIndex = 0; nStepIndex < listStep.Count; nStepIndex++)
                            {
                                //获取审批步骤数据
                                long   nStepId                = listStep[nStepIndex].Id;
                                string strStepName            = listStep[nStepIndex].StepName;
                                int    nStepNum               = listStep[nStepIndex].StepNum;
                                long   nDisposerId            = listStep[nStepIndex].DisposerId;
                                string strDisposerName        = listStep[nStepIndex].DisposerName;
                                string strConditionExpression = listStep[nStepIndex].ConditionExpression;

                                //读取审批步骤条件数据
                                List <ApproveFlowStepCondition> listCondition = dao.LoadApproveFlowStepConditionsByStepId(nStepId, nOpStaffId, strOpStaffName, out strMessage);
                                if (listCondition == null)
                                {
                                    return(false);
                                }

                                //创建条件运算结果中间变量
                                string[] arrayIntermediateResults = new string[listCondition.Count + 1];//为什么加1?因为条件序号是从1开始的

                                //对每个条件进行运算,运算结果存入中间变量中
                                int nConditionIndex = 0;
                                for (nConditionIndex = 0; nConditionIndex < listCondition.Count; nConditionIndex++)
                                {
                                    //获取条件数据
                                    string strFieldName       = listCondition[nConditionIndex].FieldName;
                                    string strCompareOperator = listCondition[nConditionIndex].CompareOperator;
                                    string strFieldValue      = listCondition[nConditionIndex].FieldValue;

                                    if (strFieldName == InnoSoft.LS.Resources.Options.OverPercentage)
                                    {
                                        decimal decFieldValue = decimal.Parse(strFieldValue);

                                        if (strCompareOperator == InnoSoft.LS.Resources.Options.Equal)
                                        {
                                            arrayIntermediateResults[nConditionIndex + 1] = ((bool)(decOverPercentage == decFieldValue)).ToString();
                                        }
                                        else if (strCompareOperator == InnoSoft.LS.Resources.Options.GreaterThanOrEqual)
                                        {
                                            arrayIntermediateResults[nConditionIndex + 1] = ((bool)(decOverPercentage >= decFieldValue)).ToString();
                                        }
                                        else if (strCompareOperator == InnoSoft.LS.Resources.Options.LessThanOrEqual)
                                        {
                                            arrayIntermediateResults[nConditionIndex + 1] = ((bool)(decOverPercentage <= decFieldValue)).ToString();
                                        }
                                        else if (strCompareOperator == InnoSoft.LS.Resources.Options.GreaterThan)
                                        {
                                            arrayIntermediateResults[nConditionIndex + 1] = ((bool)(decOverPercentage > decFieldValue)).ToString();
                                        }
                                        else if (strCompareOperator == InnoSoft.LS.Resources.Options.LessThan)
                                        {
                                            arrayIntermediateResults[nConditionIndex + 1] = ((bool)(decOverPercentage < decFieldValue)).ToString();
                                        }
                                        else if (strCompareOperator == InnoSoft.LS.Resources.Options.NotEqual)
                                        {
                                            arrayIntermediateResults[nConditionIndex + 1] = ((bool)(decOverPercentage != decFieldValue)).ToString();
                                        }
                                        else
                                        {
                                            strMessage = string.Format(InnoSoft.LS.Resources.Strings.OverPercentageConditionNotSupportOperator, strCompareOperator);
                                            return(false);
                                        }
                                    }
                                    else if (strFieldName == InnoSoft.LS.Resources.Options.OverAmount)
                                    {
                                        decimal decFieldValue = decimal.Parse(strFieldValue);

                                        if (strCompareOperator == InnoSoft.LS.Resources.Options.Equal)
                                        {
                                            arrayIntermediateResults[nConditionIndex + 1] = ((bool)(decOverAmount == decFieldValue)).ToString();
                                        }
                                        else if (strCompareOperator == InnoSoft.LS.Resources.Options.GreaterThanOrEqual)
                                        {
                                            arrayIntermediateResults[nConditionIndex + 1] = ((bool)(decOverAmount >= decFieldValue)).ToString();
                                        }
                                        else if (strCompareOperator == InnoSoft.LS.Resources.Options.LessThanOrEqual)
                                        {
                                            arrayIntermediateResults[nConditionIndex + 1] = ((bool)(decOverAmount <= decFieldValue)).ToString();
                                        }
                                        else if (strCompareOperator == InnoSoft.LS.Resources.Options.GreaterThan)
                                        {
                                            arrayIntermediateResults[nConditionIndex + 1] = ((bool)(decOverAmount > decFieldValue)).ToString();
                                        }
                                        else if (strCompareOperator == InnoSoft.LS.Resources.Options.LessThan)
                                        {
                                            arrayIntermediateResults[nConditionIndex + 1] = ((bool)(decOverAmount < decFieldValue)).ToString();
                                        }
                                        else if (strCompareOperator == InnoSoft.LS.Resources.Options.NotEqual)
                                        {
                                            arrayIntermediateResults[nConditionIndex + 1] = ((bool)(decOverAmount != decFieldValue)).ToString();
                                        }
                                        else
                                        {
                                            strMessage = string.Format(InnoSoft.LS.Resources.Strings.OverAmountConditionNotSupportOperator, strCompareOperator);
                                            return(false);
                                        }
                                    }
                                    else
                                    {
                                        strMessage = string.Format(InnoSoft.LS.Resources.Strings.NotSupportApproveCondition, strFieldName);
                                        return(false);
                                    }
                                }

                                //对所有条件运算的结果进行综合判断
                                bool bFinalResult;
                                if (listCondition.Count == 0)
                                {
                                    bFinalResult = true;
                                }
                                else if (listCondition.Count == 1)
                                {
                                    bFinalResult = bool.Parse(arrayIntermediateResults[1]);
                                }
                                else
                                {
                                    //根据条件组合表达式计算最终结果
                                    string strFinalConditionExpression = string.Format(strConditionExpression, arrayIntermediateResults);
                                    bFinalResult = Utils.CalculateApproveFlowStepConditionExpression(strFinalConditionExpression);
                                }

                                //根据最终结果决定下一个步骤
                                if (!bFinalResult)
                                {
                                    //如果不执行当前步骤,则继续匹配下一步骤
                                    continue;
                                }
                                else
                                {
                                    //设置当前审批人
                                    nApproveFlowStepNum    = nStepNum;
                                    strApproveFlowStepName = strStepName;
                                    nApproverId            = nDisposerId;
                                    strApproverName        = strDisposerName;

                                    break;
                                }
                            }
                        }
                    }

                    //修改合同审批人和审批状态
                    using (ContractDAO dao = new ContractDAO())
                    {
                        if (!dao.UpdateContractApprover(nId, nApproveFlowStepNum, strApproveFlowStepName, nApproverId, strApproverName, nOpStaffId, strOpStaffName, out strMessage))
                        {
                            return(false);
                        }

                        //修改合同状态为“已审批”
                        if (nApproverId == 0)
                        {
                            if (!dao.UpdateContractApproveState(nId, nOpStaffId, strOpStaffName, out strMessage))
                            {
                                return(false);
                            }
                        }
                    }

                    if (nApproverId > 0)
                    {
                        strMessage = string.Format(InnoSoft.LS.Resources.Strings.ContractNeedApprove, strApproverName);
                    }

                    #endregion

                    transScope.Complete();
                }
                return(true);
            }
            catch (Exception e)
            {
                strMessage = e.Message;
                return(false);
            }
        }
Example #21
0
        /// <summary>
        /// 取消出仓单
        /// </summary>
        /// <param name="nId"></param>
        /// <param name="nOpStaffId"></param>
        /// <param name="strOpStaffName"></param>
        /// <param name="strErrText"></param>
        /// <returns></returns>
        public bool CancelShipmentBill(long nId, 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;

                        //删除出仓单数据
                        if (!dao.DeleteShipmentBill(nId, nOpStaffId, strOpStaffName, out strErrText))
                        {
                            return(false);
                        }

                        //删除出仓单货物数据
                        if (!dao.DeleteShipmentBillAllGoods(nId, nOpStaffId, strOpStaffName, out strErrText))
                        {
                            return(false);
                        }
                    }

                    //删除出库单数据
                    using (StockDAO dao = new StockDAO())
                    {
                        //读取出库单数据
                        OutWarehouseBill bill = dao.LoadOutWarehouseBillByShipmentBillId(nId, nOpStaffId, strOpStaffName, out strErrText);
                        if (bill == null)
                        {
                            return(false);
                        }

                        //删除出库单数据
                        if (!dao.DeleteOutWarehouseBill(bill.Id, nOpStaffId, strOpStaffName, out strErrText))
                        {
                            return(false);
                        }

                        //删除出库单货物数据
                        if (!dao.DeleteOutWarehouseBillAllGoods(bill.Id, 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);
                            }

                            //删除入库单货物数据
                            if (!dao.DeleteEnterWarehouseBillAllGoods(bill.Id, nOpStaffId, strOpStaffName, out strErrText))
                            {
                                return(false);
                            }

                            //删除入库单数据
                            if (!dao.DeleteEnterWarehouseBill(bill.Id, 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);
                            }

                            //读取调度单数据
                            DispatchBill bill = dao.LoadDispatchBill(nDispatchBillId, nOpStaffId, strOpStaffName, out strErrText);
                            if (bill == null)
                            {
                                return(false);
                            }

                            //修改或删除调度单数据
                            bill.TotalPackages         = bill.TotalPackages - plan.Packages;
                            bill.TotalTunnages         = bill.TotalTunnages - plan.Tunnages;
                            bill.TotalPiles            = bill.TotalPiles - plan.Piles;
                            bill.TotalTenThousands     = bill.TotalTenThousands - plan.TenThousands;
                            bill.TotalTransportCharges = bill.TotalTransportCharges - plan.TransportCharges;

                            if (bill.TotalPackages == 0 && bill.TotalTunnages == 0 && bill.TotalPiles == 0 && bill.TotalTenThousands == 0)
                            {
                                if (!dao.DeleteDispatchBill(nDispatchBillId, nOpStaffId, strOpStaffName, out strErrText))
                                {
                                    return(false);
                                }
                            }
                            else
                            {
                                if (!dao.UpdateDispatchBill(bill, nOpStaffId, strOpStaffName, out strErrText))
                                {
                                    return(false);
                                }
                            }

                            //删除调度单计划数据
                            if (!dao.DeleteDispatchBillDeliverPlan(nDispatchBillId, nPlanId, nOpStaffId, strOpStaffName, out strErrText))
                            {
                                return(false);
                            }

                            //删除调度计划货物数据
                            if (!dao.DeleteDispatchBillDeliverPlanAllGoods(nDispatchBillId, nPlanId, nOpStaffId, strOpStaffName, out strErrText))
                            {
                                return(false);
                            }

                            //校验调度单数据
                            if (bill.TotalPackages != 0 || bill.TotalTunnages != 0 || bill.TotalPiles != 0 || bill.TotalTenThousands != 0)
                            {
                                if (!dao.CheckDispatchBill(nDispatchBillId, nOpStaffId, strOpStaffName, out strErrText))
                                {
                                    return(false);
                                }
                            }
                        }
                    }

                    //如果是划拨出库,则直接取消发货计划
                    if (strOutType == InnoSoft.LS.Resources.Options.AllocateGoods)
                    {
                        using (PlanDAO dao = new PlanDAO())
                        {
                            if (!dao.CancelDeliverPlan(nPlanId, nOpStaffId, strOpStaffName, out strErrText))
                            {
                                return(false);
                            }
                        }
                    }

                    transScope.Complete();
                }
                return(true);
            }
            catch (Exception e)
            {
                strErrText = e.Message;
                return(false);
            }
        }
Example #22
0
        /// <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);
            }
        }
Example #23
0
        /// <summary>
        /// 取消送货单数据
        /// </summary>
        /// <param name="nId"></param>
        /// <param name="nOpStaffId"></param>
        /// <param name="strOpStaffName"></param>
        /// <param name="strErrText"></param>
        /// <returns></returns>
        public bool CancelDeliverBill(long nId, long nOpStaffId, string strOpStaffName, out string strErrText)
        {
            try
            {
                strErrText = string.Empty;
                long nShipmentBillId = 0;
                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);
                        }
                        nShipmentBillId = bill.ShipmentBillId;
                        nDispatchBillId = bill.DispatchBillId;
                        nPlanId         = bill.PlanId;

                        //删除送货单数据
                        if (!dao.DeleteDeliverBill(nId, nOpStaffId, strOpStaffName, out strErrText))
                        {
                            return(false);
                        }

                        //删除送货单货物数据
                        if (!dao.DeleteDeliverBillAllGoods(nId, nOpStaffId, strOpStaffName, out strErrText))
                        {
                            return(false);
                        }

                        //删除出仓单数据
                        if (!dao.DeleteShipmentBill(nShipmentBillId, nOpStaffId, strOpStaffName, out strErrText))
                        {
                            return(false);
                        }

                        //删除出仓单货物数据
                        if (!dao.DeleteShipmentBillAllGoods(nShipmentBillId, nOpStaffId, strOpStaffName, out strErrText))
                        {
                            return(false);
                        }
                    }

                    using (StockDAO dao = new StockDAO())
                    {
                        //读取出库单数据
                        OutWarehouseBill bill = dao.LoadOutWarehouseBillByShipmentBillId(nShipmentBillId, nOpStaffId, strOpStaffName, out strErrText);
                        if (bill == null)
                        {
                            return(false);
                        }

                        //删除出库单数据
                        if (!dao.DeleteOutWarehouseBill(bill.Id, nOpStaffId, strOpStaffName, out strErrText))
                        {
                            return(false);
                        }

                        //删除出库单货物数据
                        if (!dao.DeleteOutWarehouseBillAllGoods(bill.Id, 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);
                        }

                        //读取调度单数据
                        DispatchBill bill = dao.LoadDispatchBill(nDispatchBillId, nOpStaffId, strOpStaffName, out strErrText);
                        if (bill == null)
                        {
                            return(false);
                        }

                        //修改或删除调度单数据
                        bill.TotalPackages         = bill.TotalPackages - plan.Packages;
                        bill.TotalTunnages         = bill.TotalTunnages - plan.Tunnages;
                        bill.TotalPiles            = bill.TotalPiles - plan.Piles;
                        bill.TotalTenThousands     = bill.TotalTenThousands - plan.TenThousands;
                        bill.TotalTransportCharges = bill.TotalTransportCharges - plan.TransportCharges;

                        if (bill.TotalPackages == 0 && bill.TotalTunnages == 0 && bill.TotalPiles == 0 && bill.TotalTenThousands == 0)
                        {
                            if (!dao.DeleteDispatchBill(nDispatchBillId, nOpStaffId, strOpStaffName, out strErrText))
                            {
                                return(false);
                            }
                        }
                        else
                        {
                            if (!dao.UpdateDispatchBill(bill, nOpStaffId, strOpStaffName, out strErrText))
                            {
                                return(false);
                            }
                        }

                        //删除调度单计划数据
                        if (!dao.DeleteDispatchBillDeliverPlan(nDispatchBillId, nPlanId, nOpStaffId, strOpStaffName, out strErrText))
                        {
                            return(false);
                        }

                        //删除调度计划货物数据
                        if (!dao.DeleteDispatchBillDeliverPlanAllGoods(nDispatchBillId, nPlanId, nOpStaffId, strOpStaffName, out strErrText))
                        {
                            return(false);
                        }

                        //校验调度单数据
                        if (bill.TotalPackages != 0 || bill.TotalTunnages != 0 || bill.TotalPiles != 0 || bill.TotalTenThousands != 0)
                        {
                            if (!dao.CheckDispatchBill(nDispatchBillId, nOpStaffId, strOpStaffName, out strErrText))
                            {
                                return(false);
                            }
                        }
                    }
                    transScope.Complete();
                }
                return(true);
            }
            catch (Exception e)
            {
                strErrText = e.Message;
                return(false);
            }
        }