protected override void OnRowsDeleted(object sender, SyncroSim.Core.DataSheetRowEventArgs e) { bool DeletedRows = false; Dictionary <int, bool> RemainingStockTypes = LookupKeyUtilities.CreateRecordLookup(this, Constants.STOCK_TYPE_ID_COLUMN_NAME); DataSheet FlowPathwaySheet = this.GetDataSheet(Constants.DATASHEET_FLOW_PATHWAY_NAME); DataTable FlowPathwayData = FlowPathwaySheet.GetData(); for (int i = FlowPathwayData.Rows.Count - 1; i >= 0; i--) { DataRow dr = FlowPathwayData.Rows[i]; if (dr.RowState == DataRowState.Deleted) { continue; } int?FromStockTypeId = null; if (dr[Constants.FROM_STOCK_TYPE_ID_COLUMN_NAME] != DBNull.Value) { FromStockTypeId = Convert.ToInt32(dr[Constants.FROM_STOCK_TYPE_ID_COLUMN_NAME], CultureInfo.InvariantCulture); } int?ToStockTypeId = null; if (dr[Constants.TO_STOCK_TYPE_ID_COLUMN_NAME] != DBNull.Value) { ToStockTypeId = Convert.ToInt32(dr[Constants.TO_STOCK_TYPE_ID_COLUMN_NAME], CultureInfo.InvariantCulture); } if (FromStockTypeId.HasValue && ToStockTypeId.HasValue) { if ((!RemainingStockTypes.ContainsKey(FromStockTypeId.Value)) | (!RemainingStockTypes.ContainsKey(ToStockTypeId.Value))) { DataTableUtilities.DeleteTableRow(FlowPathwayData, dr); DeletedRows = true; } } } if (DeletedRows) { FlowPathwaySheet.Changes.Add(new ChangeRecord(this, "Diagram data deleted rows")); } base.OnRowsDeleted(sender, e); }
/// <summary> /// Overrides OnAfterRowsDeleted /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// If deterministic transitions have been deleted then it's possible that some transitions no longer reference /// valid state classes. If it is a deterministic transition then we just need to fix up its destination state /// class and stratum to be the same as the source state class and stratum. If it's a probabilistic transition, /// however, we need to delete it. /// <remarks></remarks> protected override void OnRowsDeleted(object sender, SyncroSim.Core.DataSheetRowEventArgs e) { DTAnalyzer Analyzer = new DTAnalyzer(this.GetData(), this.Project); if (this.ResolveDeterministicTransitions(Analyzer)) { this.Changes.Add(new ChangeRecord(this, "DT OnRowsDeleted Modified DT Rows")); } if (this.ResolveProbabilisticTransitions(Analyzer)) { this.GetDataSheet(Strings.DATASHEET_PT_NAME).Changes.Add(new ChangeRecord(this, "DT OnRowsDeleted Deleted PT Rows")); } base.OnRowsDeleted(sender, e); #if DEBUG this.VALIDATE_DETERMINISTIC_TRANSITIONS(); this.VALIDATE_PROBABILISTIC_TRANSITIONS(); #endif }