private void cbxValTable_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            cbxValField.Items.Clear();
            int n = cbxValTable.SelectedIndex;

            if (n >= 0)
            {
                EPField    fld;
                TableAlias tbl = cbxValTable.Items[n] as TableAlias;
                for (int i = 0; i < tbl.FieldCount; i++)
                {
                    fld = tbl.GetField(i);
                    if (!EPField.IsBinary(fld.OleDbType))
                    {
                        cbxValField.Items.Add(fld);
                    }
                }
                if (cbxValField.Items.Count > 0)
                {
                    cbxValField.SelectedIndex = 0;
                }
            }
        }
        private void cbxField_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            lstOP.Items.Clear();
            int n = cbxField.SelectedIndex;

            if (n >= 0)
            {
                int     i;
                EPField fld = cbxField.Items[n] as EPField;
                if (EPField.IsString(fld.OleDbType) || EPField.IsBinary(fld.OleDbType))
                {
                    for (i = 0; i < opList.Count; i++)
                    {
                        lstOP.Items.Add(opList[i]);
                    }
                }
                else if (EPField.IsBoolean(fld.OleDbType))
                {
                    lstOP.Items.Add(opList[0]);
                }
                else
                {
                    for (i = 0; i < opList.Count; i++)
                    {
                        if (!opList[i].bStringOnly)
                        {
                            lstOP.Items.Add(opList[i]);
                        }
                    }
                }
                if (lstOP.Items.Count > 0)
                {
                    lstOP.SelectedIndex = 0;
                }
            }
        }
