/// <summary> /// Remove a table fromt the dataset, and all constraints and references refering to it /// </summary> /// <param name="ATableName">table to remove</param> public void RemoveTable(String ATableName) { DataTable TableToDelete; // remove all constraints referencing the table that should be deleted foreach (TTypedConstraint constr in FConstraints) { if ((constr.FTable1 == ATableName) || (constr.FTable2 == ATableName)) { TableToDelete = Tables[constr.FTable2]; if (TableToDelete != null) { if (TableToDelete.Constraints.IndexOf(constr.FName) != -1) { TableToDelete.Constraints.Remove(constr.FName); } } } } // remove all relations referencing the table that should be deleted foreach (TTypedRelation relation in FRelations) { if ((relation.FTable1 == ATableName) || (relation.FTable2 == ATableName)) { TableToDelete = Tables[relation.FTable2]; if (TableToDelete != null) { if (Relations.IndexOf(relation.FName) != -1) { Relations.Remove(relation.FName); } if (TableToDelete.Constraints.IndexOf(relation.FName) != -1) { TableToDelete.Constraints.Remove(relation.FName); } } } } TableToDelete = Tables[ATableName]; if (TableToDelete != null) { // remove the table itself Tables.Remove(TableToDelete); } }
/// <summary> /// Disable a specific relation /// /// </summary> /// <returns>void</returns> public void DisableRelation(String AName) { DataTable Table2; foreach (TTypedRelation Relation in FRelations) { if (Relation.FName == AName) { Relation.FEnabled = false; Table2 = Tables[Relation.FTable2]; if (Table2 != null) { if (Relations.IndexOf(AName) != -1) { Relations.Remove(AName); } } } } }