Exemple #1
0
        /// <summary>
        /// 查询库存
        /// </summary>
        /// <param name="queryFilter"></param>
        /// <returns></returns>
        public static QueryResult <InventoryQueryInfo> QueryProductInventory(InventoryQueryFilter queryFilter)
        {
            if (queryFilter == null || string.IsNullOrEmpty(queryFilter.ProductSysNo))
            {
                throw new BusinessException("请输入商品编号");
            }
            if (string.IsNullOrEmpty(queryFilter.MerchantSysNo))
            {
                throw new BusinessException("商家编号不能为空");
            }

            queryFilter.CompanyCode = "8601";
            //查询总库存
            if (string.IsNullOrEmpty(queryFilter.StockSysNo))
            {
                return(InventoryDA.QueryProductInventoryTotal(queryFilter));
            }
            else
            {
                QueryResult <InventoryQueryInfo> result      = InventoryDA.QueryProductInventoryByStock(queryFilter);
                QueryResult <InventoryQueryInfo> resultTotal = InventoryDA.QueryProductInventoryTotal(queryFilter);
                if (resultTotal == null)
                {
                    resultTotal            = new QueryResult <InventoryQueryInfo>();
                    resultTotal.ResultList = new List <InventoryQueryInfo>();
                    resultTotal.PageInfo   = new PageInfo();
                }
                if (result != null && result.ResultList != null && result.ResultList.Count > 0)
                {
                    resultTotal.ResultList.AddRange(result.ResultList);
                    resultTotal.PageInfo.TotalCount += result.PageInfo.TotalCount;
                }
                return(resultTotal);
            }
        }
        private void buttonUpdateBook_Click(object sender, EventArgs e)
        {
            List <Inventory> listI = InventoryDA.ListInventory();

            if (IsValidInventoryData())
            {
                Inventory aProducts = new Inventory();
                aProducts.ISBNProduct          = Convert.ToInt32(textBoxISBN.Text);
                aProducts.ProductTitle         = textBoxBookTitle.Text;
                aProducts.ProductDescription   = comboboxProductDescription.Text;
                aProducts.AuthorID             = Convert.ToInt32(comboBoxAuthorId.Text);
                aProducts.PublisherName        = comboBoxPublisherName.Text;
                aProducts.ProductYearPublished = Convert.ToInt32(textBoxYearPushlished.Text);
                aProducts.ProductQuantity      = Convert.ToInt32(textBoxQuantityOnHand.Text);
                aProducts.ProductPrice         = Convert.ToDouble(textBoxBookPrice.Text);
                DialogResult ans = MessageBox.Show("Do you really want to update this Books?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                if (ans == DialogResult.Yes)
                {
                    InventoryDA.Update(aProducts);
                    MessageBox.Show("Product record has been updated successfully", "Confirmation");
                    ClearAll();
                    textBoxISBN.Enabled = true;
                }
            }
        }
        private void buttonSaveBook_Click(object sender, EventArgs e)
        {
            List <Inventory> listI = InventoryDA.ListInventory();

            if (IsValidInventoryData())
            {
                if (!Validation.IsUniqueISBN(listI, Convert.ToInt32(textBoxISBN.Text)))
                {
                    MessageBox.Show("Duplicate", "DUPLICATE Author ID");
                    textBoxISBN.Clear();
                    textBoxISBN.Focus();
                    return;
                }
                Inventory aProducts = new Inventory();
                aProducts.ISBNProduct          = Convert.ToInt32(textBoxISBN.Text);
                aProducts.ProductTitle         = textBoxBookTitle.Text;
                aProducts.ProductDescription   = comboboxProductDescription.Text;
                aProducts.LastName             = comboBoxAuthorId.Text;
                aProducts.PublisherName        = comboBoxPublisherName.Text;
                aProducts.ProductYearPublished = Convert.ToInt32(textBoxYearPushlished.Text);
                aProducts.ProductQuantity      = Convert.ToInt32(textBoxQuantityOnHand.Text);
                aProducts.ProductPrice         = Convert.ToDouble(textBoxBookPrice.Text);
                InventoryDA.Save(aProducts);
                listB.Add(aProducts);
                buttonListBook.Enabled = true;
                ClearAll();
            }
        }
        private void Orders_Clerk_Load(object sender, EventArgs e)
        {
            InventoryDA.ListOrderInventory(listViewOrderInventory);
            Random random       = new Random();
            int    randomNumber = random.Next(10000, 19999);

            textBoxOnumber.Text = randomNumber.ToString();
            ClientDA.Comboboxlist(comboBoxClientID);
        }
        public int GetProductAvailableSaleQty(int productSysNo)
        {
            var result = InventoryDA.GetProductTotalInventoryInfo(productSysNo);

            if (result != null)
            {
                return(result.AvailableQty + result.ConsignQty + result.VirtualQty - result.InvalidQty);
            }
            else
            {
                return(0);
            }
        }
        private void buttonSaveOrder_Click_1(object sender, EventArgs e)
        {
            List <Orders> listO = OrderDA.ListOrder();

            if (IsValidOrderData())
            {
                Inventory product         = InventoryDA.Search(Convert.ToInt32(textBoxISBN.Text));
                Client    client          = ClientDA.Search(Convert.ToInt32(comboBoxClientID.Text));
                string    isbn            = textBoxISBN.Text;
                int       quantityproduct = Convert.ToInt32(textBoxOQty.Text);
                int       id = (Convert.ToInt32(comboBoxClientID.Text));

                if (product == null)
                {
                    MessageBox.Show("Wrong Information product, try again", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else if (product.ProductQuantity < Convert.ToInt32(textBoxOQty.Text))
                {
                    MessageBox.Show("We do not have the quantity required on Inventory", "Missing Product");
                    textBoxOQty.Clear();
                    return;
                }
                else
                {
                    if (client.ClientID == (Convert.ToInt32(comboBoxClientID.Text)))
                    {
                        textBoxClientName.Text = client.InstitutionName;
                    }

                    Int32  quantityselected = Convert.ToInt32(textBoxOQty.Text);
                    Double priceselected    = Convert.ToDouble(textBoxProductPrice.Text);
                    Double finalamout       = quantityselected * priceselected;
                    textBoxFinalAmount.Text = finalamout.ToString();
                    Orders aOrder = new Orders();
                    aOrder.OrderNumber        = Convert.ToInt32(textBoxOnumber.Text);
                    aOrder.ISBNProduct        = Convert.ToInt32(textBoxISBN.Text);
                    aOrder.ProductTitle       = textBoxOProductTitle.Text;
                    aOrder.ProductDescription = textBoxProductDescription.Text;
                    aOrder.ClientID           = (Convert.ToInt32(comboBoxClientID.Text));
                    aOrder.ClientName         = textBoxClientName.Text;
                    aOrder.OrderDate          = dateTimePickerOdate.Text;
                    aOrder.ShippingDate       = dateTimePickerSDate.Text;
                    aOrder.OrderQuantity      = Convert.ToInt32(textBoxOQty.Text);
                    aOrder.ProductPrice       = Convert.ToDouble(textBoxProductPrice.Text);
                    aOrder.FinalAmount        = Convert.ToDouble(textBoxFinalAmount.Text);
                    OrderDA.Save(aOrder);
                    listO.Add(aOrder);
                    ClearAll();
                }
            }
        }
 private void buttonDeleteBook_Click(object sender, EventArgs e)
 {
     if (IsValidInventoryData())
     {
         DialogResult ans = MessageBox.Show("Do you really want to delete this Product?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
         if (ans == DialogResult.Yes)
         {
             InventoryDA.Delete(Convert.ToInt32(textBoxISBN.Text));
             MessageBox.Show("Product record has been deleted successfully", "Confirmation");
             ClearAll();
             textBoxISBN.Enabled = true;
         }
     }
 }
Exemple #8
0
        /// <summary>
        /// 查询库存变化单据
        /// </summary>
        /// <param name="queryFilter"></param>
        /// <returns></returns>
        public static QueryResult <InventoryItemCardInfo> QueryCardItemOrders(InventoryItemCardQueryFilter queryFilter)
        {
            if (queryFilter == null || string.IsNullOrEmpty(queryFilter.ProductSysNo))
            {
                throw new BusinessException("请输入商品编号");
            }
            if (string.IsNullOrEmpty(queryFilter.MerchantSysNo))
            {
                throw new BusinessException("商家编号不能为空");
            }
            queryFilter.CompanyCode = "8601";

            //获取RMAInventoryOnlineDate:
            string rmaInventoryOnlineDate = CommonDA.GetSysConfigurationValue("RMAInventoryOnlineDate", queryFilter.CompanyCode);

            queryFilter.RMAInventoryOnlineDate = string.IsNullOrEmpty(rmaInventoryOnlineDate) ? new DateTime() : Convert.ToDateTime(rmaInventoryOnlineDate);

            return(InventoryDA.QueryCardItemOrdersRelated(queryFilter));
        }
        private void buttonSearchBook_Click(object sender, EventArgs e)
        {
            int choice = comboBoxSearchBook.SelectedIndex;

            switch (choice)
            {
            case -1:     // The user didn't select any search option
                MessageBox.Show("Please select the search option");
                break;

            case 0:     //The user selected the search by Customer ID
                Inventory products = InventoryDA.Search(Convert.ToInt32(textBoxInfoBook.Text));
                if (products != null)
                {
                    textBoxISBN.Text                = Convert.ToString(products.ISBNProduct);
                    textBoxBookTitle.Text           = products.ProductTitle;
                    comboboxProductDescription.Text = products.ProductDescription;
                    comboBoxAuthorId.Text           = Convert.ToString(products.AuthorID);
                    comboBoxPublisherName.Text      = products.PublisherName;
                    textBoxYearPushlished.Text      = Convert.ToString(products.ProductYearPublished);
                    textBoxBookPrice.Text           = Convert.ToString(products.ProductPrice);
                    textBoxQuantityOnHand.Text      = Convert.ToString(products.ProductQuantity);
                    textBoxAuthorInfo.Clear();
                    textBoxISBN.Enabled = false;
                }
                else
                {
                    MessageBox.Show("Product not Found!");
                    textBoxISBN.Clear();
                    textBoxISBN.Focus();
                }
                break;

            default:
                break;
            }
        }
Exemple #10
0
 /// <summary>
 /// 查询仓库
 /// </summary>
 /// <param name="merchantSysNo">商家编号</param>
 /// <returns></returns>
 public static List <StockInfo> GetStock(int merchantSysNo)
 {
     return(InventoryDA.GetStock(merchantSysNo));
 }
Exemple #11
0
        private static void AdjustSendSSBToWMS(int sysNo, string inWarehouseNumber, List <InventoryBatchDetailsInfo> batchDetailsInfoEntity, List <InventoryAdjustItemInfo> adjustCaseEntityList)
        {
            List <ECommerce.Entity.Inventory.Item> itemList = new List <ECommerce.Entity.Inventory.Item>();

            // List<BatchDetailsInfoEntity> batchDetailsInfoEntity = AdjustDAL.GetBatchDetailsInfoEntityListByNumber(SysNumber);
            if ((batchDetailsInfoEntity != null && batchDetailsInfoEntity.Count > 0) || (adjustCaseEntityList != null && adjustCaseEntityList.Count > 0))
            {
                if (batchDetailsInfoEntity != null && batchDetailsInfoEntity.Count > 0)
                {
                    foreach (var BatchItem in batchDetailsInfoEntity)
                    {
                        ProductBatch pbEntity = new ProductBatch
                        {
                            BatchNumber = BatchItem.BatchNumber
                            ,
                            Quantity = BatchItem.Quantity.ToString()
                        };
                        ECommerce.Entity.Inventory.Item item = new ECommerce.Entity.Inventory.Item()
                        {
                            ProductBatch = pbEntity
                            ,
                            ProductSysNo = BatchItem.ProductSysNo.ToString()
                            ,
                            Quantity = BatchItem.Quantity.ToString()
                        };
                        itemList.Add(item);
                    }
                }
                if (adjustCaseEntityList != null && adjustCaseEntityList.Count > 0)
                {
                    //初始非批次商品调整信息
                    foreach (var NOTBatchItem in adjustCaseEntityList)
                    {
                        ECommerce.Entity.Inventory.Item item = new ECommerce.Entity.Inventory.Item()
                        {
                            ProductSysNo = NOTBatchItem.ProductSysNo.ToString(),
                            Quantity     = NOTBatchItem.AdjustQuantity.ToString()
                        };
                        itemList.Add(item);
                    }
                }

                SendToWMSSSBXMLMessage sendTOWMSSSBXMLMessage = new SendToWMSSSBXMLMessage()
                {
                    RequestRoot = new RequestRoot()
                    {
                        MessageHeader = new MessageHeader
                        {
                            Language     = "CH",
                            Sender       = "IPP",
                            CompanyCode  = "8601",
                            Action       = "Adjust",
                            Version      = "0.1",
                            Type         = "InventoryAdjust",
                            OriginalGUID = ""
                        },
                        Body = new ECommerce.Entity.Inventory.Body
                        {
                            Operation = new Operation()
                            {
                                Type            = "60",
                                Number          = sysNo.ToString(),
                                User            = "******",//ServiceContext.Current.UserDisplayName,
                                Memo            = "损益单出库给仓库发送SSB",
                                Item            = itemList,
                                WarehouseNumber = inWarehouseNumber
                            }
                        }
                    }
                };
                string      paramXml = SerializationUtility.XmlSerialize(sendTOWMSSSBXMLMessage);
                XmlDocument xmlD     = new XmlDocument();
                xmlD.LoadXml(paramXml);
                paramXml = "<" + xmlD.DocumentElement.Name + ">" + xmlD.DocumentElement.InnerXml + "</" + xmlD.DocumentElement.Name + ">";

                if (itemList != null && itemList.Count > 0)
                {
                    InventoryDA.SendSSBToWMS(paramXml);
                }
            }
        }
Exemple #12
0
        /// <summary>
        /// 损益单出库 (确认成功):
        /// </summary>
        /// <param name="adjustRequestSysNo">原始损益单编号</param>
        /// <param name="productSysNo">损益商品编号</param>
        /// <param name="realAdjustQty">该商品的实际损益数量</param>
        /// <returns></returns>
        public static AdjustRequestInfo AdjustOutStock(int adjustRequestSysNo, int?productSysNo, int?realAdjustQty, int sellerSysNo)
        {
            var adjustRequestInfo = GetAdjustRequestInfoBySysNo(adjustRequestSysNo);


            #region Check操作 :
            if (null == adjustRequestInfo || adjustRequestInfo.SysNo <= 0)
            {
                throw new BusinessException(string.Format("找不到编号为{0}的损益单据信息!", adjustRequestSysNo));
            }

            if (productSysNo.HasValue && realAdjustQty.HasValue)
            {
                var productItemInfo = adjustRequestInfo.AdjustItemInfoList.FirstOrDefault(x => x.ProductSysNo == productSysNo);
                if (productItemInfo == null)
                {
                    throw new BusinessException(string.Format("编号为{0}的商品不存在于该损益单中!损益单编号 :{1}", productSysNo, adjustRequestSysNo));
                }
                if (realAdjustQty >= 0)
                {
                    if (realAdjustQty > productItemInfo.AdjustQuantity)
                    {
                        throw new BusinessException(string.Format("编号为{0}的商品实际损益的数量大于预损益的数量!损益单编号 :{1}", productSysNo, adjustRequestSysNo));
                    }
                }
                else
                {
                    if (realAdjustQty < productItemInfo.AdjustQuantity)
                    {
                        throw new BusinessException(string.Format("编号为{0}的商品实际损益的数量大于预损益的数量!损益单编号 :{1}", productSysNo, adjustRequestSysNo));
                    }
                }
            }

            var stockInfo = StockService.LoadStock(adjustRequestInfo.Stock.SysNo);
            if (null == stockInfo)
            {
                throw new BusinessException("损益单据关联的仓库编号无效!");
            }
            if (stockInfo.MerchantSysNo != sellerSysNo)
            {
                throw new BusinessException("此商家无权操作此单据!");
            }

            //增加损益单状态Check (已申报状态):
            if (adjustRequestInfo.RequestStatus != AdjustRequestStatus.Reported)
            {
                throw new BusinessException(string.Format("损益单编号 :{1},当前单据的状态不是'已申报'状态,不能进行损益单确认操作", productSysNo, adjustRequestSysNo));
            }

            #endregion

            bool isConsign = false;
            adjustRequestInfo.OutStockDate  = DateTime.Now;
            adjustRequestInfo.RequestStatus = Enums.AdjustRequestStatus.OutStock;
            isConsign = (adjustRequestInfo.ConsignFlag == RequestConsignFlag.Consign || adjustRequestInfo.ConsignFlag == RequestConsignFlag.GatherPay);
            var inventoryAdjustContract = new InventoryAdjustContractInfo
            {
                SourceBizFunctionName = InventoryAdjustSourceBizFunction.Inventory_AdjustRequest,
                SourceActionName      = InventoryAdjustSourceAction.OutStock,
                ReferenceSysNo        = adjustRequestInfo.SysNo.ToString(),
                AdjustItemList        = new List <InventoryAdjustItemInfo>()
            };

            using (TransactionScope scope = new TransactionScope())
            {
                if (adjustRequestInfo.AdjustItemInfoList != null && adjustRequestInfo.AdjustItemInfoList.Count > 0)
                {
                    adjustRequestInfo.AdjustItemInfoList.ForEach(adjustItem =>
                    {
                        //if (adjustItem.AdjustProduct.ProductPriceInfo == null)
                        //{
                        //    BizExceptionHelper.Throw("Common_CannotFindPriceInformation");
                        //    throw new BusinessException("损益数量只能为非0的整数!");
                        //}
                        if (adjustItem.AdjustQuantity == 0)
                        {
                            throw new BusinessException("损益数量只能为非0的整数!");
                        }

                        var cost = InventoryDA.GetItemCost(adjustItem.ProductSysNo.Value);
                        inventoryAdjustContract.AdjustItemList.Add(new InventoryAdjustItemInfo
                        {
                            AdjustQuantity = adjustItem.AdjustQuantity.Value,
                            ProductSysNo   = adjustItem.ProductSysNo.Value,
                            StockSysNo     = (int)adjustRequestInfo.Stock.SysNo,
                            AdjustUnitCost = cost,
                        });

                        //update flash item unit cost
                        if (adjustItem.AdjustCost != cost)
                        {
                            adjustItem.AdjustCost = cost;
                            InventoryDA.UpdateAdjustItemCost(adjustItem);
                        }
                    });
                }
                InventoryDA.UpdateAdjustRequestStatus(adjustRequestInfo);

                if (inventoryAdjustContract.AdjustItemList.Count > 0)
                {
                    //string adjustResult = ObjectFactory<InventoryAdjustContractProcessor>.Instance.ProcessAdjustContract(inventoryAdjustContract);
                    //if (!string.IsNullOrEmpty(adjustResult))
                    //{
                    //    throw new BizException("库存调整失败: " + adjustResult);
                    //}


                    #region 调整库存:

                    foreach (InventoryAdjustItemInfo adjustItem in inventoryAdjustContract.AdjustItemList)
                    {
                        ProductQueryInfo productInfo = ProductService.GetProductBySysNo(adjustItem.ProductSysNo);
                        if (productInfo == null || productInfo.SysNo <= 0)
                        {
                            throw new BusinessException(string.Format("欲调库存的商品不存在,商品编号:{0}", adjustItem.ProductSysNo));
                        }
                        InventoryDA.InitProductInventoryInfo(adjustItem.ProductSysNo, adjustItem.StockSysNo);
                        var inventoryType = InventoryDA.GetProductInventroyType(adjustItem.ProductSysNo);
                        ECommerce.Entity.Inventory.ProductInventoryInfo stockInventoryCurrentInfo = InventoryDA.GetProductInventoryInfoByStock(adjustItem.ProductSysNo, adjustItem.StockSysNo);
                        ECommerce.Entity.Inventory.ProductInventoryInfo totalInventoryCurrentInfo = InventoryDA.GetProductTotalInventoryInfo(adjustItem.ProductSysNo);

                        ECommerce.Entity.Inventory.ProductInventoryInfo stockInventoryAdjustInfo = new Entity.Inventory.ProductInventoryInfo()
                        {
                            ProductSysNo = adjustItem.ProductSysNo,
                            StockSysNo   = adjustItem.StockSysNo
                        };

                        ECommerce.Entity.Inventory.ProductInventoryInfo totalInventoryAdjustInfo = new ECommerce.Entity.Inventory.ProductInventoryInfo()
                        {
                            ProductSysNo = adjustItem.ProductSysNo
                        };


                        if (adjustItem.AdjustQuantity < 0)
                        {
                            //损单出库
                            if (adjustRequestInfo.ConsignFlag == RequestConsignFlag.Consign || adjustRequestInfo.ConsignFlag == RequestConsignFlag.GatherPay)
                            {
                                //代销商品, 恢复可用库存, 减少已分配库存/代销库存
                                stockInventoryAdjustInfo.AvailableQty = -adjustItem.AdjustQuantity;
                                totalInventoryAdjustInfo.AvailableQty = -adjustItem.AdjustQuantity;

                                if (adjustItem.AdjustQuantity < 0)
                                {
                                    //AllocatedQty(-,->0),小于0则自动调为0。
                                    if (stockInventoryCurrentInfo.AllocatedQty + adjustItem.AdjustQuantity < 0)
                                    {
                                        stockInventoryAdjustInfo.AllocatedQty = -stockInventoryCurrentInfo.AllocatedQty;
                                    }
                                    else
                                    {
                                        stockInventoryAdjustInfo.AllocatedQty = adjustItem.AdjustQuantity;
                                    }

                                    if (totalInventoryCurrentInfo.AllocatedQty + adjustItem.AdjustQuantity < 0)
                                    {
                                        totalInventoryAdjustInfo.AllocatedQty = -totalInventoryCurrentInfo.AllocatedQty;
                                    }
                                    else
                                    {
                                        totalInventoryAdjustInfo.AllocatedQty = adjustItem.AdjustQuantity;
                                    }
                                }
                                else
                                {
                                    stockInventoryAdjustInfo.AllocatedQty = adjustItem.AdjustQuantity;
                                    totalInventoryAdjustInfo.AllocatedQty = adjustItem.AdjustQuantity;
                                }

                                stockInventoryAdjustInfo.ConsignQty = adjustItem.AdjustQuantity;
                                totalInventoryAdjustInfo.ConsignQty = adjustItem.AdjustQuantity;
                            }
                            else
                            {
                                //非代销商品, 减少财务库存/已分配库存
                                stockInventoryAdjustInfo.AccountQty = adjustItem.AdjustQuantity;
                                totalInventoryAdjustInfo.AccountQty = adjustItem.AdjustQuantity;

                                if (adjustItem.AdjustQuantity < 0)
                                {
                                    //AllocatedQty(-,->0),小于0则自动调为0。
                                    if (stockInventoryCurrentInfo.AllocatedQty + adjustItem.AdjustQuantity < 0)
                                    {
                                        stockInventoryAdjustInfo.AllocatedQty = -stockInventoryCurrentInfo.AllocatedQty;
                                    }
                                    else
                                    {
                                        stockInventoryAdjustInfo.AllocatedQty = adjustItem.AdjustQuantity;
                                    }

                                    if (totalInventoryCurrentInfo.AllocatedQty + adjustItem.AdjustQuantity < 0)
                                    {
                                        totalInventoryAdjustInfo.AllocatedQty = -totalInventoryCurrentInfo.AllocatedQty;
                                    }
                                    else
                                    {
                                        totalInventoryAdjustInfo.AllocatedQty = adjustItem.AdjustQuantity;
                                    }
                                }
                                else
                                {
                                    stockInventoryAdjustInfo.AllocatedQty = adjustItem.AdjustQuantity;
                                    totalInventoryAdjustInfo.AllocatedQty = adjustItem.AdjustQuantity;
                                }
                            }
                        }
                        else
                        {
                            //溢单出库
                            if (adjustRequestInfo.ConsignFlag == RequestConsignFlag.Consign || adjustRequestInfo.ConsignFlag == RequestConsignFlag.GatherPay)
                            {
                                //代销商品, 增加代销库存 (损/溢单都增加代销库存?)
                                stockInventoryAdjustInfo.ConsignQty = adjustItem.AdjustQuantity;
                                totalInventoryAdjustInfo.ConsignQty = adjustItem.AdjustQuantity;
                            }
                            else
                            {
                                //非代销商品, 增加财务库存/可用库存
                                stockInventoryAdjustInfo.AccountQty   = adjustItem.AdjustQuantity;
                                totalInventoryAdjustInfo.AccountQty   = adjustItem.AdjustQuantity;
                                stockInventoryAdjustInfo.AvailableQty = adjustItem.AdjustQuantity;
                                totalInventoryAdjustInfo.AvailableQty = adjustItem.AdjustQuantity;
                            }
                        }

                        //预检调整后的商品库存是否合法
                        Entity.Inventory.ProductInventoryInfo stockInventoryAdjustAfterAdjust = InventoryService.PreCalculateInventoryAfterAdjust(stockInventoryCurrentInfo, stockInventoryAdjustInfo);
                        Entity.Inventory.ProductInventoryInfo totalInventoryAdjustAfterAdjust = InventoryService.PreCalculateInventoryAfterAdjust(totalInventoryCurrentInfo, totalInventoryAdjustInfo);

                        bool isNeedCompareAvailableQtyAndAccountQty = true;
                        InventoryService.PreCheckGeneralRules(stockInventoryAdjustAfterAdjust, ref isNeedCompareAvailableQtyAndAccountQty);
                        InventoryService.PreCheckGeneralRules(totalInventoryAdjustAfterAdjust, ref isNeedCompareAvailableQtyAndAccountQty);

                        //调整商品库存:
                        InventoryDA.AdjustProductStockInventoryInfo(stockInventoryAdjustInfo);
                        InventoryDA.AdjustProductTotalInventoryInfo(totalInventoryAdjustInfo);
                    }
                    #endregion

                    #region 损益单为代销类型,出库时需要写入代销转财务日志
                    if (isConsign)
                    {
                        List <ConsignToAcctLogInfo> acctLogInfoList = new List <ConsignToAcctLogInfo>();
                        adjustRequestInfo.AdjustItemInfoList.ForEach(x =>
                        {
                            ConsignToAcctLogInfo acctLog = new ConsignToAcctLogInfo();
                            acctLog.ProductSysNo         = x.ProductSysNo;
                            acctLog.StockSysNo           = adjustRequestInfo.Stock.SysNo;
                            acctLog.VendorSysNo          = InventoryDA.GetProductBelongVendorSysNo(x.ProductSysNo.Value);
                            acctLog.ProductQuantity      = -x.AdjustQuantity;
                            acctLog.OutStockTime         = adjustRequestInfo.OutStockDate;
                            acctLog.CreateCost           = x.AdjustCost;
                            acctLog.OrderSysNo           = adjustRequestInfo.SysNo;
                            acctLog.CompanyCode          = adjustRequestInfo.CompanyCode;
                            acctLog.StoreCompanyCode     = adjustRequestInfo.CompanyCode;
                            acctLog.IsConsign            = (int)adjustRequestInfo.ConsignFlag;
                            acctLogInfoList.Add(acctLog);
                        });

                        if (acctLogInfoList.Count > 0)
                        {
                            foreach (var item in acctLogInfoList)
                            {
                                InventoryDA.CreatePOConsignToAccLogForInventory(item);
                            }
                        }
                    }
                    #endregion

                    #region
                    string InUser = "******";
                    List <InventoryBatchDetailsInfo> batchDetailsInfoEntitylist = InventoryDA.GetBatchDetailsInfoEntityListByNumber(adjustRequestInfo.SysNo.Value);
                    if (batchDetailsInfoEntitylist != null && batchDetailsInfoEntitylist.Count > 0)
                    {
                        #region 构建损益单 出库调整批次库存表的SSB消息 调整库存
                        List <ItemBatchInfo> itemBatchInfoList = new List <ItemBatchInfo>();
                        foreach (var item in batchDetailsInfoEntitylist)
                        {
                            ItemBatchInfo itemBatchInfo = new ItemBatchInfo();
                            itemBatchInfo.BatchNumber   = item.BatchNumber;
                            itemBatchInfo.ProductNumber = item.ProductSysNo.ToString();
                            Stock stock = new Stock();
                            AdjustRequestItemInfo aEntity = new AdjustRequestItemInfo();
                            aEntity = adjustRequestInfo.AdjustItemInfoList.Find(x => { return(x.ProductSysNo == item.ProductSysNo); });
                            if (aEntity != null && aEntity.AdjustQuantity > 0)
                            {
                                stock.Quantity     = item.Quantity.ToString(); //单据出库两个数量都要调整
                                stock.AllocatedQty = string.Empty;             //益单不调 占用库存 作废 取消作废 单据 只调整 占用库存
                            }
                            else
                            {
                                stock.Quantity     = item.Quantity.ToString(); //单据出库两个数量都要调整
                                stock.AllocatedQty = item.Quantity.ToString(); //损单 需要调整 占用库存 作废 取消作废 单据 只调整 占用库存
                            }
                            stock.WarehouseNumber = item.StockSysNo.ToString();
                            List <Stock> StockList = new List <Stock>();
                            StockList.Add(stock);

                            Stocks stocks = new Stocks();
                            stocks.Stock = StockList;

                            itemBatchInfo.Stocks = stocks;
                            itemBatchInfoList.Add(itemBatchInfo);
                        }
                        BatchXMLMessage batchXMLMessage = new BatchXMLMessage()
                        {
                            Header = new InventoryHeader
                            {
                                NameSpace          = "http://soa.ECommerce.com/InventoryProfile",
                                Action             = "OutStock",
                                Version            = "V10",
                                Type               = "Adjust",
                                CompanyCode        = "8601",
                                Tag                = "AdjustOutStock",
                                Language           = "zh-CN",
                                From               = "IPP",
                                GlobalBusinessType = "Listing",
                                StoreCompanyCode   = "8601",
                                TransactionCode    = adjustRequestInfo.SysNo.ToString()
                            },
                            Body = new InventoryBody
                            {
                                InUser        = InUser,
                                Number        = adjustRequestInfo.SysNo.ToString(),
                                ItemBatchInfo = itemBatchInfoList
                            }
                        };
                        string      paramXml = SerializationUtility.XmlSerialize(batchXMLMessage);
                        XmlDocument xmlD     = new XmlDocument();
                        xmlD.LoadXml(paramXml);
                        paramXml = "<" + xmlD.DocumentElement.Name + ">" + xmlD.DocumentElement.InnerXml + "</" + xmlD.DocumentElement.Name + ">";

                        InventoryDA.AdjustBatchNumberInventory(paramXml);//调整批次库存表 占用数量
                        #endregion
                    }
                    List <InventoryAdjustItemInfo> adjustCaseEntityList = new List <InventoryAdjustItemInfo>();
                    foreach (var item in inventoryAdjustContract.AdjustItemList)
                    {
                        if (!InventoryDA.CheckISBatchNumberProduct(item.ProductSysNo))
                        {
                            item.AdjustQuantity = item.AdjustQuantity;

                            adjustCaseEntityList.Add(item);
                        }
                    }
                    AdjustSendSSBToWMS(adjustRequestInfo.SysNo.Value, adjustRequestInfo.Stock.SysNo.ToString(), batchDetailsInfoEntitylist, adjustCaseEntityList);//损益单出库向仓库发送SSB消息

                    #endregion
                }

                scope.Complete();
            }

            return(adjustRequestInfo);
        }
Exemple #13
0
 public static AdjustRequestInfo GetAdjustRequestInfoBySysNo(int adjustSysNo)
 {
     return(InventoryDA.GetAdjustRequestInfoBySysNo(adjustSysNo));
 }
 private void buttonListBook_Click(object sender, EventArgs e)
 {
     listViewInventory.Items.Clear();
     InventoryDA.ListInventory(listViewInventory);
 }
Exemple #15
0
        /// <summary>
        /// 采购单确认入库(接口调用)
        /// </summary>
        /// <param name="poSysNo"></param>
        public static PurchaseOrderInfo WaitingInstockPO(PurchaseOrderInfo poInfo, List <KeyValuePair <string, int> > productList)
        {
            if (null == poInfo || !poInfo.SysNo.HasValue)
            {
                throw new BusinessException("找不到相关的采购单信息!");
            }
            if (poInfo.PurchaseOrderBasicInfo.PurchaseOrderStatus != PurchaseOrderStatus.Reporting)
            {
                throw new BusinessException("该采购单状态不是'申报中'状态,不能进行入库确认操作!");
            }
            if (productList == null || productList.Count <= 0)
            {
                throw new BusinessException("该采购单商品明细传入为空!");
            }
            //poInfo.PurchaseOrderBasicInfo.ETATimeInfo.ETATime = localEntity.PurchaseOrderBasicInfo.ETATimeInfo.ETATime;
            //poInfo.PurchaseOrderBasicInfo.ETATimeInfo.HalfDay = localEntity.PurchaseOrderBasicInfo.ETATimeInfo.HalfDay;
            TransactionOptions options = new TransactionOptions();

            options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
            options.Timeout        = System.Transactions.TransactionManager.DefaultTimeout;
            using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options))
            {
                #region 更新PO单Item的PurchaseQty:
                if (null != productList && productList.Count > 0)
                {
                    foreach (var item in productList)
                    {
                        var poItem = poInfo.POItems.SingleOrDefault(x => x.ProductID.Trim().ToLower() == item.Key.Trim().ToLower());
                        if (null != poItem)
                        {
                            if (poItem.PrePurchaseQty < item.Value)
                            {
                                throw new BusinessException(string.Format("采购单编号:{0},商品ID为{1}的实际采购数量(ItemNum)大于计划采购数量!", poInfo.SysNo.Value, item.Key));
                            }

                            poItem.PurchaseQty = item.Value;
                            ProductPurchaseDA.UpdatePOItemPurchaseQty(poItem.ItemSysNo.Value, item.Value);
                        }
                        else
                        {
                            throw new BusinessException(string.Format("采购单编号:{0},找不到商品ID为{1}的采购单商品信息!", poInfo.SysNo.Value, item.Key));
                        }
                    }
                }
                #endregion

                #region 更新采购单状态:
                poInfo.PurchaseOrderBasicInfo.PurchaseOrderStatus = PurchaseOrderStatus.WaitingInStock;
                poInfo.PurchaseOrderBasicInfo.MemoInfo.RefuseMemo = string.Empty;

                ProductPurchaseDA.WaitingInStockPO(poInfo);
                #endregion

                #region 更新POItem信息:
                List <KeyValuePair <int, int> > kv = new List <KeyValuePair <int, int> >();
                foreach (PurchaseOrderItemInfo item in poInfo.POItems)
                {
                    kv.Add(new KeyValuePair <int, int>(item.ProductSysNo.Value, item.PurchaseQty.Value));

                    //总仓有效库存 上月销售总量
                    PurchaseOrderItemInfo tempPoItem = ProductPurchaseDA.LoadExtendPOItem(item.ProductSysNo.Value);
                    item.M1                  = tempPoItem.M1;
                    item.AvailableQty        = tempPoItem.AvailableQty;
                    item.UnitCostWithoutTax  = item.UnitCostWithoutTax ?? 0;
                    item.CurrentUnitCost     = tempPoItem.CurrentUnitCost;
                    item.CurrentPrice        = tempPoItem.CurrentPrice;
                    item.LastInTime          = tempPoItem.LastInTime;
                    item.LastAdjustPriceDate = tempPoItem.LastAdjustPriceDate;
                    item.LastOrderPrice      = tempPoItem.LastOrderPrice;
                    ProductPurchaseDA.UpdatePOItem(item);
                }
                #endregion

                #region 设置采购在途数量,(代销PO该业务逻辑不变)

                ProductPurchaseInstockAdjustInventoryInfo inventoryAdjustInfo = new ProductPurchaseInstockAdjustInventoryInfo()
                {
                    ReferenceSysNo   = poInfo.SysNo.Value,
                    SourceActionName = "Audit",
                    AdjustItemList   = new List <Entity.Inventory.InventoryAdjustItemInfo>()
                };
                kv.ForEach(x =>
                {
                    inventoryAdjustInfo.AdjustItemList.Add(new InventoryAdjustItemInfo()
                    {
                        ProductSysNo   = x.Key,
                        StockSysNo     = poInfo.PurchaseOrderBasicInfo.StockInfo.SysNo.Value,
                        AdjustQuantity = x.Value
                    });
                });

                foreach (InventoryAdjustItemInfo adjustItem in inventoryAdjustInfo.AdjustItemList)
                {
                    //this.CurrentAdjustItemInfo = adjustItem;
                    //this.AdjustQuantity = adjustItem.AdjustQuantity;
                    //ProcessAdjustItemInfo();
                    CostLockType     costLockAction = CostLockType.NoUse;
                    ProductQueryInfo productInfo    = ProductService.GetProductBySysNo(adjustItem.ProductSysNo);
                    if (productInfo == null || productInfo.SysNo <= 0)
                    {
                        throw new BusinessException(string.Format("欲调库存的商品不存在,商品编号:{0}", adjustItem.ProductSysNo));
                    }
                    InventoryDA.InitProductInventoryInfo(adjustItem.ProductSysNo, adjustItem.StockSysNo);
                    var inventoryType = InventoryDA.GetProductInventroyType(adjustItem.ProductSysNo);
                    ECommerce.Entity.Inventory.ProductInventoryInfo stockInventoryCurrentInfo = InventoryDA.GetProductInventoryInfoByStock(adjustItem.ProductSysNo, adjustItem.StockSysNo);
                    ECommerce.Entity.Inventory.ProductInventoryInfo totalInventoryCurrentInfo = InventoryDA.GetProductTotalInventoryInfo(adjustItem.ProductSysNo);

                    ECommerce.Entity.Inventory.ProductInventoryInfo stockInventoryAdjustInfo = new Entity.Inventory.ProductInventoryInfo()
                    {
                        ProductSysNo = adjustItem.ProductSysNo,
                        StockSysNo   = adjustItem.StockSysNo
                    };

                    ECommerce.Entity.Inventory.ProductInventoryInfo totalInventoryAdjustInfo = new ECommerce.Entity.Inventory.ProductInventoryInfo()
                    {
                        ProductSysNo = adjustItem.ProductSysNo
                    };
                    //获取负po的成本库存
                    List <ProductCostIn> productCostInList = InventoryDA.GetProductCostIn(adjustItem.ProductSysNo, Convert.ToInt32(inventoryAdjustInfo.ReferenceSysNo), adjustItem.StockSysNo);


                    List <ProductCostIn> adjustProductCostInList = new List <ProductCostIn>();
                    int CanUseQuantity = 0;
                    //区分正负PO单
                    if (adjustItem.AdjustQuantity < 0)
                    {
                        //负PO单审核, AdjustQty<0, 减少可用库存, 增加已分配库存
                        stockInventoryAdjustInfo.AvailableQty = adjustItem.AdjustQuantity;
                        totalInventoryAdjustInfo.AvailableQty = adjustItem.AdjustQuantity;

                        if (adjustItem.AdjustQuantity < 0)
                        {
                            //AllocatedQty(-,->0),小于0则自动调为0。
                            if (stockInventoryCurrentInfo.AllocatedQty + adjustItem.AdjustQuantity < 0)
                            {
                                stockInventoryAdjustInfo.AllocatedQty = -stockInventoryCurrentInfo.AllocatedQty;
                            }
                            else
                            {
                                stockInventoryAdjustInfo.AllocatedQty = adjustItem.AdjustQuantity;
                            }

                            if (totalInventoryCurrentInfo.AllocatedQty + adjustItem.AdjustQuantity < 0)
                            {
                                totalInventoryAdjustInfo.AllocatedQty = -totalInventoryCurrentInfo.AllocatedQty;
                            }
                            else
                            {
                                totalInventoryAdjustInfo.AllocatedQty = adjustItem.AdjustQuantity;
                            }
                        }
                        else
                        {
                            stockInventoryAdjustInfo.AllocatedQty = adjustItem.AdjustQuantity;
                            totalInventoryAdjustInfo.AllocatedQty = adjustItem.AdjustQuantity;
                        }

                        //标识要锁定成本库存
                        costLockAction = CostLockType.Lock;
                        int temp = Math.Abs(adjustItem.AdjustQuantity);
                        //锁定库存
                        foreach (var item in productCostInList)
                        {
                            CanUseQuantity = item.LeftQuantity - item.LockQuantity;
                            //可用数量大于要锁定数量,直接累加加到锁定数量
                            if (CanUseQuantity >= temp)
                            {
                                item.LockQuantity += temp;
                                adjustProductCostInList.Add(item);
                                break;
                            }
                            else if (CanUseQuantity > 0) //可用数量不足且大于0,
                            {
                                //调整数量减少相应值,进行一次锁定分配
                                temp = temp - CanUseQuantity;
                                //将可用加到锁定数量上
                                item.LockQuantity += CanUseQuantity;
                                adjustProductCostInList.Add(item);
                            }
                        }
                    }
                    else
                    {
                        //正PO单审核, AdjustQty>0, 增加采购库存
                        stockInventoryAdjustInfo.PurchaseQty = adjustItem.AdjustQuantity;
                        totalInventoryAdjustInfo.PurchaseQty = adjustItem.AdjustQuantity;
                    }

                    //预检调整后的商品库存是否合法
                    Entity.Inventory.ProductInventoryInfo stockInventoryAdjustAfterAdjust = InventoryService.PreCalculateInventoryAfterAdjust(stockInventoryCurrentInfo, stockInventoryAdjustInfo);
                    Entity.Inventory.ProductInventoryInfo totalInventoryAdjustAfterAdjust = InventoryService.PreCalculateInventoryAfterAdjust(totalInventoryCurrentInfo, totalInventoryAdjustInfo);

                    bool isNeedCompareAvailableQtyAndAccountQty = true;
                    InventoryService.PreCheckGeneralRules(stockInventoryAdjustAfterAdjust, ref isNeedCompareAvailableQtyAndAccountQty);
                    InventoryService.PreCheckGeneralRules(totalInventoryAdjustAfterAdjust, ref isNeedCompareAvailableQtyAndAccountQty);

                    //调整商品库存:

                    InventoryDA.AdjustProductStockInventoryInfo(stockInventoryAdjustInfo);
                    InventoryDA.AdjustProductTotalInventoryInfo(totalInventoryAdjustInfo);
                    //如果需要调整锁定库存
                    if (costLockAction != CostLockType.NoUse && adjustProductCostInList != null)
                    {
                        InventoryDA.LockProductCostInList(adjustProductCostInList);
                    }
                }
                #endregion

                #region 如果是负采购单,调整批次库存:
                if (poInfo.PurchaseOrderBasicInfo.PurchaseOrderType == PurchaseOrderType.Negative)
                {
                    SetInventoryInfo(poInfo, "");
                }

                #endregion

                scope.Complete();
            }
            return(poInfo);
        }
Exemple #16
0
        /// <summary>
        /// 调整批次库存
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="sysNo"></param>
        private static void SetInventoryInfo(PurchaseOrderInfo entity, string sysNo)
        {
            string xml    = @"<Message>
                              <Header>
                                <NameSpace>http://soa.ECommerce.com/CustomerProfile</NameSpace>
                                <Action>#Audit#</Action>
                                <Version>V10</Version>
                                <Type>NPO</Type>
                                <CompanyCode>#CompanyCode#</CompanyCode>      
                                <Tag>POInstock</Tag>
                                <Language>zh-CN</Language>
                                <From>IPP</From>
                                <GlobalBusinessType>Listing</GlobalBusinessType>
                                <StoreCompanyCode>#StoreCompanyCode#</StoreCompanyCode>   
                                <TransactionCode>05-001-0-001</TransactionCode>
                              </Header>
                                <Body>
                                   <Number>#Number#</Number> 
                                   <InUser>#InUser#</InUser>  
                                   ######
                                </Body>
                            </Message>";
            string batch  = @"<ItemBatchInfo>
                                       <BatchNumber>#BatchNumber#</BatchNumber>  
                                       <Status></Status>
                                       <ProductNumber>#ProductNumber#</ProductNumber> 
                                       <ExpDate></ExpDate>
                                       <MfgDate></MfgDate>
                                       <LotNo></LotNo>
                                       <Stocks>
                                          <Stock>
                                          <Quantity>#Quantity#</Quantity>            
                                          <AllocatedQty>#Quantity#</AllocatedQty>  
                                          <WarehouseNumber>#WarehouseNumber#</WarehouseNumber> 
                                          </Stock>
                                       </Stocks>
                                   </ItemBatchInfo>";
            string newxml = xml.Replace("#InUser#", entity.PurchaseOrderBasicInfo.AuditUserSysNo.ToString())
                            .Replace("#Number#", entity.SysNo.ToString())
                            .Replace("#StoreCompanyCode#", entity.CompanyCode)
                            .Replace("#CompanyCode#", entity.CompanyCode);

            if (sysNo == "")
            {
                newxml = newxml.Replace("#Audit#", "Audit");
            }
            else
            {
                newxml = newxml.Replace("#Audit#", "CancelAudit");
            }
            StringBuilder strb = new StringBuilder();

            foreach (var item in entity.POItems)
            {
                if (!ProductPurchaseDA.IsBatchProduct(item))
                {
                    continue;
                }

                string[] strs = item.BatchInfo.Split(new char[] { ';' });
                foreach (string str in strs)
                {
                    string[] strChild = str.Split(new char[] { ':' });
                    if (strChild.Length == 3)
                    {
                        strb.Append(batch.Replace("#WarehouseNumber#", strChild[1])
                                    .Replace("#Quantity#", sysNo + strChild[2])
                                    .Replace("#ProductNumber#", item.ProductSysNo.ToString())
                                    .Replace("#BatchNumber#", strChild[0])
                                    );
                    }
                }
            }

            InventoryDA.AdjustBatchNumberInventory(newxml.Replace("######", strb.ToString()));
        }
 public InventoryFactory()
 {
     invenDa = new InventoryDA();
 }