示例#1
0
        protected void btnSaveChanges_Click(object sender, EventArgs e)
        {
            DbObjects.Business.User customer = CurrentUser;

            if (String.IsNullOrEmpty(txtFirstName.Text))
            {
                lblError.Text = "Please enter your first name";
                mpeError.Show();
                return;
            }

            if (String.IsNullOrEmpty(txtSurname.Text))
            {
                lblError.Text = "Please enter your surname";
                mpeError.Show();
                return;
            }

            if (txtEmailAddress.Text != customer.EmailAddress)
            {
                if (String.IsNullOrEmpty(txtEmailAddress.Text))
                {
                    lblError.Text = "Please enter your email address";
                    mpeError.Show();
                    return;
                }

                if (!(IsEmailAddressValid(txtEmailAddress.Text)))
                {
                    lblError.Text = "Please enter a valid email address";
                    mpeError.Show();
                    return;
                }

                if (DbObjects.Business.User.EmailAddressExists(txtEmailAddress.Text))
                {
                    lblError.Text = "There is already another customer with that email address";
                    mpeError.Show();
                    return;
                }
            }

            customer.FirstName    = txtFirstName.Text;
            customer.Surname      = txtSurname.Text;
            customer.EmailAddress = txtEmailAddress.Text;
            customer.Save();

            BindCustomer();

            lblConfirmation.Text = "Successfully saved changes";
        }
示例#2
0
        protected void btnChangePasswordOk_Click(object sender, EventArgs e)
        {
            DbObjects.Business.User customer = CurrentUser;
            lblChangePasswordError.Text = "";

            if (String.IsNullOrEmpty(txtCurrentPassword.Text))
            {
                lblChangePasswordError.Text = "Please enter your current password";
                mpeChangePassword.Show();
                return;
            }

            if (txtCurrentPassword.Text != customer.Password)
            {
                lblChangePasswordError.Text = "That is not your current password";
                mpeChangePassword.Show();
                return;
            }

            if (String.IsNullOrEmpty(txtNewPassword.Text))
            {
                lblChangePasswordError.Text = "Please enter your new password";
                mpeChangePassword.Show();
                return;
            }

            if (txtConfirmPassword.Text != txtNewPassword.Text)
            {
                lblChangePasswordError.Text = "Passwords to not match";
                mpeChangePassword.Show();
                return;
            }

            customer.Password = txtNewPassword.Text;
            customer.Save();

            lblConfirmation.Text = "Successfully changed password";
        }
        protected void btnSaveChanges_Click(object sender, EventArgs e)
        {
            DbObjects.Business.User customer = SelectedCustomer;
            lblError.Text = "";

            if (String.IsNullOrEmpty(txtFirstName.Text))
            {
                lblError.Text = "Please give the customer a first name";
                mpeError.Show();
                return;
            }

            if (String.IsNullOrEmpty(txtSurname.Text))
            {
                lblError.Text = "Please give the customer a surname";
                mpeError.Show();
                return;
            }

            if (String.IsNullOrEmpty(txtEmailAddress.Text))
            {
                lblError.Text = "Please give the customer an email address";
                mpeError.Show();
                return;
            }

            if (!(IsEmailAddressValid(txtEmailAddress.Text)))
            {
                lblError.Text = "Please enter a valid email address";
                mpeError.Show();
                return;
            }

            if (DbObjects.Business.User.EmailAddressExists(txtEmailAddress.Text))
            {
                lblError.Text = "There is already another customer with that email address";
                mpeError.Show();
                return;
            }

            if (String.IsNullOrEmpty(txtPassword.Text))
            {
                lblError.Text = "Please give the new customer a password";
                mpeError.Show();
                return;
            }

            if (!(txtPassword.Text == txtConfirmPassword.Text))
            {
                lblError.Text = "Please make sure both passwords match";
                mpeError.Show();
                return;
            }

            customer.FirstName    = txtFirstName.Text;
            customer.Surname      = txtSurname.Text;
            customer.EmailAddress = txtEmailAddress.Text;
            customer.Password     = txtPassword.Text;

            customer.Save();
            BindCustomer();
        }