Beispiel #1
0
 protected void btn_Submit_Click(object sender, EventArgs e)
 {
     EShop.Model.Account_User objUser = Session["User"] as EShop.Model.Account_User;
     if (objUser == null)
     {
         Server.Transfer("~/account/Login.aspx");
     }
     else
     {
         bool isNew = false;
         EShop.Model.Account_Cart objCart = null;
         objCart = bllCart.GetModelList(string.Format(" UserCode = '{0}' and GoodsCode = '{1}' and Status = '1'", objUser.UserCode, this.goods.Value)).FirstOrDefault();
         EShop.Model.Goods_BaseInfo objGoods = bllBasic.GetModelList(" GoodsCode = '" + this.goods.Value + "'").FirstOrDefault();
         if (objCart == null)
         {
             isNew               = true;
             objCart             = new EShop.Model.Account_Cart();
             objCart.UserCode    = objUser.UserCode;
             objCart.GoodsCode   = objGoods.GoodsCode;
             objCart.MarketPrice = objGoods.MarketPrice;
             objCart.OurPrice    = objGoods.OurPrice;
             objCart.BuyCount    = 1;
             objCart.SubTotal    = objGoods.OurPrice;
             objCart.Status      = 1;
         }
         else
         {
             objCart.BuyCount += 1;
             objCart.SubTotal  = objCart.OurPrice * objCart.BuyCount;
         }
         if (isNew)
         {
             isNew = bllCart.Add(objCart) == 1;
         }
         else
         {
             isNew = bllCart.Update(objCart);
         }
         if (isNew)
         {
             Server.Transfer("~/product/Cart.aspx");
         }
         else
         {
             Page.ClientScript.RegisterStartupScript(this.GetType(), "failed", "<script>alert('购买失败!请重试!');</script>");
         }
     }
 }
Beispiel #2
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(EShop.Model.Goods_BaseInfo model)
 {
     return(dal.Update(model));
 }
Beispiel #3
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int  Add(EShop.Model.Goods_BaseInfo model)
 {
     return(dal.Add(model));
 }