Exemple #1
0
        private String CreateColumns(InfoDataSet ids, XmlNode xn, List<Panel> panels)
        {
            int columnWidth = Convert.ToInt16(xn.Attributes["ColumnWidth"].Value);
            int ColumnsCount = Count;
            if (120 + ColumnsCount * 30 > this.Height) this.Height += 30;

            int standard = 40;
            CheckBox cbActive = new CheckBox();
            cbActive.Name = ColumnsCount + "AnyQueryActiveCheckBox";
            if (xn.Attributes["IsActive"].Value == "1")
                cbActive.Checked = true;
            cbActive.Width = 15;
            cbActive.Location = new Point(standard, 13 + ColumnsCount * 30);
            cbActive.CheckedChanged += new EventHandler(cbActive_CheckedChanged);
            this.panel2.Controls.Add(cbActive);

            //standard += 30;
            //Label labelCondition = new Label();
            //labelCondition.Name = ColumnsCount + "AnyQueryConditionLabel";
            //labelCondition.Width = 50;
            //labelCondition.Text = xn.Attributes["Condition"].Value;
            //labelCondition.Location = new Point(standard, 17 + ColumnsCount * 30);
            //labelCondition.Click += new EventHandler(labelCondition_Click);
            //this.panel2.Controls.Add(labelCondition);

            standard += 30;
            ComboBox cbColumn = new ComboBox();
            cbColumn.Name = ColumnsCount + "AnyQueryColumnComboBox";
            this.panel2.Controls.Add(cbColumn);
            DataView dvColumn = CreateDataViewColumn(ids);
            cbColumn.DataSource = dvColumn;
            cbColumn.DisplayMember = "CAPTION";
            cbColumn.ValueMember = "FIELDNAME";
            cbColumn.DropDownStyle = ComboBoxStyle.DropDownList;
            cbColumn.Width = columnWidth;
            cbColumn.Location = new Point(standard, 15 + ColumnsCount * 30);
            cbColumn.Text = xn.Attributes["Caption"].Value;
            cbColumn.SelectedIndexChanged += new EventHandler(cbColumn_SelectedIndexChanged);

            standard += cbColumn.Width + 5;
            ComboBox cbOperator = new ComboBox();
            Type cbType = GetDataType(CaptionToColumn(xn.Attributes["Caption"].Value, innerAnyQuery.BindingSource));
            List<String> op = new List<string>();
            op.AddRange(new String[] { "=", "!=", ">", "<", ">=", "<=", "%**", "**%", "%%", "!%%", "<->", "!<->", "IN", "NOT IN" });
            if (!innerAnyQuery.DisplayAllOperator)
            {
                if (cbType == typeof(Char) || cbType == typeof(String))
                {
                    op.Clear();
                    //op.AddRange(new String[] { "=", "!=", "%**", "**%", "%%", "!%%", "IN", "NOT IN" });
                    op.AddRange(new String[] { "=", "!=", "%**", "**%", "%%", "!%%" });
                }
                else if (cbType != null && (cbType == typeof(int) || cbType == typeof(float) || cbType == typeof(double) || cbType == typeof(DateTime) || cbType.FullName == "System.Decimal" || cbType == typeof(Int16) || cbType == typeof(Int64)))
                {
                    op.Clear();
                    //op.AddRange(new String[] { "=", "!=", "<", ">", "<=", ">=", "<->", "!<->", "IN", "NOT IN" });
                    op.AddRange(new String[] { "=", "!=", "<", ">", "<=", ">=", "<->", "!<->" });
                }
            }
            cbOperator.Items.AddRange(op.ToArray());
            cbOperator.DropDownStyle = ComboBoxStyle.DropDownList;
            cbOperator.Name = ColumnsCount + "AnyQueryOperatorComboBox";
            cbOperator.Width = 65;
            cbOperator.Location = new Point(standard, 15 + ColumnsCount * 30);
            SetOperatorHelp(cbOperator);
            cbOperator.SelectedIndexChanged += new EventHandler(cbOperator_SelectedIndexChanged);
            this.panel2.Controls.Add(cbOperator);

            standard += cbOperator.Width + 5;
            switch (xn.Attributes["ValueType"].Value)
            {
                case "AnyQueryTextBoxColumn":
                    TextBox tbValue = new TextBox();
                    tbValue.Name = ColumnsCount + "AnyQueryValue1TextBox" + xn.Attributes["ValueEnabled"].Value;
                    tbValue.Text = xn.Attributes["Value1"].Value;
                    tbValue.Width = Convert.ToInt16(xn.Attributes["Width"].Value);
                    tbValue.Location = new Point(standard, 15 + ColumnsCount * 30);
                    tbValue.Enabled = Convert.ToBoolean(xn.Attributes["Enabled"].Value);
                    tbValue.Enter += new EventHandler(tbValue_Enter);
                    this.panel2.Controls.Add(tbValue);
                    break;
                case "AnyQueryComboBoxColumn":
                    cbOperator.Items.Clear();
                    op.Clear();
                    op.AddRange(new String[] { "=", "!=" });
                    cbOperator.Items.AddRange(op.ToArray());

                    InfoComboBox icbValue = new InfoComboBox();
                    if (xn.Attributes["SelectAlias"].Value == String.Empty || xn.Attributes["SelectCommand"].Value == String.Empty)
                    {
                        if (xn.Attributes["RemoteName"].Value == String.Empty)
                        {
                            String[] temp = xn.Attributes["Items"].Value.Split(';');
                            foreach (String str in temp)
                            {
                                if (str != String.Empty)
                                    icbValue.Items.Add(str);
                            }
                        }
                        else
                        {
                            InfoDataSet idsComboBox = new InfoDataSet();
                            idsComboBox.RemoteName = xn.Attributes["RemoteName"].Value;
                            idsComboBox.Active = true;
                            InfoBindingSource ibsComboBox = new InfoBindingSource();
                            ibsComboBox.DataSource = idsComboBox;
                            ibsComboBox.DataMember = idsComboBox.RealDataSet.Tables[0].TableName;

                            icbValue.DataSource = ibsComboBox;
                            icbValue.DisplayMember = xn.Attributes["DisplayMember"].Value;
                            icbValue.ValueMember = xn.Attributes["ValueMember"].Value;
                            icbValue.EndInit();
                        }
                    }
                    else
                    {
                        icbValue.SelectAlias = xn.Attributes["SelectAlias"].Value;
                        icbValue.SelectCommand = xn.Attributes["SelectCommand"].Value;
                        icbValue.DisplayMember = xn.Attributes["DisplayMember"].Value;
                        icbValue.ValueMember = xn.Attributes["ValueMember"].Value;
                        icbValue.EndInit();
                    }

                    icbValue.DisplayMemberOnly = Convert.ToBoolean(xn.Attributes["DisplayMemberOnly"].Value);
                    icbValue.Name = ColumnsCount + "AnyQueryValue1InfoComboBox" + xn.Attributes["ValueEnabled"].Value;
                    icbValue.Width = Convert.ToInt16(xn.Attributes["Width"].Value);
                    icbValue.Location = new Point(standard, 15 + ColumnsCount * 30);
                    icbValue.Enabled = Convert.ToBoolean(xn.Attributes["Enabled"].Value);
                    icbValue.Enter += new EventHandler(tbValue_Enter);
                    this.panel2.Controls.Add(icbValue);
                    icbValue.SelectedValue = xn.Attributes["Value1"].Value;
                    icbValue.Text = xn.Attributes["ValueReal"].Value;
                    break;
                case "AnyQueryCheckBoxColumn":
                    cbOperator.Items.Clear();
                    op.Clear();
                    op.AddRange(new String[] { "=", "!=" });
                    cbOperator.Items.AddRange(op.ToArray());

                    CheckBox cbValue = new CheckBox();
                    cbValue.Name = ColumnsCount + "AnyQueryValue1CheckBox" + xn.Attributes["ValueEnabled"].Value;
                    if (xn.Attributes["Value1"].Value == "1")
                        cbValue.Checked = true;
                    cbValue.Width = Convert.ToInt16(xn.Attributes["Width"].Value);
                    cbValue.Location = new Point(standard, 15 + ColumnsCount * 30);
                    cbValue.Enabled = Convert.ToBoolean(xn.Attributes["Enabled"].Value);
                    cbValue.Enter += new EventHandler(tbValue_Enter);
                    this.panel2.Controls.Add(cbValue);
                    break;
                case "AnyQueryRefValColumn":
                    cbOperator.Items.Clear();
                    op.Clear();
                    op.AddRange(new String[] { "=", "!=", "IN", "NOT IN" });
                    cbOperator.Items.AddRange(op.ToArray());

                    if (xn.Attributes["Operator"].Value == "IN" || xn.Attributes["Operator"].Value == "NOT IN")
                    {
                        InfoDataSet idsRefButton = new InfoDataSet();
                        idsRefButton.RemoteName = "GLModule.cmdRefValUse";
                        idsRefButton.Execute(xn.Attributes["SelectCommand"].Value, CliUtils.fLoginDB, true);

                        InfoBindingSource ibsRefButton = new InfoBindingSource();
                        ibsRefButton.DataSource = idsRefButton;
                        ibsRefButton.DataMember = "cmdRefValUse";
                        InfoTranslate it = new InfoTranslate();
                        it.BindingSource = ibsRefButton;
                        TranslateRefReturnFields trrf = new TranslateRefReturnFields();
                        trrf.ColumnName = xn.Attributes["ValueMember"].Value;
                        trrf.DisplayColumnName = xn.Attributes["DisplayMember"].Value;
                        it.RefReturnFields.Add(trrf);

                        InfoRefbuttonBox aInfoRefbuttonBox = new InfoRefbuttonBox();
                        aInfoRefbuttonBox.Name = ColumnsCount + "AnyQueryValue1RefTextBox" + xn.Attributes["ValueEnabled"].Value;
                        aInfoRefbuttonBox.Text = xn.Attributes["Value1"].Value;
                        aInfoRefbuttonBox.RealValue = xn.Attributes["ValueReal"].Value;
                        aInfoRefbuttonBox.Location = new Point(standard, 15 + ColumnsCount * 30);
                        aInfoRefbuttonBox.Width = Convert.ToInt16(xn.Attributes["Width"].Value); ;
                        aInfoRefbuttonBox.Enabled = Convert.ToBoolean(xn.Attributes["Enabled"].Value);
                        aInfoRefbuttonBox.Enter += new EventHandler(tbValue_Enter);
                        this.panel2.Controls.Add(aInfoRefbuttonBox);

                        //TextBox tbRefButton = new TextBox();
                        //tbRefButton.Name = ColumnsCount + "AnyQueryValue1RefTextBox" + xn.Attributes["ValueEnabled"].Value;
                        //tbRefButton.Text = xn.Attributes["Value1"].Value;
                        //tbRefButton.AccessibleName = xn.Attributes["ValueReal"].Value;
                        //tbRefButton.Width = Convert.ToInt16(xn.Attributes["Width"].Value);
                        //tbRefButton.Location = new Point(standard, 15 + ColumnsCount * 30);
                        //tbRefButton.Enabled = Convert.ToBoolean(xn.Attributes["Enabled"].Value);
                        //tbRefButton.Enter += new EventHandler(tbValue_Enter);
                        //this.panel2.Controls.Add(tbRefButton);

                        InfoRefButton ifb = new InfoRefButton();
                        ifb.autoPanel = true;
                        ifb.infoTranslate = it;
                        RefButtonMatch rbm = new RefButtonMatch();
                        rbm.matchColumnName = aInfoRefbuttonBox.Name;
                        ifb.refButtonMatchs.Add(rbm);
                        ifb.Name = ColumnsCount + "AnyQueryValue1InfoRefButton" + xn.Attributes["ValueEnabled"].Value;
                        ifb.Text = "...";
                        ifb.Width = 20;
                        ifb.Location = new Point(aInfoRefbuttonBox.Location.X + aInfoRefbuttonBox.Width + 2, 15 + ColumnsCount * 30);
                        //ifb.Enabled = Convert.ToBoolean(xn.Attributes["Enabled"].Value);
                        this.panel2.Controls.Add(ifb);
                    }
                    else
                    {
                        cbOperator.Items.Remove("IN");
                        cbOperator.Items.Remove("NOT IN");

                        InfoRefvalBox irbValue = new InfoRefvalBox();
                        InfoRefVal aInfoRefVal = new InfoRefVal();
                        if (xn.Attributes["SelectAlias"].Value != String.Empty && xn.Attributes["SelectCommand"].Value != String.Empty)
                        {
                            aInfoRefVal.SelectAlias = xn.Attributes["SelectAlias"].Value;
                            aInfoRefVal.SelectCommand = xn.Attributes["SelectCommand"].Value;
                        }
                        else
                        {
                            InfoDataSet idsRefVal = new InfoDataSet();
                            idsRefVal.RemoteName = xn.Attributes["RemoteName"].Value;
                            idsRefVal.Active = true;
                            InfoBindingSource ibsRefVal = new InfoBindingSource();
                            ibsRefVal.DataSource = idsRefVal;
                            ibsRefVal.DataMember = idsRefVal.RealDataSet.Tables[0].TableName;

                            aInfoRefVal.DataSource = ibsRefVal;
                        }
                        aInfoRefVal.DisplayMember = xn.Attributes["DisplayMember"].Value;
                        aInfoRefVal.ValueMember = xn.Attributes["ValueMember"].Value;
                        aInfoRefVal.EndInit();

                        irbValue.Name = ColumnsCount + "AnyQueryValue1InfoRefvalBox" + xn.Attributes["ValueEnabled"].Value;
                        irbValue.RefVal = aInfoRefVal;
                        irbValue.TextBoxText = xn.Attributes["Value1"].Value;
                        irbValue.Width = Convert.ToInt16(xn.Attributes["Width"].Value);
                        irbValue.Location = new Point(standard, 15 + ColumnsCount * 30);
                        irbValue.TextBoxEnabled = Convert.ToBoolean(xn.Attributes["Enabled"].Value);
                        irbValue.TextBoxSelectedValue = xn.Attributes["ValueReal"].Value;
                        irbValue.Enter += new EventHandler(tbValue_Enter);
                        this.panel2.Controls.Add(irbValue);
                    }
                    break;
                case "AnyQueryCalendarColumn":
                    InfoDateTimePicker idtpValue = new InfoDateTimePicker();
                    idtpValue.BeginInit();
                    idtpValue.Name = ColumnsCount + "AnyQueryValue1InfoDateTimePicker" + xn.Attributes["ValueEnabled"].Value;
                    idtpValue.Text = xn.Attributes["Value1"].Value;
                    idtpValue.Width = Convert.ToInt16(xn.Attributes["Width"].Value);
                    idtpValue.Location = new Point(standard, 15 + ColumnsCount * 30);
                    idtpValue.Enabled = Convert.ToBoolean(xn.Attributes["Enabled"].Value);
                    idtpValue.Format = DateTimePickerFormat.Long;
                    idtpValue.EndInit();
                    idtpValue.Enter += new EventHandler(tbValue_Enter);
                    this.panel2.Controls.Add(idtpValue);
                    break;
                case "AnyQueryRefButtonColumn":
                    cbOperator.Items.Clear();
                    op.Clear();
                    op.AddRange(new String[] { "IN", "NOT IN" });
                    cbOperator.Items.AddRange(op.ToArray());

                    InfoDataSet idsRefButton2 = new InfoDataSet();
                    if (xn.Attributes["RemoteName"].Value == "GLModule.cmdRefValUse")
                    {
                        idsRefButton2.RemoteName = "GLModule.cmdRefValUse";
                        idsRefButton2.Execute(xn.Attributes["SelectCommand"].Value, CliUtils.fLoginDB, true);
                    }
                    else
                    {
                        idsRefButton2.RemoteName = xn.Attributes["RemoteName"].Value;
                        idsRefButton2.Active = true;
                    }

                    InfoBindingSource ibsRefButton2 = new InfoBindingSource();
                    ibsRefButton2.DataSource = idsRefButton2;
                    if (xn.Attributes["RemoteName"].Value != null)
                        ibsRefButton2.DataMember = idsRefButton2.RealDataSet.Tables[0].TableName;
                    else
                        ibsRefButton2.DataMember = "cmdRefValUse";

                    InfoTranslate it2 = new InfoTranslate();
                    it2.BindingSource = ibsRefButton2;
                    TranslateRefReturnFields trrf2 = new TranslateRefReturnFields();
                    trrf2.ColumnName = xn.Attributes["ValueMember"].Value;
                    trrf2.DisplayColumnName = xn.Attributes["DisplayMember"].Value;
                    it2.RefReturnFields.Add(trrf2);

                    InfoRefbuttonBox aInfoRefbuttonBox2 = new InfoRefbuttonBox();
                    aInfoRefbuttonBox2.Name = ColumnsCount + "AnyQueryValue1RefTextBox" + xn.Attributes["ValueEnabled"].Value;
                    aInfoRefbuttonBox2.Text = xn.Attributes["Value1"].Value;
                    aInfoRefbuttonBox2.RealValue = xn.Attributes["ValueReal"].Value;
                    aInfoRefbuttonBox2.Location = new Point(standard, 15 + ColumnsCount * 30);
                    aInfoRefbuttonBox2.Width = Convert.ToInt16(xn.Attributes["Width"].Value); ;
                    aInfoRefbuttonBox2.Enabled = Convert.ToBoolean(xn.Attributes["Enabled"].Value);
                    aInfoRefbuttonBox2.Enter += new EventHandler(tbValue_Enter);
                    this.panel2.Controls.Add(aInfoRefbuttonBox2);

                    //TextBox tbRefButton2 = new TextBox();
                    //tbRefButton2.Name = ColumnsCount + "AnyQueryValue1RefTextBox" + xn.Attributes["ValueEnabled"].Value;
                    //tbRefButton2.Text = xn.Attributes["Value1"].Value;
                    //tbRefButton2.AccessibleName = xn.Attributes["ValueReal"].Value;
                    //tbRefButton2.Width = Convert.ToInt16(xn.Attributes["Width"].Value);
                    //tbRefButton2.Location = new Point(standard, 15 + ColumnsCount * 30);
                    //tbRefButton2.Enabled = Convert.ToBoolean(xn.Attributes["Enabled"].Value);
                    //tbRefButton2.Enter += new EventHandler(tbValue_Enter);
                    //this.panel2.Controls.Add(tbRefButton2);

                    InfoRefButton ifb2 = new InfoRefButton();
                    ifb2.autoPanel = Convert.ToBoolean(xn.Attributes["AutoPanel"].Value);
                    if (!ifb2.autoPanel)
                    {
                        Control[] innerPanel = (this.innerAnyQuery.OwnerComp as InfoForm).Controls.Find(xn.Attributes["Panel"].Value, true);
                        if (innerPanel.Length > 0)
                        {
                            ifb2.panel = innerPanel[0] as Panel;
                        }

                        if (ifb2.panel == null)
                        {
                            for (int i = 0; i < panels.Count; i++)
                            {
                                if (panels[i] == null) continue;
                                ifb2.panel = panels[i];
                            }

                            if (ifb2.panel == null)
                            {
                                MessageBox.Show("Can not find the Panel '" + xn.Attributes["Panel"].Value + "' in your Form.");
                                return "AND";
                            }
                        }
                    }
                    ifb2.infoTranslate = it2;
                    RefButtonMatch rbm2 = new RefButtonMatch();
                    rbm2.matchColumnName = aInfoRefbuttonBox2.Name;
                    ifb2.refButtonMatchs.Add(rbm2);
                    ifb2.Name = ColumnsCount + "AnyQueryValue1InfoRefButton" + xn.Attributes["ValueEnabled"].Value;
                    ifb2.Text = "...";
                    ifb2.Width = 20;
                    ifb2.Location = new Point(aInfoRefbuttonBox2.Location.X + aInfoRefbuttonBox2.Width + 2, 15 + ColumnsCount * 30);
                    //ifb2.Enabled = Convert.ToBoolean(xn.Attributes["Enabled"].Value);
                    this.panel2.Controls.Add(ifb2);
                    break;
            }
            cbOperator.SelectedIndexChanged -= new EventHandler(cbOperator_SelectedIndexChanged);
            cbOperator.Text = xn.Attributes["Operator"].Value;
            cbOperator.SelectedIndexChanged += new EventHandler(cbOperator_SelectedIndexChanged);

            if (xn.Attributes["Operator"].Value == "<->" || xn.Attributes["Operator"].Value == "!<->")
            {
                standard += Convert.ToInt16(xn.Attributes["Width"].Value) + 5;

                Label aLabel = new Label();
                aLabel.Name = ColumnsCount + "AnyQueryValue1to2Label";
                aLabel.Text = "~";
                aLabel.Width = 10;
                aLabel.Location = new Point(standard, 15 + ColumnsCount * 30);
                this.panel2.Controls.Add(aLabel);

                standard += aLabel.Width + 5;
                switch (xn.Attributes["ValueType"].Value)
                {
                    case "AnyQueryTextBoxColumn":
                        TextBox tbValue = new TextBox();
                        tbValue.Name = ColumnsCount + "AnyQueryValue2TextBox2" + xn.Attributes["ValueEnabled"].Value;
                        tbValue.Text = xn.Attributes["Value2"].Value;
                        tbValue.Width = Convert.ToInt16(xn.Attributes["Width"].Value);
                        tbValue.Location = new Point(standard, 15 + ColumnsCount * 30);
                        tbValue.Enabled = Convert.ToBoolean(xn.Attributes["Enabled"].Value);
                        tbValue.Enter += new EventHandler(tbValue_Enter);
                        this.panel2.Controls.Add(tbValue);
                        break;
                    case "AnyQueryComboBoxColumn":
                        InfoComboBox icbValue = new InfoComboBox();
                        icbValue.DisplayMemberOnly = true;
                        if (xn.Attributes["SelectAlias"].Value == String.Empty || xn.Attributes["SelectCommand"].Value == String.Empty)
                        {

                            if (xn.Attributes["DataSource"].Value == String.Empty)
                            {
                                String[] temp = xn.Attributes["Items"].Value.Split(';');
                                foreach (String str in temp)
                                {
                                    if (str != String.Empty)
                                        icbValue.Items.Add(str);
                                }
                            }
                            else
                            {
                                InfoDataSet idsComboBox = new InfoDataSet();
                                idsComboBox.RemoteName = xn.Attributes["RemoteName"].Value;
                                idsComboBox.Active = true;
                                InfoBindingSource ibsComboBox = new InfoBindingSource();
                                ibsComboBox.DataSource = idsComboBox;
                                ibsComboBox.DataMember = idsComboBox.RealDataSet.Tables[0].TableName;

                                icbValue.DataSource = ibsComboBox;
                                icbValue.DisplayMember = xn.Attributes["DisplayMember"].Value;
                                icbValue.ValueMember = xn.Attributes["ValueMember"].Value;
                                icbValue.EndInit();
                            }
                        }
                        else
                        {
                            icbValue.SelectAlias = xn.Attributes["SelectAlias"].Value;
                            icbValue.SelectCommand = xn.Attributes["SelectCommand"].Value;
                            icbValue.DisplayMember = xn.Attributes["DisplayMember"].Value;
                            icbValue.ValueMember = xn.Attributes["ValueMember"].Value;
                            icbValue.EndInit();
                        }

                        icbValue.Name = ColumnsCount + "AnyQueryValue1InfoComboBox" + xn.Attributes["ValueEnabled"].Value;
                        icbValue.Text = xn.Attributes["Value1"].Value;
                        icbValue.Width = Convert.ToInt16(xn.Attributes["Width"].Value);
                        icbValue.Location = new Point(standard, 15 + ColumnsCount * 30);
                        icbValue.Enabled = Convert.ToBoolean(xn.Attributes["Enabled"].Value);
                        icbValue.Enter += new EventHandler(tbValue_Enter);
                        this.panel2.Controls.Add(icbValue);
                        break;
                    case "AnyQueryCheckBoxColumn":
                        break;
                    case "AnyQueryRefValColumn":
                        InfoRefvalBox irbValue = new InfoRefvalBox();
                        InfoRefVal aInfoRefVal = new InfoRefVal();
                        aInfoRefVal.SelectAlias = xn.Attributes["SelectAlias"].Value;
                        aInfoRefVal.SelectCommand = xn.Attributes["SelectCommand"].Value;
                        aInfoRefVal.DisplayMember = xn.Attributes["DisplayMember"].Value;
                        aInfoRefVal.ValueMember = xn.Attributes["ValueMember"].Value;
                        aInfoRefVal.EndInit();

                        irbValue.Name = ColumnsCount + "AnyQueryValue2InfoRefvalBox2" + xn.Attributes["ValueEnabled"].Value;
                        irbValue.RefVal = aInfoRefVal;
                        irbValue.TextBoxText = xn.Attributes["Value2"].Value;
                        irbValue.Width = Convert.ToInt16(xn.Attributes["Width"].Value);
                        irbValue.Location = new Point(standard, 15 + ColumnsCount * 30);
                        irbValue.TextBoxEnabled = Convert.ToBoolean(xn.Attributes["Enabled"].Value);
                        irbValue.Enter += new EventHandler(tbValue_Enter);
                        this.panel2.Controls.Add(irbValue);
                        break;
                    case "AnyQueryCalendarColumn":
                        InfoDateTimePicker idtpValue = new InfoDateTimePicker();
                        idtpValue.BeginInit();
                        idtpValue.Name = ColumnsCount + "AnyQueryValue2InfoDateTimePicker2" + xn.Attributes["ValueEnabled"].Value;
                        idtpValue.Text = xn.Attributes["Value2"].Value;
                        idtpValue.Width = Convert.ToInt16(xn.Attributes["Width"].Value);
                        idtpValue.Location = new Point(standard, 15 + ColumnsCount * 30);
                        idtpValue.Enabled = Convert.ToBoolean(xn.Attributes["Enabled"].Value);
                        idtpValue.Format = DateTimePickerFormat.Long;
                        idtpValue.EndInit();
                        idtpValue.Enter += new EventHandler(tbValue_Enter);
                        this.panel2.Controls.Add(idtpValue);
                        break;
                    case "AnyQueryRefButtonColumn"://<->不会用到RefButton
                        //InfoDataSet idsRefButton2 = new InfoDataSet();
                        //if (xn.Attributes["RemoteName"].Value == "GLModule.cmdRefValUse")
                        //{
                        //    idsRefButton2.RemoteName = "GLModule.cmdRefValUse";
                        //    idsRefButton2.Execute(xn.Attributes["SelectCommand"].Value, xn.Attributes["SelectAlias"].Value, true);
                        //}
                        //else
                        //{
                        //    idsRefButton2.RemoteName = xn.Attributes["RemoteName"].Value;
                        //    idsRefButton2.Active = true;
                        //}

                        //InfoBindingSource ibsRefButton2 = new InfoBindingSource();
                        //ibsRefButton2.DataSource = idsRefButton2;
                        //if (xn.Attributes["RemoteName"].Value != null)
                        //    ibsRefButton2.DataMember = idsRefButton2.RealDataSet.Tables[0].TableName;
                        //else
                        //    ibsRefButton2.DataMember = "cmdRefValUse";

                        //InfoTranslate it2 = new InfoTranslate();
                        //it2.BindingSource = ibsRefButton2;
                        //TranslateRefReturnFields trrf2 = new TranslateRefReturnFields();
                        //trrf2.ColumnName = xn.Attributes["ValueMember"].Value;
                        //it2.RefReturnFields.Add(trrf2);

                        //TextBox tbRefButton2 = new TextBox();
                        //tbRefButton2.Name = ColumnsCount + "AnyQueryValue1RefTextBox" + xn.Attributes["ValueEnabled"].Value;
                        //tbRefButton2.Text = xn.Attributes["Value1"].Value;
                        //tbRefButton2.Width = Convert.ToInt16(xn.Attributes["Width"].Value);
                        //tbRefButton2.Location = new Point(standard, 15 + ColumnsCount * 30);
                        //tbRefButton2.Enabled = Convert.ToBoolean(xn.Attributes["Enabled"].Value);
                        //this.panel2.Controls.Add(tbRefButton2);

                        //InfoRefButton ifb2 = new InfoRefButton();
                        //ifb2.autoPanel = Convert.ToBoolean(xn.Attributes["AutoPanel"].Value);
                        //if (!ifb2.autoPanel)
                        //{
                        //    Control[] innerPanel = (this.innerAnyQuery.OwnerComp as InfoForm).Controls.Find(xn.Attributes["Panel"].Value, true);
                        //    if (innerPanel.Length > 0)
                        //    {
                        //        ifb2.panel = innerPanel[0] as Panel;
                        //    }

                        //    if (ifb2.panel == null)
                        //    {
                        //        for (int i = 0; i < panels.Count; i++)
                        //        {
                        //            if (panels[i] == null) continue;
                        //            ifb2.panel = panels[i];
                        //        }

                        //        if (ifb2.panel == null)
                        //        {
                        //            MessageBox.Show("Can not find the Panel '" + xn.Attributes["Panel"].Value + "' in your Form.");
                        //            return "AND";
                        //        }
                        //    }
                        //}
                        //ifb2.infoTranslate = it2;
                        //RefButtonMatch rbm2 = new RefButtonMatch();
                        //rbm2.matchColumnName = tbRefButton2.Name;
                        //ifb2.refButtonMatchs.Add(rbm2);
                        //ifb2.Name = ColumnsCount + "AnyQueryValue1InfoRefButton" + xn.Attributes["ValueEnabled"].Value;
                        //ifb2.Text = "...";
                        //ifb2.Width = 20;
                        //ifb2.Location = new Point(tbRefButton2.Location.X + tbRefButton2.Width + 2, 15 + ColumnsCount * 30);
                        ////ifb2.Enabled = Convert.ToBoolean(xn.Attributes["Enabled"].Value);
                        //this.panel2.Controls.Add(ifb2);
                        break;
                }
            }

            if (innerAnyQuery.AutoDisableColumns)
            {
                cbActive_CheckedChanged(cbActive, new EventArgs());
            }

            return xn.Attributes["Condition"].Value;
        }
