Esempio n. 1
0
        private static void AddStockInfo(PresentInfo presentInfo)
        {
            StockInfo stockInfo = new StockInfo();

            stockInfo.StockId   = StockManage.GetMaxId() + 1;
            stockInfo.StockNum  = StockItem.GetInStockNum();
            stockInfo.InputTime = DateTime.Now;
            stockInfo.StockType = StockType.InStock;
            stockInfo.Inputer   = PEContext.Current.Admin.AdminName;
            stockInfo.Remark    = "商品库存初始";
            if (StockManage.Add(stockInfo))
            {
                StockItemInfo info = new StockItemInfo();
                info.Amount      = presentInfo.Stocks;
                info.Price       = presentInfo.Price;
                info.ProductId   = presentInfo.PresentId;
                info.TableName   = string.Empty;
                info.Property    = string.Empty;
                info.ProductNum  = presentInfo.PresentNum;
                info.Unit        = presentInfo.Unit;
                info.ProductName = presentInfo.PresentName;
                StockItem.Add(info, stockInfo.StockId);
            }
        }
Esempio n. 2
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);
        }
Esempio n. 3
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);
        }
Esempio n. 4
0
        public static int BatchImport(DataTable dtField, string filePath, string specialId, int nodeId, int modelId)
        {
            ModelInfo modelInfoById = ModelManager.GetModelInfoById(modelId);

            if (modelInfoById.IsNull)
            {
                return(0);
            }
            string      tableName = modelInfoById.TableName;
            ProductInfo info      = new ProductInfo();

            info.EnableWholesale   = false;
            info.EnableSingleSell  = true;
            info.SalePromotionType = 0;
            info.ProductCharacter  = modelInfoById.Character;
            DataTable dataTable = GetDataTableFromModel(modelId, specialId, nodeId);

            info.Fields = ContentManage.GetNewContentData(dataTable);
            OleDbConnection  selectConnection  = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filePath + ";Extended Properties=\"Excel 8.0;HDR=Yes;IMEX=1\"");
            string           selectCommandText = "select * from [sheet1$]";
            OleDbDataAdapter adapter           = new OleDbDataAdapter(selectCommandText, selectConnection);
            DataSet          dataSet           = new DataSet();

            try
            {
                adapter.Fill(dataSet, "ss");
            }
            catch (OleDbException)
            {
            }
            StringBuilder builder = new StringBuilder();
            int           num2    = 0;

            for (int i = 0; i < dataSet.Tables[0].Rows.Count; i++)
            {
                int newProductId = GetNewProductId();
                info.ProductId = newProductId;
                DataRow rows = dataSet.Tables[0].Rows[i];
                info.ProductName = GetExcelFieldValue(rows, dtField, "ProductName", string.Empty);
                info.ProductNum  = GetExcelFieldValue(rows, dtField, "ProductNum", string.Empty);
                if (string.IsNullOrEmpty(info.ProductNum))
                {
                    Random random = new Random();
                    info.ProductNum = DateTime.Now.ToString("yyyyMMddHHmmss") + random.Next().ToString();
                }
                else if (IsExistSameProductNum(info.ProductNum))
                {
                    builder.Append("<li>商品:" + info.ProductName + "的编号已存在,未导入!</li>");
                    continue;
                }
                info.Unit                  = GetExcelFieldValue(rows, dtField, "Unit", "个");
                info.PriceInfo.Price       = DataConverter.CDecimal(GetExcelFieldValue(rows, dtField, "Price", string.Empty));
                info.PriceMarket           = DataConverter.CDecimal(GetExcelFieldValue(rows, dtField, "Price_Market", string.Empty));
                info.Weight                = DataConverter.CDouble(GetExcelFieldValue(rows, dtField, "Weight", string.Empty));
                info.Stocks                = DataConverter.CLng(GetExcelFieldValue(rows, dtField, "Stocks", string.Empty));
                info.AlarmNum              = DataConverter.CLng(GetExcelFieldValue(rows, dtField, "AlarmNum", string.Empty));
                info.ProducerName          = GetExcelFieldValue(rows, dtField, "ProducerName", string.Empty);
                info.TrademarkName         = GetExcelFieldValue(rows, dtField, "TrademarkName", string.Empty);
                info.BarCode               = GetExcelFieldValue(rows, dtField, "BarCode", string.Empty);
                info.ProductIntro          = GetExcelFieldValue(rows, dtField, "ProductIntro", string.Empty);
                info.ProductExplain        = GetExcelFieldValue(rows, dtField, "ProductExplain", string.Empty);
                info.Stars                 = DataConverter.CLng(GetExcelFieldValue(rows, dtField, "Stars", "3"));
                info.PriceInfo.PriceMember = DataConverter.CDecimal(GetExcelFieldValue(rows, dtField, "PriceMember", string.Empty));
                info.PriceInfo.PriceAgent  = DataConverter.CDecimal(GetExcelFieldValue(rows, dtField, "PriceAgent", string.Empty));
                DataRow[] rowArray = info.Fields.Select("FieldName='Title'");
                if (rowArray.Length == 0)
                {
                    AddNewRows(dataTable, "Title", info.ProductName, FieldType.TitleType, 0);
                }
                else
                {
                    rowArray[0][1] = info.ProductName;
                }
                foreach (DataRow row2 in info.Fields.Select("FieldLevel=1"))
                {
                    string str5 = GetExcelFieldValue(rows, dtField, row2["FieldName"].ToString() + "_F", string.Empty);
                    if (string.IsNullOrEmpty(str5))
                    {
                        goto Label_04AA;
                    }
                    FieldType fieldtype = (FieldType)Enum.Parse(typeof(FieldType), row2["FieldType"].ToString());
                    string    name      = Field.GetFieldDataType(fieldtype).Name;
                    if (name != null)
                    {
                        if (!(name == "Double"))
                        {
                            if (name == "Decimal")
                            {
                                goto Label_0448;
                            }
                            if (name == "DateTime")
                            {
                                goto Label_045C;
                            }
                            if (name == "Boolean")
                            {
                                goto Label_0476;
                            }
                            if (name == "Int32")
                            {
                                goto Label_048A;
                            }
                        }
                        else
                        {
                            str5 = DataConverter.CDouble(str5).ToString();
                        }
                    }
                    goto Label_049C;
Label_0448:
                    str5 = DataConverter.CDecimal(str5).ToString();
                    goto Label_049C;
Label_045C:
                    str5 = DataConverter.CDate(str5).ToString();
                    goto Label_049C;
Label_0476:
                    str5 = DataConverter.CBoolean(str5).ToString();
                    goto Label_049C;
Label_048A:
                    str5 = DataConverter.CLng(str5).ToString();
Label_049C:
                    row2["FieldValue"] = str5;
                    Label_04AA :;
                }
                bool      flag      = Add(modelId, tableName, info);
                StockInfo stockInfo = new StockInfo();
                stockInfo.StockId  = StockManage.GetMaxId() + 1;
                stockInfo.StockNum = StockItem.GetInStockNum();
                DataRow[] rowArray3 = info.Fields.Select("FieldName='Inputer'");
                if (rowArray3.Length > 0)
                {
                    stockInfo.Inputer = rowArray3[0]["FieldValue"].ToString();
                }
                stockInfo.InputTime = DateTime.Now;
                stockInfo.StockType = StockType.InStock;
                stockInfo.Remark    = "商品库存初始";
                StockManage.Add(stockInfo);
                if (flag)
                {
                    IList <StockItemInfo> infoList = new List <StockItemInfo>();
                    StockItemInfo         item     = new StockItemInfo();
                    item.Amount      = info.Stocks;
                    item.Price       = info.PriceInfo.Price;
                    item.ProductId   = newProductId;
                    item.TableName   = tableName;
                    item.Property    = string.Empty;
                    item.ProductNum  = info.ProductNum;
                    item.Unit        = info.Unit;
                    item.ProductName = info.ProductName;
                    infoList.Add(item);
                    StockItem.Add(infoList, stockInfo.StockId);
                }
                else
                {
                    builder.Append("<li>商品:" + info.ProductName + "导入失败!</li>");
                    continue;
                }
                num2++;
            }
            s_MessgeOfBatchImport = builder.ToString();
            dataSet.Dispose();
            adapter.Dispose();
            selectConnection.Dispose();
            return(num2);
        }