private void FormPasswordPrompt_Load(object sender, System.EventArgs e) { this.label_Password.Text = ResourceUtility.GetString("RtPassword"); this.button_OK.Text = ResourceUtility.GetString("RtOK"); this.button_Cancel.Text = ResourceUtility.GetString("RtCancel"); }
public FormPasswordPrompt(PasswordFile currentPasswordFile, AccessLevel currentAccessLevel) { // // Required for Windows Form Designer support // InitializeComponent(); comboBox_Login.Items.Add(new AccessLevel_Localized(AccessLevel.Operator, ResourceUtility.GetString("RtOperator"))); comboBox_Login.Items.Add(new AccessLevel_Localized(AccessLevel.Supervisor, ResourceUtility.GetString("RtSupervisor"))); comboBox_Login.Items.Add(new AccessLevel_Localized(AccessLevel.Administrator, ResourceUtility.GetString("RtAdministrator"))); mPasswordFile = currentPasswordFile; CurrentAccessLevel = currentAccessLevel; comboBox_Login.SelectedIndex = (int)currentAccessLevel; foreach (AccessLevel_Localized al in comboBox_Login.Items) { if (al.val == mCurrentAccessLevel) { comboBox_Login.SelectedItem = al; } } }
private void button_OK_Click(object sender, System.EventArgs e) { AccessLevel newAccessLevel = ((AccessLevel_Localized)(comboBox_Login.SelectedItem)).val; bool isSuccess = true; if (newAccessLevel > mCurrentAccessLevel) { string expected = mPasswordFile.GetPasswordForAccessLevel(newAccessLevel); if (expected != "") { this.Text = ResourceUtility.FormatString("RtEnterPassword", newAccessLevel.ToString()); string enteredPassword = this.textBox_Password.Text; if (enteredPassword != expected) { isSuccess = false; MessageBox.Show(ResourceUtility.GetString("RtInvalidPassword2"), ResourceUtility.GetString("RtInvalidPassword")); } } } if (isSuccess) { mCurrentAccessLevel = newAccessLevel; this.DialogResult = DialogResult.OK; this.Close(); MessageLoggerManager.Log.Info("[Action] Log-in as " + mCurrentAccessLevel.ToString()); } //else //{ // this.DialogResult = DialogResult.Cancel; //} }