Esempio n. 1
0
        /// <summary>
        /// Genera un combobox, y le agrega los valores deseados.
        /// </summary>
        /// <param name="valores"></param>
        /// <returns></returns>
        private static Ext.Net.Field GenerarCampoCombo(CustomValue[] valores)
        {
            Ext.Net.ComboBox.Config cf = new Ext.Net.ComboBox.Config();
            Ext.Net.ComboBox cb = new Ext.Net.ComboBox(cf);

            foreach (CustomValue valor in valores)
            {
                string stringValor;
                if (valor.Valor != null)
                    stringValor = valor.Valor.ToString();
                else
                    stringValor = "";

                cb.Items.Add(new Ext.Net.ListItem(valor.Nombre, stringValor));
            }

            return cb;
        }
Esempio n. 2
0
        protected void AddSearchPanel(Ext.Net.Window parent, string caption, Guid identifier, TypeEnum type)
        {
            List<SearchExpression> searchList = this.SearchConditions;

            /* строка поиска */
            Ext.Net.Toolbar searchBar = new Ext.Net.Toolbar();
            searchBar.CtCls = "searchBar";
            searchBar.Layout = "hbox";

            /* text label */
            Ext.Net.Label searchLabel = new Ext.Net.Label(caption);
            searchLabel.Margins = "4 2 2 2";
            searchLabel.Flex = 1;
            searchBar.Add(searchLabel);

            /* combo box */
            Ext.Net.ComboBox searchCombo = new Ext.Net.ComboBox();
            searchCombo.CtCls = "condition";
            searchCombo.Editable = false;
            searchCombo.Items.Add(new Ext.Net.ListItem("~"));
            if (type == TypeEnum.Integer || type == TypeEnum.Decimal)
            {
                searchCombo.Items.Add(new Ext.Net.ListItem(">"));
                searchCombo.Items.Add(new Ext.Net.ListItem("<"));
                searchCombo.Items.Add(new Ext.Net.ListItem("!~"));
            }
            searchCombo.SelectedIndex = 0;
            searchCombo.HiddenName = "";
            searchCombo.Margins = "2 5 0 5";
            searchCombo.Width = 80;
            searchCombo.SubmitValue = false;
            searchBar.Add(searchCombo);

            /* editor field */
            Ext.Net.TextField searchField = new Ext.Net.TextField();
            searchField.CtCls = "value";
            searchField.Flex = 1;
            searchField.Margins = "2 2 0 0";
            searchField.SubmitValue = false;
            if (type == TypeEnum.Integer)
            {
                searchField.Regex = @"^\d+$";
                searchField.RegexText = "Введите целое число";
            }
            if (type == TypeEnum.Decimal)
            {
                searchField.Regex = @"^\d+(,\d+)?$";
                searchField.RegexText = "Введи вещественное число с запятой";
            }
            if (type == TypeEnum.Boolean)
            {
                searchField.Regex = @"^0|1$";
                searchField.RegexText = "Введи либо 0 (да) либо 1 (нет)";
            }
            searchBar.Add(searchField);

            /* hidden value */
            Ext.Net.Hidden searchIdent = new Ext.Net.Hidden();
            searchIdent.CtCls = "identifier";
            searchIdent.Value = identifier.ToString();
            searchIdent.HideLabel = true;
            searchIdent.SubmitValue = false;
            searchBar.Add(searchIdent);

            parent.Items.Add(searchBar);

            /* Restore previous state */
            try
            {
                SearchExpression searchExpr = searchList.First(p => p.FieldID == identifier);
                searchField.Value = searchExpr.FieldValue;
                searchCombo.Value = searchExpr.FieldCond.toString();
            }
            catch {}
        }
