public void addProd() { string ts = "加入购物车失败"; ShoppingCart shopcCart = new ShoppingCart(); shopcCart.ProCode = Request["codes"]; shopcCart.Qty = Convert.ToInt32(Request["num"]); shopcCart.CusId = Convert.ToInt32(Session["cusId"]); shopcCart.CreateTime = DateTime.Now; shopcCart.checks = 0; var shca = ShopCartService.GetEntities(n => n.CusId == shopcCart.CusId && n.ProCode == shopcCart.ProCode); if (shca.Count() > 0) { if (shca.First().Qty + shopcCart.Qty >= 5) { ts = "购物车内该物品数量已达到上限"; return; } shopcCart.Qty += shca.First().Qty; if (ShopCartService.Add(shopcCart)) { ts = "加入购物车成功"; } } else if (ShopCartService.Add(shopcCart)) { ts = "加入购物车成功"; } Response.ContentType = "text/plain"; Response.Write(ts); Response.End(); }
} //商品信息表 public ActionResult Index() { //查看购物车 var ShopCartResult = ShopCartService.GetEntities(x => true); ViewBag.ShopCart = ShopCartResult.ToList(); ViewBag.ProductInfo = ProductService; return(View()); }
// GET: Order public ActionResult Index(int num = 0) { orderViewModel.ProNum = num; var pro = ShopCartService.GetEntities(n => n.checks == 1); orderViewModel.ShoppingCarts = ShopCartService.GetEntities(n => n.checks == 1); orderViewModel.Addrresses = AddrressService.GetEntity(n => n.State == 1); foreach (var ppp in pro) { orderViewModel.price += ppp.Qty * ppp.Product.SellPrice; } return(View(orderViewModel)); }
} //收藏 // GET: ShopCart public ActionResult ShopCart() { //获取购物车信息 string cid = Session["cid"].ToString(); var shoppongCart = ShopCartService.GetEntities(x => x.Cid == cid); ViewBag.shopCart = shoppongCart.ToList(); //把商品的信息传入前台供查询 // var pro = proService.GetEntity(x => x.Code == "E00100010001"); // ViewBag.pro1 = pro.Name; ViewBag.pro = proService; //把规格的信息传入前台 ViewBag.Speci = specificationService; return(View()); }
// GET: Order public ActionResult Index() { string[] id = Request["id"].Split(',');// foreach (var item in id) { var shopOrder = ShopCartService.GetEntities(x => x.Cid == item); } ViewBag.id = id; ViewBag.pro = proService; ViewBag.shopcartService = ShopCartService; OAuthUserInfo userInfo = Session["userInfo"] as OAuthUserInfo; //获取用户的信息 string cid = userInfo.openid; //获取用户的openid var address = addressService.GetEntity(x => x.IsDefault == true && x.cid == cid); //查找出关于用户的默认收货底座 ViewBag.name = address.name; //把收货人传到前台 ViewBag.address = address.address1; //把收货地址传到前台 ViewBag.tel = address.tel; return(View()); }
public void addorder() { var ts = 0; var Num = Convert.ToInt32(Request["proNum"]); var Code = Request["proCode"].ToString(); ShoppingCart shopcCart = new ShoppingCart(); shopcCart.ProCode = Code; shopcCart.Qty = Num; shopcCart.CusId = Convert.ToInt32(Session["cusId"]); shopcCart.CreateTime = DateTime.Now; shopcCart.checks = 1; if (Num > ProductService.GetEntity(n => n.Code == Code).Stock.QTY) { ts = 2000; } var shca = ShopCartService.GetEntities(n => n.CusId == shopcCart.CusId && n.ProCode == shopcCart.ProCode); if (shca.Count() > 0) { if (ShopCartService.Add(shopcCart)) { ts = shca.First().Qty; } else { ts = 2000; } } else if (ShopCartService.Add(shopcCart)) { ts = 0; } else { ts = 2000; } Response.ContentType = "text/plain"; Response.Write(ts); Response.End(); }
public void addOrder() { var aa = "200"; var pink = 0; var memo = Request["Memo"]; if (memo == "") { memo = null; } var pro = ShopCartService.GetEntities(n => n.checks == 1); orderViewModel.Addrresses = AddrressService.GetEntity(n => n.State == 1); foreach (var ppp in pro) { orderViewModel.price += ppp.Qty * ppp.Product.SellPrice; } int cusid = Convert.ToInt32(Session["cusId"]); foreach (var od in pro) { if (od.Product.IsPinkage) { pink = 10; break; } } var code = cusid + DateTime.Now.Year.ToString().Substring(2, 2) + DateTime.Now.Month + DateTime.Now.Day + DateTime.Now.Hour + DateTime.Now.Minute + DateTime.Now.Second + pro.First().ProCode.Substring(12, 2); var sql = $"exec addOrder '{code}',{cusid},'{"待付款"}',{orderViewModel.price},{pink},'{memo}'"; var nums = pro.Count() * 2 + 1; if (OrddeService.QueryBySql(sql) == nums) { aa = code; } Response.ContentType = "text/plain"; Response.Write(aa); Response.End(); }