tbf/TestBenchFramework/Forms/EnterPasswordDlg.cs
2014-07-28 09:56:40 +02:00

49 lines
1.4 KiB
C#

using System;
using System.Windows.Forms;
using TBF.Resources;
namespace TBF.Forms
{
public partial class EnterPasswordDlg : Form
{
/// <summary>
/// If set, this is the password that should be entered by the user to pass,
/// otherwise user has to enter the current user password (Entities.User.CurrentUser).
/// </summary>
public string Password;
public EnterPasswordDlg()
{
InitializeComponent();
}
private void PasswordDlg_Load(object sender, EventArgs e)
{
Text = Strings.Enter_password;
passwordLabel.Text = Strings.Password;
okButton.Text = Strings.OkBtnText;
cancelButton.Text = Strings.CancelBtnText;
}
private void okButton_Click(object sender, EventArgs e)
{
if ((Password != null && Password.Equals(passwordTextBox.Text)) ||
(Password == null && Entities.User.CurrentUser.CheckPassword(passwordTextBox.Text)))
{
DialogResult = DialogResult.OK;
Close();
return;
}
MessageBox.Show(Strings.Invalid_password, Strings.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
DialogResult = DialogResult.None;
}
private void cancelButton_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
}
}