Пример #1
0
    protected void reviewOrder()
    {
        List <item> myCart = (List <item>)(HttpContext.Current.Session["myCart"]);

        //If cart is not empty
        if (myCart != null)
        {
            //add cart items to gridview
            DataTable dt = new DataTable();

            dt.Columns.Add("ProductID", System.Type.GetType("System.Int32"));
            dt.Columns.Add("Name", System.Type.GetType("System.String"));
            dt.Columns.Add("Price", System.Type.GetType("System.Int32"));
            dt.Columns.Add("Quantity", System.Type.GetType("System.Int32"));
            double total = 0.0;

            foreach (item j in myCart)
            {
                try
                {
                    total += (j.Quantity * j.Price);
                }
                catch { }
                dt.Rows.Add(j.Num, j.Name, j.Price, j.Quantity);
            }
            LblTotal.Text       = total.ToString();
            Session["Total"]    = total.ToString();
            GvReview.DataSource = dt;
            GvReview.DataBind();
            if (myCart.Count == 0)
            {
                LnkShipBill.Visible = false;
                //LnkCheckout.Visible = false;
            }
            else
            {
                LnkShipBill.Visible = true;
                //LnkCheckout.Visible = true;
            }
        }
        else
        {
            LnkShipBill.Visible = false;
            //LnkCheckout.Visible = false;
        }
    }
    //Show the order summary
    protected void reviewOrder()
    {
        List <item> myCart = (List <item>)(HttpContext.Current.Session["myCart"]);

        if (myCart != null)
        {
            //add cart items to gridview
            DataTable dt = new DataTable();

            dt.Columns.Add("ProductID", System.Type.GetType("System.Int32"));
            dt.Columns.Add("Name", System.Type.GetType("System.String"));
            dt.Columns.Add("Price", System.Type.GetType("System.Int32"));
            dt.Columns.Add("Quantity", System.Type.GetType("System.Int32"));

            foreach (item j in myCart)
            {
                dt.Rows.Add(j.Num, j.Name, j.Price, j.Quantity);
            }

            //bind the datatable to the gridview
            GvReview.DataSource = dt;
            GvReview.DataBind();
        }
    }