Beispiel #1
0
        /// <summary>
        /// 商品列表分布视图
        /// </summary>
        /// <returns></returns>
        public ActionResult GoodsIndexPartial(int?pageindex, int typeid, string text = "")
        {
            List <GoodsTable> list = null;

            if (typeid == 0)
            {
                list = GoodsBll.SelectAllGoods().Where(p => p.GoodsName.Contains(text)).ToList();
            }
            else
            {
                //查询第一大类的商品
                list = GoodsBll.SelectType1GoodsAdmin(typeid).Where(p => p.GoodsName.Contains(text)).ToList();
                //查询所有分类
                List <TypeTable> typelist = TypeTableBll.SelectAllType();
                //防止错误赋值给typetable导航属性
                list.ForEach(p => p.TypeTable = typelist.Where(a => a.TypeID == p.TID).ToList()[0]);
            }
            if (list != null && list.Count() > 0)
            {
                Session["goodscount"] = list.Count();
            }
            else
            {
                Session["goodscount"] = 0;
            }
            Session["goodpagecount"] = Math.Ceiling(list.Count() / 8.0);
            ViewBag.pageindex        = pageindex;
            ViewBag.text             = text;
            ViewBag.typeid           = typeid;
            Session["allgoods"]      = list.Skip(((pageindex ?? 1) - 1) * 8).Take(8).ToList();
            return(PartialView("GoodsIndexPartial"));
        }
Beispiel #2
0
        /// <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));
        }
 // GET: Goods
 public ActionResult GoodsIndex(int?tid_1, int?typeid_1, int?typeid_2, string txt = "")
 {
     //清空session数据
     Session.Remove("Goods");
     Session.Remove("Goods_tid");
     Session.Remove("Goods_typeid");
     //获得所有分类数据
     ViewBag.Type       = TypeTableBll.SelectAllType();
     ViewBag.GoodsPhoto = GoodsPhotoBll.SelectAllGoodsPhoto();
     if (tid_1 != null)
     {
         //根据tid查询
         Session["Goods_tid"] = GoodsBll.SelectTidGoods(tid_1 ?? 0);
         //ViewBag.tid = tid_1 ?? 0;
     }
     else if (typeid_1 != null)
     {
         //根据tiyeid查询
         Session["Goods_typeid"] = GoodsBll.SelectTypeidGoods(typeid_1 ?? 0);
     }
     else if (typeid_2 != null)
     {
         Session["Goods_typeid_2"] = GoodsBll.SelectType1Goods(typeid_2 ?? 0);
     }
     else
     {
         Session["Goods"] = GoodsBll.SelectAllGoods().Where(p => p.GoodsName.Contains(txt) && p.IsDelte == 0).OrderBy(p => p.GoodsHot).ToList();
     }
     return(View());
 }
        /// <summary>
        /// 查询所有商品信息的分布视图
        /// </summary>
        /// <param name="pageindex"></param>
        /// <returns></returns>
        public ActionResult Show(int?pageindex)
        {
            ViewBag.GoodsPhoto = GoodsPhotoBll.SelectAllGoodsPhoto();
            List <GoodsTable> list = GoodsBll.SelectAllGoods().Where(p => p.IsDelte == 0).ToList();

            ViewBag.count     = Math.Ceiling(list.Count() / 12.0);
            ViewBag.pageindex = pageindex;
            return(PartialView("Show", list.Skip(((pageindex ?? 1) - 1) * 12).Take(12).ToList()));
        }
Beispiel #5
0
        /// <summary>
        /// 查询一个商品的详情
        /// </summary>
        /// <param name="GoodsID">商品id</param>
        /// <returns></returns>
        public JsonResult GoodsDesc(string GoodsID)
        {
            //查询商品的信息
            GoodsTable good = GoodsBll.SelectAllGoods().SingleOrDefault(p => p.GoodsID == Convert.ToInt32(GoodsID));
            //查询商品对应的所有图片
            var goodsphoto = GoodsPhotoBll.SelectAllGoodsPhoto().Where(p => p.GoodsID == Convert.ToInt32(GoodsID)).Select(p => new { RID = p.RID, GoodsID = p.GoodsID, PhotoPath = p.PhotoPath }).ToList();
            //查询所有最小的分类
            var typelist = TypeTableBll.SelectSmallType().Select(p => new { typeid = p.TypeID, typename = p.TypeName });
            JsonSerializerSettings jsonstring = new JsonSerializerSettings();

            jsonstring.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
            string list_1 = JsonConvert.SerializeObject(good, jsonstring);
            string list_2 = JsonConvert.SerializeObject(goodsphoto, jsonstring);
            string list_3 = JsonConvert.SerializeObject(typelist, jsonstring);

            return(Json(new { Good = list_1, GoodPhoto = list_2, GoodType = list_3 }, JsonRequestBehavior.AllowGet));
        }
Beispiel #6
0
 /// <summary>
 /// 商城首页
 /// </summary>
 /// <returns></returns>
 public ActionResult Index()
 {
     //获取导航栏的分类数据
     Session["Type"] = TypeTableBll.SelectTypeTable();
     //获得所有分类数据
     ViewBag.Type = TypeTableBll.SelectAllType();
     //获取图片
     ViewBag.GoodsPhoto = GoodsPhotoBll.SelectAllGoodsPhoto();
     ViewBag.goods_1    = GoodsBll.SelectType1Goods(1).OrderBy(p => p.GoodsHot).Take(8);
     ViewBag.goods_2    = GoodsBll.SelectType1Goods(2).OrderBy(p => p.GoodsHot).Take(8);
     ViewBag.goods_3    = GoodsBll.SelectType1Goods(3).OrderBy(p => p.GoodsHot).Take(8);
     ViewBag.goods_4    = GoodsBll.SelectType1Goods(4).OrderBy(p => p.GoodsHot).Take(8);
     if (Session["userid"] != null)
     {
         Session["carcount"] = ShopingCarBll.SelectAllShopCar(Convert.ToInt32(Session["userid"])).Count();
     }
     return(View(GoodsBll.SelectAllGoods().Where(p => p.IsDelte == 0).ToList()));
 }
Beispiel #7
0
        /// <summary>
        /// 后台商品管理
        /// </summary>
        /// <returns></returns>
        public ActionResult BackGoodsIndex()
        {
            Session["li_1"] = 1;
            Session["li_2"] = 0;
            //商品的图片
            Session["GoodsPhoto"] = GoodsPhotoBll.SelectAllGoodsPhoto();
            //查询所有商品
            List <GoodsTable> list = GoodsBll.SelectAllGoods();

            if (list != null && list.Count() > 0)
            {
                Session["goodscount"] = list.Count();
            }
            else
            {
                Session["goodscount"] = 0;
            }
            Session["goodpagecount"] = Math.Ceiling(list.Count() / 8.0);
            Session["allgoods"]      = list.Take(8).ToList();
            return(View());
        }