Exemplo n.º 3
0
 private void listView1_SelectedIndexChanged(object sender, System.EventArgs e)
 {
     txtLookup.Enabled = false;
     if (listView1.SelectedItems.Count > 0)
     {
         item = listView1.SelectedItems[0];
         if (item != null)
         {
             if (fields[item.Index].OleDbType == System.Data.OleDb.OleDbType.Date)
             {
                 cbDataType.SelectedIndex = 0;
                 lblDataType.Visible      = true;
                 cbDataType.Visible       = true;
             }
             else if (fields[item.Index].OleDbType == System.Data.OleDb.OleDbType.DBDate)
             {
                 cbDataType.SelectedIndex = 1;
                 lblDataType.Visible      = true;
                 cbDataType.Visible       = true;
             }
             else if (fields[item.Index].OleDbType == System.Data.OleDb.OleDbType.DBTimeStamp)
             {
                 cbDataType.SelectedIndex = 2;
                 lblDataType.Visible      = true;
                 cbDataType.Visible       = true;
             }
             else if (fields[item.Index].OleDbType == System.Data.OleDb.OleDbType.DBTime)
             {
                 cbDataType.SelectedIndex = 3;
                 lblDataType.Visible      = true;
                 cbDataType.Visible       = true;
             }
             else
             {
                 lblDataType.Visible = false;
                 cbDataType.Visible  = false;
                 if (fields[item.Index].OleDbType != System.Data.OleDb.OleDbType.Boolean &&
                     !fields[item.Index].IsFile &&
                     !fields[item.Index].IsIdentity &&
                     !fields[item.Index].ReadOnly)
                 {
                     btLookup.Enabled = true;
                     if (fields[item.Index].editor != null)
                     {
                         txtLookup.Text = fields[item.Index].editor.ToString();
                     }
                     else
                     {
                         txtLookup.Text = "";
                     }
                     txtLookup.Enabled = true;
                 }
             }
             cbFile.SelectedIndex      = (fields[item.Index].IsFile ? 0 : 1);
             cbVisible.SelectedIndex   = (fields[item.Index].Visible ? 0 : 1);
             cbxReadOnly.SelectedIndex = (fields[item.Index].ReadOnly ? 0 : 1);
             txtWidth.Text             = fields[item.Index].ColumnWidth.ToString();
             txtFormat.Text            = fields[item.Index].Format;
             chkIndexed.Checked        = fields[item.Index].Indexed;
             btML.Enabled = (EPField.IsBinary(fields[item.Index].OleDbType) || EPField.IsString(fields[item.Index].OleDbType));
             for (int i = 0; i < cbxAlignment.Items.Count; i++)
             {
                 if ((System.Windows.Forms.HorizontalAlignment)cbxAlignment.Items[i] == fields[item.Index].TxtAlignment)
                 {
                     cbxAlignment.SelectedIndex = i;
                     break;
                 }
             }
             for (int i = 0; i < cbxHdrAlign.Items.Count; i++)
             {
                 if ((System.Windows.Forms.HorizontalAlignment)cbxHdrAlign.Items[i] == fields[item.Index].HeaderAlignment)
                 {
                     cbxHdrAlign.SelectedIndex = i;
                     break;
                 }
             }
         }
     }
 }
        public virtual void ApplyStyle()
        {
            //btSave.Visible = (!bReadOnly);
            if (_query == null)
            {
                return;
            }
            if (_query.Fields.Count == 0)
            {
                return;
            }
            int i;
            int n = _query.Fields.Count;

            if (cbx != null)
            {
                for (i = 0; i < cbx.Length; i++)
                {
                    try
                    {
                        this.Controls.Remove(cbx[i]);
                    }
                    catch
                    {
                    }
                    cbx[i] = null;
                }
            }
            if (bts != null)
            {
                for (i = 0; i < bts.Length; i++)
                {
                    try
                    {
                        this.Controls.Remove(bts[i]);
                    }
                    catch
                    {
                    }
                    bts[i] = null;
                }
            }
            cbx = new System.Windows.Forms.ComboBox[n];
            bts = new System.Windows.Forms.Button[n];
            DataGridColumnStyle TextCol;

            myGridTableStyle             = new DataGridTableStyle();
            myGridTableStyle.MappingName = DataTableName;
            //			myGridTableStyle.AlternatingBackColor = System.Drawing.Color.LightPink;
            //			int j=0;

            string cap;

            for (i = 0; i < _query.Fields.Count; i++)
            {
                if (ReadOnly || !EPField.IsBinary(_query.Fields[i].OleDbType))
                {
                    if (_query.Fields[i].OleDbType == System.Data.OleDb.OleDbType.Boolean)
                    {
                        TextCol = new DataGridBoolColumn();
                    }
                    else
                    {
                        TextCol = new TextColumnStyle(_query.Fields[i].HeaderAlignment);// new DataGridTextBoxColumn();
                        //						((DataGridTextBoxColumn)TextCol).TextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
                        ((DataGridTextBoxColumn)TextCol).TextBox.DoubleClick += new EventHandler(TextBox_DoubleClick);
                        ((DataGridTextBoxColumn)TextCol).TextBox.Click       += new EventHandler(TextBox_Click);
                        ((DataGridTextBoxColumn)TextCol).TextBox.GotFocus    += new EventHandler(TextBox_GotFocus);
                        ((TextColumnStyle)TextCol).Format = _query.Fields[i].Format;
                        if (NullText != null)
                        {
                            ((TextColumnStyle)TextCol).NullText = NullText;
                        }
                    }

                    TextCol.MappingName = _query.Fields[i].Name;
                    TextCol.Alignment   = _query.Fields[i].TxtAlignment;
                    cap = _query.Fields[i].FieldCaption;
                    if (string.IsNullOrEmpty(cap))
                    {
                        cap = _query.Fields[i].Name;
                    }
                    TextCol.HeaderText = cap;
                    if (ReadOnly)
                    {
                        TextCol.ReadOnly = true;
                    }
                    else
                    {
                        if (_query.Fields[i].IsIdentity || _query.Fields[i].ReadOnly ||
                            EPField.IsBinary(_query.Fields[i].OleDbType) ||
                            _query.Fields[i].OleDbType == System.Data.OleDb.OleDbType.DBTimeStamp)
                        {
                            TextCol.ReadOnly = true;
                        }
                    }
                    if (_query.Fields[i].Visible)
                    {
                        TextCol.Width = _query.Fields[i].ColumnWidth;
                    }
                    else
                    {
                        TextCol.Width = 0;
                    }

                    myGridTableStyle.GridColumnStyles.Add(TextCol);
                    if (_query.Fields[i].editor != null)
                    {
                        DataEditorButton bn = _query.Fields[i].editor as DataEditorButton;
                        if (bn != null)
                        {
                            bts[i] = bn.MakeButton(this.FindForm());
                            if (bts[i] != null)
                            {
                                bts[i].Parent  = this;
                                bts[i].Visible = false;
                                _query.Fields[i].editor.OnPickValue += new fnOnPickValue(onPickValueByButton);
                            }
                        }
                        else
                        {
                            DataEditorLookupYesNo LK = _query.Fields[i].editor as DataEditorLookupYesNo;
                            if (LK != null)
                            {
                                cbx[i] = LK.MakeComboBox();
                                if (cbx[i] != null)
                                {
                                    cbx[i].Parent  = this;
                                    cbx[i].Visible = false;
                                    cbx[i].SelectedIndexChanged += new System.EventHandler(onLookupSelected);
                                }
                            }
                        }
                    }
                    //					j++;
                }
            }
            //this.ReadOnly = bReadOnly;
            this.TableStyles.Clear();
            this.TableStyles.Add(myGridTableStyle);
        }
