Пример #1
0
        public static void AddStockItemBySendCard(int stockId, OrderItemInfo orderItemInfo)
        {
            string productNum = string.Empty;

            if (!string.IsNullOrEmpty(orderItemInfo.TableName))
            {
                ProductInfo productById = Product.GetProductById(orderItemInfo.ProductId);
                productById.Stocks   -= orderItemInfo.Amount;
                productById.OrderNum -= orderItemInfo.Amount;
                ProductCommon.Update(productById, productById.TableName);
                productNum = productById.ProductNum;
            }
            else
            {
                PresentInfo presentById = Present.GetPresentById(orderItemInfo.ProductId);
                presentById.Stocks   -= orderItemInfo.Amount;
                presentById.OrderNum -= orderItemInfo.Amount;
                Present.UpdatePressent(presentById);
                productNum = presentById.PresentNum;
            }
            StockItemInfo info3 = new StockItemInfo();

            info3.Amount      = orderItemInfo.Amount;
            info3.Price       = orderItemInfo.TruePrice;
            info3.ProductId   = orderItemInfo.ProductId;
            info3.TableName   = orderItemInfo.TableName;
            info3.ProductName = orderItemInfo.ProductName;
            info3.ProductNum  = productNum;
            info3.Property    = orderItemInfo.Property;
            info3.StockId     = stockId;
            info3.Unit        = orderItemInfo.Unit;
            StockItem.Add(info3, stockId);
        }
Пример #2
0
        private static Parameters GetParameters(StockItemInfo stockItemInfo)
        {
            Parameters parameters = new Parameters();

            parameters.AddInParameter("@ItemID", DbType.Int32, stockItemInfo.ItemId);
            parameters.AddInParameter("@StockID", DbType.Int32, stockItemInfo.StockId);
            parameters.AddInParameter("@ProductID", DbType.Int32, stockItemInfo.ProductId);
            parameters.AddInParameter("@TableName", DbType.String, stockItemInfo.TableName);
            parameters.AddInParameter("@Property", DbType.String, stockItemInfo.Property);
            parameters.AddInParameter("@Amount", DbType.Int32, stockItemInfo.Amount);
            parameters.AddInParameter("@Price", DbType.Currency, stockItemInfo.Price);
            return(parameters);
        }
Пример #3
0
 private static void AddStocks(CardInfo info, int qty)
 {
     if (info.ProductId > 0)
     {
         StockInfo stockInfo = new StockInfo();
         stockInfo.StockId   = StockManage.GetMaxId() + 1;
         stockInfo.Inputer   = PEContext.Current.Admin.AdminName;
         stockInfo.InputTime = DateTime.Now;
         stockInfo.Remark    = (qty > 1) ? "批量生成点卡" : "生成点卡";
         stockInfo.StockNum  = StockItem.GetInStockNum();
         stockInfo.StockType = StockType.InStock;
         if (StockManage.Add(stockInfo))
         {
             decimal price       = 0M;
             string  productNum  = string.Empty;
             string  unit        = string.Empty;
             string  productName = string.Empty;
             if (!string.IsNullOrEmpty(info.TableName))
             {
                 Product.AddStocks(info.ProductId, qty);
                 ProductInfo productById = Product.GetProductById(info.ProductId);
                 price       = productById.PriceInfo.Price;
                 productNum  = productById.ProductNum;
                 unit        = productById.Unit;
                 productName = productById.ProductName;
             }
             else
             {
                 Present.AddStocks(info.ProductId, qty);
                 PresentInfo presentById = Present.GetPresentById(info.ProductId);
                 price       = presentById.Price;
                 productNum  = presentById.PresentNum;
                 unit        = presentById.Unit;
                 productName = presentById.PresentName;
             }
             if (!string.IsNullOrEmpty(productName))
             {
                 StockItemInfo info5 = new StockItemInfo();
                 info5.Amount      = qty;
                 info5.ItemId      = StockItem.GetMaxId() + 1;
                 info5.ProductId   = info.ProductId;
                 info5.TableName   = info.TableName;
                 info5.Price       = price;
                 info5.ProductNum  = productNum;
                 info5.Unit        = unit;
                 info5.ProductName = productName;
                 StockItem.Add(info5, stockInfo.StockId);
             }
         }
     }
 }
Пример #4
0
        private static StockItemInfo StockItemFromrdr(NullableDataReader rdr)
        {
            StockItemInfo info = new StockItemInfo();

            info.ItemId      = rdr.GetInt32("ItemID");
            info.StockId     = rdr.GetInt32("StockID");
            info.ProductId   = rdr.GetInt32("ProductID");
            info.TableName   = rdr.GetString("TableName");
            info.Property    = rdr.GetString("Property");
            info.Amount      = rdr.GetInt32("Amount");
            info.Price       = rdr.GetDecimal("Price");
            info.ProductName = rdr.GetString("ProductName");
            info.ProductNum  = rdr.GetString("ProductNum");
            info.Unit        = rdr.GetString("Unit");
            return(info);
        }
Пример #5
0
 private static bool DeleteSingleCard(CardInfo info, int stockId)
 {
     if (Product.AddStocks(info.ProductId, -1))
     {
         ProductInfo productById = Product.GetProductById(info.ProductId, info.TableName);
         if (!productById.IsNull)
         {
             StockItemInfo info3 = new StockItemInfo();
             info3.Amount      = 1;
             info3.Price       = productById.PriceInfo.Price;
             info3.ProductId   = productById.ProductId;
             info3.TableName   = productById.TableName;
             info3.Unit        = productById.Unit;
             info3.ProductNum  = productById.ProductNum;
             info3.ProductName = productById.ProductName;
             return(StockItem.Add(info3, stockId));
         }
     }
     return(false);
 }
Пример #6
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);
            }
        }
Пример #7
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);
        }
Пример #8
0
 public bool Add(StockItemInfo stockItemInfo)
 {
     return(DBHelper.ExecuteSql("INSERT INTO PE_StockItem(ItemID, StockID, ProductID, [TableName], [Property], Amount, Price) VALUES (@ItemID, @StockID, @ProductID, @TableName, @Property, @Amount, @Price)", GetParameters(stockItemInfo)));
 }
Пример #9
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);
        }
Пример #10
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);
        }
Пример #11
0
 public static bool Add(StockItemInfo info, int stockId)
 {
     info.ItemId  = GetMaxId() + 1;
     info.StockId = stockId;
     return(dal.Add(info));
 }