Interaction logic for SelectPage.xaml
Inheritance: System.Windows.Controls.Page
Exemple #1
0
        /// <summary>
        /// Handles the Click event of the btnNext control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param>
        private void btnNext_Click(object sender, RoutedEventArgs e)
        {
            if (excavator == null || CurrentConnection == null)
            {
                lblDbConnect.Style      = (Style)FindResource("labelStyleAlert");
                DbConnectMsg            = "Please select a valid source and destination.";
                lblDbConnect.Visibility = Visibility.Visible;
                return;
            }

            var appConfig            = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
            var rockConnectionString = appConfig.ConnectionStrings.ConnectionStrings["RockContext"];

            if (rockConnectionString == null)
            {
                rockConnectionString = new ConnectionStringSettings("RockContext", CurrentConnection, "System.Data.SqlClient");
                appConfig.ConnectionStrings.ConnectionStrings.Add(rockConnectionString);
            }
            else
            {
                rockConnectionString.ConnectionString = CurrentConnection;
            }

            try
            {
                // Save the user's selected connection string
                appConfig.Save(ConfigurationSaveMode.Modified);
                ConfigurationManager.RefreshSection("connectionStrings");

                var selectPage = new SelectPage(excavator);
                this.NavigationService.Navigate(selectPage);
            }
            catch (Exception ex)
            {
                App.LogException("Next Page", ex.ToString());
                lblDbConnect.Style      = (Style)FindResource("labelStyleAlert");
                DbConnectMsg            = "Unable to save the database connection: " + ex.InnerException.ToString();
                lblDbConnect.Visibility = Visibility.Visible;
            }
        }
Exemple #2
0
        /// <summary>
        /// Handles the Click event of the btnNext control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param>
        private void btnNext_Click( object sender, RoutedEventArgs e )
        {
            if ( excavator == null || CurrentConnection == null )
            {
                lblDbConnect.Style = (Style)FindResource( "labelStyleAlert" );
                DbConnectMsg = "Please select a valid source and destination.";
                lblDbConnect.Visibility = Visibility.Visible;
                return;
            }

            var appConfig = ConfigurationManager.OpenExeConfiguration( ConfigurationUserLevel.None );
            var rockConnectionString = appConfig.ConnectionStrings.ConnectionStrings["RockContext"];

            if ( rockConnectionString == null )
            {
                rockConnectionString = new ConnectionStringSettings( "RockContext", CurrentConnection, "System.Data.SqlClient" );
                appConfig.ConnectionStrings.ConnectionStrings.Add( rockConnectionString );
            }
            else
            {
                rockConnectionString.ConnectionString = CurrentConnection;
            }

            try
            {
                // Save the user's selected connection string
                appConfig.Save( ConfigurationSaveMode.Modified );
                ConfigurationManager.RefreshSection( "connectionStrings" );

                var selectPage = new SelectPage( excavator );
                this.NavigationService.Navigate( selectPage );
            }
            catch ( Exception ex )
            {
                App.LogException( "Next Page", ex.ToString() );
                lblDbConnect.Style = (Style)FindResource( "labelStyleAlert" );
                DbConnectMsg = "Unable to save the database connection: " + ex.InnerException.ToString();
                lblDbConnect.Visibility = Visibility.Visible;
            }
        }
Exemple #3
0
 /// <summary>
 /// Handles the Click event of the btnNext control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param>
 private void btnNext_Click( object sender, RoutedEventArgs e )
 {
     var selectPage = new SelectPage( excavator );
     this.NavigationService.Navigate( selectPage );
 }