protected void btnCheckOut_Click(object sender, EventArgs e) { string strTotalAmount = string.Empty; string strOrderID = string.Empty; bool success = false; try { using (ShoppingCartAccess shoppingCart = new ShoppingCartAccess()) { DataTable dtTotalAmount = shoppingCart.ShoppingCart_GetTotalAmount(); strOrderID = shoppingCart.ShoppingCart_CreateOrder(rbtnPaymentOption.SelectedValue); if (dtTotalAmount.Rows.Count > 0) { strTotalAmount = dtTotalAmount.Rows[0]["TotalAmount"].ToString(); success = true; } } } catch (Exception ex) { lblSystemMessage.Text = "Error: " + ex.Message; } if (success) { this.Session["PAYMENT_OPTION"] = rbtnPaymentOption.SelectedItem.Text; this.Session["ORDER_ID"] = strOrderID; Response.Redirect("Default.aspx"); } else { Response.Redirect("~/Default.aspx"); } }
private void PopulateControls() { //this.Title = ShopConfiguration.SiteName + " : Shopping Cart"; // get the items in the shopping cart try { using (ShoppingCartAccess cart = new ShoppingCartAccess()) { dtCartItems = new DataTable(); dtCartItems = cart.LoadList_ShoppingCartItems(); DataTable dtAmount = cart.ShoppingCart_GetTotalAmount(); if (dtAmount.Rows.Count > 0) { lblTotalAmount.Text = "<span class=\"price\">" + dtAmount.Rows[0]["TotalAmount"].ToString() + "</span>"; lblCurrency.Text = "<span class=\"price\">" + dtAmount.Rows[0]["Currency"].ToString() + "</span>"; } } } catch (Exception ex) { lblSystemMessage.Text = "Error: " + ex.Message; } // if the shopping cart is empty... if (dtCartItems.Rows.Count == 0) { titleLabel.Text = "<span class=\"pagetitle\">Your shopping cart is empty!</span>"; grid.Visible = false; btnUpdate.Enabled = false; btnCheckOut.Enabled = false; lblTotalAmount.Text = ""; lblCurrency.Text = ""; //lblTotalAmount.Text = String.Format("{0:c}", 0); } else { grid.DataSource = dtCartItems; grid.DataBind(); titleLabel.Text = "<span class=\"pagetitle\">These are the products in your shopping cart:</span>"; grid.Visible = true; btnUpdate.Enabled = true; btnCheckOut.Enabled = true; } }