Exemplo n.º 5
0
        public void LoadData(QueryParser q)
        {
            qParser = q;
            lstFields.Items.Clear();
            EPField   fld;
            int       i;
            FieldList fl = q.query.Fields;

            for (i = 0; i < fl.Count; i++)
            {
                fld = fl[i];
                if (!EPField.IsBinary(fld.OleDbType))
                {
                    lstFields.Items.Add(new OrderByField(fld, qParser.Sep1, qParser.Sep2));
                    //lstFields.Items.Add(fld);
                }
            }
            clsOrder.Items.Clear();
            int    nType;
            string s, s2;
            string sOrder = q.query.OrderBy;

            if (sOrder == null)
            {
                sOrder = "";
            }
            sOrder = sOrder.Trim();
            if (sOrder.StartsWith("ORDER BY ", StringComparison.OrdinalIgnoreCase))
            {
                sOrder = sOrder.Substring(9);
                sOrder = sOrder.Trim();
            }
            i = FieldsParser.FindStringIndex(sOrder, ",", 0, q.Sep1, q.Sep2);
            while (sOrder.Length > 0)
            {
                if (i < 0)
                {
                    s      = sOrder;
                    sOrder = "";
                }
                else
                {
                    s      = sOrder.Substring(0, i);
                    sOrder = sOrder.Substring(i + 1);
                    sOrder = sOrder.Trim();
                }
                s     = s.Trim();
                nType = -1;
                if (s.Length > 4)
                {
                    s2 = s.Substring(s.Length - 4, 4);
                    if (string.Compare(s2, " ASC", StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        s     = s.Substring(0, s.Length - 4);
                        s     = s.Trim();
                        nType = 0;
                    }
                }
                if (nType < 0)
                {
                    if (s.Length > 5)
                    {
                        s2 = s.Substring(s.Length - 5, 5);
                        if (string.Compare(s2, " DESC", StringComparison.OrdinalIgnoreCase) == 0)
                        {
                            s     = s.Substring(0, s.Length - 5);
                            s     = s.Trim();
                            nType = 1;
                        }
                    }
                }
                clsOrder.Items.Add(s, (nType == 1));
                i = FieldsParser.FindStringIndex(sOrder, ",", 0, q.Sep1, q.Sep2);
            }
        }