Ejemplo n.º 1
0
        /// <summary>
        /// 读取出库单数据
        /// </summary>
        /// <param name="nId"></param>
        /// <param name="nOpStaffId"></param>
        /// <param name="strOpStaffName"></param>
        /// <param name="strErrText"></param>
        /// <returns></returns>
        public OutWarehouseBill LoadOutWarehouseBill(long nId, long nOpStaffId, string strOpStaffName, out string strErrText)
        {
            try
            {
                OutWarehouseBill ret = null;

                using (TransactionScope transScope = new TransactionScope(TransactionScopeOption.Required, new TimeSpan(2, 0, 0)))
                {
                    using (StockDAO dao = new StockDAO())
                    {
                        ret = dao.LoadOutWarehouseBill(nId, nOpStaffId, strOpStaffName, out strErrText);
                        if (ret == null)
                        {
                            return(null);
                        }
                    }
                    transScope.Complete();
                }
                return(ret);
            }
            catch (Exception e)
            {
                strErrText = e.Message;
                return(null);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 删除出库单数据
        /// </summary>
        /// <param name="bill"></param>
        /// <param name="listGoods"></param>
        /// <param name="nOpStaffId"></param>
        /// <param name="strOpStaffName"></param>
        /// <param name="strErrText"></param>
        /// <returns></returns>
        public bool DeleteOutWarehouseBill(long nId, long nOpStaffId, string strOpStaffName, out string strErrText)
        {
            try
            {
                using (TransactionScope transScope = new TransactionScope(TransactionScopeOption.Required, new TimeSpan(2, 0, 0)))
                {
                    using (StockDAO dao = new StockDAO())
                    {
                        //如果出库单是由出仓单自动生成的,则不允许手工删除
                        OutWarehouseBill bill = dao.LoadOutWarehouseBill(nId, nOpStaffId, strOpStaffName, out strErrText);
                        if (bill == null)
                        {
                            return(false);
                        }
                        if (bill.ShipmentBillId > 0)
                        {
                            strErrText = InnoSoft.LS.Resources.Strings.CanNotDeleteOutWarehouseBillCreateByShipmentBill;
                            return(false);
                        }

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

                        //删除出库单货物数据
                        if (!dao.DeleteOutWarehouseBillAllGoods(nId, nOpStaffId, strOpStaffName, out strErrText))
                        {
                            return(false);
                        }
                    }
                    transScope.Complete();
                }
                return(true);
            }
            catch (Exception e)
            {
                strErrText = e.Message;
                return(false);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 修改出库单数据
        /// </summary>
        /// <param name="bill"></param>
        /// <param name="listGoods"></param>
        /// <param name="nOpStaffId"></param>
        /// <param name="strOpStaffName"></param>
        /// <param name="strErrText"></param>
        /// <returns></returns>
        public bool UpdateOutWarehouseBill(OutWarehouseBill bill, List <OutWarehouseBillGoods> listGoods, long nOpStaffId, string strOpStaffName, out string strErrText)
        {
            try
            {
                using (TransactionScope transScope = new TransactionScope(TransactionScopeOption.Required, new TimeSpan(2, 0, 0)))
                {
                    using (StockDAO dao = new StockDAO())
                    {
                        //修改出库单数据
                        if (!dao.UpdateOutWarehouseBill(bill, nOpStaffId, strOpStaffName, out strErrText))
                        {
                            return(false);
                        }

                        //修改出库货物数据
                        foreach (OutWarehouseBillGoods goods in listGoods)
                        {
                            if (!dao.UpdateOutWarehouseBillGoods(goods, nOpStaffId, strOpStaffName, out strErrText))
                            {
                                return(false);
                            }
                        }
                    }

                    using (CustomerDAO dao = new CustomerDAO())
                    {
                        //修改上力支费价格数据
                        List <CustomerForceFeePrice> listForceFeePrice = dao.LoadCustomerForceFeePricesByCustomerId(bill.CustomerId, nOpStaffId, strOpStaffName, out strErrText);
                        if (listForceFeePrice.Count == 0)
                        {
                            //新增力支费价格数据
                            CustomerForceFeePrice data = new CustomerForceFeePrice();
                            data.CustomerId             = bill.CustomerId;
                            data.StartTime              = bill.CreateTime;
                            data.EndTime                = DateTime.Parse("9999-12-31");
                            data.LoadingForceFeePrice   = bill.LoadingForceFeePrice;
                            data.UnloadingForceFeePrice = 0;

                            if (!dao.InsertCustomerForceFeePrice(data, nOpStaffId, strOpStaffName, out strErrText))
                            {
                                return(false);
                            }
                        }
                        else
                        {
                            int i = 0;
                            while (i < listForceFeePrice.Count)
                            {
                                if (bill.CreateTime.Date >= listForceFeePrice[i].StartTime.Date && bill.CreateTime.Date <= listForceFeePrice[i].EndTime.Date)
                                {
                                    break;
                                }
                                i++;
                            }
                            if (i < listForceFeePrice.Count)
                            {
                                //修改力支费价格数据
                                listForceFeePrice[i].LoadingForceFeePrice = bill.LoadingForceFeePrice;

                                if (!dao.UpdateCustomerForceFeePrice(listForceFeePrice[i], nOpStaffId, strOpStaffName, out strErrText))
                                {
                                    return(false);
                                }
                            }
                            else
                            {
                                //新增力支费价格数据
                                CustomerForceFeePrice data = new CustomerForceFeePrice();
                                data.CustomerId             = bill.CustomerId;
                                data.StartTime              = bill.CreateTime;
                                data.LoadingForceFeePrice   = bill.LoadingForceFeePrice;
                                data.UnloadingForceFeePrice = 0;

                                //计算截止时间
                                i = 0;
                                while (i < listForceFeePrice.Count)
                                {
                                    if (bill.CreateTime.Date < listForceFeePrice[i].StartTime.Date)
                                    {
                                        break;
                                    }
                                    i++;
                                }
                                if (i < listForceFeePrice.Count)
                                {
                                    data.EndTime = listForceFeePrice[i].StartTime.Date.AddDays(-1);
                                }
                                else
                                {
                                    data.EndTime = DateTime.Parse("9999-12-31");
                                }

                                if (!dao.InsertCustomerForceFeePrice(data, nOpStaffId, strOpStaffName, out strErrText))
                                {
                                    return(false);
                                }
                            }
                        }
                    }
                    transScope.Complete();
                }
                return(true);
            }
            catch (Exception e)
            {
                strErrText = e.Message;
                return(false);
            }
        }
Ejemplo n.º 4
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);
            }
        }
Ejemplo n.º 5
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);
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 修改出库单数据
        /// </summary>
        /// <param name="bill"></param>
        /// <param name="listGoods"></param>
        /// <param name="nOpStaffId"></param>
        /// <param name="strOpStaffName"></param>
        /// <param name="strErrText"></param>
        /// <returns></returns>
        public bool UpdateOutWarehouseBill(OutWarehouseBill bill, List <OutWarehouseBillGoods> listGoods, long nOpStaffId, string strOpStaffName, out string strErrText)
        {
            StockRule rule = new StockRule();

            return(rule.UpdateOutWarehouseBill(bill, listGoods, nOpStaffId, strOpStaffName, out strErrText));
        }