Пример #1
1
 /// <summary>
 /// Construct a new <see cref="Table" />.
 /// </summary>
 /// <param name="tableName">
 /// The name of the <see cref="Table" />.
 /// </param>
 /// <param name="headerAlignment">
 /// The method to use to align the text in the table's header.
 /// Defaults to <see cref="StringFormatting.LeftJustified" />.
 /// </param>
 public Table(string tableName=null, Alignment headerAlignment=null)
 {
     Title = tableName ?? string.Empty;
     HeaderAlignment = headerAlignment ?? StringFormatting.LeftJustified;
     Columns = new ColumnCollection();
     Rows = new RowCollection(this);
 }
Пример #2
1
		private ColumnCollection CollectionWith2Columns()
		{
			ColumnCollection cc = new ColumnCollection();
			cc.Add (new SortColumn("Column1",typeof(System.String)));
			cc.Add(new SortColumn("Column2",System.ComponentModel.ListSortDirection.Ascending,typeof(System.String),true));
			return cc;
			        
		}
Пример #3
0
        internal PrimaryKeys(ColumnCollection columns)
        {
            var pk = columns.Where(column => (column as ColumnSchema).PkContraintName != null);

            this.keys = pk.Select(column => column.ColumnName).ToArray();
            if (this.keys.Length != 0)
                this.constraintName = pk.Select(column => (column as ColumnSchema).PkContraintName).First();
        }
Пример #4
0
		public TreeGrid1()
		{
			InitializeComponent();
			columns = new ColumnCollection(this);

			realGrid.LostFocus += new EventHandler(realGrid_LostFocus);
			realGrid.GotFocus += new EventHandler(realGrid_GotFocus);
		}
Пример #5
0
        private static void AddColumnsInternal(ColumnCollection columns, Type itemType, IPageableList owner, string prefix = null, string tableName = null)
        {
            var props = itemType.GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.FlattenHierarchy);
            foreach (var prop in props)
            {
                if (prop.Name == Constants.BaseInfoPropertyName) // Add columns from the "base" classes
                {
                    var method = prop.PropertyType.GetMethod("GetProcessDefinition",
                                                             BindingFlags.Static | BindingFlags.Public);

                    var procDefinition = method.Invoke(null, BindingFlags.InvokeMethod, null, null, null);
                    var table = ((ProcessDefinition)procDefinition).TableList.Last().Name;

                    AddColumnsInternal(columns,prop.PropertyType, owner,
                                       string.IsNullOrEmpty(prefix)
                                           ? Constants.BaseInfoPropertyName
                                           : string.Format("{0}.{1}", prefix, Constants.BaseInfoPropertyName), table);
                }

                var display = (from d in prop.GetCustomAttributes(typeof(DisplayAttribute), false) select d).FirstOrDefault();
                var crossRef = (CrossRefFieldAttribute) (from d in prop.GetCustomAttributes(typeof(CrossRefFieldAttribute), false) select d).FirstOrDefault();
                if (display == null || string.IsNullOrEmpty(((DisplayAttribute)display).Name)) continue;
                var column = ColumnFactory.CreateColumn(owner, columns, crossRef);
                column.Header = ((DisplayAttribute) display).Name;
                //ColumnName =
                                    //    (crossRef == null || string.IsNullOrWhiteSpace(crossRef.RefFieldName))
                                    //        ? prop.Name
                                    //        : crossRef.RefFieldName,
                column.ReferenceTableName = (crossRef == null || string.IsNullOrWhiteSpace(crossRef.ReferenceTableName))
                                                ? string.Empty
                                                : crossRef.ReferenceTableName;
                                    //Width = getWidth(prop),
                column.IsBase = !string.IsNullOrWhiteSpace(prefix);
                column.ColumnName = prop.Name;
                column.Property = prop;
                column.Prefix = prefix;
                column.TableName = tableName;
                column.Width = prop.PropertyType == typeof (string) ? 200 : 50;

                // this cycle is need only to display hyperlink column for field file.
                // search for an item with the equals name, but only at the end + "Url",
                // if found, write AdditionalDataPropertyName item name + "Url"
                foreach (var prop1 in props)
                {
                    if (prop1.Name.EndsWith("Url") && prop1.Name.Remove(prop1.Name.Length - 3, 3) == prop.Name)
                    {
                        column.AdditionalDataPropertyName = prop1.Name;
                        break;
                    }
                }

                columns.Add(column);
            }
            

            //RaisePropertyChanged(() => Columns);

        }
Пример #6
0
 public TableBase()
 {
     Table = new NewTablix
                 {
                     Name = Name ?? "Table_" + Guid.NewGuid().ToString().Replace("-", ""),
                     Style = new Style { Border = new Border { Style = "Solid" }.Create() }
                 };
     Columns = new ColumnCollection();
     Rows = new CornerRowCollection();
 }
