Exemple #1
0
        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();
                }
            }
        }
Exemple #2
0
        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";
                }
            }
        }