Exemple #2
0
        void cbOperator_SelectedIndexChanged(object sender, EventArgs e)
        {
            int count = 0;
            bool flag = false;
            object cValue1 = null;
            object cValue2 = null;
            Label cLabel = null;
            for (int i = 0; i < (sender as ComboBox).Name.Length; i++)
            {
                if (Char.IsDigit((sender as ComboBox).Name[i]))
                {
                    count = count * Convert.ToInt16(Math.Pow(10, i)) + Convert.ToInt16(Char.ToString((sender as ComboBox).Name[i]));
                }
            }

            if (count > 0)
            {
                foreach (Control c in this.panel2.Controls)
                {
                    if (c.Name.StartsWith(count + "AnyQueryValue1to2Label"))
                    {
                        cLabel = c as Label;
                        continue;
                    }

                    if (c.Name.StartsWith(count + "AnyQueryValue1"))
                    {
                        cValue1 = c;
                        continue;
                    }

                    if (c.Name.StartsWith(count + "AnyQueryValue2"))
                    {
                        flag = true;
                        cValue2 = c;
                        continue;
                    }
                }
            }

            if ((sender as ComboBox).Text == "<->" || (sender as ComboBox).Text == "!<->")
            {
                if (!flag)
                {
                    int standard = (cValue1 as Control).Location.X + (cValue1 as Control).Width + 10;

                    Label aLabel = new Label();
                    aLabel.Name = count + "AnyQueryValue1to2Label";
                    aLabel.Text = "~";
                    aLabel.Width = 10;
                    aLabel.Location = new Point(standard, 15 + count * 30);
                    this.panel2.Controls.Add(aLabel);

                    standard += aLabel.Width + 10;
                    if (cValue1 is TextBox)
                    {
                        cValue2 = new TextBox();
                        (cValue2 as TextBox).Name = count + "AnyQueryValue2TextBox";
                        (cValue2 as TextBox).Text = (cValue1 as TextBox).Text;
                        (cValue2 as TextBox).Width = (cValue1 as TextBox).Width;
                        (cValue2 as TextBox).Location = new Point(standard, (cValue1 as TextBox).Location.Y);
                        (cValue2 as TextBox).Enter += new EventHandler(tbValue_Enter);
                        (cValue2 as TextBox).KeyPress += new KeyPressEventHandler(tbValue_KeyPress);
                        this.panel2.Controls.Add((cValue2 as TextBox));
                    }
                    else if (cValue1 is InfoComboBox)
                    {
                        cValue2 = new InfoComboBox();
                        (cValue2 as InfoComboBox).SelectAlias = (cValue1 as InfoComboBox).SelectAlias;
                        (cValue2 as InfoComboBox).SelectCommand = (cValue1 as InfoComboBox).SelectCommand;
                        (cValue2 as InfoComboBox).DisplayMember = (cValue1 as InfoComboBox).DisplayMember;
                        (cValue2 as InfoComboBox).ValueMember = (cValue1 as InfoComboBox).ValueMember;
                        (cValue2 as InfoComboBox).EndInit();

                        (cValue2 as InfoComboBox).DisplayMemberOnly = (cValue1 as InfoComboBox).DisplayMemberOnly; ;
                        (cValue2 as InfoComboBox).Name = count + "AnyQueryValue2InfoComboBox2";
                        (cValue2 as InfoComboBox).Text = (cValue1 as InfoComboBox).Text;
                        (cValue2 as InfoComboBox).Width = (cValue1 as InfoComboBox).Width;
                        (cValue2 as InfoComboBox).Location = new Point(standard, (cValue1 as InfoComboBox).Location.Y);
                        this.panel2.Controls.Add((cValue2 as InfoComboBox));
                    }
                    else if (cValue1 is CheckBox)
                    {

                    }
                    else if (cValue1 is InfoRefvalBox)
                    {
                        cValue2 = new InfoRefvalBox();
                        (cValue2 as InfoRefvalBox).Name = count + "AnyQueryValue2InfoRefvalBox2";
                        (cValue2 as InfoRefvalBox).RefVal = (cValue1 as InfoRefvalBox).RefVal;
                        (cValue2 as InfoRefvalBox).TextBoxText = (cValue1 as InfoRefvalBox).TextBoxText;
                        (cValue2 as InfoRefvalBox).Width = (cValue1 as InfoRefvalBox).Width;
                        (cValue2 as InfoRefvalBox).Location = new Point(standard, (cValue1 as InfoRefvalBox).Location.Y);
                        this.panel2.Controls.Add((cValue2 as InfoRefvalBox));
                    }
                    else if (cValue1 is InfoDateTimePicker)
                    {
                        cValue2 = new InfoDateTimePicker();
                        (cValue2 as InfoDateTimePicker).BeginInit();
                        (cValue2 as InfoDateTimePicker).Name = count + "AnyQueryValue2InfoDateTimePicker2";
                        (cValue2 as InfoDateTimePicker).Text = (cValue1 as InfoDateTimePicker).Text;
                        (cValue2 as InfoDateTimePicker).Width = (cValue1 as InfoDateTimePicker).Width;
                        (cValue2 as InfoDateTimePicker).Location = new Point(standard, (cValue1 as InfoDateTimePicker).Location.Y);
                        (cValue2 as InfoDateTimePicker).Format = DateTimePickerFormat.Long;
                        (cValue2 as InfoDateTimePicker).EndInit();
                        this.panel2.Controls.Add((cValue2 as InfoDateTimePicker));
                    }
                }
            }
            else
            {
                if (flag)
                {
                    this.panel2.Controls.Remove((cValue2 as Control));
                    this.panel2.Controls.Remove(cLabel);
                }
            }
        }
