コード例 #1
0
        private void SetCollumns()
        {
            if (VisbleColumns.Count == 0)
            {
                ViewResult.FormatGrid(Query.Fields, ColumnsParameters);
            }
            else
            {
                var columns = Query.Fields.Where(p => VisbleColumns.Any(v => v == p.Name));
                var col     = new TableAdapterFieldCollection();
                col.AddRange(columns);
                ViewResult.FormatGrid(col);
            }

            ViewResult.FocusedColumn = SearchColumns.IsEmpty()
                ? ViewResult.Columns[0]
                : ViewResult.Columns[SearchColumns.First().Name];

            ViewResult.SetColors();
            ViewResult.FormatConditions.Clear();

            foreach (var item in Conditions)
            {
                var col = ViewResult.Columns[item.ColumnName];

                if (col == null)
                {
                    continue;
                }

                var scon = new DevExpress.XtraGrid.StyleFormatCondition(
                    item.FormatConditionEnum,
                    col,
                    null,
                    item.val1,
                    item.val2,
                    item.applyToRow);

                scon.Appearance.BackColor = item.BackColor;
                scon.Appearance.ForeColor = item.ForeColor;
                ViewResult.FormatConditions.Add(scon);
            }
        }
コード例 #2
0
        private void FillResult()
        {
            try
            {
                Cursor.Current = Cursors.WaitCursor;

                var query = new TableQuery(Query);

                if (!String.IsNullOrEmpty(SearchBy))
                {
                    var where = new WhereCollection();
                    foreach (var item in SearchColumns)
                    {
                        QueryParam param;

                        if (item.DbTypeIsNumeric())
                        {
                            int intConvert;

                            if (!int.TryParse(SearchBy, out intConvert))
                            {
                                continue;
                            }

                            param = new QueryParam(item, intConvert);
                        }
                        else
                        {
                            param = new QueryParam(item, eCondition.ecLike, SearchBy);
                        }

                        param.Relationship = eRelationship.erOr;
                        where.Add(param);

                        query.OrderBy.Add(new OrderBy(param));
                    }
                    query.Wheres.Add(where);
                }

                var command = new SqlServerScriptWizard(query).GetSelectStatment();
                grdResult.DataSource = Connection.Instance.SqlServerQuery(command.Item1, command.Item2);
                ViewResult.BestFitColumns();

                ViewResult.ClearSorting();

                if (!SearchColumns.IsEmpty())
                {
                    ViewResult.FocusedColumn           = ViewResult.Columns[SearchColumns.First().Name];
                    ViewResult.FocusedColumn.SortOrder = DevExpress.Data.ColumnSortOrder.Ascending;

                    if (Record != null)
                    {
                        var fieldValue = Record[ViewResult.FocusedColumn.FieldName].ToString();
                        ViewResult.StartIncrementalSearch(fieldValue);
                    }
                }
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }