public void Rename(object sender, ExecutedRoutedEventArgs e) { var menuInfo = ValidateMenuInfo(sender); if (menuInfo == null) return; try { using (IRepository repository = Helpers.DataConnectionHelper.CreateRepository(menuInfo.DatabaseInfo)) { RenameDialog ro = new RenameDialog(menuInfo.Name); ro.ShowModal(); if (ro.DialogResult.HasValue && ro.DialogResult.Value == true && !string.IsNullOrWhiteSpace(ro.NewName) && !menuInfo.Name.Equals(ro.NewName)) { repository.RenameTable(menuInfo.Name, ro.NewName); if (ParentWindow != null && ParentWindow.Content != null) { ExplorerControl control = ParentWindow.Content as ExplorerControl; control.RefreshTables(menuInfo.DatabaseInfo); } Helpers.DataConnectionHelper.LogUsage("TableRename"); } } } catch (Exception ex) { Helpers.DataConnectionHelper.SendError(ex, menuInfo.DatabaseInfo.DatabaseType, false); } }
public void Rename(object sender, ExecutedRoutedEventArgs e) { var menuInfo = ValidateMenuInfo(sender); if (menuInfo != null) { try { using (IRepository repository = RepoHelper.CreateRepository(menuInfo.Connectionstring)) { RenameDialog ro = new RenameDialog(menuInfo.Name); ro.Owner = Application.Current.MainWindow; ro.ShowDialog(); if (ro.DialogResult.HasValue && ro.DialogResult.Value == true && !string.IsNullOrWhiteSpace(ro.NewName)) { repository.RenameTable(menuInfo.Name, ro.NewName); if (_parent != null) { _parent.BuildDatabaseTree(); } } } } catch (Exception ex) { MessageBox.Show(Helpers.DataConnectionHelper.ShowErrors(ex)); } } }
public void RenameConnection(object sender, ExecutedRoutedEventArgs e) { var databaseInfo = ValidateMenuInfo(sender); if (databaseInfo == null) return; if (databaseInfo.DatabaseInfo.FromServerExplorer) return; try { RenameDialog ro = new RenameDialog(databaseInfo.DatabaseInfo.Caption); ro.ShowModal(); if (ro.DialogResult.HasValue && ro.DialogResult.Value == true && !string.IsNullOrWhiteSpace(ro.NewName) && !databaseInfo.DatabaseInfo.Caption.Equals(ro.NewName)) { Helpers.DataConnectionHelper.RenameDataConnection(databaseInfo.DatabaseInfo.ConnectionString, ro.NewName); ExplorerControl control = _parentWindow.Content as ExplorerControl; control.BuildDatabaseTree(); Helpers.DataConnectionHelper.LogUsage("DatabaseRenameConnection"); } } catch (Exception ex) { Helpers.DataConnectionHelper.SendError(ex, databaseInfo.DatabaseInfo.DatabaseType); } }