Exemplo n.º 1
0
 //添加子商品
 private void InsertProPart(SaleOrder ent)
 {
     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)
         {
             //一个一个的添加
             entPart = new OrdersPart
             {
                 OId          = ent.Id,
                 PId          = dic["Id"] + "",
                 PName        = dic["Name"] + "",
                 PCode        = dic["Code"] + "",
                 Isbn         = dic["Isbn"] + "",
                 MinSalePrice = dic.ContainsKey("MinSalePrice") ? (decimal?)Convert.ToDecimal(dic["MinSalePrice"]) : null,
                 SalePrice    = dic.ContainsKey("Price") ? (decimal?)Convert.ToDecimal(dic["Price"]) : null,
                 Amount       = dic.ContainsKey("Amount") ? (decimal?)Convert.ToDecimal(dic["Amount"]) : null,
                 Unit         = dic.ContainsKey("Unit") ? dic["Unit"] + "" : null,
                 Count        = dic.ContainsKey("Count") ? (int?)Convert.ToInt32(dic["Count"]) : null,
                 Remark       = dic.ContainsKey("Remark") ? dic["Remark"] + "" : "",
                 IsValid      = true,
                 Guids        = dic.ContainsKey("Guids") ? dic["Guids"] + "" : "",
                 CreateId     = UserInfo.UserID,
                 CreateName   = UserInfo.Name,
                 CreateTime   = DateTime.Now
             };
             entPart.DoCreate();
         }
     }
 }
Exemplo n.º 2
0
        //添加子商品
        private void InsertProPart(SaleOrder ent, IList <string> strList)
        {
            for (int i = 0; i < strList.Count; i++)
            {
                dic = FromJson(strList[i]) as Dictionary <string, object>;

                if (dic != null)
                {
                    //一个一个的添加
                    entPart = new OrdersPart
                    {
                        OId             = ent.Id,
                        PId             = dic["PId"] + "",
                        PName           = dic["Name"] + "",
                        PCode           = dic["Code"] + "",
                        Isbn            = dic.ContainsKey("Isbn") ? dic["Isbn"] + "" : "",
                        MinSalePrice    = dic.ContainsKey("MinSalePrice") && dic["MinSalePrice"] + "" != "" ? (decimal?)Convert.ToDecimal(dic["MinSalePrice"]) : null,
                        SalePrice       = dic.ContainsKey("Price") && dic["Price"] + "" != "" ? (decimal?)Convert.ToDecimal(dic["Price"]) : null,
                        Amount          = dic.ContainsKey("Amount") && dic["Amount"] + "" != "NaN" ? (decimal?)Convert.ToDecimal(dic["Amount"]) : null,
                        Unit            = dic.ContainsKey("Unit") ? dic["Unit"] + "" : null,
                        Count           = dic.ContainsKey("Count") && dic["Count"] + "" != "" ? (int?)Convert.ToInt32(dic["Count"]) : null,
                        OutCount        = dic.ContainsKey("OutCount") && dic["OutCount"] + "" != "" ? (int?)Convert.ToInt32(dic["OutCount"]) : null,
                        CustomerOrderNo = dic.ContainsKey("CustomerOrderNo") ? dic["CustomerOrderNo"] + "" : "",
                        Remark          = dic.ContainsKey("Remark") ? dic["Remark"] + "" : "",
                        IsValid         = true,
                        Guids           = dic.ContainsKey("Guids") ? dic["Guids"] + "" : "",
                        CreateId        = UserInfo.UserID,
                        CreateName      = UserInfo.Name,
                        CreateTime      = ent.CreateTime
                    };
                    //entPart.OId = ent.Id;
                    //entPart.PId = dic["PId"] + "";
                    //entPart.MinSalePrice = dic.ContainsKey("MinSalePrice") && dic["MinSalePrice"] + "" != "" ? (decimal?)Convert.ToDecimal(dic["MinSalePrice"]) : null;
                    //entPart.SalePrice = dic.ContainsKey("Price") && dic["Price"] + "" != "" ? (decimal?)Convert.ToDecimal(dic["Price"]) : null;
                    //if (dic.ContainsKey("Amount"))
                    //{
                    //    entPart.Amount = Convert.ToDecimal(dic["Amount"]);
                    //}
                    entPart.DoCreate();
                }
            }
        }