Пример #7
0
        public ColumnCollection List(IEnumerable<IFilter> filters)
        {
            var columns = new ColumnCollection();

            var rows = Discover(filters);
            foreach (var row in rows)
                columns.AddOrIgnore(row.Name);

            return columns;
        }
Пример #8
0
 public Type(string name)
 {
     if (name == null)
     {
         throw Error.SchemaRequirementViolation("Type", "Name");
     }
     this.name = name;
     columns = new ColumnCollection();
     associations = new AssociationCollection();
     subTypes = new TypeCollection();
 }
Пример #9
0
 internal GridPanel(C1FlexGrid grid, CellType cellType, int rowHeight, int colWidth)
 {
     Grid = grid;
     CellType = cellType;
     _cells = new CellRangeDictionary();
     ViewRange = CellRange.Empty;
     Rows = new RowCollection(this, rowHeight);
     Columns = new ColumnCollection(this, colWidth);
     HorizontalAlignment = HorizontalAlignment.Left;
     VerticalAlignment = VerticalAlignment.Top;
 }
Пример #10
0
        public void SetLayoutTest()
        {
            #region Arrange

            var layoutFieldViewModelFactory = new ExportFactory<LayoutFieldViewModel>(() => new Tuple<LayoutFieldViewModel, Action>(new LayoutFieldViewModel(), () => { }));

            var field1Name = "BaseField1";
            var field2Name = "BaseField2";
            var field3Name = "Field1";
            var field4Name = "Field2";
            var field1Prefix = Constants.BaseInfoPropertyName;
            var field2Prefix = string.Format("{0}.{0}.{0}", Constants.BaseInfoPropertyName);
            string field3Prefix = null;
            string field4Prefix = null;

            var column1 = CreateColumnItem(field1Name, field1Prefix);
            var column2 = CreateColumnItem(field2Name, field2Prefix);
            var column3 = CreateColumnItem(field3Name, field3Prefix);
            var column4 = CreateColumnItem(field4Name, field4Prefix);

            var columns = new ColumnCollection() { column1, column2, column3, column4 };

            var modelLayoutList = new List<string>()
                                      {
                                          GetFullyQualifiedName(field1Name, field1Prefix),
                                          GetFullyQualifiedName(field2Name, field2Prefix),
                                          GetFullyQualifiedName(field3Name, field3Prefix),
                                          GetFullyQualifiedName(field4Name, field4Prefix)
                                      };
            var model = new SearchViewModel() { LayoutList = modelLayoutList, Columns = columns };
            var vm = new LayoutViewModel() { Model = model, LayoutFieldViewModelFactory = layoutFieldViewModelFactory };

            #endregion Arrange

            //Act
            SetupRadGridViewHelper(new RadGridView(), new[] { column2, column3 });
            vm.SetLayout(new List<string>());

            //Assert
            Assert.AreEqual(vm.LayoutList.Count, 0);
            //Assert.AreEqual(vm.LayoutList[0].ColumnSystemName, GetFullyQualifiedName(field2Name, field2Prefix));
            //Assert.AreEqual(vm.LayoutList[1].ColumnSystemName, GetFullyQualifiedName(field3Name, field3Prefix));

            ////Act
            //SetupRadGridViewHelper(new RadGridView(), new[] { column1, column4 });
            //vm.SetLayout(new List<string>());

            ////Assert
            //Assert.AreEqual(vm.LayoutList.Count, 2);
            //Assert.AreEqual(vm.LayoutList[0].ColumnSystemName, GetFullyQualifiedName(field1Name, field1Prefix));
            //Assert.AreEqual(vm.LayoutList[1].ColumnSystemName, GetFullyQualifiedName(field4Name, field4Prefix));
        }
Пример #11
0
        public void GetColumnsFromDefaultLayout(string processSystemName, Action<ColumnCollection> callback)
        {
            var filter = GetLayoutFilter(processSystemName);

            TheDynamicTypeManager.BeginGetList<ILayoutList<ILayoutInfo>>(Constants.LayoutProcessName, (o, r) =>
                {
                    if (r.Error != null)
                    {
                        return;
                    }

                    var defaultLayout = (ILayoutInfo)r.Object[0];

                    var layoutViewModel = new NewLayoutViewModel
                    {
                        Id = defaultLayout.Id,
                        AccountId = defaultLayout.AccountId,
                        LayoutString = defaultLayout.LayoutDefinition,
                        IsAdminLayout = defaultLayout.IsAdminLayout ?? false,
                        IsDefault = defaultLayout.IsDefault ?? false,
                        Name = defaultLayout.Name,
                    };

                    layoutViewModel.Parse(layoutViewModel.LayoutString);

                    var type = TheDynamicTypeManager.GetListType(processSystemName).BaseType.GetGenericArguments()[1];

                    var columnCollection = new ColumnCollection();

                    for (int i = 0; i < layoutViewModel.LayoutColumns.Count; i++)
                    {
                        var layoutColumn = layoutViewModel.LayoutColumns[i];
                        var property = type.GetProperty(layoutColumn.SystemName);

                        var column = new ColumnItem(null, null)
                        {
                            Header = layoutColumn.Header,
                            ColumnName = layoutColumn.SystemName,
                            Width = layoutColumn.Width.HasValue ? layoutColumn.Width.Value : 0,
                            Order = i,
                            Property = property
                        };

                        columnCollection.Add(column);
                    }

                    callback(columnCollection);

                }, filterExpression: filter.ToJSON(), pageSize: 1);
        }
