private void ButtonNext_Click(object sender, RoutedEventArgs e) { //Getting data from the form string login = TextBoxLogin.Text; string email = TextBoxEmail.Text; bool correctInputData = false; try { correctInputData = ClassSQLConnection.CheckLoginAndEmail(login, email); } catch (Exception ex) { MessageBox.Show(ex.Message + "\nTry again later", "Error"); return; } //Checking if login and email are incorrect if (!correctInputData) { Main.UpdateMainContent(new WindowInputCode(Main)); return; } try { Main.UpdateMainContent(new WindowInputCode(Main, login, ClassSend.EmailSender(login, email), email)); } catch (Exception ex) { MessageBox.Show(ex.Message + "\nTry again later", "Error"); return; } }
private void ButtonLogging_Click(object sender, RoutedEventArgs e) { //Getting data from the form string login = TextBoxLogin.Text; string password = PasswordBoxPassword.Password; bool correctData; try { correctData = new ClassSQLConnection().CheckLoginDetails(login, password); } catch (Exception ex) { MessageBox.Show(ex.Message + "\nTry again later", "Error"); return; } //Invalid data if (!correctData) { failedAttempts++; string message = "Incorrect password or login"; if (failedAttempts == 2) { message += "\nNext unsuccessful attempt will block the login for five minutes"; } MessageBox.Show(message, "Incorrect data"); if (failedAttempts < 3) { return; } //Block app ButtonLogging.IsEnabled = false; TextBlockNextTry.Visibility = Visibility.Visible; TextBoxLogin.IsEnabled = false; PasswordBoxPassword.IsEnabled = false; TextBoxLogin.Text = ""; PasswordBoxPassword.Password = ""; //Time counting ClassTimer ct = new ClassTimer(5, 0, this); ct.StartTimer(); return; } try { ClassPermission permission = new ClassSQLConnection().GetUserType(login, password); if (permission.Permission == "Administrator") { //Opening MainWindow Main.OpenAdministratorWindow(); return; } Main.OpenMainWindow(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void ButtonSave_Click(object sender, RoutedEventArgs e) { if (MessageBox.Show("Are you sure you want change your password?", "Continue?", MessageBoxButton.YesNo) != MessageBoxResult.Yes) { return; } try { //Change the password in the database ClassSQLConnection.ChangePassword(login, email, PasswordBoxPassword.Password); } catch (Exception ex) { MessageBox.Show(ex.Message + "\nTry again later", "Error"); return; } Main.OpenLogin(); }