コード例 #1
0
        public ActionResult GetProductNumber(string classfiy, string series, string brand)
        {
            var        classfiyID = product_ClassfiyBLL.GetModel(p => p.分类名称 == classfiy).ID; //分类ID(沙发、床。。。)
            var        seriesID   = product_SeriesBLL.GetModel(p => p.系列 == series).ID;       //系列ID(时光,绽放。。)
            var        brandID    = product_BrandBLL.GetModel(p => p.品牌名称 == brand).ID;       //品牌ID(CHIC CASA,CHIC HOME,CHIC ALIVAR。。)
            SelectList productSelectListItems;

            try
            {
                var producCodetID = productCodeBLL.GetModel(p => p.分类ID == classfiyID && p.品牌ID == brandID && p.系列ID == seriesID).ID; //型号ID
                var productList   = productBLL.GetModels(p => p.型号ID == producCodetID).ToList();                                      //商品集合
                productSelectListItems = new SelectList(productList, "编号", "编号");
            }
            catch (Exception)
            {
                return(Json("null"));
            }

            return(Json(productSelectListItems));
        }
コード例 #2
0
        public ActionResult ExceptedBuyAdd(string exceptModel)
        {
            if (Session["method"].ToString() == "Y")
            {
                string str = string.Format("<script>alert('重复操作!');parent.location.href='CustomerIndex';</script>");
                return(Json(str));
            }
            List <CustomerExceptedBuyModel> list = JsonConvert.DeserializeObject <List <CustomerExceptedBuyModel> >(exceptModel);

            if (list.Count == 0)
            {
                return(Json("<script>alert('不存在你跟进的客户,你不能执行预购操作!');window.history.go(-1);</script>"));
            }
            foreach (var item in list)
            {
                销售_接待记录_意向明细 model = new 销售_接待记录_意向明细
                {
                    商品型号ID = productCodeBLL.GetModel(p => p.型号 == item.型号).ID,
                    备注     = item.备注,
                    接待ID   = item.接待,
                    空间     = item.空间
                };
                if (ModelState.IsValid)
                {
                    exceptedBuyBLL.Add(model);
                    Session["method"] = "Y";
                }

                else
                {
                    List <string> sb = new List <string>();
                    //获取所有错误的Key
                    List <string> Keys = ModelState.Keys.ToList();
                    //获取每一个key对应的ModelStateDictionary
                    foreach (var key in Keys)
                    {
                        var errors = ModelState[key].Errors.ToList();
                        //将错误描述添加到sb中
                        foreach (var error in errors)
                        {
                            sb.Add(error.ErrorMessage);
                        }
                    }
                    string s = null;
                    foreach (var it in sb)
                    {
                        s += it.ToString() + ";";
                    }
                    return(Json("<script>alert('" + s + "');window.history.go(-1);</script>"));
                }
            }


            //BuildExceptedBuy(model.接待ID);
            //ViewBag.receptionid = model.接待ID;
            //var productList = productCodeBLL.GetModels(p => true).ToList();
            //SelectList productSelectListItems = new SelectList(productList, "型号", "型号");
            //ViewBag.ProductOptions = productSelectListItems;
            //return RedirectToAction("ExceptedBuyIndex", new { id = list.FirstOrDefault().接待 });
            return(Json("success"));
        }