예제 #1
0
        private void OnAddButtonClick(object sender, RoutedEventArgs e)
        {
            try
            {
                var newDtabaseConnection = new AddNewDatabaseConnection();
                var result = newDtabaseConnection.ShowDialog();
                if (result != true)
                {
                    return;
                }

                var connection = newDtabaseConnection.Connection;
                if (_context.DatabaseConnections.Where(c => c.Name == connection.Name).ToList().Count > 0)
                {
                    MessageBox.Show("Connection with name " + connection.Name + " already exist",
                                    "name already exists", MessageBoxButton.OK, MessageBoxImage.Error,
                                    MessageBoxResult.OK);
                    return;
                }
                _context.DatabaseConnections.Add(connection);
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message + "\n" + exception.StackTrace,
                                "An error occurred  while adding new connection ", MessageBoxButton.OK, MessageBoxImage.Error,
                                MessageBoxResult.OK);
            }
        }
예제 #2
0
        private void OnEditButtonClick(object sender, RoutedEventArgs e)
        {
            if (_context.SelectedDatabaseConnection == null)
            {
                return;
            }

            try
            {
                var newDtabaseConnection = new AddNewDatabaseConnection(_context.SelectedDatabaseConnection);
                newDtabaseConnection.ShowDialog();
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message + "\n" + exception.StackTrace,
                                "An error occurred  while editing a connection ", MessageBoxButton.OK, MessageBoxImage.Error,
                                MessageBoxResult.OK);
            }
        }