private void Login_Load(object sender, EventArgs e) { (new ShowHelper()).ShowDialog(); var chkDoNotLogin = GetConfigData("ChkDoNotLogin"); ChkDoNotLogin.Checked = chkDoNotLogin == true.ToString(); var idSave = GetConfigData("CbIdSave"); if (idSave == true.ToString()) { CbIdSave.Checked = true; var id = GetConfigData("TxtId"); if (!string.IsNullOrEmpty(id)) { TxtId.Text = id; } else { TxtId.Text = IdText; } } else { TxtId.Text = IdText; } TxtPw.Text = PwText; TxtId.Focus(); TxtPw.Focus(); TxtId.Focus(); }
private async void BtnGo_Click(object sender, RoutedEventArgs e) { BtnGo.IsEnabled = false; try { if (!await Utils.PatoClient.Login(TxtUsr.Text, TxtPw.Password)) { LoginWarning.Text = "Contraseña inválida."; TxtPw.Focus(); } else { DialogResult = true; Close(); } } catch (Exception ex) { LoginWarning.Text = ex.Message; } finally { BtnGo.IsEnabled = true; } }
public void BtnLogin_Click(object sender, EventArgs e) { if (!loggedIn) { while (attempt <= MaxAttempts) { if (TxtPw.Text != myPassword && TxtUser.Text != username) { MessageBox.Show("Incorrect login," + (MaxAttempts - attempt) + " attempts remaining"); attempt++; return; } else if (TxtUser.Text != username) { // username is incorrect MessageBox.Show("Invalid username, " + (MaxAttempts - attempt) + " attempts remaining"); attempt++; return; } else { // username is correct // so check password if (TxtPw.Text != myPassword) { // Incorrect password MessageBox.Show("Incorrect password," + (MaxAttempts - attempt) + " attempts remaining"); attempt++; return; } else { //Both are correct attempt = 1; // reset the number of attempts MessageBox.Show("Login successful"); loggedIn = true; BtnLogin.Text = "Logout"; // this.Width = 1600; break; // come out of while loop }//endif }//endif }//end while } else { BtnLogin.Text = "Login"; loggedIn = false; TxtUser.Clear(); TxtPw.Clear(); } }
private void Reset() { BtnAdd.Visible = true; BtnDel.Visible = false; BtnUpdate.Visible = false; TxtLogin.ResetText(); TxtName.ResetText(); TxtPhone.ResetText(); TxtPw.ResetText(); TxtSurname.ResetText(); CkbIsBoss.Checked = false; }