Пример #12
0
        /// <summary>
        /// Adds the columns.
        /// </summary>
        /// <param name="columns">The columns.</param>
        /// <param name="itemType">Type of the item.</param>
        /// <param name="owner">The owner.</param>
        /// <param name="prefix">The prefix.</param>
        /// <param name="tableName">Name of the table.</param>
        /// <param name="forFilter">if set to <c>true</c> [for filter].</param>
        /// <param name="displayColumns">The display columns.</param>
        /// <param name="columnOrder">The column order.</param>
        public static void AddColumns(
            this ColumnCollection columns,
            Type itemType,
            IRefreashable owner,
            string prefix = null,
            string tableName = null,
            bool forFilter = false,
            string[] displayColumns = null,
            IList<string> columnOrder = null)
        {
            //aggregate own and parent's columns and return in default order
            var columnsList = new ColumnCollection();

            AddColumnsInternal(columnsList, itemType, owner, prefix, tableName, forFilter, displayColumns, columnOrder);

            columns.AddRange(columnsList.OrderBy(c => c.DefaultOrder));
        }
Пример #13
0
        public Table()
        {
            //ExpandedColumnCount = 1;

            //ExpandedRowCount = 1;

            FullColumns = 1;

            FullRows = 1;

            DefaultColumnWidth = 54.0;

            DefaultRowHeight = 13.5;

            Rows = new RowCollection();
            Columns = new ColumnCollection();
        }
    protected void SynchronizeColumnSort(
      SynchronizationContext synchronizationContext,
      SortDescriptionCollection sortDescriptions,
      ColumnCollection columns )
    {
      ColumnSortCommand.ThrowIfNull( synchronizationContext, "synchronizationContext" );
      ColumnSortCommand.ThrowIfNull( sortDescriptions, "sortDescriptions" );
      ColumnSortCommand.ThrowIfNull( columns, "columns" );

      if( !synchronizationContext.Own || !columns.Any() )
        return;

      this.SetResortCallback( sortDescriptions, columns );

      int count = sortDescriptions.Count;
      Dictionary<string, ColumnSortInfo> sortOrder = new Dictionary<string, ColumnSortInfo>( count );

      for( int i = 0; i < count; i++ )
      {
        var sortDescription = sortDescriptions[ i ];
        string propertyName = sortDescription.PropertyName;

        if( sortOrder.ContainsKey( propertyName ) )
          continue;

        sortOrder.Add( propertyName, new ColumnSortInfo( i, sortDescription.Direction ) );
      }

      foreach( var column in columns )
      {
        ColumnSortInfo entry;

        if( sortOrder.TryGetValue( column.FieldName, out entry ) )
        {
          column.SetSortIndex( entry.Index );
          column.SetSortDirection( entry.Direction );
        }
        else
        {
          column.SetSortIndex( -1 );
          column.SetSortDirection( SortDirection.None );
        }
      }
    }
Пример #15
0
        public ColumnCollection GetColumns()
        {
            ColumnCollection temp = new ColumnCollection();

            DataTable dt = (DataTable)data_source.DataSource;

            int i = 0;

            foreach (DataColumn dc in dt.Columns)
            {
                IColumn col = ColumnTypeDelegator.getByType(dc.DataType);
                col.HeadText = dc.ColumnName;
                col.Width = 100;
                col.DataSourceColumnIndex = i;
                temp.Add(col);
                i++;
            }

            return temp;
        }
