public CrossDataGroupColumnValue(CrossDataGroupColumnValue parent, object value)
 {
     Parent = parent;
     Value  = value;
     if (parent != null)
     {
         Parent._childValues.Add(this);
     }
 }
        public CrossDataGroupColumnValue GetValue(CrossDataGroupColumnValue parent, object value)
        {
            var colValue = FindValue(parent, value);

            if (colValue != null)
            {
                return(colValue);
            }
            colValue = new CrossDataGroupColumnValue(parent, value);
            Values.Add(colValue);
            return(colValue);
        }
        public void AddValue(CrossDataColumn column, CrossDataGroupColumnValue columnValue, object value)
        {
            var data = Find(column, columnValue);

            if (data == null)
            {
                _values.Add(new CrossDataRowGroupColumnValue(column, columnValue, value));
            }
            else
            {
                data.Value = value;
            }
        }
        public CrossDataColumnItem(CrossDataFuncColumn column, CrossDataGroupColumnValue value)
        {
            Caption = value.Value != null?value.Value.ToString() : "";

            Column       = column;
            ColumnValues = new List <CrossDataGroupColumnValue> {
                value
            };
            var parent = value.Parent;

            while (parent != null)
            {
                ColumnValues.Add(parent);
                parent = parent.Parent;
            }
        }
        public void Fill(SqlQueryDataSet dataSet, Dictionary <CrossDataColumn, SqlQueryDataSetField> columnFieldMaps)
        {
            while (!dataSet.Eof())
            {
                var row = new CrossDataRow();
                foreach (var column in Columns.OfType <CrossDataKeyColumn>())
                {
                    var field = columnFieldMaps[column];
                    var value = field.GetValue();
                    row.AddValue(column, value);
                }

                var existsRow = Find(row);
                if (existsRow != null)
                {
                    row = existsRow;
                }
                else
                {
                    Rows.Add(row);
                }

                var i = 0;
                CrossDataGroupColumnValue columnValue = null;
                foreach (var column in Columns.OfType <CrossDataGroupColumn>())
                {
                    var field = columnFieldMaps[column];
                    var value = field.GetValue();

                    var currColumnValue = i == 0 ? column.GetValue(value) : column.GetValue(columnValue, value);
                    // row.AddValue(column, columnValue, value);
                    columnValue = currColumnValue;
                    i++;
                }

                foreach (var column in Columns.OfType <CrossDataFuncColumn>())
                {
                    var field = columnFieldMaps[column];
                    var value = field.GetValue();

                    row.AddValue(column, columnValue, value);
                }

                dataSet.Next();
            }
        }
        public void Fill(IDataReader reader)
        {
            while (reader.Read())
            {
                var row = new CrossDataRow();
                foreach (var column in Columns.OfType <CrossDataKeyColumn>())
                {
                    var value = reader.IsDBNull(column.Key) ? null : reader.GetValue(column.Key);
                    row.AddValue(column, value);
                }

                var existsRow = Find(row);
                if (existsRow != null)
                {
                    row = existsRow;
                }
                else
                {
                    Rows.Add(row);
                }

                var i = 0;
                CrossDataGroupColumnValue columnValue = null;
                foreach (var column in Columns.OfType <CrossDataGroupColumn>())
                {
                    var value = reader.IsDBNull(column.Key) ? null : reader.GetValue(column.Key);

                    var currColumnValue = i == 0 ? column.GetValue(value) : column.GetValue(columnValue, value);
                    // row.AddValue(column, columnValue, value);
                    columnValue = currColumnValue;
                    i++;
                }

                foreach (var column in Columns.OfType <CrossDataFuncColumn>())
                {
                    var value = reader.IsDBNull(column.Key) ? null : reader.GetValue(column.Key);

                    row.AddValue(column, columnValue, value);
                }
            }
        }
 public CrossDataRowGroupColumnValue(CrossDataColumn column, CrossDataGroupColumnValue groupValue, object value) : base(column, value)
 {
     GroupValue = groupValue;
 }
 public CrossDataGroupColumnValue FindValue(CrossDataGroupColumnValue parent, object value)
 {
     return(Values.Where(cv => cv.Parent == parent).FirstOrDefault(colValue => colValue.ValueEquals(value)));
 }
 public CrossDataRowValue Find(CrossDataColumn column, CrossDataGroupColumnValue groupValue)
 {
     return(_values.OfType <CrossDataRowGroupColumnValue>().FirstOrDefault(v => v.Column == column && v.GroupValue == groupValue));
 }