예제 #1
0
        protected void btnNewPwd_Click(object sender, EventArgs e)
        {
            // Validation Code
            // Set flag to false
            flgValidationError = false;

            // If built in validation finds an error
            //if (IsValid != true) { flgValidationError = true; }

            // ** Email validation **
            lblErrorEmail.Visible = false;
            // Check for blank email
            if (txtEmail.Text.Trim() == "")
            {
                lblErrorEmail.Visible = true;
                flgValidationError    = true;
                ValidationError.Display("Email address is blank");
            }
            else
            {
                // Check for valid email format
                if (GlobalClass.isValidEmail(txtEmail.Text) == false)
                {
                    lblErrorEmail.Visible = true;
                    flgValidationError    = true;
                    ValidationError.Display("Email address is formatted incorrectly");
                }
            }

            // ** Password validation **
            if (flgValidationError == true)
            {
                return;
            }

            if (GlobalClass.isUniqueEmail(txtEmail.Text) == false)
            {
                Random rnd            = new Random();
                string strNewPassword = RandomString(rnd, 8);
                if (UpdatePassword(strNewPassword) == true)
                {
                    EmailPassword(strNewPassword);
                }
            }
            Response.Redirect("SignIn.aspx?page=PreferencesReset");
        }
예제 #2
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            // Validation Code
            // Set flag to false
            bool flgValidationError = false;

            // If built in validation finds an error
            //if (IsValid != true) { flgValidationError = true; }

            // ** Email validation **
            lblErrorAccEmail.Visible = false;
            // Check for blank email
            if (txtAccEmail.Text.Trim() == "")
            {
                lblErrorAccEmail.Visible = true;
                flgValidationError       = true;
                ValidationError.Display("Account Email address is blank");
            }
            else
            {
                // Check for valid email format
                if (GlobalClass.isValidEmail(txtAccEmail.Text) == false)
                {
                    lblErrorAccEmail.Visible = true;
                    flgValidationError       = true;
                    ValidationError.Display("Account Email address " + txtAccEmail.Text.Trim() + " is formatted incorrectly");
                }
            }

            // ** New Password validation **
            lblErrorNewPassword.Visible = false;
            // Check for blank password
            if (txtPassword.Text.Trim() != "")
            {
                // Check for password lenght
                if (txtPassword.Text.Length < 6)
                {
                    lblErrorNewPassword.Visible = true;
                    flgValidationError          = true;
                    ValidationError.Display("Password needs to be longer");
                }
            }

            // ** Send To Email validation **
            lblErrorToEmail.Visible = false;

            // Check for blank email 1
            if (txtToEmail1.Text.Trim() != "")
            {
                // Check for valid email format
                if (GlobalClass.isValidEmail(txtToEmail1.Text) == false)
                {
                    lblErrorToEmail.Visible = true;
                    flgValidationError      = true;
                    ValidationError.Display("Email address " + txtToEmail1.Text.Trim() + " is formatted incorrectly");
                }
            }
            else
            {
                // Check for name with no email
                if (txtToName1.Text.Trim() != "")
                {
                    lblErrorToEmail.Visible = true;
                    flgValidationError      = true;
                    ValidationError.Display("Email address is required for " + txtToName1.Text);
                }
                else if (chkToSMS1.Checked == true)
                {
                    lblErrorToEmail.Visible = true;
                    flgValidationError      = true;
                    ValidationError.Display("First Send List To email address is required for checked SMS (Text)");
                }
            }
            // Check for blank email 2
            if (txtToEmail2.Text.Trim() != "")
            {
                // Check for valid email format
                if (GlobalClass.isValidEmail(txtToEmail2.Text) == false)
                {
                    lblErrorToEmail.Visible = true;
                    flgValidationError      = true;
                    ValidationError.Display("Email address " + txtToEmail2.Text.Trim() + " is formatted incorrectly");
                }
            }
            else
            {
                // Check for name with no email
                if (txtToName2.Text.Trim() != "")
                {
                    lblErrorToEmail.Visible = true;
                    flgValidationError      = true;
                    ValidationError.Display("Email address is required for " + txtToName2.Text);
                }
                else if (chkToSMS2.Checked == true)
                {
                    lblErrorToEmail.Visible = true;
                    flgValidationError      = true;
                    ValidationError.Display("Second Send List To email address is required for checked SMS (Text)");
                }
            }
            // Check for blank email 3
            if (txtToEmail3.Text.Trim() != "")
            {
                // Check for valid email format
                if (GlobalClass.isValidEmail(txtToEmail3.Text) == false)
                {
                    lblErrorToEmail.Visible = true;
                    flgValidationError      = true;
                    ValidationError.Display("Email address " + txtToEmail1.Text.Trim() + " is formatted incorrectly");
                }
            }
            else
            {
                // Check for name with no email
                if (txtToName3.Text.Trim() != "")
                {
                    lblErrorToEmail.Visible = true;
                    flgValidationError      = true;
                    ValidationError.Display("Email address is required for " + txtToName3.Text);
                }
                else if (chkToSMS3.Checked == true)
                {
                    lblErrorToEmail.Visible = true;
                    flgValidationError      = true;
                    ValidationError.Display("Third Send List To email address is required for checked SMS (Text)");
                }
            }

            // if error found by this point return control to the user
            if (flgValidationError == true)
            {
                return;
            }

            // Check for unique email
            if (hfOldEmail.Value != txtAccEmail.Text.Trim())
            {
                if (GlobalClass.isUniqueEmail(txtAccEmail.Text) == false)
                {
                    lblErrorAccEmail.Visible = true;
                    flgValidationError       = true;
                    ValidationError.Display("Another list already exisit for the email address " + txtAccEmail.Text.Trim());
                    return;
                }
            }

            // Update Preferences
            if (UpdatePreferences() == false)
            {
                flgValidationError = true;
                ValidationError.Display("Error updating preferences");
            }
            else
            {
                // load new display name
                if (string.IsNullOrEmpty(txtAccName.Text) == true)
                {
                    Session["DisplayName"] = txtAccEmail.Text;
                }
                else
                {
                    Session["DisplayName"] = txtAccName.Text;
                }

                // go back to previous page
                if (Request.QueryString["page"] == "List")
                {
                    Response.Redirect("List.aspx");
                }
                else
                {
                    Response.Redirect("Shopping.aspx");
                }
            }
        }
