public void CartDetails() { BetaDB db = new BetaDB(); if (Session["email"] != null) { var email = Session["email"].ToString(); var Id = db.Logins.Where(x => x.Email.Equals(email)).Select(x => x.ID).FirstOrDefault(); var producttt = (from c in db.Carts join p in db.Products on c.ProductID equals p.ProductID where c.UserId == Id orderby c.ID select new { cartId = c.ID, ProductId = p.ProductID, size = c.Size, quantity = c.Quantity, productName = p.ProductName, price = p.ProductPrice * c.Quantity }).ToList(); cartViewRepeater.DataSource = producttt; cartViewRepeater.DataBind(); if (producttt.Count == 0) { cartempty.Visible = true; cartemptymsg.Text = "YOUR CART IS EMPTY"; } } else if (carthandler.GetCount() != 0) { var productt = carthandler.cookiehandler.cartitems.Select(x => new { ProductId = x.Id, size = x.Size, quantity = x.Quantity }).ToList(); cartViewRepeater.DataSource = productt; cartViewRepeater.DataBind(); } else { cartempty.Visible = true; cartemptymsg.Text = "YOUR CART IS EMPTY"; } }
public void CartCount() { if (carthandler == null) { carthandler = new CartHandler(); } lblCartNumber.Text = carthandler.GetCount().ToString() == "0" ? "": carthandler.GetCount().ToString(); }
protected void Page_Load(object sender, EventArgs e) { BetaDB db = new BetaDB(); carthandler = new CartHandler(); if (!IsPostBack) { CartDetails(); } if (carthandler.GetCount() == 0) { cartCalculation.Visible = false; } //else //{ // cartCalculation.Visible = true; //} if (!Page.IsPostBack) { lblCartTotal.Text = totalPrice.ToString() + "$"; double tax = (((double)totalPrice * 15) / 100); lbltax.Text = tax.ToString(); lbldelivery.Text = NicePayment.PaymentHandler._fixedShipping.ToString() + "$"; double grandtotal = totalPrice + Convert.ToDouble(lbltax.Text) + NicePayment.PaymentHandler._fixedShipping; lbltax.Text += "$"; lblGrandCartTotal.Text = grandtotal.ToString() + "$"; } }