Esempio n. 1
0
        private void Sort(RowComparator Comparator, bool SortChildren)
        {
            _rows.Sort(Comparator);

            if (SortChildren)
            {
                foreach (var row in _rows)
                {
                    row.Rows.Sort(Comparator, SortChildren);
                }
            }
        }
        private void Sort(RowComparator comparator, bool sortChildren)
        {
            _rows.Sort(comparator);

            if (sortChildren)
            {
                foreach (var row in _rows)
                {
                    row.Rows.Sort(comparator, sortChildren);
                }
            }
        }
Esempio n. 3
0
 /// <summary>
 /// Sort the loaded data.
 /// </summary>
 ///
 private void SortData()
 {
     IComparer<LoadedRow> comp = new RowComparator(this);
     _data.Sort(comp);
 }
Esempio n. 4
0
        private List <DataRow> GetChildRowsForCurrentRow(DataTable dt, DataRow row, DataTable childDt)
        {
            List <DataRow> childRows = new List <DataRow>();

            List <string> idColumns = new List <string>();
            Dictionary <string, string> idValues = new Dictionary <string, string>();

            for (int i = 0; i < dt.Columns.Count; i++)
            {
                string columnName = dt.Columns[i].ColumnName;

                if (columnName.EndsWith("_ID") || columnName.EndsWith("_ID_COUNTCOLUMN"))
                {
                    idColumns.Add(columnName);

                    object val = row[columnName];

                    if (val != DBNull.Value)
                    {
                        idValues.Add(columnName, val.ToString());
                    }
                    else
                    {
                        idValues.Add(columnName, "");
                    }
                }
            }

            for (int i = 0; i < childDt.Rows.Count; i++)
            {
                DataRow childRow = childDt.Rows[i];

                bool match = true;

                for (int x = 0; match && x < idColumns.Count; x++)
                {
                    string columnName = idColumns[x];

                    string parentVal = idValues[columnName];
                    string childVal  = null;

                    // the column name could be SYSTEM_ID, but in the child table it could be SYSTEM_ID_COUNTCOLUMN
                    object childValObj = null;

                    if (childDt.Columns.Contains(columnName))
                    {
                        childValObj = childRow[columnName];
                    }
                    else if (childDt.Columns.Contains(columnName + "_COUNTCOLUMN"))
                    {
                        childValObj = childRow[columnName + "_COUNTCOLUMN"];
                    }
                    else
                    {
                        // the column isn't shared between the two sets (some columns from parent are exluded from being passed down)
                        // in this case, we just ignore it
                        continue;
                    }

                    if (string.IsNullOrWhiteSpace(parentVal))
                    {
                        parentVal = null;
                    }

                    if (childValObj != null && childValObj != DBNull.Value)
                    {
                        childVal = childValObj.ToString();

                        if (string.IsNullOrWhiteSpace(childVal))
                        {
                            childVal = null;
                        }
                    }

                    if (RowComparator != null) // row comparator is needed when special logic needs to be done other than just comparing column to column
                    {
                        match &= RowComparator.DoesChildRowColumnMatchParentRowColumn(row, parentVal, childRow, childVal, columnName);
                    }
                    else if (parentVal != childVal)
                    {
                        match = false;
                    }
                }

                if (match)
                {
                    childRows.Add(childRow);
                }
            }

            return(childRows);
        }
Esempio n. 5
0
 private void x116e636386480d14()
 {
     IComparer<LoadedRow> comparer = new RowComparator(this);
     this._x4a3f0a05c02f235f.Sort(comparer);
 }