private void InStorage(string proId, int iQuan, string warehouseId)
        {
            Product           proEnt = Product.Find(proId);
            Warehouse         whEnt  = Warehouse.Find(warehouseId);
            IList <StockInfo> siEnts = StockInfo.FindAll("from StockInfo where ProductId='" + proId + "' and WarehouseId='" + warehouseId + "'");

            if (siEnts.Count > 0)
            {
                siEnts[0].StockQuantity = siEnts[0].StockQuantity + iQuan;
                siEnts[0].DoUpdate();
            }
            else
            {
                StockInfo siEnt = new StockInfo();
                siEnt.ProductId     = proId;
                siEnt.WarehouseId   = warehouseId;
                siEnt.WarehouseName = whEnt.Name;
                siEnt.ProductCode   = proEnt.Code;
                siEnt.ProductName   = proEnt.Name;
                siEnt.StockQuantity = iQuan;
                siEnt.DoCreate();
            }
        }
        string type = String.Empty; // 对象类型

        #endregion

        #region ASP.NET 事件

        protected void Page_Load(object sender, EventArgs e)
        {
            switch (this.RequestAction)
            {
            case RequestActionEnum.Insert:
            case RequestActionEnum.Create:

                //添加库存数量
                string WarehouseId              = RequestData.Get <string>("WarehouseId");
                string WarehouseName            = RequestData.Get <string>("WarehouseName");
                string json                     = RequestData.Get <string>("json");
                Dictionary <string, object> dic = null;

                json = json.Substring(1, json.Length - 2);
                string[] objarr = json.Replace("},{", "#").Split('#');

                for (int i = 0; i < objarr.Length; i++)
                {
                    if (objarr.Length == 1)
                    {
                        dic = FromJson(objarr[i]) as Dictionary <string, object>;
                    }
                    else
                    {
                        if (i == 0)
                        {
                            dic = FromJson(objarr[i] + "}") as Dictionary <string, object>;
                        }
                        else if (i == objarr.Length - 1)
                        {
                            dic = FromJson("{" + objarr[i]) as Dictionary <string, object>;
                        }
                        else
                        {
                            dic = FromJson("{" + objarr[i] + "}") as Dictionary <string, object>;
                        }
                    }
                    if (dic != null)
                    {
                        StockInfo stoinfo = StockInfo.FindAllByProperties("ProductId", dic["Id"], "WarehouseId", WarehouseId).FirstOrDefault <StockInfo>();
                        if (stoinfo != null)
                        {
                            stoinfo.StockQuantity = (stoinfo.StockQuantity == null ? 0 : stoinfo.StockQuantity) + (dic.ContainsKey("Count") ? Convert.ToInt32(dic["Count"]) : 0);
                            stoinfo.DoUpdate();
                        }
                        else
                        {
                            stoinfo = new StockInfo
                            {
                                ProductCode   = dic["Code"] + "",
                                ProductName   = dic["Name"] + "",
                                ProductId     = dic["Id"] + "",
                                WarehouseId   = WarehouseId,
                                WarehouseName = WarehouseName,
                                StockQuantity = dic.ContainsKey("Count") ? Convert.ToInt32(dic["Count"]) : 0
                            };
                            stoinfo.DoCreate();
                        }
                    }
                }

                break;
            }
        }
        /// <summary>
        /// 更新库存
        /// </summary>
        /// <param name="childjson">出库单出库商品json</param>
        private void UpdateStockInfo(IList <string> strList, DeliveryOrder deorder)
        {
            string db       = ConfigurationManager.AppSettings["ExamineDB"];
            string strguids = "";

            Dictionary <string, object> dic = null;

            StockInfo stoinfo = null;

            for (int i = 0; i < strList.Count; i++)
            {
                dic = FromJson(strList[i]) as Dictionary <string, object>;

                if (dic != null)
                {
                    //记录日志begin
                    if (dic.ContainsKey("SmCount") && dic["SmCount"] + "" != "")
                    {
                        StockLog slEnt = new StockLog();//创建库存变更日志
                        slEnt.InOrOutDetailId = dic["Id"] + "";
                        slEnt.InOrOutBillNo   = deorder.Number;
                        slEnt.OperateType     = "产品出库";
                        slEnt.WarehouseId     = deorder.WarehouseId;
                        slEnt.WarehouseName   = deorder.WarehouseName;
                        IList <StockInfo> siEnts = StockInfo.FindAllByProperties(StockInfo.Prop_ProductId, dic["ProductId"], StockInfo.Prop_WarehouseId, deorder.WarehouseId);
                        if (siEnts.Count > 0)
                        {
                            slEnt.StockQuantity = siEnts[0].StockQuantity;
                        }
                        slEnt.Quantity  = Convert.ToInt32(dic["SmCount"]);
                        slEnt.ProductId = dic["ProductId"] + "";
                        Product pEnt = Product.Find(dic["ProductId"]);
                        slEnt.ProductCode = pEnt.Code;
                        slEnt.ProductName = pEnt.Name;
                        slEnt.ProductIsbn = pEnt.Isbn;
                        slEnt.ProductPcn  = pEnt.Pcn;
                        slEnt.DoCreate();
                    }
                    //记录日志end

                    //更新唯一编号的状态
                    if (dic.ContainsKey("Guids") && dic["Guids"] + "" != "")
                    {
                        string guids = dic["Guids"] + "";
                        guids    = guids.Substring(0, guids.Length - 1);
                        strguids = "'" + guids.Replace(",", "','") + "'";

                        DataHelper.ExecSql("update " + db + "..Compressor set [state]='已出库',CustomerId='" + deorder.CId + "',DeliveryOrderId='" + deorder.Id + "' where SeriesNo in (" + strguids + ")");
                    }
                    //更新库存 OutCount
                    stoinfo = StockInfo.FindAllByProperties("ProductId", dic["ProductId"], "WarehouseId", deorder.WarehouseId).FirstOrDefault <StockInfo>();
                    if (stoinfo != null)
                    {
                        //SmCount 本次出库数量
                        stoinfo.StockQuantity -= (dic.ContainsKey("SmCount") && dic["SmCount"] + "" != "" ? Convert.ToInt32(dic["SmCount"]) : 0);
                        stoinfo.DoUpdate();
                    }
                    else
                    {
                        stoinfo = new StockInfo
                        {
                            ProductCode   = dic["Code"] + "",
                            ProductId     = dic["ProductId"] + "",
                            ProductName   = dic["Name"] + "",
                            StockQuantity = -(dic.ContainsKey("SmCount") && dic["SmCount"] + "" != "" ? Convert.ToInt32(dic["SmCount"]) : 0),
                            WarehouseId   = deorder.WarehouseId,
                            WarehouseName = deorder.WarehouseName
                        };
                        stoinfo.DoCreate();
                    }
                }
            }
        }