Пример #1
0
        private void DoBatchSave()
        {
            IList <string> entStrList = RequestData.GetList <string>("data");
            string         priceType  = RequestData.Get <string>("PriceType");
            string         sql        = string.Empty;

            if (entStrList != null && entStrList.Count > 0)
            {
                for (int k = 0; k < entStrList.Count; k++)
                {
                    Newtonsoft.Json.Linq.JObject objL    = JsonHelper.GetObject <Newtonsoft.Json.Linq.JObject>(entStrList[k]);
                    IList <ProductPriceDetail>   ppdEnts = ProductPriceDetail.FindAllByProperties("ProductId", objL.Value <string>("ProductId"), "PriceTypeName", priceType);
                    if (ppdEnts.Count > 0)
                    {
                        ppdEnts[0].Price = objL.Value <decimal>(priceType);
                        ppdEnts[0].DoUpdate();
                    }
                    else
                    {
                        ProductPriceDetail ppdEnt   = new ProductPriceDetail();
                        string             parentId = DataHelper.QueryValue("select EnumerationID from SHHG_AimPortal.dbo.SysEnumeration where Code='PriceType'").ToString();
                        SysEnumeration[]   seEnts   = SysEnumeration.FindAllByProperties("Name", priceType, "ParentID", parentId);
                        if (seEnts.Length > 0)
                        {
                            ppdEnt.EnumerationID = seEnts[0].EnumerationID;
                        }
                        ppdEnt.PriceTypeName = priceType;
                        ppdEnt.ProductId     = objL.Value <string>("ProductId");
                        ppdEnt.ProductName   = objL.Value <string>("产品名称");
                        ppdEnt.ProductCode   = objL.Value <string>("产品型号");
                        ppdEnt.ProductPCN    = objL.Value <string>("PCN");
                        ppdEnt.Price         = objL.Value <decimal>(priceType);
                        ppdEnt.DoCreate();
                    }
                }
            }
        }