Exemple #3
0
        private void CreateColumns(InfoDataSet ids, AnyQueryColumns aqc, int columnsCount, bool isActive)
        {
            String value = aqc.DefaultValue;
            if (aqc.DefaultValue.StartsWith("_"))
            {
                object[] realValue = CliUtils.GetValue(aqc.DefaultValue);
                if (realValue[0].ToString() == "0")
                    value = realValue[1].ToString();
            }

            int columnWidth = aqc.ColumnWidth;
            int ColumnsCount = columnsCount;
            if (120 + ColumnsCount * 30 > this.Height) this.Height += 30;

            int standard = 40;
            CheckBox cbActive = new CheckBox();
            cbActive.Name = ColumnsCount + "AnyQueryActiveCheckBox";
            cbActive.Width = 15;
            cbActive.Location = new Point(standard, 13 + ColumnsCount * 30);
            cbActive.Checked = isActive;
            cbActive.CheckedChanged += new EventHandler(cbActive_CheckedChanged);
            this.panel2.Controls.Add(cbActive);

            //standard += 30;
            //Label labelCondition = new Label();
            //labelCondition.Name = ColumnsCount + "AnyQueryConditionLabel";
            //labelCondition.Width = 50;
            //labelCondition.Text = aqc.Condition.ToUpper();
            //labelCondition.Location = new Point(standard, 17 + ColumnsCount * 30);
            //labelCondition.Click += new EventHandler(labelCondition_Click);
            //this.panel2.Controls.Add(labelCondition);

            standard += 30;
            ComboBox cbColumn = new ComboBox();
            cbColumn.Name = ColumnsCount + "AnyQueryColumnComboBox";
            this.panel2.Controls.Add(cbColumn);
            DataView dvColumn = CreateDataViewColumn(ids);
            cbColumn.DataSource = dvColumn;
            cbColumn.DisplayMember = "CAPTION";
            cbColumn.ValueMember = "FIELDNAME";
            cbColumn.Width = columnWidth;
            //if (innerAnyQuery.QueryColumnMode == AnyQueryColumnMode.ByBindingSource)
            //    cbColumn.Text = GetHeaderText(aqc.Column);
            //else
            cbColumn.DropDownStyle = ComboBoxStyle.DropDownList;
            cbColumn.Location = new Point(standard, 15 + ColumnsCount * 30);
            cbColumn.Text = aqc.Caption;
            cbColumn.SelectedIndexChanged += new EventHandler(cbColumn_SelectedIndexChanged);

            standard += cbColumn.Width + 5;
            ComboBox cbOperator = new ComboBox();
            Type cbType = GetDataType(aqc.Column);
            List<String> op = new List<string>();
            op.AddRange(new String[] { "=", "!=", ">", "<", ">=", "<=", "%**", "**%", "%%", "!%%", "<->", "!<->", "IN", "NOT IN" });
            if (!innerAnyQuery.DisplayAllOperator)
            {
                if (cbType == typeof(Char) || cbType == typeof(String))
                {
                    op.Clear();
                    //op.AddRange(new String[] { "=", "!=", "%**", "**%", "%%", "!%%", "IN", "NOT IN" });
                    op.AddRange(new String[] { "=", "!=", "%**", "**%", "%%", "!%%" });
                }
                else if (cbType != null && (cbType == typeof(int) || cbType == typeof(float) || cbType == typeof(double) || cbType == typeof(DateTime) || cbType.FullName == "System.Decimal" || cbType == typeof(Int16) || cbType == typeof(Int64)))
                {
                    op.Clear();
                    //op.AddRange(new String[] { "=", "!=", "<", ">", "<=", ">=", "<->", "!<->", "IN", "NOT IN" });
                    op.AddRange(new String[] { "=", "!=", "<", ">", "<=", ">=", "<->", "!<->" });
                }
            }
            cbOperator.Items.AddRange(op.ToArray());
            cbOperator.DropDownStyle = ComboBoxStyle.DropDownList;
            cbOperator.Name = ColumnsCount + "AnyQueryOperatorComboBox";
            cbOperator.Width = 65;
            cbOperator.Location = new Point(standard, 15 + ColumnsCount * 30);
            SetOperatorHelp(cbOperator);
            cbOperator.SelectedIndexChanged += new EventHandler(cbOperator_SelectedIndexChanged);
            this.panel2.Controls.Add(cbOperator);

            standard += cbOperator.Width + 5;
            switch (aqc.ColumnType)
            {
                case "AnyQueryTextBoxColumn":
                    TextBox tbValue = new TextBox();
                    tbValue.Name = ColumnsCount + "AnyQueryValue1TextBox" + aqc.Enabled.ToString();
                    tbValue.Text = value;
                    tbValue.Width = aqc.Width;
                    tbValue.Location = new Point(standard, 15 + ColumnsCount * 30);
                    tbValue.Enabled = aqc.Enabled;
                    tbValue.Enter += new EventHandler(tbValue_Enter);
                    tbValue.KeyPress += new KeyPressEventHandler(tbValue_KeyPress);
                    this.panel2.Controls.Add(tbValue);
                    break;
                case "AnyQueryComboBoxColumn":
                    cbOperator.Items.Clear();
                    op.Clear();
                    op.AddRange(new String[] { "=", "!=" });
                    cbOperator.Items.AddRange(op.ToArray());

                    InfoComboBox icbValue = new InfoComboBox();
                    if (aqc.InfoRefVal != null)
                    {
                        icbValue.DisplayMemberOnly = true;
                        if (aqc.InfoRefVal.SelectAlias != null && aqc.InfoRefVal.SelectAlias != String.Empty && aqc.InfoRefVal.SelectCommand != null && aqc.InfoRefVal.SelectCommand != String.Empty)
                        {
                            icbValue.SelectAlias = aqc.InfoRefVal.SelectAlias;
                            icbValue.SelectCommand = aqc.InfoRefVal.SelectCommand;
                        }
                        else
                        {
                            icbValue.DataSource = aqc.InfoRefVal.DataSource;
                        }
                        icbValue.DisplayMember = aqc.InfoRefVal.DisplayMember;
                        icbValue.ValueMember = aqc.InfoRefVal.ValueMember;
                        icbValue.EndInit();
                    }
                    else
                    {
                        icbValue.DisplayMemberOnly = false;
                        icbValue.Items.AddRange(aqc.Items);
                    }

                    icbValue.Name = ColumnsCount + "AnyQueryValue1InfoComboBox" + aqc.Enabled.ToString();
                    icbValue.Text = value;
                    icbValue.Width = aqc.Width;
                    icbValue.Location = new Point(standard, 15 + ColumnsCount * 30);
                    icbValue.Enabled = aqc.Enabled;
                    icbValue.Enter += new EventHandler(tbValue_Enter);
                    this.panel2.Controls.Add(icbValue);
                    break;
                case "AnyQueryCheckBoxColumn":
                    cbOperator.Items.Clear();
                    op.Clear();
                    op.AddRange(new String[] { "=", "!=" });
                    cbOperator.Items.AddRange(op.ToArray());

                    CheckBox cbValue = new CheckBox();
                    cbValue.Name = ColumnsCount + "AnyQueryValue1CheckBox" + aqc.Enabled.ToString();
                    if (aqc.DefaultValue == "1")
                        cbValue.Checked = true;
                    cbValue.Width = aqc.Width;
                    cbValue.Location = new Point(standard, 15 + ColumnsCount * 30);
                    cbValue.Enabled = aqc.Enabled;
                    cbValue.Enter += new EventHandler(tbValue_Enter);
                    this.panel2.Controls.Add(cbValue);
                    break;
                case "AnyQueryRefValColumn":
                    cbOperator.Items.Clear();
                    op.Clear();
                    op.AddRange(new String[] { "=", "!=", "IN", "NOT IN" });
                    cbOperator.Items.AddRange(op.ToArray());

                    if (aqc.Operator == "IN" || aqc.Operator == "NOT IN")
                    {
                        InfoTranslate it = new InfoTranslate();
                        if (aqc.InfoRefVal.SelectAlias != null && aqc.InfoRefVal.SelectCommand != null && aqc.InfoRefVal.SelectAlias != String.Empty && aqc.InfoRefVal.SelectCommand != String.Empty)
                        {
                            InfoDataSet idsRefButton = new InfoDataSet();
                            idsRefButton.RemoteName = "GLModule.cmdRefValUse";
                            idsRefButton.Execute(aqc.InfoRefVal.SelectCommand, CliUtils.fLoginDB, true);
                            InfoBindingSource ibsRefButton = new InfoBindingSource();
                            ibsRefButton.DataSource = idsRefButton;
                            ibsRefButton.DataMember = "cmdRefValUse";
                            it.BindingSource = ibsRefButton;
                        }
                        else
                        {
                            it.BindingSource = aqc.InfoRefVal.DataSource as InfoBindingSource;
                        }
                        TranslateRefReturnFields trrf = new TranslateRefReturnFields();
                        trrf.ColumnName = aqc.InfoRefVal.ValueMember;
                        trrf.DisplayColumnName = aqc.InfoRefVal.DisplayMember;
                        it.RefReturnFields.Add(trrf);

                        InfoRefbuttonBox aInfoRefbuttonBox = new InfoRefbuttonBox();
                        aInfoRefbuttonBox.Name = ColumnsCount + "AnyQueryValue1RefTextBox" + aqc.Enabled.ToString();
                        aInfoRefbuttonBox.Text = value;
                        aInfoRefbuttonBox.Location = new Point(standard, 15 + ColumnsCount * 30);
                        aInfoRefbuttonBox.Width = aqc.Width;
                        aInfoRefbuttonBox.Enabled = aqc.Enabled;
                        aInfoRefbuttonBox.Enter += new EventHandler(tbValue_Enter);
                        this.panel2.Controls.Add(aInfoRefbuttonBox);

                        //TextBox tbRefButton = new TextBox();
                        //tbRefButton.Name = ColumnsCount + "AnyQueryValue1RefTextBox" + aqc.Enabled.ToString();
                        //tbRefButton.Text = aqc.DefaultValue;
                        //tbRefButton.Width = aqc.Width;
                        //tbRefButton.Location = new Point(standard, 15 + ColumnsCount * 30);
                        //tbRefButton.Enabled = aqc.Enabled;
                        //tbRefButton.Enter += new EventHandler(tbValue_Enter);
                        //this.panel2.Controls.Add(tbRefButton);

                        InfoRefButton ifb = new InfoRefButton();
                        ifb.autoPanel = true;
                        ifb.infoTranslate = it;
                        RefButtonMatch rbm = new RefButtonMatch();
                        rbm.matchColumnName = aInfoRefbuttonBox.Name;
                        ifb.refButtonMatchs.Add(rbm);
                        ifb.Name = ColumnsCount + "AnyQueryValue1InfoRefButton" + aqc.Enabled.ToString();
                        ifb.Text = "...";
                        ifb.Width = 20;
                        ifb.Location = new Point(aInfoRefbuttonBox.Location.X + aInfoRefbuttonBox.Width + 2, 15 + ColumnsCount * 30);
                        //ifb.Enabled = aqc.Enabled;
                        this.panel2.Controls.Add(ifb);
                    }
                    else
                    {
                        cbOperator.Items.Remove("IN");
                        cbOperator.Items.Remove("NOT IN");

                        InfoRefvalBox irbValue = new InfoRefvalBox();
                        irbValue.Name = ColumnsCount + "AnyQueryValue1InfoRefvalBox" + aqc.Enabled.ToString();
                        irbValue.RefVal = aqc.InfoRefVal;
                        irbValue.TextBoxText = value;
                        irbValue.Width = aqc.Width;
                        irbValue.Location = new Point(standard, 15 + ColumnsCount * 30);
                        irbValue.TextBoxEnabled = aqc.Enabled;
                        irbValue.Enter += new EventHandler(tbValue_Enter);
                        this.panel2.Controls.Add(irbValue);
                    }
                    break;
                case "AnyQueryCalendarColumn":
                    InfoDateTimePicker idtpValue = new InfoDateTimePicker();
                    idtpValue.BeginInit();
                    idtpValue.Name = ColumnsCount + "AnyQueryValue1InfoDateTimePicker" + aqc.Enabled.ToString();
                    idtpValue.Text = value;
                    idtpValue.Width = aqc.Width;
                    idtpValue.Location = new Point(standard, 15 + ColumnsCount * 30);
                    idtpValue.Enabled = aqc.Enabled;
                    idtpValue.Format = DateTimePickerFormat.Long;
                    idtpValue.EndInit();
                    idtpValue.Enter += new EventHandler(tbValue_Enter);
                    this.panel2.Controls.Add(idtpValue);
                    break;
                case "AnyQueryRefButtonColumn":
                    cbOperator.Items.Clear();
                    op.Clear();
                    op.AddRange(new String[] { "IN", "NOT IN" });
                    cbOperator.Items.AddRange(op.ToArray());

                    InfoTranslate itRefButton = new InfoTranslate();
                    if (aqc.InfoRefVal.SelectAlias != null && aqc.InfoRefVal.SelectCommand != null && aqc.InfoRefVal.SelectAlias != String.Empty && aqc.InfoRefVal.SelectCommand != String.Empty)
                    {
                        InfoDataSet idsRefButton = new InfoDataSet();
                        idsRefButton.RemoteName = "GLModule.cmdRefValUse";
                        idsRefButton.Execute(aqc.InfoRefVal.SelectCommand, CliUtils.fLoginDB, true);
                        InfoBindingSource ibsRefButton = new InfoBindingSource();
                        ibsRefButton.DataSource = idsRefButton;
                        ibsRefButton.DataMember = "cmdRefValUse";
                        itRefButton.BindingSource = ibsRefButton;
                    }
                    else
                    {
                        itRefButton.BindingSource = aqc.InfoRefVal.DataSource as InfoBindingSource;
                    }
                    TranslateRefReturnFields trrf2 = new TranslateRefReturnFields();
                    trrf2.ColumnName = aqc.InfoRefVal.ValueMember;
                    trrf2.DisplayColumnName = aqc.InfoRefVal.DisplayMember;
                    itRefButton.RefReturnFields.Add(trrf2);

                    InfoRefbuttonBox aInfoRefbuttonBox2 = new InfoRefbuttonBox();
                    aInfoRefbuttonBox2.Name = ColumnsCount + "AnyQueryValue1RefTextBox" + aqc.Enabled.ToString();
                    aInfoRefbuttonBox2.Text = value;
                    aInfoRefbuttonBox2.Location = new Point(standard, 15 + ColumnsCount * 30);
                    aInfoRefbuttonBox2.Width = aqc.Width;
                    aInfoRefbuttonBox2.Enabled = aqc.Enabled;
                    aInfoRefbuttonBox2.Enter += new EventHandler(tbValue_Enter);
                    this.panel2.Controls.Add(aInfoRefbuttonBox2);

                    //TextBox tbRefButton2 = new TextBox();
                    //tbRefButton2.Name = ColumnsCount + "AnyQueryValue1RefTextBox" + aqc.Enabled.ToString();
                    //tbRefButton2.Text = aqc.DefaultValue;
                    //tbRefButton2.Width = aqc.Width;
                    //tbRefButton2.Location = new Point(standard, 15 + ColumnsCount * 30);
                    //tbRefButton2.Enabled = aqc.Enabled;
                    //tbRefButton2.Enter += new EventHandler(tbValue_Enter);
                    //this.panel2.Controls.Add(tbRefButton2);

                    InfoRefButton ifb2 = new InfoRefButton();
                    if (aqc.InfoRefButtonAutoPanel)
                        ifb2.autoPanel = true;
                    else
                    {
                        ifb2.autoPanel = false;
                        ifb2.panel = aqc.InfoRefButtonPanel;
                    }
                    ifb2.infoTranslate = itRefButton;
                    RefButtonMatch rbm2 = new RefButtonMatch();
                    rbm2.matchColumnName = aInfoRefbuttonBox2.Name;//rbm2.matchColumnName = tbRefButton2.Name;
                    ifb2.refButtonMatchs.Add(rbm2);
                    ifb2.Name = ColumnsCount + "AnyQueryValue1InfoRefButton" + aqc.Enabled.ToString();
                    ifb2.Text = "...";
                    ifb2.Width = 20;
                    ifb2.Location = new Point(aInfoRefbuttonBox2.Location.X + aInfoRefbuttonBox2.Width + 2, 15 + ColumnsCount * 30);//ifb2.Location = new Point(tbRefButton2.Location.X + tbRefButton2.Width + 2, 15 + ColumnsCount * 30);
                    //ifb2.Enabled = aqc.Enabled;
                    this.panel2.Controls.Add(ifb2);
                    break;
            }
            if (aqc.Operator == "%")
                cbOperator.Text = "**%";
            else
                cbOperator.Text = aqc.Operator;

            //if (aqc.Operator == "<->" || aqc.Operator == "!<->")
            //{
            //    standard += aqc.Width + 5;

            //    Label aLabel = new Label();
            //    aLabel.Name = ColumnsCount + "AnyQueryValue1to2Label";
            //    aLabel.Text = "~";
            //    aLabel.Width = 10;
            //    aLabel.Location = new Point(standard, 15 + ColumnsCount * 30);
            //    this.panel2.Controls.Add(aLabel);

            //    standard += aLabel.Width + 5;
            //    switch (aqc.ColumnType)
            //    {
            //        case "AnyQueryTextBoxColumn":
            //            TextBox tbValue = new TextBox();
            //            tbValue.Name = ColumnsCount + "AnyQueryValue2TextBox" + aqc.Enabled.ToString();
            //            tbValue.Text = aqc.DefaultValue;
            //            tbValue.Width = aqc.Width;
            //            tbValue.Location = new Point(standard, 15 + ColumnsCount * 30);
            //            tbValue.Enabled = aqc.Enabled;
            //            tbValue.Enter += new EventHandler(tbValue_Enter);
            //            this.panel2.Controls.Add(tbValue);
            //            break;
            //        case "AnyQueryComboBoxColumn":
            //            InfoComboBox icbValue = new InfoComboBox();
            //            icbValue.DisplayMemberOnly = true;
            //            if (aqc.InfoRefVal != null)
            //            {
            //                if (icbValue.SelectAlias != null && icbValue.SelectAlias != String.Empty && icbValue.SelectCommand != null && icbValue.SelectCommand != String.Empty)
            //                {
            //                    icbValue.SelectAlias = aqc.InfoRefVal.SelectAlias;
            //                    icbValue.SelectCommand = aqc.InfoRefVal.SelectCommand;
            //                }
            //                else
            //                {
            //                    icbValue.DataSource = aqc.InfoRefVal.DataSource;
            //                }
            //                icbValue.DisplayMember = aqc.InfoRefVal.DisplayMember;
            //                icbValue.ValueMember = aqc.InfoRefVal.ValueMember;
            //                icbValue.EndInit();
            //            }
            //            else
            //            {
            //                icbValue.Items.AddRange(aqc.Items);
            //            }

            //            icbValue.Name = ColumnsCount + "AnyQueryValue2InfoComboBox2" + aqc.Enabled.ToString();
            //            icbValue.Text = aqc.DefaultValue;
            //            icbValue.Width = aqc.Width;
            //            icbValue.Location = new Point(standard, 15 + ColumnsCount * 30);
            //            icbValue.Enabled = aqc.Enabled;
            //            icbValue.Enter += new EventHandler(tbValue_Enter);
            //            this.panel2.Controls.Add(icbValue);
            //            break;
            //        case "AnyQueryCheckBoxColumn":
            //            break;
            //        case "AnyQueryRefValColumn":
            //            InfoRefvalBox irbValue = new InfoRefvalBox();
            //            irbValue.Name = ColumnsCount + "AnyQueryValue2InfoRefvalBox2" + aqc.Enabled.ToString();
            //            irbValue.RefVal = aqc.InfoRefVal;
            //            irbValue.TextBoxText = aqc.DefaultValue;
            //            irbValue.Width = aqc.Width;
            //            irbValue.Location = new Point(standard, 15 + ColumnsCount * 30);
            //            irbValue.TextBoxEnabled = aqc.Enabled;
            //            irbValue.Enter += new EventHandler(tbValue_Enter);
            //            this.panel2.Controls.Add(irbValue);
            //            break;
            //        case "AnyQueryCalendarColumn":
            //            InfoDateTimePicker idtpValue = new InfoDateTimePicker();
            //            idtpValue.BeginInit();
            //            idtpValue.Name = ColumnsCount + "AnyQueryValue2InfoDateTimePicker2" + aqc.Enabled.ToString();
            //            idtpValue.Text = aqc.DefaultValue;
            //            idtpValue.Width = aqc.Width;
            //            idtpValue.Location = new Point(standard, 15 + ColumnsCount * 30);
            //            idtpValue.Enabled = aqc.Enabled;
            //            idtpValue.Format = DateTimePickerFormat.Long;
            //            idtpValue.EndInit();
            //            idtpValue.Enter += new EventHandler(tbValue_Enter);
            //            this.panel2.Controls.Add(idtpValue);
            //            break;
            //        case "AnyQueryRefButtonColumn"://<->不会用到RefButton
            //            //InfoTranslate itRefButton = new InfoTranslate();
            //            //if (aqc.InfoRefVal.SelectAlias != null && aqc.InfoRefVal.SelectCommand != null && aqc.InfoRefVal.SelectAlias != String.Empty && aqc.InfoRefVal.SelectCommand != String.Empty)
            //            //{
            //            //    InfoDataSet idsRefButton = new InfoDataSet();
            //            //    idsRefButton.RemoteName = "GLModule.cmdRefValUse";
            //            //    idsRefButton.Execute(aqc.InfoRefVal.SelectCommand, aqc.InfoRefVal.SelectAlias, true);
            //            //    InfoBindingSource ibsRefButton = new InfoBindingSource();
            //            //    ibsRefButton.DataSource = idsRefButton;
            //            //    ibsRefButton.DataMember = "cmdRefValUse";
            //            //    itRefButton.BindingSource = ibsRefButton;
            //            //}
            //            //else
            //            //{
            //            //    itRefButton.BindingSource = aqc.InfoRefVal.DataSource as InfoBindingSource;
            //            //}
            //            //TranslateRefReturnFields trrf2 = new TranslateRefReturnFields();
            //            //trrf2.ColumnName = aqc.InfoRefVal.ValueMember;
            //            //itRefButton.RefReturnFields.Add(trrf2);

            //            //TextBox tbRefButton2 = new TextBox();
            //            //tbRefButton2.Name = ColumnsCount + "AnyQueryValue1RefTextBox" + aqc.Enabled.ToString();
            //            //tbRefButton2.Text = aqc.DefaultValue;
            //            //tbRefButton2.Width = aqc.Width;
            //            //tbRefButton2.Location = new Point(standard, 15 + ColumnsCount * 30);
            //            //tbRefButton2.Enabled = aqc.Enabled;
            //            //this.panel2.Controls.Add(tbRefButton2);

            //            //InfoRefButton ifb2 = new InfoRefButton();
            //            //if (aqc.InfoRefButtonAutoPanel)
            //            //    ifb2.autoPanel = true;
            //            //else
            //            //{
            //            //    ifb2.autoPanel = false;
            //            //    ifb2.panel = aqc.InfoRefButtonPanel;
            //            //}
            //            //ifb2.infoTranslate = itRefButton;
            //            //RefButtonMatch rbm2 = new RefButtonMatch();
            //            //rbm2.matchColumnName = tbRefButton2.Name;
            //            //ifb2.refButtonMatchs.Add(rbm2);
            //            //ifb2.Name = ColumnsCount + "AnyQueryValue1InfoRefButton" + aqc.Enabled.ToString();
            //            //ifb2.Text = "...";
            //            //ifb2.Width = 20;
            //            //ifb2.Location = new Point(tbRefButton2.Location.X + tbRefButton2.Width + 2, 15 + ColumnsCount * 30);
            //            //ifb2.Enabled = aqc.Enabled;
            //            //this.panel2.Controls.Add(ifb2);
            //            break;
            //    }
            //}

            if (innerAnyQuery.AutoDisableColumns)
            {
                cbActive_CheckedChanged(cbActive, new EventArgs());
            }
        }
        private void InitializeQueryConditionItem()
        {
            captionLabels = new System.Windows.Forms.Label[colNum];
            textcomboBox = new InfoComboBox[colNum];
            textTextBox = new InfoTextBox[colNum];
            textRefValBox = new InfoRefvalBox[colNum];
            textDateTimePicker = new InfoDateTimePicker[colNum];
            textButton = new System.Windows.Forms.Button[colNum];

            int LocationX = 130;
            int LocationY = 30;
            int formWidth = LocationX;

            for (int i = 0; i < colNum; i++)
            {
               // HorizontalAlignment txtalign = GetAlignment(((QueryColumns)cqFormQuery.Columns[i]).TextAlign);

                //conditionlabels & newline
                if (((WebQueryColumns)wcqCopy.Columns[i]).Column == string.Empty)
                {
                    MessageBox.Show(string.Format("The columnname of column[{0}] is empty", i.ToString()));
                }
                if (i > 0)
                {
                    if (((WebQueryColumns)wcqCopy.Columns[i]).NewLine == true)
                    {
                        LocationY += wcqCopy.GapVertical + captionLabels[i - 1].PreferredHeight + 9;
                        LocationX = 130;
                    }
                    else
                    {
                        LocationX += ((WebQueryColumns)wcqCopy.Columns[i - 1]).Width + wcqCopy.GapHorizontal + 90;
                    }
                }

                //captionlabels
                captionLabels[i] = new System.Windows.Forms.Label();
                captionLabels[i].AutoSize = true;
                captionLabels[i].TextAlign = ContentAlignment.MiddleRight;
                captionLabels[i].Name = "caplbl" + ((WebQueryColumns)wcqCopy.Columns[i]).Column.ToString();
                captionLabels[i].Text = ((WebQueryColumns)wcqCopy.Columns[i]).Caption;
                captionLabels[i].BackColor = System.Drawing.Color.Transparent;
                captionLabels[i].ForeColor = wcqCopy.LabelColor;
                captionLabels[i].Font = new Font(wcqCopy.Font.Name, fontsize, fontStyle);

                captionLabels[i].Location = new System.Drawing.Point(LocationX - captionLabels[i].PreferredWidth, LocationY + 4);

             //   this.splitContainer1.Panel1.Controls.Add(captionLabels[i]);
                this.Controls.Add(captionLabels[i]);

                //textcolumn
                switch (((WebQueryColumns)wcqCopy.Columns[i]).ColumnType)
                {
                    case "ClientQueryComboBoxColumn":
                        {
                            textcomboBox[i] = new InfoComboBox();
                            textcomboBox[i].RightToLeft = RightToLeft.No;
                            textcomboBox[i].Font = new Font(wcqCopy.Font.Name, fontsize, fontStyle);
                            textcomboBox[i].ForeColor = wcqCopy.TextColor;

                            textcomboBox[i].Location = new System.Drawing.Point(LocationX, LocationY);
                            textcomboBox[i].Name = "txtcbb" + ((WebQueryColumns)wcqCopy.Columns[i]).Column.ToString();
                            textcomboBox[i].Size = new System.Drawing.Size(((WebQueryColumns)wcqCopy.Columns[i]).Width, 20);
                            //this.splitContainer1.Panel1.Controls.Add(textcomboBox[i]);
                            this.Controls.Add(textcomboBox[i]);
                            break;
                        }
                    case "ClientQueryTextBoxColumn":
                        {
                            textTextBox[i] = new InfoTextBox();
                            textTextBox[i].Font =  new Font(wcqCopy.Font.Name, fontsize, fontStyle);
                            textTextBox[i].ForeColor = wcqCopy.TextColor;

                            textTextBox[i].Location = new System.Drawing.Point(LocationX, LocationY);
                            textTextBox[i].Name = "txttb" + ((WebQueryColumns)wcqCopy.Columns[i]).Column.ToString();
                            textTextBox[i].Size = new System.Drawing.Size(((WebQueryColumns)wcqCopy.Columns[i]).Width, 20);
                            //textTextBox[i].TextAlign = txtalign;
                            //this.splitContainer1.Panel1.Controls.Add(textTextBox[i]);
                            this.Controls.Add(textTextBox[i]);
                            break;
                        }
                    case "ClientQueryRefValColumn":
                        {
                            textRefValBox[i] = new InfoRefvalBox();
                            textRefValBox[i].Font = new Font(wcqCopy.Font.Name, fontsize, fontStyle);
                            textRefValBox[i].TextBoxForeColor = wcqCopy.TextColor;

                            textRefValBox[i].Location = new System.Drawing.Point(LocationX, LocationY);
                            textRefValBox[i].Name = "txtrvb" + (((WebQueryColumns)wcqCopy.Columns[i]).Column.ToString());
                            textRefValBox[i].Size = new System.Drawing.Size(((WebQueryColumns)wcqCopy.Columns[i]).Width, 20);
                            textRefValBox[i].RefVal = infoRefValQuery;
                          // textRefValBox[i].TextBoxTextAlign = txtalign;
                           // this.splitContainer1.Panel1.Controls.Add(textRefValBox[i]);
                            this.Controls.Add(textRefValBox[i]);
                            break;
                        }
                    case "ClientQueryCalendarColumn":
                        {
                            textDateTimePicker[i] = new InfoDateTimePicker();
                            //textDateTimePicker[i].Font = cqFormQuery.Font;
                            //textDateTimePicker[i].CalendarTrailingForeColor = cqFormQuery.TextColor;
                            textDateTimePicker[i].Location = new System.Drawing.Point(LocationX, LocationY);
                            textDateTimePicker[i].Name = "txtdtp" + ((WebQueryColumns)wcqCopy.Columns[i]).Column.ToString();
                            textDateTimePicker[i].Size = new System.Drawing.Size(((WebQueryColumns)wcqCopy.Columns[i]).Width, 20);

                            //this.splitContainer1.Panel1.Controls.Add(textDateTimePicker[i]);
                            this.Controls.Add(textDateTimePicker[i]);
                            break;
                        }
                    case "ClientQueryRefButtonColumn":
                        {
                            textTextBox[i] = new InfoTextBox();

                            textTextBox[i].Font = new Font(wcqCopy.Font.Name, fontsize, fontStyle);
                            textTextBox[i].ForeColor = wcqCopy.TextColor;

                            textTextBox[i].Location = new System.Drawing.Point(LocationX, LocationY);
                            textTextBox[i].Name = "txttb" + ((WebQueryColumns)wcqCopy.Columns[i]).Column.ToString();
                            textTextBox[i].Size = new System.Drawing.Size(((WebQueryColumns)wcqCopy.Columns[i]).Width, 20);
                            textButton[i] = new System.Windows.Forms.Button();
                            textButton[i].Size = new Size(20, 20);
                            textButton[i].Location = new Point(LocationX + ((WebQueryColumns)wcqCopy.Columns[i]).Width, LocationY);

                            //textTextBox[i].TextAlign = txtalign;
                            //this.splitContainer1.Panel1.Controls.Add(textTextBox[i]);
                            this.Controls.Add(textTextBox[i]);
                            this.Controls.Add(textButton[i]);
                            break;
                        }
                    default: break;
                }
            }

            //SYS_LANGUAGE language = CliSysMegLag.GetClientLanguage();
            SYS_LANGUAGE language = CliUtils.fClientLang;
            string caption = SysMsg.GetSystemMessage(language, "Srvtools", "InfoNavigator", "NavText");

            for (int i = 0; i < 7; i++)
            {
                caption = caption.Substring(caption.IndexOf(";") + 1);
            }

            btnOk.Name = "btnOk";
            btnOk.Text = caption.Substring(0, caption.IndexOf(";"));
            caption = caption.Substring(caption.IndexOf(";") + 1);
            btnOk.Location = new System.Drawing.Point((this.Width / 2 - 95), LocationY + 30);

            btnOk.Size = new System.Drawing.Size(75, 26);
            btnCancel.Name = "btnCancel";
            btnCancel.Text = caption.Substring(0, caption.IndexOf(";"));
            btnCancel.Location = new System.Drawing.Point((this.Width / 2 + 20), LocationY + 30);

            btnCancel.Size = new System.Drawing.Size(75, 26);

            //this.splitContainer1.Panel2.Controls.Add(btnOk);
            //this.splitContainer1.Panel2.Controls.Add(btnCancel);
            this.Controls.Add(btnOk);
            this.Controls.Add(btnCancel);
        }