Beispiel #1
0
        /// <summary>
        /// 提交入库
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnStorge_Click(object sender, EventArgs e)
        {
            bool       isAudit    = false;
            string     errMessage = "";
            List <int> storageIDs = this.Master.GetSelectedIds(this.grdvStorage);

            if (storageIDs.Count <= 0)
            {
                base.ShowMessage("你没有选择任何记录");
                return;
            }
            else
            {
                foreach (int ID in storageIDs)
                {
                    var storages = base.XMStorageService.GetXMStorageById(ID);
                    if (storages != null)
                    {
                        bool storageIsAudit = storages.IsAudit == null ? false : storages.IsAudit.Value;
                        if (!storageIsAudit)
                        {
                            isAudit    = true;
                            errMessage = errMessage + storages.Ref + ";";
                        }
                    }
                }
            }
            if (isAudit)
            {
                base.ShowMessage("入库单号为:" + errMessage + "未通过审核,无法入库!");
                BindGrid(this.Master.PageIndex, this.Master.PageSize);
                return;
            }

            if (storageIDs.Count <= 0)
            {
                base.ShowMessage("你没有选择任何记录");
                return;
            }
            else
            {
                //提交入库
                foreach (int ID in storageIDs)
                {
                    using (TransactionScope scope = new TransactionScope())
                    {
                        var storages = base.XMStorageService.GetXMStorageById(ID);
                        if (storages != null && storages.BillStatus == 0)
                        {
                            //更新状态
                            storages.BillStatus  = 1000;     //状态更新为已入库
                            storages.StorageDate = DateTime.Now;
                            base.XMStorageService.UpdateXMStorage(storages);
                            //更新产品库存表
                            var storageProductDetails = base.XMStorageProductDetailsService.GetXMStorageProductDetailsByStorageID(storages.Id);
                            if (storageProductDetails != null && storageProductDetails.Count > 0)
                            {
                                foreach (XMStorageProductDetails Info in storageProductDetails)
                                {
                                    string code          = Info.PlatformMerchantCode;
                                    int    wfID          = storages.WareHouseId;
                                    var    InventoryInfo = base.XMInventoryInfoService.GetXMInventoryInfoByParm(code, wfID);
                                    if (InventoryInfo != null)                       //商品编码为code的产品在库存表中已经存在 更新库存数量
                                    {
                                        InventoryInfo.StockNumber  += Info.ProductsCount;
                                        InventoryInfo.CanOrderCount = InventoryInfo.StockNumber;
                                        InventoryInfo.UpdateDate    = DateTime.Now;
                                        InventoryInfo.UpdateID      = HozestERPContext.Current.User.CustomerID;
                                        base.XMInventoryInfoService.UpdateXMInventoryInfo(InventoryInfo);
                                        //更新入库产品条形码
                                        UpdateProductBarCodeList(InventoryInfo.Id, Info.Id);
                                    }
                                    else
                                    {
                                        //产品不存在  新增
                                        XMInventoryInfo parm = new XMInventoryInfo();
                                        parm.PrductId             = Info.ProductId.Value;
                                        parm.PlatformMerchantCode = Info.PlatformMerchantCode;
                                        parm.WfId          = storages.WareHouseId;
                                        parm.StockNumber   = Info.ProductsCount;
                                        parm.CanOrderCount = parm.StockNumber;
                                        parm.WarningValue  = 0;
                                        parm.CreateID      = HozestERPContext.Current.User.CustomerID;
                                        parm.CreateDate    = DateTime.Now;
                                        parm.UpdateID      = HozestERPContext.Current.User.CustomerID;
                                        parm.UpdateDate    = DateTime.Now;
                                        parm.IsEnable      = false;
                                        base.XMInventoryInfoService.InsertXMInventoryInfo(parm);
                                        //更新入库产品条形码
                                        UpdateProductBarCodeList(parm.Id, Info.Id);
                                    }

                                    //更新库存总账主表数据   从表添加一条记录
                                    UpdateInventoryLederInfo(storages.WareHouseId, Info);
                                }
                                if (storages.PurchaseNumber.IndexOf("jd") > -1)//京东自营自动生成采购退货单
                                {
                                    AutoInsertPurchaseRejectedData(storages.PurchaseNumber, storages.Ref);
                                }
                            }
                        }
                        scope.Complete();
                    }
                }
                BindGrid(this.Master.PageIndex, this.Master.PageSize);
                base.ShowMessage("提交入库成功!");
            }
        }
