예제 #1
0
파일: Shop.cs 프로젝트: 503945930/baoxin
        public bool GenOrder(Shop_People people,Shop_Store store,Shop_Order order)
        {
            using (TransactionScope transaction=new TransactionScope())
            {
                try
                {
                    DbEntityEntry<Shop_People> entity = db.Entry(people);
                    entity.State = EntityState.Added;
                    db.SaveChanges();
                    order.PeopleId_buy = people.PeopleId;
                    order.StoreId = store.StoreId;
                    order.BoolYX = false;
                    order.butTime = DateTime.Now;
                    order.BoolSeng = false;
                    DbEntityEntry<Shop_Order> entity1 = db.Entry(order);
                    entity1.State = EntityState.Added;
                    db.SaveChanges();
                    transaction.Complete();
                    return true;

                }
                catch (Exception)
                {
                    transaction.Dispose();
                    return false;
                    throw;
                }
            }
        }
예제 #2
0
        public ActionResult DoOrder(Shop_Goods goods, Shop_Store store, Shop_People people, Shop_Order order, int stock)
        {
            BuyGoods buyGoods= BuildFactory.GoodsFactory().GetBuyTotl(goods.GoodsId);

            if (buyGoods != null && (buyGoods.buyNum + order.buyNum) > stock)
            {

                return Content("<script>alert('订单数已超库存,库存尚余" + (stock - buyGoods.buyNum) + "个,请调整订单数或联系商家!');;</script>");
            }

            if (BuildFactory.GoodsFactory().GenOrder(people,store,order))
            {
                return Content("<script>alert('已发送购买信息,卖家收到信息后会进行联系确认');location.href = 'https://www.alipay.com/'</script>");
            }
            ;

            return Content("<script>alert('购买信息填写出错,请重新填写');;</script>");
        }