예제 #1
0
        private static void AddExtraRelationships(IDataTableFinder TableFinder, VirtualDataTable aData, TRelationshipList Relations, TBand band, TMasterDetailLinkList MasterDetailLinkList)
        {
            foreach (TRelationship tr in Relations)
            {
                TDataSourceInfo dParent = TableFinder.TryGetDataTable(tr.ParentTable);
                if (dParent == null || dParent.Table == null)
                {
                    FlxMessages.ThrowException(FlxErr.ErrInvalidManualRelationshipDatasetNull, tr.ParentTable);
                }

                TDataSourceInfo dChild = TableFinder.TryGetDataTable(tr.ChildTable);
                if (dChild == null || dChild.Table == null)
                {
                    FlxMessages.ThrowException(FlxErr.ErrInvalidManualRelationshipDatasetNull, tr.ChildTable);
                }

                if (SameTable(dChild.Table, aData) && SameTable(dParent.Table, band.DataSource.Data))
                {
                    GetColIndexes(dParent.Table, tr.ParentColumns, true); //we do it here so it checks all columns exist in the parent. They might not exist in our table, and that is ok if our table is a distinct for example)
                    GetColIndexes(dChild.Table, tr.ChildColumns, true);
                    int[] ChildCols  = GetColIndexes(aData, tr.ChildColumns, false);
                    int[] ParentCols = GetColIndexes(band.DataSource.Data, tr.ParentColumns, false);

                    if (ChildCols != null && ParentCols != null)
                    {
                        MasterDetailLinkList.AddRelation(band.DataSource.DataState,
                                                         new TRelation(band.DataSource.Data, aData, ParentCols,
                                                                       ChildCols));
                    }
                }
            }
        }
예제 #2
0
 internal TDataSourceInfo(string aName, VirtualDataTable aTable, string aRowFilter, string aSort, bool aDisposeVirtualTable, bool aTempTable, IDataTableFinder aTableFinder)
 {
     Filter(ref aTable, aRowFilter, ref aDisposeVirtualTable, aName);
     FTable = aTable;
     FSort  = aSort;
     FDisposeVirtualTable = aDisposeVirtualTable;
     FTempTable           = aTempTable;
     TableFinder          = aTableFinder;
 }
예제 #3
0
        public TFlexCelDataSource(string dtName, VirtualDataTable aData, TRelationshipList ExtraRelations, TRelationshipList StaticRelations,
                                  TBand MasterBand, string Sort, IDataTableFinder TableFinder)
        {
            SplitLink = null;

            TBand band = MasterBand;
            TMasterDetailLinkList MasterDetailLinkList = new TMasterDetailLinkList();

            while (band != null)
            {
                if (band.DataSource != null)
                {
                    TRelation RelToMaster = band.DataSource.Data.GetRelationWith(aData);
                    if (RelToMaster != null)
                    {
                        MasterDetailLinkList.AddRelation(band.DataSource.DataState, RelToMaster);
                    }

                    //Create the splitlink.
                    TMasterSplitDataTableState SplitMaster = band.DataSource.DataState as TMasterSplitDataTableState;
                    if (SplitMaster != null && String.Equals(SplitMaster.DetailName, dtName, StringComparison.CurrentCultureIgnoreCase))
                    {
                        if (SplitLink != null)
                        {
                            FlxMessages.ThrowException(FlxErr.ErrSplitNeedsOnlyOneMaster, dtName, SplitMaster.TableName, SplitLink.ParentDataSource.TableName);
                        }
                        SplitLink = new TSplitLink(SplitMaster, SplitMaster.SplitCount);
                    }

                    AddExtraRelationships(TableFinder, aData, ExtraRelations, band, MasterDetailLinkList);
                    AddExtraRelationships(TableFinder, aData, StaticRelations, band, MasterDetailLinkList);
                }
                band = band.MasterBand;
            }

            MasterDetailLinks = MasterDetailLinkList.ToArray();

            Data                 = aData;
            DataState            = aData.CreateState(Sort, MasterDetailLinks, SplitLink);
            DataState.FTableName = dtName;
            FName                = dtName;
        }
예제 #4
0
 internal TDataSourceInfoList(bool aOwnsObjects, IDataTableFinder aTableFinder)
 {
     OwnsObjects = aOwnsObjects;
     FList       = new Dictionary <string, TDataSourceInfo>(StringComparer.InvariantCultureIgnoreCase);
     TableFinder = aTableFinder;
 }