Esempio n. 3
0
        /*private void BindGridColumns()
        {
            using (EditConfigurationProvider provider = new EditConfigurationProvider())
            {
                Aspect.Domain.Product prod = provider.GetProduct(this.ProductID);
                if (prod == null) return;
                this.Title = HeaderLiteral.Text = string.Format(HeaderLiteral.Text, prod.PublicName, prod.Version == null ? string.Empty : prod.Version.ToString());
                HeaderDateLiteral.Text = string.Format(HeaderDateLiteral.Text, DateTime.Now.ToShortDateString(), DateTime.Now.ToLongTimeString());

                //---
                SelectorProductGridField selector = new SelectorProductGridField(string.Empty, "ConfigurationID", true);
                selector.ItemStyle.Width = new Unit(15, UnitType.Pixel);
                EditConfigurationGrid.Columns.Add(selector);
                //---

                bool actionColumnAdded = false;
                List<GridColumn> list = provider.GetGridColumns();
                foreach (GridColumn item in list)
                {
                    BoundField field = null;
                    EditableGridColumn editableColumn = item as EditableGridColumn;
                    if (editableColumn == null)
                    {
                        if (item.GridColumnType == TypeEnum.Boolean)
                        {
                            field = new BooleanGridField();
                            field.DataField = item.DataItem;
                            field.HeaderText = item.Name;
                            field.ReadOnly = true;
                        }
                        else
                        {
                            if (!actionColumnAdded)
                            {
                                field = new ActionProductGridField(item.Name, item.DataItem);
                                actionColumnAdded = true;
                            }
                            else
                            {
                                field = new ProductGridField(item.Name, item.DataItem);
                            }
                            field.ItemStyle.Font.Size = new FontUnit(FontSize.Smaller);
                        }
                        //field = new ActionProductGridField(item.Name, item.DataItem);
                    }
                    else
                    {

                        if (editableColumn.View == EditableGridColumn.GridColumnView.TextBox)
                        {
                            field = new TextBoxProductGridField(editableColumn);
                        }
                        else if (editableColumn.View == EditableGridColumn.GridColumnView.DropDown)
                        {
                            field = new DropDownProductGridField(editableColumn);
                        }
                        else if (editableColumn.View == EditableGridColumn.GridColumnView.CheckBox)
                        {
                            field = new CheckBoxProductGridField(editableColumn);
                        }
                    }

                    if (field != null)
                    {
                        EditConfigurationGrid.Columns.Add(field);
                        //EditAddedConfigurationGrid.Columns.Add(field);
                    }
                }
            }
        }*/
        private void BindGridColumns2()
        {
            using (EditConfigurationProvider provider = new EditConfigurationProvider())
            {
                Aspect.Domain.Product prod = provider.GetProduct(this.ProductID);
                if (prod == null) return;

                this.Title = HeaderLiteral.Text = string.Format(HeaderLiteral.Text, prod.PublicName, prod.Version == null ? string.Empty : prod.Version.ToString());
                HeaderDateLiteral.Text = string.Format(HeaderDateLiteral.Text, DateTime.Now.ToShortDateString(), DateTime.Now.ToLongTimeString());

                // извлекаем ширины колонок для данного класса
                List<ColumnWidth> columnWidths = provider.ColumnWidths.Where(p => p.ClassificationTreeID == new Guid("11110000-0000-0000-0000-000011110001")
                    && p.UserID == this.User.ID).ToList();

                List<GridColumn> list = provider.GetGridColumns();

                // sort columns by user's order
                list = list.OrderBy(clm => columnWidths.Exists(w => w.ColumnID == clm.ID) ? columnWidths.Single(w => w.ColumnID == clm.ID).Index : Int32.MaxValue).ToList();

                foreach (GridColumn column in list)
                {
                    Ext.Net.ColumnBase extjsColumn = null;
                    EditableGridColumn editableColumn = column as EditableGridColumn;
                    if (editableColumn == null)
                    {
                        if (column.GridColumnType == TypeEnum.Boolean)
                        {
                            extjsColumn = new Ext.Net.CheckColumn();
                            extjsColumn.DataIndex = column.DataItem;
                            extjsColumn.Header = column.Name;
                        }
                        else
                        {
                            extjsColumn = new Ext.Net.Column();
                            extjsColumn.DataIndex = column.DataItem;
                            extjsColumn.Header = column.Name;
                        }
                    }
                    else
                    {

                        if (editableColumn.View == EditableGridColumn.GridColumnView.TextBox)
                        {
                            extjsColumn = new Ext.Net.Column();
                            if (editableColumn.Type == typeof(int) || editableColumn.Type == typeof(decimal))
                            {
                                Ext.Net.TextField field = new Ext.Net.TextField();
                                field.Regex = @"^\d+(,\d+)?$";
                                field.RegexText = "0";
                                extjsColumn.Editor.Add(field);
                            }
                            else
                            {
                                extjsColumn.Editor.Add(new Ext.Net.TextField());
                            }
                            extjsColumn.DataIndex = column.DataItem;
                            extjsColumn.Header = column.Name;
                            extjsColumn.Editable = true;
                        }
                        else if (editableColumn.View == EditableGridColumn.GridColumnView.DropDown)
                        {
                            extjsColumn = new Ext.Net.Column();
                            extjsColumn.DataIndex = column.DataItem;
                            extjsColumn.Header = column.Name;
                            extjsColumn.Editable = true;

                            StringBuilder renderFunction = new StringBuilder();
                            renderFunction.AppendLine("function(value){");
                            Ext.Net.ComboBox field = new Ext.Net.ComboBox();
                            field.Editable = false;
                            foreach (Pair<Guid, string> itemDropList in (editableColumn.DataSource.DataSource as List<Pair<Guid, string>>))
                            {
                                field.Items.Add(new Ext.Net.ListItem(itemDropList.Second, itemDropList.First.ToString()));
                                renderFunction.AppendFormat("if (value=='{0}') return '{1}';\n", itemDropList.First.ToString(), itemDropList.Second);
                            }
                            renderFunction.AppendLine("return 'error'; }");

                            extjsColumn.Editor.Add(field);
                            extjsColumn.Renderer.Handler = renderFunction.ToString();
                        }
                        else if (editableColumn.View == EditableGridColumn.GridColumnView.CheckBox)
                        {
                            extjsColumn = new Ext.Net.CheckColumn();
                            extjsColumn.DataIndex = column.DataItem;
                            extjsColumn.Header = column.Name;
                            extjsColumn.Editable = true;
                            extjsColumn.Editor.Add(new Ext.Net.Checkbox());
                        }
                    }

                    if (extjsColumn != null)
                    {
                        // setting visibility column
                        extjsColumn.Hidden = columnWidths.Exists(w => w.ColumnID == column.ID) ? columnWidths.Single(w => w.ColumnID == column.ID).Hidden : false;

                        extjsColumn.ColumnID = column.ID.ToString();
                        foreach (int width in columnWidths.Where(p => p.ColumnID == column.ID).Select(p => p.Width))
                        {
                            extjsColumn.Width = width;
                        }
                        Store1.AddField( new Ext.Net.RecordField(extjsColumn.DataIndex));
                        GridPanel.ColumnModel.Columns.Add(extjsColumn);
                    }
                }
                // дополнительные поля
                Store1.AddField(new Ext.Net.RecordField("ID"));
                Store1.AddField(new Ext.Net.RecordField("CID"));
                Store1.AddField(new Ext.Net.RecordField("ConfID"));
            }
        }