private void ShowSQLConnectionStringBuilder() { ConnectionStringCreatorGUI.SqlConnectionString initialConnStr; try { initialConnStr = new ConnectionStringCreatorGUI.SqlConnectionString(Model.ConnectionString); } catch (Exception) { initialConnStr = new ConnectionStringCreatorGUI.SqlConnectionString(); } Window win = new ConnectionStringCreatorGUI.ConnectionStringBuilderWindow(initialConnStr, returnConnBuilder => { Model.ConnectionString = returnConnBuilder.ToString(); try { AdhocDataAccess adhd = new AdhocDataAccess(Model.ConnectionString); adhd.TestConnection(); } catch (Exception e) { MessageBox.Show("The connection is not valid, Check Server, Database and credentials: " + Environment.NewLine + Environment.NewLine + e.Message); } }); win.Show(); }
public ConnectionStringBuilderWindow(ConnectionStringCreatorGUI.SqlConnectionString connStr, Action <SqlConnectionString> action) { SqlConnectionString con = new SqlConnectionString(); InitializeComponent(); _viewModel = new ConnectionStringBuilderWindowViewModel(connStr, action); Loaded += new RoutedEventHandler(MainWindow_Loaded); }
public ConnectionStringBuilderWindow(ConnectionStringCreatorGUI.SqlConnectionString connStr , Control[] content , Action <SqlConnectionString> action) : this(connStr, action) { foreach (var item in content) { ContentStackPanel.Children.Add(item); } }
public ConnectionStringBuilderWindowViewModel(ConnectionStringCreatorGUI.SqlConnectionString connStr, Action <SqlConnectionString> action) { ConnectionString = connStr ?? new SqlConnectionString(); _exitReturnAction = action; OkClickCommand = new DelegateCommand(() => { string connectionString = ConnectionString.ToString(); IsOpen = false; _exitReturnAction(ConnectionString); }); }
public QueryConfigViewModel() { OpenConnectionGUICommand = new RelayCommand(() => { ConnectionStringCreatorGUI.SqlConnectionString initialConnStr; try { initialConnStr = new ConnectionStringCreatorGUI.SqlConnectionString(ConnectionString); } catch (Exception) { initialConnStr = new ConnectionStringCreatorGUI.SqlConnectionString(); } Window win = new ConnectionStringCreatorGUI.ConnectionStringBuilderWindow(initialConnStr, returnConnBuilder => { ConnectionString = returnConnBuilder.ToString(); }); win.Show(); }); }
public MainWindowViewModel() { _metaAccess = new MetadataFacade(); SaveTableCommand = new DelegateCommand <TableMetadata>(tmd => { SaveChangesForTable(tmd, ConnectionString); }); LoadDatabaseCommand = new DelegateCommand(() => { try { ReloadDBMetaData(ConnectionString); } catch (DbException ex) { MessageBox.Show("Could not connect to the database, make sure you have entered the correct information: " + ex.ToString()); } catch (Exception exx) { MessageBox.Show("Critical error somewhere: " + exx.ToString()); } }); CreateWikiMarkupForTablesCommand = new DelegateCommand(() => { string result = _metaAccess.GenerateWikiMarkupForTablesAndViews(ConnectionString, null, Level1Types.Table); var d = new SaveFileDialog(); d.Title = "Save markup to file:"; var res = d.ShowDialog(); System.IO.File.WriteAllText(d.FileName, result); }); CreateWikiMarkupForAllIndexesCommand = new DelegateCommand(() => { string result = _metaAccess.CreateWikiMarkupForIndexesOnAllTables(ConnectionString); var d = new SaveFileDialog(); d.Title = "Save markup to file:"; var res = d.ShowDialog(); System.IO.File.WriteAllText(d.FileName, result); }); CreateWikiMarkupForSPsCommand = new DelegateCommand(() => { string result = _metaAccess.GenerateWikiMarkupForStoredProcedures(ConnectionString); var d = new SaveFileDialog(); d.Title = "Save markup to file:"; var res = d.ShowDialog(); System.IO.File.WriteAllText(d.FileName, result); }); CreateWikiMarkupForSelectedTableCommand = new DelegateCommand <TableMetadata>(tmd => { string result = _metaAccess.GenerateWikiMarkupForTablesAndViews(ConnectionString, tmd, Level1Types.Table); ModalWindows.WikiMarkupDisplay disp = new ModalWindows.WikiMarkupDisplay(); disp.Show(result); }); CreateWikiMarkupForIndexOnSelectedTableCommand = new DelegateCommand <TableMetadata>(tmd => { string result = _metaAccess.CreateWikiMarkupForIndexesOnTable(tmd, ConnectionString); ModalWindows.WikiMarkupDisplay disp = new ModalWindows.WikiMarkupDisplay(); disp.Show(result); }); CreateWikiMarkupForSelectedStoredProcedureCommand = new DelegateCommand <StoredProcedureMetaData>(spMetadata => { string result = _metaAccess.GenerateWikiMarkupForSelectedStoredProcedure(spMetadata, ConnectionString); ModalWindows.WikiMarkupDisplay disp = new ModalWindows.WikiMarkupDisplay(); disp.Show(result); }); SaveStoreProcedureCommand = new DelegateCommand <StoredProcedureMetaData>(spMetadata => { _metaAccess.SaveStoredProcedureMetadata(_selectedSPMetadata, ConnectionString); }); OpenSqlConnectionBuilder = new DelegateCommand(() => { ConnectionStringCreatorGUI.SqlConnectionString initialConnStr; try { initialConnStr = new ConnectionStringCreatorGUI.SqlConnectionString(ConnectionString); } catch (Exception) { initialConnStr = new ConnectionStringCreatorGUI.SqlConnectionString(); } Window win = new ConnectionStringCreatorGUI.ConnectionStringBuilderWindow(initialConnStr, returnConnBuilder => { ConnectionString = returnConnBuilder.ToString(); }); win.Show(); }); OpenOptionsCommand = new DelegateCommand(() => { Window win = new ExtendedPropertiesDocumentationTool.ModalWindows.ConfigurationWindow(AppSettings); win.Show(); }); SaveViewCommand = new DelegateCommand <ViewMetadata>(vw => { _metaAccess.SaveViewMetaData(vw, ConnectionString); }); CreateWikiMarkupForSelectedViewCommand = new DelegateCommand <ViewMetadata>(vw => { string result = _metaAccess.GenerateWikiMarkupForTablesAndViews(ConnectionString, vw, Level1Types.View); ModalWindows.WikiMarkupDisplay disp = new ModalWindows.WikiMarkupDisplay(); disp.Show(result); }); CreateWikiMarkupFoViewsCommand = new DelegateCommand(() => { string result = _metaAccess.GenerateWikiMarkupForTablesAndViews(ConnectionString, null, Level1Types.View); ModalWindows.WikiMarkupDisplay disp = new ModalWindows.WikiMarkupDisplay(); disp.Show(result); }); CreateSQLStatementsForSelectedTableCommand = new DelegateCommand <TableMetadata>(tmd => { string result = _metaAccess.GenerateSQLStatementForTable(ConnectionString, tmd, Level1Types.Table); ModalWindows.WikiMarkupDisplay disp = new ModalWindows.WikiMarkupDisplay(); disp.Show(result); }); }