Пример #1
0
        internal void DeleteAutoGeneratedRows(IEnumerable <DataRow> rows)
        {
            this.BeginDeleteRows();

            DataTable dt = this.GetData();

            foreach (DataRow dr in rows)
            {
                DataTableUtilities.DeleteTableRow(dt, dr);
            }

            this.EndDeleteRows();
        }
Пример #2
0
        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);
        }