예제 #3
0
        protected void btnSignIn_Click(object sender, EventArgs e)
        {
            // Validation Code
            // Set flag to false
            flgValidationError = false;

            // If built in validation finds an error
            //if (IsValid != true) { flgValidationError = true; }

            // ** Email validation **
            lblErrorEmail.Visible = false;
            // Check for blank email
            if (txtEmail.Text.Trim() == "")
            {
                lblErrorEmail.Visible = true;
                flgValidationError    = true;
                ValidationError.Display("Email address is blank");
            }
            else
            {
                // Check for valid email format
                if (GlobalClass.isValidEmail(txtEmail.Text) == false)
                {
                    lblErrorEmail.Visible = true;
                    flgValidationError    = true;
                    ValidationError.Display("Email address is formatted incorrectly");
                }
            }

            // ** Password validation **
            lblErrorPassword.Visible = false;
            // Check for blank password
            if (txtPassword.Text.Trim() == "")
            {
                lblErrorPassword.Visible = true;
                flgValidationError       = true;
                ValidationError.Display("Password is blank");
            }

            if (flgValidationError == true)
            {
                return;
            }

            // Try to sign in user
            if (SignInUser(txtEmail.Text, GlobalClass.encodePassword(txtPassword.Text)) == false)
            {
                flgValidationError = true;
                ValidationError.Display("Email address or Password is incorrect");
            }
            else
            {
                GlobalClass.checkFavorites();
                GlobalClass.logLogin("SignIn");

                if (Request.QueryString["page"] == "List")
                {
                    Response.Redirect("List.aspx");
                }
                else if (Request.QueryString["page"] == "Preferences")
                {
                    Response.Redirect("Preferences.aspx");
                }
                else if (Request.QueryString["page"] == "PreferencesReset")
                {
                    Response.Redirect("Preferences.aspx?page=PreferencesReset");
                }
                else
                {
                    Response.Redirect("Shopping.aspx");
                }
            }
        }