Пример #16
0
        public DataTableDpoClass(DataTable table)
        {
            DatabaseName dname = new DatabaseName(ConnectionProviderManager.DefaultProvider, "MEM");

            this.table = table;

            this.tableName = new ClassTableName(new TableName(dname, TableName.dbo, table.TableName));

            this._columns = new ColumnCollection(this);
            foreach (DataColumn c in table.Columns)
            {
                this._columns.Add(new DtColumn(c));
            }

            this._identity = new IdentityKeys(this._columns);
            this._computedColumns = new ComputedColumns(this._columns);

            this._columns.UpdatePrimary(this.PrimaryKeys);
            this._columns.UpdateForeign(this.ForeignKeys);
        }
    public DetailConfiguration()
    {
      var columns = new ColumnCollection( this.DataGridControl, this );

      this.SetColumns( columns );
      this.Columns.CollectionChanged += new NotifyCollectionChangedEventHandler( this.OnColumnsCollectionChanged );
      VisibilityChangedEventManager.AddListener( this.Columns, this );

      this.SetVisibleColumns( new ReadOnlyColumnCollection() );

      m_columnsByVisiblePosition = new HashedLinkedList<ColumnBase>();
      m_columnSynchronizationManager = new ColumnSynchronizationManager( this );

      this.SetHeaders( new ObservableCollection<DataTemplate>() );
      this.SetFooters( new ObservableCollection<DataTemplate>() );

      this.SetGroupLevelDescriptions( new GroupLevelDescriptionCollection() );
      this.SetDetailConfigurations( new DetailConfigurationCollection( this.DataGridControl, this ) );
      CollectionChangedEventManager.AddListener( this.DetailConfigurations, this );

    }
Пример #18
0
        public List<UserViewSettings> GetUserViewSettings(Guid userId, List<string> calendarIds)
        {
            var cc = new ColumnCollection();

            var extCalId = cc.RegistryColumn("ext_calendar_id");
            var usrId = cc.RegistryColumn("user_id");
            var hideEvents = cc.RegistryColumn("hide_events");
            var isAccepted = cc.RegistryColumn("is_accepted");
            var textColor = cc.RegistryColumn("text_color");
            var background = cc.RegistryColumn("background_color");
            var alertType = cc.RegistryColumn("alert_type");
            var calId = cc.RegistryColumn("calendar_id");
            var calName = cc.RegistryColumn("name");
            var timeZone = cc.RegistryColumn("time_zone");

            var data = DbManager
               .ExecuteList(
               new SqlQuery("calendar_calendar_user").Select(cc.SelectQuery)
                   .Where((Exp.In(extCalId.Name, calendarIds) | Exp.In(calId.Name, calendarIds)) & Exp.Eq(usrId.Name, userId))
                   );

            var options = new List<UserViewSettings>();
            foreach (var r in data)
            {
                options.Add(new UserViewSettings()
                {
                    CalendarId = Convert.ToInt32(r[calId.Ind]) == 0 ? Convert.ToString(r[extCalId.Ind]) : Convert.ToString(r[calId.Ind]),
                    UserId = usrId.Parse<Guid>(r),
                    IsHideEvents = hideEvents.Parse<bool>(r),
                    IsAccepted = isAccepted.Parse<bool>(r),
                    TextColor = textColor.Parse<string>(r),
                    BackgroundColor = background.Parse<string>(r),
                    EventAlertType = (EventAlertType)alertType.Parse<int>(r),
                    Name = calName.Parse<string>(r),
                    TimeZone = timeZone.Parse<TimeZoneInfo>(r)
                });
            }

            return options;
        }
Пример #19
0
        /// <summary>
        /// Creates and caches an instance of a <see cref="ColumnCollection"/> for a <see cref="View"/>.
        /// </summary>
        /// <param name="view">The <see cref="View"/> from which column information is retrieved.</param>
        /// <returns>A new or cached copy of columns for the <see cref="View.QueryString"/>.</returns>
        /// <exception cref="ArgumentNullException">The <paramref name="view"/> parameter value is null.</exception>
        internal static ColumnCollection GetColumns(View view)
        {
            if (null == view)
            {
                throw new ArgumentNullException("view");
            }

            ColumnCollection columns;
            if (views.ContainsKey(view.QueryString) && views[view.QueryString].IsAlive)
            {
                // Get an existing collection.
                columns = (ColumnCollection)views[view.QueryString].Target;
            }
            else
            {
                // Add or set a new column collection;
                columns = new ColumnCollection(view);
                views[view.QueryString] = new WeakReference(columns);
            }

            return columns;
        }
