private void LineDelete_Cliked(object sender, RoutedEventArgs e) { string message = $"Are you sure you want to delete the relation between {this.ParentTable} and {this.ChildTable}?"; if (MessageBox.Show(message, "Warning", MessageBoxButton.YesNo) != MessageBoxResult.Yes) { return; } Integrity.RemoveForeighKey(this); foreach (Path item in this.linePath) { item.Visibility = Visibility.Collapsed; } }
private void DatabaseRelation_Delete(DatabaseRelation sender) { try { Integrity.RemoveForeighKey(sender); string dictionaryKey = $"{sender.ParentTable}||{sender.ChildTable}"; UIElement tableControl = this.FindVisualControls(typeof(TableObject)).FirstOrDefault(t => ((TableObject)t).Table.TableName == sender.ChildTable); UIElement parentTableControl = this.FindVisualControls(typeof(TableObject)).FirstOrDefault(t => ((TableObject)t).Table.TableName == sender.ParentTable); if (tableControl != null) { TableObject childTable = (TableObject)tableControl; childTable.ColumnRelationModel.Remove(dictionaryKey); childTable.LinkedRelations.Remove(dictionaryKey); } if (parentTableControl != null) { TableObject childTable = (TableObject)parentTableControl; childTable.ColumnRelationModel.Remove(dictionaryKey); childTable.LinkedRelations.Remove(dictionaryKey); } foreach (Path relationPath in this.FindVisualControls(typeof(Path)).Where(p => ((Path)p).Name.EndsWith(sender.RelationshipName))) { this.Children.Remove(relationPath); } this.columnRelationModel.Remove(dictionaryKey); this.CanvasChanged?.Invoke(this, sender); sender.Dispose(); } catch (Exception err) { MessageBox.Show(err.InnerExceptionMessage()); } }