예제 #4
0
        protected void btnCreateList_Click(object sender, EventArgs e)
        {
            // Validation Code
            // Set flag to false
            bool flgValidationError = false;

            // If built in validation finds an error
            //if (IsValid != true) { flgValidationError = true; }

            // ** Email validation **
            lblErrorEmail.Visible = false;
            // Check for blank email
            if (txtEmail.Text.Trim() == "")
            {
                lblErrorEmail.Visible = true;
                flgValidationError    = true;
                ValidationError.Display("Email address is blank");
            }
            else
            {
                // Check for valid email format
                if (GlobalClass.isValidEmail(txtEmail.Text) == false)
                {
                    lblErrorEmail.Visible = true;
                    flgValidationError    = true;
                    ValidationError.Display("Email address is formatted incorrectly");
                }
            }

            // ** Password validation **
            lblErrorPassword.Visible = false;
            // Check for blank password
            if (txtPassword.Text.Trim() == "")
            {
                lblErrorPassword.Visible = true;
                flgValidationError       = true;
                ValidationError.Display("Password is blank");
            }
            else
            {
                // Check for password lenght
                if (txtPassword.Text.Length < 6)
                {
                    lblErrorPassword.Visible = true;
                    flgValidationError       = true;
                    ValidationError.Display("Password needs to be longer");
                }
            }

            if (flgValidationError == true)
            {
                return;
            }

            // Check for unique email
            if (GlobalClass.isUniqueEmail(txtEmail.Text) == false)
            {
                lblErrorEmail.Visible = true;
                flgValidationError    = true;
                ValidationError.Display("A list already exisit for this email address, use the Sign in link below to see it");
            }
            else
            {
                // Create new user account
                string strUserId = System.Guid.NewGuid().ToString();
                if (CreateAccount(strUserId, txtEmail.Text, GlobalClass.encodePassword(txtPassword.Text)) == false)
                {
                    flgValidationError = true;
                    ValidationError.Display("Error creating account");
                }
                else
                {
                    Session["UserId"]      = strUserId;
                    Session["DisplayName"] = txtEmail.Text;
                    Session["FirstVisit"]  = "Yes";
                    Session["Favorites"]   = "1"; // new

                    // write coded user id cookie
                    //http://stackoverflow.com/questions/1093181/how-can-i-encrypt-a-cookie-content-in-a-simple-way-in-c-3-0
                    var plainBytes = Encoding.ASCII.GetBytes(strUserId);
                    var codedBytes = plainBytes;
                    Response.Cookies["timeout"].Value   = Convert.ToBase64String(codedBytes);
                    Response.Cookies["timeout"].Expires = DateTime.Now.AddDays(30);


                    CreateSampleItems(strUserId, 3, "Milk", 8, 3.49, 2, "Whole");
                    CreateSampleItems(strUserId, 1, "White Bread", 1, 1.25, 1, "Check for fresh");
                    CreateSampleItems(strUserId, 5, "Ice Cream", 4, 4, 0, "Gallon of Vanilla");
                    CreateSampleItems(strUserId, 3, "Ceddar Cheese", 7, 2, 1, "Small bag shredded");
                    CreateSampleItems(strUserId, 3, "Eggs", 8, 2.25, 1, "Large, Grade A");
                    CreateSampleItems(strUserId, 8, "Paper Towels", 0, 0, 1, "");
                    CreateSampleItems(strUserId, 2, "Ground Chuck", 1, 6.50, 1, "2 pounds");
                    CreateSampleItems(strUserId, 6, "Tomatoes", 10, 0, 3, "Get extra if they look good");
                    CreateSampleItems(strUserId, 1, "~", 0, 0, 0, "");

                    EmailWelcome(txtEmail.Text);
                    GlobalClass.logLogin("Home - New Account");
                    Response.Redirect("List.aspx");
                }
            }
        }