示例#1
0
 protected void btnSignUp_Click(object sender, EventArgs e)
 {
     if (Session["AttemptedPassword"] == null)
     {
         txtPasswordNew.Text = "";
     }
     else
     {
         txtPasswordNew.Text = Session["AttemptedPassword"].ToString();
         txtPasswordNew.Attributes.Add("value", txtPasswordNew.Text);
     }
     if (Session["AttemptedPasswordRetype"] == null)
     {
         txtPasswordNewRetype.Text = "";
     }
     else
     {
         txtPasswordNewRetype.Text = Session["AttemptedPasswordRetype"].ToString();
         txtPasswordNewRetype.Attributes.Add("value", txtPasswordNewRetype.Text);
     }
     if (Page.IsValid)
     {
         lblSignUpErrors.Text = "";
         // 1 - No duplicate usernames allowed
         Classes.cLogin Login = new Classes.cLogin();
         Login.CheckForExistingUsername(txtNewUsername.Text);
         if (Login.MemberID != 0)  // UserID is taken
         {
             lblSignUpErrors.Text = "This username is already in use.  Please select a different one.";
         }
         // 2 - Password must meet parameter standards
         int            ValidPassword;
         Classes.cLogin PasswordValidate = new Classes.cLogin();
         PasswordValidate.ValidateNewPassword(txtPasswordNew.Text);
         ValidPassword = PasswordValidate.PasswordValidation;
         if (ValidPassword == 0)
         {
             if (lblSignUpErrors.Text != "")
             {
                 lblSignUpErrors.Text = lblSignUpErrors.Text + "<p></p>" + PasswordValidate.PasswordFailMessage + ".";
             }
             else
             {
                 lblSignUpErrors.Text = PasswordValidate.PasswordFailMessage + ".";
             }
         }
         // 3 - Both passwords must be the same
         if (txtPasswordNew.Text != txtPasswordNewRetype.Text)
         //set an error message
         {
             if (lblSignUpErrors.Text != "")
             {
                 lblSignUpErrors.Text = lblSignUpErrors.Text + "<p></p>Passwords don't match.  Please re-enter.";
             }
             else
             {
                 lblSignUpErrors.Text = "Passwords don't match.  Please re-enter.";
             }
             txtPasswordNew.Text       = "";
             txtPasswordNewRetype.Text = "";
         }
         // 4 - New request - If the email address is already on file, warn them and suggest they go to the Forgot Username / Password section
         Classes.cLogin ExistingEmailAddress = new Classes.cLogin();
         ExistingEmailAddress.GetUsernameByEmail(txtEmail.Text);
         if (ExistingEmailAddress.Username != "")
         {
             if (lblSignUpErrors.Text != "")
             {
                 lblSignUpErrors.Text = lblSignUpErrors.Text + "<p></p>This email address is already associated with an account.  If you've forgotten your username or password, please use the link above.";
             }
             else
             {
                 lblSignUpErrors.Text = "This email address is already associated with an account.  If you've forgotten your username or password, please use the link above.";
             }
         }
         // If there were errors, display them and return to form
         if (lblSignUpErrors.Text != "")
         {
             lblSignUpErrors.Visible = true;
             txtNewUsername.Focus();
         }
         else
         {
             // Everything is ok.  Create the record.  If successful, go to the member demographics screen.
             Classes.cUser NewUser = new Classes.cUser(txtNewUsername.Text, txtPasswordNew.Text);
             NewUser.FirstName     = txtFirstName.Text;
             NewUser.LastName      = txtLastName.Text;
             NewUser.LoginPassword = txtPasswordNew.Text;
             NewUser.LoginEmail    = txtEmail.Text;
             NewUser.LoginName     = txtNewUsername.Text;
             NewUser.Save();
             Classes.cLogin Activation = new Classes.cLogin();
             Activation.Load(txtNewUsername.Text, txtPasswordNew.Text);
             string ActivationKey = "";
             ActivationKey = Activation.SecurityResetCode;
             GenerateWelcomeEmail(txtFirstName.Text, txtLastName.Text, txtNewUsername.Text, txtEmail.Text, ActivationKey);
             Response.Write("<script>");
             Response.Write("window.open('NewUserLoginDirections.aspx','_blank')");
             Response.Write("</script>");
             // TODO-Rick-0e Account for versioning of 'terms of use' and keeping track of date/time and which version user agreed to
         }
     }
     else
     {
         // TODO-Rick-3 On create user if something totally unexpected is wrong put up a message
     }
 }
