/// <summary> /// 新增商品 /// </summary> /// <param name="Arr">图片数组</param> /// <param name="GoodsPrice">现价</param> /// <param name="GoodsName">名称</param> /// <param name="OldGoodsPrice">原价</param> /// <param name="GoodsInventory">库存</param> /// <param name="TID">分类id</param> /// <param name="GoodsDescribe">描述</param> /// <returns></returns> public JsonResult AddGoodsAjax() { GoodsTable good = new GoodsTable() { GoodsName = Request.Form["goodsname"], GoodsPrice = Convert.ToDecimal(Request.Form["goodsprice"]), OldGoodsPrice = Convert.ToDecimal(Request.Form["oldgoodsprice"]), TID = Convert.ToInt32(Request.Form["tid"]), GoodsInventory = Convert.ToInt32(Request.Form["goodsinventory"]), GoodsDescribe = Request.Form["goodsdescribe"] }; List <string> list = new List <string>(); for (int i = 0; i < Request.Files.Count; i++) { list.Add(Path.GetFileName(Request.Files[i].FileName)); } //调用新增方法 if (GoodsBll.AddGoods(good)) { //查询最后一条商品 GoodsTable lastgood = GoodsBll.SelectAllGoods().LastOrDefault(); //调用新增商品图片方法 if (GoodsPhotoBll.AddGoodsPhoto(lastgood.GoodsID, list)) { //保存图片 for (int i = 0; i < Request.Files.Count; i++) { Request.Files[i].SaveAs(Server.MapPath("~/Content/GoodImgs/" + Request.Files[i].FileName)); } return(Json(1, JsonRequestBehavior.AllowGet)); } } return(Json(0, JsonRequestBehavior.AllowGet)); }