Пример #20
0
        public void parseStringTest()
        {
            Condition_Accessor target = new Condition_Accessor(); // TODO: Initialize to an appropriate value
            ColumnCollection grid_columns = new ColumnCollection();
            grid_columns.Add(new TextColumn("Sloupec 1"));
            grid_columns.Add(new TextColumn("Sloupec 2"));
            grid_columns.Add(new NumberColumn("Sloupec 3"));
            grid_columns.Add(new NumberColumn("cislo"));

            grid_columns.Add(new TextColumn("Sloupec like"));

            Check(target, "[Sloupec 1] = 100", grid_columns, grid_columns[0], "100", Operators.equal);
            Check(target, "cislo > 56", grid_columns, grid_columns[3], "56", Operators.greater_than);
            Check(target, "cislo >= '56'", grid_columns, grid_columns[3], "56", Operators.greater_than | Operators.equal);
            Check(target, "[Sloupec 2] LIKE '160%'", grid_columns, grid_columns[1], "160%", Operators.like);
            Check(target, "[Sloupec 2] like '160%'", grid_columns, grid_columns[1], "160%", Operators.like);
            Check(target, "Sloupec 2 like '160%'", grid_columns, grid_columns[1], "160%", Operators.like);
            Check(target, "Sloupec 2 like 'neco = pokus'", grid_columns, grid_columns[1], "neco = pokus", Operators.like);
            Check(target, "Sloupec 1 REGeXp 'neco.*'", grid_columns, grid_columns[0], "neco.*", Operators.regexp);

            Check(target, "[Sloupec like] like '160%'", grid_columns, grid_columns[4], "160%", Operators.like);
        }
Пример #21
0
        internal TableInfo(Database db, string name)
        {
            if (db == null)
            {
                throw new ArgumentNullException("db");
            }

            if (string.IsNullOrWhiteSpace(name))
            {
                throw new ArgumentNullException("name");
            }

            this.name = name;

            using (View columnsView = db.OpenView("SELECT * FROM `{0}`", name))
            {
                this.columns = new ColumnCollection(columnsView);
            }

            this.primaryKeys = new ReadOnlyCollection<string>(
                TableInfo.GetTablePrimaryKeys(db, name));
        }
Пример #22
0
        /// <summary>
        /// Indexes the specified process name.
        /// </summary>
        /// <param name="processName">Name of the process.</param>
        /// <param name="name">The name.</param>
        /// <returns>ActionResult.</returns>
        public ActionResult Index(string processName, string name)
        {
            var listType = GetListType(ref processName);
            var methodName = string.Format(CultureInfo.InvariantCulture, "Get{0}List", processName);

            var list = (IInfoList)MethodCaller.CallFactoryMethod(listType, methodName, "", 0, 10, null, FilterDescriptor.GetFilterExpression(null));

            var columns = new ColumnCollection();
            var baseType = list.GetType().BaseType;
            if (baseType != null)
            {
                var itemType = baseType.GetGenericArguments()[1];
                columns.AddColumns(itemType);
            }

            var listViewModel = new ListViewModel {Columns = columns, List = new List<dynamic>()};
            foreach (var item in list)
                listViewModel.List.Add(item);

            listViewModel.OriginalList = list;

            return View(listViewModel);
        }
Пример #23
0
        //private DateTime _createdDate = DateTime.Now;

        #endregion

        #region Constructor

        public Database(INHydrateModelObject root)
            : base(root)
        {
            _tables = new TableCollection(root);
            _tables.ResetKey(Guid.Empty.ToString());
            _columns = new ColumnCollection(root);
            _columns.ResetKey(Guid.Empty.ToString());
            _relations = new RelationCollection(root);
            _relations.ResetKey(Guid.Empty.ToString());
            _viewRelations = new ViewRelationCollection(root);
            _viewRelations.ResetKey(Guid.Empty.ToString());
            _customViews = new CustomViewCollection(root);
            _customViews.ResetKey(Guid.Empty.ToString());
            _customAggregates = new CustomAggregateCollection(root);
            _customAggregates.ResetKey(Guid.Empty.ToString());
            _customStoredProcedures = new CustomStoredProcedureCollection(root);
            _customStoredProcedures.ResetKey(Guid.Empty.ToString());
            _customViewColumns = new CustomViewColumnCollection(root);
            _customViewColumns.ResetKey(Guid.Empty.ToString());
            _customAggregateColumns = new CustomAggregateColumnCollection(root);
            _customAggregateColumns.ResetKey(Guid.Empty.ToString());
            _customStoredProcedureColumns = new CustomStoredProcedureColumnCollection(root);
            _customStoredProcedureColumns.ResetKey(Guid.Empty.ToString());
            _customRetrieveRules = new CustomRetrieveRuleCollection(root);
            _customRetrieveRules.ResetKey(Guid.Empty.ToString());
            _customRetrieveRuleParameters = new ParameterCollection(root);
            _customRetrieveRuleParameters.ResetKey(Guid.Empty.ToString());
            _functionParameters = new ParameterCollection(root);
            _functionParameters.ResetKey(Guid.Empty.ToString());
            _functions = new FunctionCollection(root);
            _functions.ResetKey(Guid.Empty.ToString());
            _functionColumns = new FunctionColumnCollection(root);
            _functionColumns.ResetKey(Guid.Empty.ToString());

            this.PrecedenceOrderList = new List<Guid>();
        }
 /// <summary>
 /// Builds collection of columns.
 /// </summary>
 /// <param name="columns"></param>
 private void _BuildColumnsCollection(ColumnCollection columns)
 {
     columns.Clear();
     foreach (Column column in _columns)
     {
         if (column.FieldName.Equals("Capacities") || column.FieldName.Equals("CustomOrderProperties"))
         {
             Collection<Column> dynamicColumns = column.FieldName.Equals("Capacities") ?
                                                     _GetDynamicCapacitiesColumns(column.ReadOnly) :
                                                     _GetDynamicCustomOrderColumns(column.ReadOnly);
             foreach (Column dynamicColumn in dynamicColumns)
             {
                 if (column.CellEditor != null)
                     dynamicColumn.CellEditor = column.CellEditor;
                 dynamicColumn.Width = column.Width;
                 columns.Add(dynamicColumn);
             }
         }
         else if (column.FieldName.Equals("AddressFields"))
         {
             Collection<Column> dynamicColumns = _GetDynamicAddressColumns(column.ReadOnly);
             foreach (Column dynamicColumn in dynamicColumns)
                 columns.Add(dynamicColumn);
         }
         else
             columns.Add(column);
     }
 }
