private void btnRegister_Click(object sender, System.EventArgs e) { if (Page.IsValid == true) { // Store off old temporary shopping cart ID funstore.cartDB shoppingCart = new funstore.cartDB(); String tempCartId = shoppingCart.GetShoppingCartId(); // // Add New Customer to CustomerDB database funstore.Customer accountSystem = new funstore.Customer(); String customerId = accountSystem.AddCustomer(txtfname.Text, txtlname.Text, txtaddress.Text, txtcity.Text, txtphone.Text, txtmail.Text, txtpass.Text, txtcardt.Text, txtcardno.Text); if (customerId != "") { // Set the user's authentication name to the customerId FormsAuthentication.SetAuthCookie(customerId, false); // Migrate any existing shopping cart items into the permanent shopping cart shoppingCart.MigrateCart(tempCartId, customerId); // Store the user's fullname in a cookie for personalization purposes Response.Cookies["funstore_FirstName"].Value = Server.HtmlEncode(txtfname.Text); // Redirect browser back to shopping cart page Response.Redirect("shoppingcart.aspx"); } else { lblerror.Text = customerId.ToString(); } } }
private void btnOrder_Click(object sender, System.EventArgs e) { funstore.cartDB cart = new funstore.cartDB(); // Calculate end-user's shopping cart ID String cartId = cart.GetShoppingCartId(); funstore.Customer c1 = new Customer(); //string customerID= c1.GetCustomerDetails(User.Identity.Name); // Calculate end-user's customerID String id = (User.Identity.Name).ToString(); if ((cartId != null)) { // if ((cartId != null) && (id != "")) // { // Place the order funstore.order ordersDatabase = new funstore.order(); int orderId = ordersDatabase.PlaceOrder(id, cartId); //Update labels to reflect the fact that the order has taken place //Header.Text="Check Out Complete!"; //Message.Text = "<b>Your Order Number Is: </b>" + orderId; // SubmitBtn.Visible = false; Response.Redirect("thankyou.aspx"); } }
private void Page_Load(object sender, System.EventArgs e) { if (Request.Params["ProductID"] != null) { funstore.cartDB cart = new funstore.cartDB(); // Obtain current user's shopping cart ID String cartId = cart.GetShoppingCartId(); // Add Product Item to Cart cart.AddItem(cartId, Int32.Parse(Request.Params["ProductID"]), 1); } Response.Redirect("shoppingcart.aspx"); }
private void Page_Load(object sender, System.EventArgs e) { if (Page.IsPostBack == false) { // Calculate end-user's shopping cart ID funstore.cartDB cart = new funstore.cartDB(); String cartId = cart.GetShoppingCartId(); // Populate datagrid with shopping cart data this.DataGrid1.DataSource = cart.GetItems(cartId); this.DataGrid1.DataBind(); // Update total price label lbltotal.Text = String.Format("{0:c}", cart.GetTotal(cartId)); } }
private void btnLogin_Click(object sender, System.EventArgs e) { if (Page.IsValid == true) { // Save old ShoppingCartID funstore.cartDB shoppingCart = new funstore.cartDB(); String tempCartID = shoppingCart.GetShoppingCartId(); // Attempt to Validate User Credentials using Customers class funstore.Customer accountSystem = new funstore.Customer(); String customerId = accountSystem.Login(txtmail.Text, txtpass.Text); //funstore.CustomerDetails cutomerId= accountSystem.GetCustomerDetails(customerId); if (customerId != "") { // Migrate any existing shopping cart items into the permanent shopping cart shoppingCart.MigrateCart(tempCartID, customerId); // Lookup the customer's full account details funstore.CustomerDetails customerDetails = accountSystem.GetCustomerDetails(customerId); // Store the user's fullname in a cookie for personalization purposes Response.Cookies["funstore_FirstName"].Value = customerDetails.FirstName; // Make the cookie persistent only if the user selects "persistent" login checkbox if (this.CheckBox1.Checked == true) { Response.Cookies["funstore_FirstName"].Expires = DateTime.Now.AddMonths(1); } // Redirect browser back to originating page FormsAuthentication.RedirectFromLoginPage(customerId, this.CheckBox1.Checked); } else { lblerror.Text = "Failed To Login"; } } }
void UpdateShoppingCartDatabase() { funstore.cartDB cart = new funstore.cartDB(); // Obtain current user's shopping cart ID String cartId = cart.GetShoppingCartId(); // Iterate through all rows within shopping cart list for (int i = 0; i < this.DataGrid1.Items.Count; i++) { // Obtain references to row's controls TextBox quantityTxt = (TextBox)this.DataGrid1.Items[i].FindControl("Quantity"); CheckBox remove = (CheckBox)this.DataGrid1.Items[i].FindControl("Remove"); // Wrap in try/catch block to catch errors in the event that someone types in // an invalid value for quantity int quantity; try { quantity = Int32.Parse(quantityTxt.Text); // If the quantity field is changed or delete is checked // if ( quantity != (int)this.DataGrid1.DataKeys[quantity] ||remove.Checked == true) // { Label lblProductID = (Label)this.DataGrid1.Items[i].FindControl("ProductID"); if (quantity == 0 || remove.Checked == true) { cart.RemoveItem(cartId, Int32.Parse(lblProductID.Text)); } else { cart.UpdateItem(cartId, Int32.Parse(lblProductID.Text), quantity); } // } } catch { lberror.Text = "There has been a problem with one or more of your inputs."; } } }
private void btnCheckout_Click(object sender, System.EventArgs e) { UpdateShoppingCartDatabase(); // If cart is not empty, proceed on to checkout page funstore.cartDB cart = new funstore.cartDB(); // Calculate shopping cart ID String cartId = cart.GetShoppingCartId(); // If the cart isn't empty, navigate to checkout page if (cart.GetItemCount(cartId) != 0) { Response.Redirect("checkout.aspx"); } else { lberror.Text = "You can't proceed to the Check Out page with an empty cart."; } }
void PopulateShoppingCartList() { funstore.cartDB cart = new funstore.cartDB(); // Obtain current user's shopping cart ID String cartId = cart.GetShoppingCartId(); // If no items, hide details and display message if (cart.GetItemCount(cartId) == 0) { Panel1.Visible = false; lberror.Text = "There are currently no items in your shopping cart."; } else { // Databind Gridcontrol with Shopping Cart Items this.DataGrid1.DataSource = cart.GetItems(cartId); this.DataGrid1.DataBind(); //Update Total Price Label lblTotal.Text = String.Format("{0:c}", cart.GetTotal(cartId)); } }