protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { User us = (User)Session["user"]; if (Session["user"] != null) { lblPayment.Visible = false; btnCheckout.Visible = false; DropDownListPaymentType.Visible = false; if (us.RoleID == 2) { var data = ViewCartController.getCart(us.UserID); GridViewCart.DataSource = data.ToList(); GridViewCart.DataBind(); if (data.Count != 0) { viewCart(us.UserID); } else { empty.Visible = true; } } else { Response.Redirect("Home.aspx"); } } else { Response.Redirect("Home.aspx"); } } }
protected void DeleteCart_Click(object sender, EventArgs e) { int ProductID = Int32.Parse((sender as LinkButton).CommandArgument); User us = (User)Session["user"]; ViewCartController.deleteCart(us.UserID, ProductID); Response.Redirect("ViewCart.aspx"); }
protected void deleteBtn_Click(object sender, EventArgs e) { int id = Convert.ToInt32((sender as LinkButton).CommandArgument); int userId = Convert.ToInt32(Session["UserID"].ToString()); ViewCartController.requestDeleteProduct(userId, id); Response.Redirect("./ViewCart.aspx"); }
private List <vCart> load_data() { int id = Convert.ToInt32(Session["userID"].ToString()); List <vCart> cart = ViewCartController.getCartData(id); cartGrid.DataSource = cart; cartGrid.DataBind(); return(cart); }
private void viewCart(int id) { lblPayment.Visible = true; DropDownListPaymentType.Visible = true; GridViewCart.FooterRow.Cells[0].Font.Bold = true; GridViewCart.FooterRow.Cells[0].Text = "Grand Total"; GridViewCart.FooterRow.Cells[6].Font.Bold = true; GridViewCart.FooterRow.Cells[6].Text = ViewCartController.getGrandTotal(id).ToString(); DropDownListPaymentType.DataSource = ViewCartController.getPaymentType().Select(pt => pt.Type).ToList(); DropDownListPaymentType.DataBind(); btnCheckout.Visible = true; }
protected void checkOutBtn_Click(object sender, EventArgs e) { int userId = Convert.ToInt32(Session["UserID"].ToString()); string paymentType = paymentDD.SelectedValue.ToString(); if (!ViewCartController.isCartCanBeCheckOut()) { warningLbl.Text = "Your cart is empty."; } else { ViewCartController.checkOut(userId, paymentType); Response.Redirect("~/View/Home.aspx"); } }
protected void Page_Load(object sender, EventArgs e) { if (Session["LoginSession"] == null) { Response.Redirect("../HomeView/Home.aspx"); } else { String ID = Session["LoginSession"].ToString(); MsUser user = HomeController.FetchDataForHome(ID); if (user.RoleID != "RL2") { Response.Redirect("../HomeView/Home.aspx"); } else { GridView2.Visible = false; LabelChoose.Visible = false; List <DetailCart> Cart = ViewCartController.ViewCart(ID); if (Cart.Count != 0) { GridView1.DataSource = Cart; GridView1.DataBind(); GridView1.FooterRow.Cells[3].Text = "GrandTotal"; int GrandTotal = 0; for (int i = 0; i < GridView1.Rows.Count; i++) { GrandTotal += int.Parse(GridView1.Rows[i].Cells[4].Text); } GridView1.FooterRow.Cells[4].Text = GrandTotal.ToString(); } else { LabelViewCart.Text = "Cart Is Empty"; BtnCheckout.Visible = false; } } } }
protected void Page_Load(object sender, EventArgs e) { if (!ViewCartController.checkUserIsMember()) { userWarnLbl.Text = "You are not logged in as member to access this page"; checkOutBtn.Visible = false; paymentDD.Visible = false; } else { List <vCart> cart = load_data(); if (cart.Count == 0) { cartEmptyLbl.Text = "Empty Cart"; checkOutBtn.Enabled = false; paymentDD.Enabled = false; } load_payment(); grandTotalLbl.Text = ViewCartController.getGrandTotal(Convert.ToInt32(Session["userID"] .ToString())).ToString(); } }
private void load_payment() { paymentDD.DataSource = ViewCartController.getPaymentData(); paymentDD.DataBind(); }