Пример #25
0
		public SortComparer(ColumnCollection owner, int listIndex, object[] values):base(owner,listIndex,values)
		{
		}
Пример #26
0
        internal decimal GetSum(RowCell cell)
        {
            if (Sum == null)
            {
                return(m_GetColumnSum);
            }
            string mathExpression = Sum.ToLowerInvariant();

            if (Grid.Trace.IsTracing)
            {
                Grid.Trace.Trace("Starting getting data for math. ({0})", ColumnId);
            }
            ColumnCollection columns = m_Table.Columns;

            foreach (Column column in columns)
            {
                if (mathExpression.IndexOf(string.Format("[{0}]", column.ColumnId), StringComparison.OrdinalIgnoreCase) == -1)
                {
                    continue;
                }
                if (cell.Row[column.ColumnId].Value == null || cell.Row[column.ColumnId].Value == DBNull.Value)
                {
                    mathExpression = mathExpression.Replace(string.Format("[{0}]", column.ColumnId.ToLowerInvariant()),
                                                            "0");
                }
                else
                {
                    object myValue = cell.Row[column.ColumnId].Value;
                    if (myValue != null)
                    {
                        mathExpression =
                            mathExpression.Replace(string.Format("[{0}]", column.ColumnId.ToLowerInvariant()),
                                                   myValue.ToString().Replace(",", "."));
                    }
                    else
                    {
                        mathExpression = "";
                    }
                }
            }
            try
            {
                if (Grid.Trace.IsTracing)
                {
                    Grid.Trace.Trace("Ended getting data for math. ({0})", ColumnId);
                }

                m_GetColumnSum = Convert.ToDecimal(Evaluate(mathExpression));
                TotalSum       = TotalSum + m_GetColumnSum;
                if (Grid.Trace.IsTracing)
                {
                    Grid.Trace.Trace("Successfully calculating expression: {0} = {1} (Total: {2})", mathExpression,
                                     m_GetColumnSum.ToString(Format, Grid.Culture), TotalSum);
                }
            }
            catch (Exception ee)
            {
                throw new GridException(
                          string.Format("Error calculating expression: {0} for columnId: {1}", mathExpression, ColumnId), ee);
            }
            return(m_GetColumnSum);
        }
