private void okBtn_Click(object sender, EventArgs e) { string npass = newPassTxt.Text.Trim(); string cpass = confPassTxt.Text.Trim(); if (npass != "") { if (npass != cpass) { InfoBox ib = new InfoBox(); ib.Icon = MessageBoxIcon.Error; ib.Show("New and confirmation passwords do not match."); return; } m_user.Password = npass; } try { m_user.Save(); } catch (Exception ex) { InfoBox ib = new InfoBox(); ib.Icon = MessageBoxIcon.Error; ib.Show("Error Saving:\n{0}", ex.Message); return; } DialogResult = DialogResult.OK; }
private void okBtn_Click(object sender, EventArgs e) { if (!m_forced) { /* * Check if forced because we fill in bogus info * on the forced version. */ if (m_user.Password != oldTxt.Text) { InfoBox ib = new InfoBox(); ib.Icon = MessageBoxIcon.Error; ib.Show("Old password incorrect."); return; } } string npass = newTxt.Text.Trim(); string cpass = confirmTxt.Text.Trim(); if (npass == String.Empty) { InfoBox ib = new InfoBox(); ib.Icon = MessageBoxIcon.Error; ib.Show("A password is required."); newTxt.Focus(); return; } if (npass != cpass) { InfoBox ib = new InfoBox(); ib.Show("New and confirm passwords do not match."); return; } if (npass == m_user.Password) { InfoBox ib = new InfoBox(); ib.Show("New and old passwords must be different."); return; } m_user.Password = npass; m_user.ForcePassChange = false; try { m_user.Save(); MessageBox.Show("Password changed.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information); Close(); } catch (Exception ex) { InfoBox ib = new InfoBox(); ib.Icon = MessageBoxIcon.Error; ib.Show(ex.Message); if (!m_forced) { return; } } DialogResult = DialogResult.OK; }