Пример #1
0
        private void ChangeCurrentPassword()
        {
            if (DITHelper.isEmptyString(txtCurrentPassword.Text))
            {
                DITHelper.ShowMessage(this, MessageType.Error, "Please insert your current password.");
                return;
            }

            if (DITHelper.isEmptyString(txtNewPassword.Text))
            {
                DITHelper.ShowMessage(this, MessageType.Error, "Please insert your new password.");
                return;
            }

            if (DITHelper.isEmptyString(txtConfirmPassword.Text))
            {
                DITHelper.ShowMessage(this, MessageType.Error, "Please insert your confirm password.");
                return;
            }

            if (DITUsers.CheckCurrentPassword(HQUser, txtCurrentPassword.Text))
            {
                if (txtNewPassword.Text == txtConfirmPassword.Text)
                {
                    if (txtConfirmPassword.Text.Length > 6)
                    {
                        string salt = DITUsers.GenerateSalt(SALTSIZE);
                        DITUsers.SetNewSalt(salt, HQUser);

                        string hash = DITUsers.GenerateHash(txtConfirmPassword.Text, salt);
                        DITUsers.SetNewPassword(hash, HQUser);

                        DITHelper.ShowMessage(this, MessageType.Success, "Change success");

                        txtCurrentPassword.Text = "";
                        txtNewPassword.Text     = "";
                        txtConfirmPassword.Text = "";
                    }
                    else
                    {
                        DITHelper.ShowMessage(this, MessageType.Error, "Password have at least 6 letters");
                    }
                }
                else
                {
                    DITHelper.ShowMessage(this, MessageType.Error, "Confirm password wrong");
                }
            }
            else
            {
                DITHelper.ShowMessage(this, MessageType.Error, "Current password wrong");
            }
        }
Пример #2
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            items                  = new HQUserItem();
            items.Username         = HQUser;
            items.FirstName        = txtFirstName.Text;
            items.LastName         = txtLastName.Text;
            items.Email            = txtEmail.Text;
            items.Gender           = Convert.ToInt32(ddlGender.SelectedValue);
            items.Birthday         = Convert.ToDateTime(txtDOB.Text);
            items.PreferedLanguage = ddlLanguage.SelectedValue;
            items.Phone            = txtPhone.Text;
            if (DITHelper.isEmptyString(txtFirstName.Text))
            {
                DITHelper.ShowMessage(this, MessageType.Error, "Please insert your first name.");
                return;
            }

            if (DITHelper.isEmptyString(txtLastName.Text))
            {
                DITHelper.ShowMessage(this, MessageType.Error, "Please insert your last name.");
                return;
            }

            if (DITHelper.isEmptyString(txtEmail.Text))
            {
                DITHelper.ShowMessage(this, MessageType.Error, "Please insert your email.");
                return;
            }

            if (DITHelper.isEmptyString(txtPhone.Text))
            {
                DITHelper.ShowMessage(this, MessageType.Error, "Please insert your phone.");
                return;
            }
            if (DITHelper.isEmptyString(txtDOB.Text))
            {
                DITHelper.ShowMessage(this, MessageType.Error, "Please insert your Date of Birth.");
                return;
            }


            if (ddlGender.SelectedIndex == 0)
            {
                DITHelper.ShowMessage(this, MessageType.Error, "Please choose your gender.");
                return;
            }


            if (DITUsers.SetData(items))
            {
                DITHelper.ShowMessage(this, MessageType.Success, "Update successfull!");
            }
            else
            {
                if (DITUsers.CheckEmail(txtEmail.Text, HQUser))
                {
                    DITHelper.ShowMessage(this, MessageType.Error, txtEmail.Text + " was used.");
                }
                else
                {
                    DITHelper.ShowMessage(this, MessageType.Error, "Fail To Update");
                }
            }
        }