Пример #27
0
    public static void GenerateColumnsFromItemsSourceFields(
      ColumnCollection columns,
      IDictionary<Type, CellEditor> defaultCellEditors,
      Dictionary<string, FieldDescriptor> fields,
      bool autoCreateForeignKeyConfigurations )
    {
      DataGridControl dataGridControl = columns.DataGridControl;

      using( columns.DeferColumnAdditionMessages() )
      {
        foreach( FieldDescriptor field in fields.Values )
        {
          string fieldName = field.Name;
          ColumnBase column = columns[ fieldName ];
          Column dataColumn = column as Column;
          Type dataType = field.DataType;

          if( column == null )
          {
            dataColumn = ItemsSourceHelper.CreateColumnFromItemsSourceField(
              dataGridControl, defaultCellEditors, field, autoCreateForeignKeyConfigurations );

            if( dataColumn != null )
            {
              columns.Add( dataColumn );
              ItemsSourceHelper.ApplySettingsRepositoryToColumn( dataColumn );
            }
          }
          else if( dataColumn != null )
          {
            if( field.ReadOnly )
            {
              if( dataColumn.ReadLocalValue( Column.ReadOnlyProperty ) == DependencyProperty.UnsetValue )
              {
                dataColumn.ReadOnly = field.ReadOnly;
              }
            }

            if( field.OverrideReadOnlyForInsertion )
            {
              if( dataColumn.ReadLocalValue( ColumnBase.OverrideReadOnlyForInsertionProperty ) == DependencyProperty.UnsetValue )
              {
                dataColumn.OverrideReadOnlyForInsertion = field.OverrideReadOnlyForInsertion;
              }
            }

            if( dataColumn.ReadLocalValue( Column.TitleProperty ) == DependencyProperty.UnsetValue )
            {
              dataColumn.Title = field.DisplayName;
            }

            if( dataColumn.ReadLocalValue( Column.CellEditorProperty ) == DependencyProperty.UnsetValue )
            {
              CellEditor cellEditor = null;

              if( defaultCellEditors != null )
              {
                defaultCellEditors.TryGetValue( dataType, out cellEditor );
              }

              if( cellEditor == null )
              {
                object descriptionItemsSource = null;
                object configurationItemsSource = null;
                ForeignKeyConfiguration configuration = dataColumn.ForeignKeyConfiguration;

                if( field.ForeignKeyDescription != null )
                {
                  descriptionItemsSource = field.ForeignKeyDescription.ItemsSource;
                }

                if( configuration != null )
                {
                  configurationItemsSource = configuration.ItemsSource;

                  if( configurationItemsSource == null )
                  {
                    configurationItemsSource = dataColumn.ReadLocalValue( Column.ForeignKeyConfigurationProperty );
                  }
                }

                // A foreign key ItemsSource is set and we can auto-create configuration
                // OR
                // if the foreign key ItemsSource was found in the ForeignKeyConfiguration
                //
                // use the Default ForeignKey CellEditor.
                if( ( ( descriptionItemsSource != null ) && ( autoCreateForeignKeyConfigurations ) )
                    || ( configurationItemsSource != null ) )
                {
                  cellEditor = DefaultCellEditorSelector.ForeignKeyCellEditor;
                }
              }

              if( cellEditor == null )
              {
                cellEditor = DefaultCellEditorSelector.SelectCellEditor( dataType );
              }

              dataColumn.CellEditor = cellEditor;
            }

            if( ( field.ForeignKeyDescription != null )
                && ( field.ForeignKeyDescription.ItemsSource != null )
                && ( autoCreateForeignKeyConfigurations ) )
            {
              // Update the ForeignKeyConfiguration from the ForeignKeyDescription
              // found on the FieldDescriptor
              ForeignKeyConfiguration.SynchronizeForeignKeyConfigurationFromForeignKeyDescription(
                dataColumn,
                field.ForeignKeyDescription,
                autoCreateForeignKeyConfigurations );
            }

            // Disable warning for DisplayMemberBinding when internaly used
#pragma warning disable 618

            if( dataColumn.DisplayMemberBinding == null )
            {
              dataColumn.DisplayMemberBinding = ItemsSourceHelper.CreateDefaultBinding(
                false, field.Name, field,
                false, ( dataColumn.ReadOnly && !dataColumn.OverrideReadOnlyForInsertion ), dataType );

              //mark the Column's Binding as AutoCreated.
              dataColumn.IsBindingAutoCreated = true;
              dataColumn.IsBoundToDataGridUnboundItemProperty = field.IsDataGridUnboundItemProperty;
            }

#pragma warning restore 618
          }
        }
      } //end using
    }