Beispiel #2
0
        /// <summary>
        /// 提交入库
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnStorge_Click(object sender, EventArgs e)
        {
            List <int> saleReturnIDs = this.Master.GetSelectedIds(this.grdvSaleReturn);

            if (saleReturnIDs.Count <= 0)
            {
                base.ShowMessage("你没有选择任何记录");
                return;
            }
            else
            {
                //提交入库
                foreach (int ID in saleReturnIDs)
                {
                    using (TransactionScope scope = new TransactionScope())
                    {
                        var saleReturn = base.XMSaleReturnService.GetXMSaleReturnById(ID);
                        if (saleReturn != null && saleReturn.BillStatus == 0)
                        {
                            //更新状态
                            saleReturn.BillStatus = 1000;     //状态更新为已入库
                            saleReturn.UpdateDate = DateTime.Now;
                            saleReturn.UpdateID   = HozestERPContext.Current.User.CustomerID;
                            base.XMSaleReturnService.UpdateXMSaleReturn(saleReturn);
                            //更新产品库存表
                            var details = base.XMSaleReturnProductDetailsService.GetXMSaleReturnProductDetailsListBySaleReturnID(saleReturn.Id);
                            if (details != null && details.Count > 0)
                            {
                                foreach (XMSaleReturnProductDetails Info in details)
                                {
                                    string platformCode = "";
                                    if (Info.DeliveryProductsDetailID != null)
                                    {
                                        var saleDelivery = base.XMSaleDeliveryProductDetailsService.GetXMSaleDeliveryProductDetailsById(Info.DeliveryProductsDetailID.Value);
                                        if (saleDelivery != null)
                                        {
                                            platformCode = saleDelivery.PlatformMerchantCode;
                                        }
                                    }
                                    int wfID          = saleReturn.WarehouseId.Value;
                                    var inventeryInfo = base.XMInventoryInfoService.GetXMInventoryInfoByParm(platformCode, wfID);
                                    if (inventeryInfo != null)                //更新库存
                                    {
                                        inventeryInfo.StockNumber  += Info.RejectionProdcutsCount;
                                        inventeryInfo.CanOrderCount = inventeryInfo.StockNumber;
                                        inventeryInfo.UpdateDate    = DateTime.Now;
                                        inventeryInfo.UpdateID      = HozestERPContext.Current.User.CustomerID;
                                        base.XMInventoryInfoService.UpdateXMInventoryInfo(inventeryInfo);
                                        //更新入库产品条形码
                                        UpdateProductBarCodeList(inventeryInfo.Id, Info.Id);
                                    }
                                    else
                                    {
                                        //产品不存在  新增
                                        XMInventoryInfo parm = new XMInventoryInfo();
                                        parm.PrductId             = Info.ProductId.Value;
                                        parm.PlatformMerchantCode = platformCode;
                                        parm.WfId          = saleReturn.WarehouseId.Value;
                                        parm.StockNumber   = Info.RejectionProdcutsCount;
                                        parm.CanOrderCount = parm.StockNumber;
                                        parm.WarningValue  = 0;                           //警戒值  可自行设定
                                        parm.CreateDate    = parm.UpdateDate = DateTime.Now;
                                        parm.CreateID      = parm.UpdateID = HozestERPContext.Current.User.CustomerID;
                                        parm.IsEnable      = false;
                                        base.XMInventoryInfoService.InsertXMInventoryInfo(parm);
                                        //更新入库产品条形码
                                        UpdateProductBarCodeList(parm.Id, Info.Id);
                                    }
                                    //更新库存总账主表数据   从表添加一条记录
                                    UpdateInventoryLederInfo(wfID, Info, platformCode);
                                }
                            }
                        }
                        scope.Complete();
                    }
                }
                this.BindGrid(this.Master.PageIndex, this.Master.PageSize);
                base.ShowMessage("提交入库成功!");
            }
        }
Beispiel #3
0
        /// <summary>
        /// 提交调拨单  更新库存
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSingleSubmitAllocate_Click(object sender, EventArgs e)
        {
            //提交调拨单
            string errMessage     = "";
            bool   isInventLess   = false; //判断库存是否不足
            bool   isAllocateFail = false; // 判断调拨是否失败
            var    dbInfo         = base.XMAllocateInfoService.GetXMAllocateInfoById(this.scid);

            if (dbInfo != null)
            {
                if (dbInfo.BillStatus == 0)      //未调拨
                {
                    var dbProductDetails = base.XMAllocateProductDetailsService.GetXMAllocateProductDetailsListByAllcateId(dbInfo.Id);
                    if (dbProductDetails != null && dbProductDetails.Count > 0)
                    {
                        foreach (XMAllocateProductDetails Info in dbProductDetails)
                        {
                            var inventInfoFrom = base.XMInventoryInfoService.GetXMInventoryInfoByParm(Info.PlatformMerchantCode, dbInfo.From_WarehouseId);
                            if (inventInfoFrom == null || (inventInfoFrom != null && inventInfoFrom.StockNumber < Info.ProductCount))              //库存不足
                            {
                                errMessage  += "厂家编码为" + Info.PlatformMerchantCode + "的商品库存不足,";
                                isInventLess = true;
                                break;
                            }
                        }
                    }
                }
                else if (dbInfo.BillStatus == 1000)
                {
                    isAllocateFail = true;
                }
            }
            if (isInventLess)      //库存不足
            {
                base.ShowMessage(errMessage + "无法调拨!");
                return;
            }
            if (isAllocateFail)
            {
                base.ShowMessage("已经调拨的调拨单操作失败!");
                return;
            }
            using (TransactionScope scope = new TransactionScope())
            {
                if (dbInfo != null && dbInfo.BillStatus == 0)
                {
                    dbInfo.BillStatus = 1000;     //更该状态为 已调拨
                    dbInfo.UpdateDate = DateTime.Now;
                    dbInfo.UpdateID   = HozestERPContext.Current.User.CustomerID;
                    base.XMAllocateInfoService.UpdateXMAllocateInfo(dbInfo);

                    //更新仓库库存
                    var dbProductDetails = base.XMAllocateProductDetailsService.GetXMAllocateProductDetailsListByAllcateId(dbInfo.Id);
                    if (dbProductDetails != null && dbProductDetails.Count > 0)
                    {
                        foreach (XMAllocateProductDetails Info in dbProductDetails)
                        {
                            //更新出库仓库库存
                            var inventInfoFrom = base.XMInventoryInfoService.GetXMInventoryInfoByParm(Info.PlatformMerchantCode, dbInfo.From_WarehouseId);
                            if ((inventInfoFrom != null && inventInfoFrom.StockNumber >= Info.ProductCount))              //库存充足减库存
                            {
                                inventInfoFrom.StockNumber   = inventInfoFrom.StockNumber - Info.ProductCount;
                                inventInfoFrom.CanOrderCount = inventInfoFrom.StockNumber;
                                inventInfoFrom.UpdateDate    = DateTime.Now;
                                inventInfoFrom.UpdateID      = HozestERPContext.Current.User.CustomerID;
                                base.XMInventoryInfoService.UpdateXMInventoryInfo(inventInfoFrom);
                                //在库存帐查询中添加记录
                                UpdateDeliveryInventoryLederInfo(dbInfo.From_WarehouseId, Info);
                                //更新仓库出库产品条形码
                                UpdateDeliveryBarCodes(inventInfoFrom.Id, Info.Id);

                                //更新入库仓库库存
                                var inventInfoTo = base.XMInventoryInfoService.GetXMInventoryInfoByParm(Info.PlatformMerchantCode, dbInfo.To_WarehouseId);
                                if (inventInfoTo == null)          //新增
                                {
                                    XMInventoryInfo inventory = new XMInventoryInfo();
                                    var             product   = base.XMProductService.getXMProductByManufacturersCode(Info.PlatformMerchantCode);
                                    if (product != null)
                                    {
                                        inventory.PrductId = product.Id;
                                    }
                                    inventory.PlatformMerchantCode = Info.PlatformMerchantCode;
                                    inventory.WfId          = dbInfo.To_WarehouseId;
                                    inventory.StockNumber   = Info.ProductCount;
                                    inventory.CanOrderCount = inventory.StockNumber;
                                    inventory.WarningValue  = 0;
                                    inventory.CreateDate    = inventory.UpdateDate = DateTime.Now;
                                    inventory.CreateID      = inventory.UpdateID = HozestERPContext.Current.User.CustomerID;
                                    inventory.IsEnable      = false;
                                    base.XMInventoryInfoService.InsertXMInventoryInfo(inventory);
                                    UpdateStorageBarCodes(inventory.Id, Info.Id);
                                }
                                else              //更新库存
                                {
                                    inventInfoTo.StockNumber   = inventInfoTo.StockNumber + Info.ProductCount;
                                    inventInfoTo.CanOrderCount = inventInfoTo.StockNumber;
                                    inventInfoTo.UpdateDate    = DateTime.Now;
                                    inventInfoTo.UpdateID      = HozestERPContext.Current.User.CustomerID;
                                    base.XMInventoryInfoService.UpdateXMInventoryInfo(inventInfoTo);
                                    UpdateStorageBarCodes(inventInfoTo.Id, Info.Id);
                                }
                                UpdateStorageInventoryLederInfo(dbInfo.To_WarehouseId, Info);
                            }
                        }
                    }
                }
                scope.Complete();
            }
            base.ShowMessage("操作成功!");
            BindGrid(this.scid);
        }