示例#2
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            //Since no matter what happens in this routine we want to preserve the state of the grids, we bind them now
            BindAllGrids();

            if (!string.IsNullOrWhiteSpace(txtFirstName.Text))
            {
                Demography.FirstName = txtFirstName.Text.Trim();
            }

            Demography.MiddleName = txtMI.Text.Trim(); //I should be able to remove my middle initial if I want

            if (!string.IsNullOrWhiteSpace(txtLastName.Text))
            {
                Demography.LastName = txtLastName.Text.Trim();
            }

            if (ddlGender.SelectedIndex != -1)
            {
                PLDemography.GenderStandared = ddlGender.SelectedValue;
            }

            PLDemography.GenderOther = txtGenderOther.Text; //We shall trust this value since the select event clears the text when needed

            Demography.NickName = txtNickname.Text;

            if (string.IsNullOrWhiteSpace(txtUsername.Text)) //If left empty set back to original setting...They may not remember it....
            {
                txtUsername.Text = Demography.LoginName;
            }

            // 1 - No duplicate usernames allowed
            Classes.cLogin Login = new Classes.cLogin();
            Login.CheckForExistingUsername(txtUsername.Text);
            if (Login.MemberID != 0 && Login.MemberID != Demography.UserID)  // UserID is taken
            {
                lblMessage.Text = "This username is already in use.  Please select a different one.";
                txtUsername.Focus();
                return;
            }
            else
            {
                Demography.LoginName = txtUsername.Text.Trim();
            }

            DateTime dob;

            if (DateTime.TryParse(txtDOB.Text, out dob))
            {
                PLDemography.DateOfBirth = dob;
            }
            else
            {
                lblMessage.Text = "Please enter a valid date";
                txtDOB.Focus();
                return;
            }

            PLDemography.AuthorName  = txtPenname.Text;
            Demography.ForumUserName = txtForumname.Text;

            PLDemography.EmergencyContactName = txtEmergencyName.Text;

            // Using the inital records merge result with the new ones.
            if (AddressesChangesValidate() == false)
            {
                return;
            }

            if (PhoneNumbersChangesValidate() == false)
            {
                return;
            }

            if (EmailsChangesValidate() == false)
            {
                return;
            }

            if (!cPhone.isValidPhoneNumber(txtEmergencyPhone.Text, 10))
            {
                lblMessage.Text = cPhone.ErrorDescription;
                txtEmergencyPhone.Focus();
                return;
            }

            if (PLDemography.EmergencyContactPhone != txtEmergencyPhone.Text)
            {
                PLDemography.EmergencyContactPhone = txtEmergencyPhone.Text;
            }

            /* 3) handle picture update/add.
             */

            //At this point all validation must have been done so it is time to merge lists
            AddressesChangesUpdate();
            PhonesChangesUpdate();
            EmailsChangesUpdate();

            if (Session["dem_Img_Url"] != null)
            {
                PLDemography.UserPhoto  = Session["dem_Img_Url"].ToString();
                imgPlayerImage.ImageUrl = Session["dem_Img_Url"].ToString();
                Session["dem_Img_Url"]  = "";
                Session.Remove("dem_Img_Id");

                //Classes.cPicture NewPicture = new Classes.cPicture();
                //int iPictureId =0;
                //if (Session["dem_Img_Id"] != null && Int32.TryParse(Session["dem_Img_Id"].ToString(), out iPictureId))
                //{
                //    //This code will be enabled once the stored procedure is created
                //    string userID = Session["UserID"].ToString();
                //    //NewPicture.Load(iPictureId, userID);
                //    //NewPicture.PictureFileName = NewPicture.PictureFileName.Replace("_2", "_1");
                //    //NewPicture.Save(userID);
                //    //Time to trash the old main picture with the picture in memory
                //    //PLDemography.UserPhoto = NewPicture.PictureFileName;
                //}
            }

            /* As I validate I will place the new values on the component prior to saving the values*/
            Demography.Save();
            PLDemography.Save();
            Session["Username"] = Demography.LoginName;

            lblMessage.Text = "Changes saved successfully.";
        }