Пример #28
0
    public static void UpdateColumnsOnItemsPropertiesChanged( 
      DataGridControl dataGridControl, 
      ColumnCollection columns,
      bool autoCreateForeignKeyConfigurations,
      NotifyCollectionChangedEventArgs e,
      DataGridItemPropertyCollection itemProperties )
    {
      if( dataGridControl == null )
        return;

      switch( e.Action )
      {
        case NotifyCollectionChangedAction.Add:
          {
            foreach( DataGridItemPropertyBase itemProperty in e.NewItems )
            {
              string name = itemProperty.Name;

              if( columns[ name ] == null )
              {
                Column column = ItemsSourceHelper.CreateColumnFromItemsSourceField(
                  dataGridControl, dataGridControl.DefaultCellEditors,
                  ItemsSourceHelper.CreateFieldFromDataGridItemProperty( itemProperty ),
                  autoCreateForeignKeyConfigurations );

                if( column != null )
                {
                  columns.Add( column );
                  ItemsSourceHelper.ApplySettingsRepositoryToColumn( column );
                }
              }
            }
          }

          break;

        case NotifyCollectionChangedAction.Remove:
          {
            foreach( DataGridItemPropertyBase itemProperty in e.OldItems )
            {
              string name = itemProperty.Name;
              Column column = columns[ name ] as Column;

              if( ( column != null ) && ( column.IsAutoCreated ) )
              {
                columns.Remove( column );
              }
            }

            break;
          }

        case NotifyCollectionChangedAction.Replace:
          {
            foreach( DataGridItemPropertyBase itemProperty in e.OldItems )
            {
              string name = itemProperty.Name;
              Column column = columns[ name ] as Column;

              if( ( column != null ) && ( column.IsAutoCreated ) )
              {
                columns.Remove( column );
              }
            }

            foreach( DataGridItemPropertyBase itemProperty in e.NewItems )
            {
              string name = itemProperty.Name;

              if( columns[ name ] == null )
              {
                Column column = ItemsSourceHelper.CreateColumnFromItemsSourceField(
                  dataGridControl, dataGridControl.DefaultCellEditors,
                  ItemsSourceHelper.CreateFieldFromDataGridItemProperty( itemProperty ),
                  autoCreateForeignKeyConfigurations );

                if( column != null )
                {
                  columns.Add( column );
                  ItemsSourceHelper.ApplySettingsRepositoryToColumn( column );
                }
              }
            }

            break;
          }

        case NotifyCollectionChangedAction.Reset:
          {
            for( int i = columns.Count - 1; i >= 0; i-- )
            {
              Column dataColumn = columns[ i ] as Column;

              if( ( dataColumn != null ) && ( dataColumn.IsAutoCreated ) )
              {
                columns.Remove( dataColumn );
              }
            }

            foreach( DataGridItemPropertyBase itemProperty in itemProperties )
            {
              string name = itemProperty.Name;

              if( columns[ name ] == null )
              {
                Column column = ItemsSourceHelper.CreateColumnFromItemsSourceField(
                  dataGridControl, dataGridControl.DefaultCellEditors,
                  ItemsSourceHelper.CreateFieldFromDataGridItemProperty( itemProperty ),
                  autoCreateForeignKeyConfigurations );

                if( column != null )
                {
                  columns.Add( column );
                  ItemsSourceHelper.ApplySettingsRepositoryToColumn( column );
                }
              }
            }

            break;
          }

        //case NotifyCollectionChangedAction.Move:
        default:
          break;

      }
    }
		/// <summary>
		/// Initializes a new instance of the ColumnCollectionEditor class 
		/// using the specified collection type
		/// </summary>
		/// <param name="type">The type of the collection for this editor to edit</param>
		public ColumnCollectionEditor(Type type) : base(type)
		{
			this.columns = null;

			this.previewColumnModel = new ColumnModel();
			this.previewColumnModel.Columns.Add(new TextColumn("Column", 116));
			
			this.previewTableModel = new TableModel();
			this.previewTableModel.Rows.Add(new Row());
			
			Cell cell = new Cell();
			cell.Editable = false;
			cell.ToolTipText = "This is a Cell ToolTip";
			
			this.previewTableModel.Rows[0].Cells.Add(cell);
			this.previewTableModel.RowHeight = 20;

			this.previewTable = new Table();
			this.previewTable.Preview = true;
			this.previewTable.Size = new Size(120, 274);
			this.previewTable.Location = new Point(246, 24);
			this.previewTable.GridLines = GridLines.Both;
			this.previewTable.TabStop = false;
			this.previewTable.EnableToolTips = true;
			this.previewTable.ColumnModel = this.previewColumnModel;
			this.previewTable.TableModel = this.previewTableModel;

			this.previewLabel = new Label();
			this.previewLabel.Text = "Preview:";
			this.previewLabel.Size = new Size(140, 16);
			this.previewLabel.Location = new Point(247, 8);
		}
Пример #30
-1
        public TableInfo(string name, ICollection<ColumnInfo> columns, IList<string> primaryKeys)
        {
            if (string.IsNullOrWhiteSpace(name))
            {
                throw new ArgumentNullException("name");
            }

            if (columns == null || columns.Count == 0)
            {
                throw new ArgumentNullException("columns");
            }

            if (primaryKeys == null || primaryKeys.Count == 0)
            {
                throw new ArgumentNullException("primaryKeys");
            }

            this.name = name;
            this.columns = new ColumnCollection(columns);
            this.primaryKeys = new List<string>(primaryKeys).AsReadOnly();
            foreach (string primaryKey in this.primaryKeys)
            {
                if (!this.columns.Contains(primaryKey))
                {
                    throw new ArgumentOutOfRangeException("primaryKeys");
                }
            }
        }
Пример #31
-1
        /// <summary>
        /// Zpracuje retezec na podminku
        /// </summary>
        /// <param name="string_condition">text podminky</param>
        /// <param name="columns">sloupce gridu, pro ktery plati podminka</param>
        public Condition(string string_condition, ColumnCollection columns)
        {
            this.left_value = null;
            this.right_value = null;
            this.compare_operator = Operators.not_equal;

            this.ParseString(string_condition, columns);
        }