예제 #1
0
        private bool ValidatePasswords(Classes.Admin admin)
        {
            bool AllBlank = (
                                ((newAdmin) ? true : txtCurrentPassword.Text.Trim() == "") &&
                                txtNewPassword.Text.Trim() == "" &&
                                txtConfirmNewPassword.Text.Trim() == "");

            bool AllFilledIn = (
                                   ((newAdmin) ? true : txtCurrentPassword.Text.Trim() != "") &&
                                   txtNewPassword.Text.Trim() != "" &&
                                   txtConfirmNewPassword.Text.Trim() != "");

            if (!(AllBlank || AllFilledIn))
            {
                MessageBox.Show(Lang.TransA("Please fill in all password fields or leave them blank!"), Misc.MessageType.Error);
                return false;
            }

            if (AllFilledIn && txtNewPassword.Text != txtConfirmNewPassword.Text)
            {
                MessageBox.Show(Lang.TransA("Password fields do not match!"), Misc.MessageType.Error);
                return false;
            }

            if (!newAdmin && admin != null)
            {
                if (AllFilledIn && !admin.IsPasswordIdentical(txtCurrentPassword.Text))
                {
                    MessageBox.Show(Lang.TransA("The specified current password is wrong!"), Misc.MessageType.Error);
                    return false;
                }
            }

            return true;
        }