예제 #1
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            string enteredPasswordHash = Security.HashString(txtPassword.Text);

            if (passwordHash == "")
            {
                if (txtPassword.Text != "" && txtPassword.Text == txtConfirm.Text)
                {
                    PasswordService.AddNew(new MasterPassword {
                        PasswordHash = enteredPasswordHash
                    });

                    this.DialogResult = DialogResult.OK;
                }
                else if (txtPassword.Text == "")
                {
                    SendMessage("I can't approve of this.", Color.Red);
                }
                else if (txtPassword.Text != txtConfirm.Text)
                {
                    SendMessage("Passwords do not match.", Color.Red);
                }
            }
            else
            {
                if (enteredPasswordHash == passwordHash)
                {
                    this.DialogResult = DialogResult.OK;
                }
                else
                {
                    SendMessage("Incorrect.", Color.Red);
                }
            }
        }