예제 #1
0
        public void BindGrid()
        {
            try
            {
                cartSub.Style.Remove("text-decoration");
                discSub.Text = "";

                if (Request.Cookies.Get("cartKey") != null)
                {
                    Guid cartKey = Guid.Parse(Request.Cookies["cartKey"].Value);

                    List <SqlParameter> p = new List <SqlParameter>();
                    p.Add(new SqlParameter("@GUID", cartKey));

                    DataTable cartDetails = DB.Get("CartSummaryGet", p.ToArray());
                    CartView.DataSource = cartDetails;

                    if (cartDetails != null && cartDetails.Rows.Count > 0)
                    {
                        p = new List <SqlParameter>();
                        p.Add(new SqlParameter("@CacheID", cartKey));

                        decimal   Subtotal = 0M;
                        DataTable dtSub    = DB.Get("CartSubtotalGet", p.ToArray());
                        if (dtSub != null && dtSub.Rows.Count > 0)
                        {
                            string  strSub     = dtSub.Rows[0][0].ToString();
                            decimal tryDecimal = 0M;
                            if (decimal.TryParse(strSub, out tryDecimal))
                            {
                                Subtotal = tryDecimal;
                            }
                        }

                        cartSub.Text = "$" + Subtotal.ToString("0.00");

                        DataRow dr = cartDetails.Rows[0];
                        if (!string.IsNullOrEmpty(dr["DiscountID"].ToString()))
                        {
                            decimal CartTotal = DiscountUtils.CalculateDiscountTotal((int)dr["DiscountID"], cartKey);
                            cartSub.Style.Add("text-decoration", "line-through");
                            discSub.Text = "W/ Discount: $" + CartTotal.ToString("0.00");
                        }
                    }
                    else
                    {
                        cartSub.Text = "$0.00";
                    }
                }
                else
                {
                    CartView.DataSource = string.Empty;
                }
                CartView.DataBind();
            }
            catch (Exception ex)
            {
                LoggingUtil.InsertError(ex);
            }
        }
예제 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            lDiscount.Visible = false;
            if (!string.IsNullOrWhiteSpace(Request.Params["paymentId"].ToString()) && !string.IsNullOrWhiteSpace(Request.Params["PayerID"].ToString()))
            {
                paymentid.Value = Request.Params["paymentId"].ToString();
                payerid.Value   = Request.Params["PayerID"].ToString();
            }
            else
            {
                Response.Redirect("~/Shop", false);
            }

            if (Request.Cookies["cartKey"] != null)
            {
                Guid cartKey          = Guid.Parse(Request.Cookies["cartKey"].Value);
                List <SqlParameter> p = new List <SqlParameter>();
                p.Add(new SqlParameter("@GUID", cartKey));

                DataTable cartDetails = DB.Get("CartSummaryGet", p.ToArray());
                CartView.DataSource = cartDetails;
                CartView.DataBind();

                p = new List <SqlParameter>();
                p.Add(new SqlParameter("@CacheID", cartKey));

                decimal   Subtotal = 0M;
                DataTable dtSub    = DB.Get("CartSubtotalGet", p.ToArray());
                if (dtSub != null && dtSub.Rows.Count > 0)
                {
                    string  strSub     = dtSub.Rows[0][0].ToString();
                    decimal tryDecimal = 0M;
                    if (decimal.TryParse(strSub, out tryDecimal))
                    {
                        Subtotal = tryDecimal;
                    }
                }

                DataRow dr       = cartDetails.Rows[0];
                decimal Discount = 0M;
                if (!string.IsNullOrEmpty(dr["DiscountID"].ToString()))
                {
                    Discount = DiscountUtils.CalculateDiscountTotal((int)dr["DiscountID"], cartKey);
                }

                decimal Shipping = ScalablePressUtils.GetShippingQuote(cartKey);
                if (Shipping > 0M)
                {
                    lSubTotal.Text = "Subtotal: $" + Subtotal.ToString("0.00");
                    if (Discount > 0)
                    {
                        lDiscount.Text    = "Discount: -$" + Discount.ToString("0.00");
                        lDiscount.Visible = true;
                    }
                    lShipTotal.Text = "S&H: $" + Shipping.ToString("0.00");
                    lTotal.Text     = "Total: $" + Math.Round(Subtotal - Discount + Shipping, 2, MidpointRounding.AwayFromZero).ToString("0.00");
                }
            }
        }
예제 #3
0
        public void BindListView()
        {
            ConnectDatabase alayer = new ConnectDatabase();
            DataTable       dt;

            if (Request.Cookies["UserID"] == null)
            {
                Response.Write("<script>alert('You have to register or login');window.location='UserLogin.aspx';</script>");
            }
            dt = alayer.GetViewCartMenuTableFromDB();

            CartView.DataSource = dt;
            CartView.DataBind();
        }