Ejemplo n.º 1
0
        public static bool Add(DeliverItemInfo deliverItemInfo)
        {
            bool flag = false;
            IList <OrderItemInfo> infoListByOrderId = OrderItem.GetInfoListByOrderId(deliverItemInfo.OrderId);
            DeliverStatus         preparative       = DeliverStatus.Preparative;
            int num = 0;
            IList <StockItemInfo> infoList = new List <StockItemInfo>();
            bool flag2 = true;

            foreach (OrderItemInfo info in infoListByOrderId)
            {
                bool flag3 = false;
                if (Product.CharacterIsExists(info.ProductCharacter, ProductCharacter.Practicality))
                {
                    flag3 = true;
                }
                else if ((deliverItemInfo.DeliverDirection != 1) && Product.CharacterIsExists(info.ProductCharacter, ProductCharacter.Card))
                {
                    flag3 = true;
                }
                if (flag3)
                {
                    if (flag2)
                    {
                        num   = StockManage.GetMaxId() + 1;
                        flag2 = false;
                    }
                    int amount = info.Amount;
                    if (deliverItemInfo.DeliverDirection == 1)
                    {
                        amount = -amount;
                        Product.AddBuyTimes(info.ProductId, info.TableName);
                    }
                    if (string.IsNullOrEmpty(info.TableName))
                    {
                        Present.AddStocks(info.ProductId, amount);
                    }
                    else
                    {
                        Product.AddStocks(info.ProductId, amount, info.Property);
                    }
                    StockItemInfo item = new StockItemInfo();
                    item.Amount      = Math.Abs(amount);
                    item.ItemId      = StockItem.GetMaxId() + 1;
                    item.Price       = info.TruePrice;
                    item.ProductId   = info.ProductId;
                    item.TableName   = info.TableName;
                    item.Property    = info.Property;
                    item.ProductName = info.ProductName;
                    item.ProductNum  = "";
                    item.StockId     = num;
                    item.Unit        = info.Unit;
                    infoList.Add(item);
                    Product.AddOrderNum(info.ProductId, info.TableName, info.Property, amount);
                }
            }
            if (!flag2)
            {
                StockInfo stockInfo = new StockInfo();
                stockInfo.Inputer   = deliverItemInfo.HandlerName;
                stockInfo.InputTime = deliverItemInfo.DeliverDate;
                stockInfo.Remark    = "退货";
                stockInfo.StockId   = num;
                if (deliverItemInfo.DeliverDirection == 1)
                {
                    stockInfo.StockNum  = StockItem.GetShipmentNum();
                    stockInfo.StockType = StockType.Shipment;
                    stockInfo.Remark    = "订单" + deliverItemInfo.OrderNum + "发货";
                    preparative         = DeliverStatus.Consignment;
                }
                else
                {
                    stockInfo.StockNum  = StockItem.GetInStockNum();
                    stockInfo.StockType = StockType.InStock;
                    stockInfo.Remark    = "订单" + deliverItemInfo.OrderNum + "退货";
                }
                if (StockManage.Add(stockInfo))
                {
                    StockItem.Add(infoList, stockInfo.StockId);
                }
            }
            if (Order.UpdateDeliverStatus(deliverItemInfo.OrderId, preparative))
            {
                flag = dal.Add(deliverItemInfo);
            }
            return(flag);
        }
Ejemplo n.º 2
0
        public static bool Add(int modelId, ProductInfo productInfo, IList <ProductDataInfo> productDataInfoList, IList <ProductPriceInfo> priceInfoList)
        {
            ModelInfo modelInfoById = ModelManager.GetModelInfoById(modelId);

            if (modelInfoById.IsNull)
            {
                return(false);
            }
            string tableName    = modelInfoById.TableName;
            int    newProductId = GetNewProductId();

            productInfo.ProductId = newProductId;
            bool flag     = true;
            int  num2     = 0;
            int  alarmNum = 0;

            foreach (ProductDataInfo info2 in productDataInfoList)
            {
                num2    += info2.Stocks;
                alarmNum = info2.AlarmNum;
            }
            productInfo.Stocks   = num2;
            productInfo.AlarmNum = alarmNum;
            flag = Add(modelId, tableName, productInfo);
            StockInfo stockInfo = new StockInfo();

            stockInfo.StockId  = StockManage.GetMaxId() + 1;
            stockInfo.StockNum = StockItem.GetInStockNum();
            DataRow[] rowArray = productInfo.Fields.Select("FieldName='Inputer'");
            if (rowArray.Length > 0)
            {
                stockInfo.Inputer = rowArray[0]["FieldValue"].ToString();
            }
            stockInfo.InputTime = DateTime.Now;
            stockInfo.StockType = StockType.InStock;
            stockInfo.Remark    = "商品库存初始";
            StockManage.Add(stockInfo);
            if (flag)
            {
                IList <StockItemInfo> infoList = new List <StockItemInfo>();
                if (!string.IsNullOrEmpty(productInfo.Properties))
                {
                    flag = ProductData.Add(newProductId, tableName, productDataInfoList);
                    foreach (ProductDataInfo info4 in productDataInfoList)
                    {
                        StockItemInfo item = new StockItemInfo();
                        item.ItemId      = StockItem.GetMaxId() + 1;
                        item.Amount      = info4.Stocks;
                        item.Price       = info4.PriceInfo.Price;
                        item.ProductId   = newProductId;
                        item.TableName   = tableName;
                        item.Property    = info4.PropertyValue;
                        item.StockId     = stockInfo.StockId;
                        item.ProductNum  = productInfo.ProductNum;
                        item.Unit        = productInfo.Unit;
                        item.ProductName = productInfo.ProductName;
                        infoList.Add(item);
                    }
                }
                else
                {
                    StockItemInfo info6 = new StockItemInfo();
                    info6.Amount      = productInfo.Stocks;
                    info6.Price       = productInfo.PriceInfo.Price;
                    info6.ProductId   = newProductId;
                    info6.TableName   = tableName;
                    info6.Property    = string.Empty;
                    info6.ProductNum  = productInfo.ProductNum;
                    info6.Unit        = productInfo.Unit;
                    info6.ProductName = productInfo.ProductName;
                    infoList.Add(info6);
                }
                StockItem.Add(infoList, stockInfo.StockId);
                if (((productInfo.PriceInfo.PriceMember == -1M) || (productInfo.PriceInfo.PriceAgent == -1M)) && (priceInfoList != null))
                {
                    flag = ProductPrice.Add(newProductId, tableName, priceInfoList);
                }
            }
            return(flag);
        }