Esempio n. 1
0
        public ActionResult index(TblCart tblCart)
        {
            try
            {
                string  cookieID        = tblCart.CookieID;
                TblCart cartGetInCookie = cartService.GetByCookieID(cookieID);
                if (cartGetInCookie != null)
                {
                    cartGetInCookie.TotalPriceAddVAT = cartGetInCookie.TotalPrice + (decimal)((double)cartGetInCookie.TotalPrice * 0.1);

                    cartGetInCookie.CartItems = cartItemService.GetByCartID(cartGetInCookie.CartID);
                    if (cartGetInCookie.CartItems != null && cartGetInCookie.CartItems.Count > 0)
                    {
                        if (cartGetInCookie.CartItems.Count == tblCart.CartItems.Count)
                        {
                            for (int i = 0; i < cartGetInCookie.CartItems.Count; i++)
                            {
                                cartGetInCookie.CartItems[i].NumberVariant = tblCart.CartItems[i].NumberVariant;
                                cartItemService.Update(cartGetInCookie.CartItems[i]);
                            }
                        }
                    }
                    cartService.UpdateTotalPrice(cartGetInCookie.CartID);
                    return(RedirectToAction("index", new { message = "update1" }));
                }
            }
            catch (Exception ex)
            {
                LogService.WriteException(ex);
                throw;
            }
            return(RedirectToAction("index", new { message = "update0" }));
        }
Esempio n. 2
0
    protected void Button3_Click(object sender, EventArgs e)
    {
        Label1.Text = "";
        GridView GridView1 = new GridView();

        GridView1 = (GridView)Page.Master.FindControl("ContentPlaceHolder2").FindControl("GridView1");
        if (GridView1 != null)
        {
            for (int i = 0; i < GridView1.Rows.Count; i++)
            {
                TextBox TextBox1 = new TextBox();
                TextBox1 = (TextBox)GridView1.Rows[i].FindControl("TextBox1");
                if (TextBox1 != null)
                {
                    var product = productService.GetProductByProductId(Convert.ToInt32(GridView1.Rows[i].Cells[1].Text));
                    if (int.Parse(TextBox1.Text) > product.Qty)
                    {
                        Label1.Text += "Error:库存不足,商品名为" + product.Name + "的库存数量为" + product.Qty.ToString() + "<br/>";
                    }
                    else
                    {
                        cartItemService.Update(Convert.ToInt32(Session["CustomerId"]), product.ProductId, Convert.ToInt32(TextBox1.Text));
                    }
                }
            }
        }
        Bind();
    }