コード例 #1
0
        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();
        }
コード例 #2
0
        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();
        }
コード例 #3
0
ファイル: SettingsWindow.xaml.cs プロジェクト: zino974/QPAS
        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);
        }