private void MySqlOKBtn_Click(object sender, RoutedEventArgs e) { MySqlConnection connection = DBUtils.CreateMySqlConnection( server: MySqlHostTextBox.Text, username: MySqlUsernameTextBox.Text, password: MySqlPasswordTextBox.Password, noDB: true); try { connection.Open(); } catch (Exception ex) { MessageBox.Show("Connection failed with error: " + ex.Message); return; } connection.Close(); Properties.Settings.Default.mySqlHost = MySqlHostTextBox.Text; Properties.Settings.Default.mySqlUsername = MySqlUsernameTextBox.Text; Properties.Settings.Default.mySqlPassword = DBUtils.Protect(MySqlPasswordTextBox.Password); Properties.Settings.Default.databaseType = "MySql"; Properties.Settings.Default.Save(); Close(); }
private void SqlServerOKBtn_Click(object sender, RoutedEventArgs e) { SqlConnection connection = DBUtils.CreateSqlServerConnection( server: SqlServerHostTextBox.Text, username: SqlServerUsernameTextBox.Text, password: SqlServerPasswordTextBox.Password, noDB: true); try { connection.Open(); } catch (Exception ex) { MessageBox.Show("Connection failed with error: " + ex.Message); return; } if (WindowsAuthenticationRadioBtn.IsChecked != null) { Properties.Settings.Default.sqlServerUseWindowsAuthentication = WindowsAuthenticationRadioBtn.IsChecked.Value; } Properties.Settings.Default.sqlServerHost = SqlServerHostTextBox.Text; Properties.Settings.Default.sqlServerUsername = SqlServerUsernameTextBox.Text; Properties.Settings.Default.sqlServerPassword = DBUtils.Protect(SqlServerPasswordTextBox.Password); Properties.Settings.Default.databaseType = "SqlServer"; Properties.Settings.Default.Save(); Close(); }
private async void SaveBtn_Click(object sender, RoutedEventArgs e) { //have to save the passwords here //because binding securely is basically impossible Properties.Settings.Default.mySqlPassword = DBUtils.Protect(MySqlPasswordBox.Password); Properties.Settings.Default.sqlitePassword = DBUtils.Protect(SqlitePasswordBox.Password); Properties.Settings.Default.sqlServerPassword = DBUtils.Protect(SqlServerPassword.Password); Properties.Settings.Default.Save(); ViewModel.Save(); await this.ShowMessageAsync("Restarting", "Settings saved. Restarting application."); System.Windows.Forms.Application.Restart(); Environment.Exit(0); }