Example #1
0
        private void succesfulLogIn()
        {
            Customer customer = databaseConnector.getCustomerObject(emailTextBox.Text);

            if (customer.getIsActive() == 1)
            {
                accountActivatedLabel.Visible = false;
                System.Diagnostics.Debug.WriteLine("logged in");
                SessionValues sessionValues = new SessionValues();
                sessionValues.setLoginSession(customer);
                // Session.Add("currentLogedInUserObject", customer);
                //Session.Add("logedInStatus", true);
                // Response.Redirect("ShoppingPage_WebForm.aspx");
                if (redirectToCart)
                {
                    Response.Redirect("ShoppingCart_WebForm.aspx");
                }
                else
                {
                    Response.Redirect("ShowAndEditProfile_WebForm.aspx");
                }
            }
            else
            {
                System.Diagnostics.Debug.WriteLine("Customer is not activated");
                accountActivatedLabel.Visible = true;
            }
        }
        protected void updateButton_Click(object sender, EventArgs e)
        {
            this.Validate();
            updateConfirmLabel.Visible = Page.IsValid;

            if (this.IsValid)
            {
                Customer newCustomerObject = new Customer(oldCustomerObject.getCustomerID(), nameTextBox.Text, streetAdressTextBox.Text, cityTextbox.Text, postCodetextBox.Text, emailTextBox.Text, passwordTextBox.Text, userNameTextBox.Text, 1);
                updateConfirmLabel.Visible = true;
                if (newCustomerObject.getCity().Equals(oldCustomerObject.getCity()) && newCustomerObject.getUserName().Equals(oldCustomerObject.getUserName()) &&
                    newCustomerObject.getEmailAdress().Equals(oldCustomerObject.getEmailAdress()) && newCustomerObject.getPostCode().Equals(oldCustomerObject.getPostCode()) &&
                    newCustomerObject.getStreetAdress().Equals(oldCustomerObject.getStreetAdress()) && newCustomerObject.getName().Equals(oldCustomerObject.getName()) &&
                    (newCustomerObject.getUserPassword().Equals(oldCustomerObject.getUserPassword()) || newCustomerObject.getUserPassword().Equals("")))
                {
                    updateConfirmLabel.Text = "You did not alter your information";
                    System.Diagnostics.Debug.WriteLine("No changes made !!!!!!!!!!!!!!!!!!!!!!!!!!");
                }

                else
                {
                    if (passwordTextBox.Text == string.Empty)
                    {
                        System.Diagnostics.Debug.WriteLine("satte till " + oldCustomerObject.getUserPassword());
                        newCustomerObject.setUserPassword(oldCustomerObject.getUserPassword());
                        System.Diagnostics.Debug.WriteLine("nytt  " + newCustomerObject.getUserPassword());
                    }
                    databaseConnecctor.updateCustomerDetails(newCustomerObject, oldCustomerObject.getEmailAdress());
                    //   Session.Add("currentLogedInUserObject", newCustomerObject);
                    sessionValues.setLoginSession(newCustomerObject);
                    updateConfirmLabel.Text = "You profile has been updated";
                }
            }
        }