Beispiel #1
0
 public InfoRefPanel(InfoRefButton irb)
 {
     InitializeComponent();
     refButton = irb;
     if (refButton.SearchColumns.Count == 0)
     {
         this.pSearch.Visible = false;
     }
     else
     {
         foreach (RefButtonSearchColumn item in refButton.SearchColumns)
         {
             label1.Text += String.Format("{0},", item.ColumnHeader);
         }
         label1.Text = label1.Text.Remove(label1.Text.Length - 1);
     }
 }
Beispiel #2
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;
        }
Beispiel #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());
            }
        }
Beispiel #4
0
        private Control CreateControl(QueryColumns column, Point location)
        {
            Control control = null;
            int height = 20;
            Point ctlocation = location;

            DataTable table = (this.BindingSource.DataSource as InfoDataSet).RealDataSet.Tables[this.BindingSource.DataMember];
            if (table == null)
            {
                throw new Exception(string.Format("Table: {0} does not exsit in dataset", this.BindingSource.DataMember));
            }

            switch (column.ColumnType)
            {
                case "ClientQueryTextBoxColumn":
                    {
                        control = new InfoTextBox();

                        (control as TextBox).TextAlign = (HorizontalAlignment)Enum.Parse(typeof(HorizontalAlignment), column.TextAlign);
                        (control as InfoTextBox).EnterEnable = true;
                        if (!table.Columns.Contains(column.Column))
                        {
                            throw new Exception(string.Format("Column: {0} does not exist in dataset", column.Column));
                        }
                        (control as TextBox).Tag = table.Columns[column.Column].DataType;
                        (control as TextBox).KeyPress += delegate(object sender, KeyPressEventArgs e)
                        {
                            Type columnType = (Type)(sender as Control).Tag;
                            if (columnType == typeof(int) || columnType == typeof(uint) || columnType == typeof(byte) || columnType == typeof(Int16))
                            {
                                if (!char.IsDigit(e.KeyChar) && !e.KeyChar.Equals('\b'))
                                {
                                    e.KeyChar = (char)0;
                                }
                            }
                            else if (columnType == typeof(float) || columnType == typeof(double) || columnType == typeof(decimal))
                            {
                                if (!char.IsDigit(e.KeyChar) && !e.KeyChar.Equals('\b') && !e.KeyChar.Equals('.'))
                                {
                                    e.KeyChar = (char)0;
                                }
                            }
                        };
                        ActivePanel.Controls.Add(control);
                        break;
                    }
                case "ClientQueryComboBoxColumn":
                    {
                        control = new ComboBox();
                        (control as ComboBox).DropDownStyle = ComboBoxStyle.DropDownList;
                        (control as ComboBox).DataSource = column.InfoRefVal.DataSource;
                        (control as ComboBox).DisplayMember = column.InfoRefVal.DisplayMember;
                        (control as ComboBox).ValueMember = column.InfoRefVal.ValueMember;
                        (control as ComboBox).KeyDown += delegate(object sender, KeyEventArgs e)
                        {
                            if (e.KeyData == Keys.Delete)
                            {
                                (sender as ComboBox).SelectedIndex = -1;
                            }
                        };
                        ActivePanel.Controls.Add(control);
                        break;
                    }
                case "ClientQueryRefValColumn":
                    {
                        control = new InfoRefvalBox();
                        (control as InfoRefvalBox).TextBoxTextAlign = (HorizontalAlignment)Enum.Parse(typeof(HorizontalAlignment), column.TextAlign);
                        (control as InfoRefvalBox).TextBoxForeColor = this.TextColor;
                        (control as InfoRefvalBox).TextBoxFont = this.Font;
                        (control as InfoRefvalBox).RefVal = column.InfoRefVal;
                        (control as InfoRefvalBox).ExternalRefVal = column.ExternalRefVal;
                        (control as InfoRefvalBox).EnterEnable = true;
                        height = 22;
                        ActivePanel.Controls.Add(control);
                        break;
                    }
                case "ClientQueryCalendarColumn":
                    {
                        control = new DateTimePicker();
                        (control as DateTimePicker).ShowCheckBox = true;
                        (control as DateTimePicker).Checked = false;
                        ActivePanel.Controls.Add(control);
                        break;
                    }
                case "ClientQueryCheckBoxColumn":
                    {
                        control = new CheckBox();
                        (control as CheckBox).Checked = false;
                        control.BackColor = Color.Transparent;
                        height = 13;
                        ctlocation.Offset(0, 3);
                        ActivePanel.Controls.Add(control);
                        break;
                    }
                case "ClientQueryRefButtonColumn":
                    {
                        InfoTranslate itRefButton = new InfoTranslate();
                        if (column.InfoRefVal.SelectAlias != String.Empty && column.InfoRefVal.SelectCommand != String.Empty)
                        {
                            InfoDataSet idsRefButton = new InfoDataSet();
                            idsRefButton.RemoteName = "GLModule.cmdRefValUse";
                            idsRefButton.Execute(column.InfoRefVal.SelectCommand, column.InfoRefVal.SelectAlias, true);
                            InfoBindingSource ibsRefButton = new InfoBindingSource();
                            ibsRefButton.DataSource = idsRefButton;
                            ibsRefButton.DataMember = "cmdRefValUse";
                            itRefButton.BindingSource = ibsRefButton;
                        }
                        else
                        {
                            itRefButton.BindingSource = column.InfoRefVal.DataSource as InfoBindingSource;
                        }
                        TranslateRefReturnFields trrf2 = new TranslateRefReturnFields();
                        trrf2.ColumnName = column.InfoRefVal.ValueMember;
                        trrf2.DisplayColumnName = column.InfoRefVal.DisplayMember;
                        itRefButton.RefReturnFields.Add(trrf2);

                        control = new InfoTextBox();
                        control.Name = "txt" + this.Columns.GetItemIndex(column);
                        (control as TextBox).TextAlign = (HorizontalAlignment)Enum.Parse(typeof(HorizontalAlignment), column.TextAlign);
                        (control as InfoTextBox).EnterEnable = true;

                        InfoRefButton ifb2 = new InfoRefButton();
                        if (column.InfoRefButtonAutoPanel)
                            ifb2.autoPanel = true;
                        else
                        {
                            ifb2.autoPanel = false;
                            ifb2.panel = column.InfoRefButtonPanel;
                        }
                        ifb2.infoTranslate = itRefButton;
                        RefButtonMatch rbm2 = new RefButtonMatch();
                        rbm2.matchColumnName = control.Name;
                        ifb2.refButtonMatchs.Add(rbm2);
                        ifb2.Name = column.Column + "ClientQueryValue1InfoRefButton";
                        ifb2.Text = "...";
                        ifb2.Width = 20;
                        ifb2.Location = new Point(ctlocation.X + control.Width, ctlocation.Y);
                        ActivePanel.Controls.Add(ifb2);
                        ActivePanel.Controls.Add(control);
                        break;
                    }
                case "ClientQueryDateTimeBoxColumn":
                    {
                        control = new InfoDateTimeBox();
                        if (column.InfoDateTimeBox != null)
                        {
                            (control as InfoDateTimeBox).Format = column.InfoDateTimeBox.Format;
                            (control as InfoDateTimeBox).BackColor = column.InfoDateTimeBox.BackColor;
                            (control as InfoDateTimeBox).ForeColor = column.InfoDateTimeBox.ForeColor;
                            (control as InfoDateTimeBox).RocYear = column.InfoDateTimeBox.RocYear;
                            (control as InfoDateTimeBox).ShowPicker = column.InfoDateTimeBox.ShowPicker;

                        }
                        (control as InfoDateTimeBox).EnterEnable = true;
                        ActivePanel.Controls.Add(control);
                        break;
                    }
                default:
                    {
                        throw new ArgumentException(string.Format("{0} is not valid clientquery columntype", column.ColumnType));
                    }
            }

            if (control is ComboBox)//should set index after add control
            {
                (control as ComboBox).SelectedIndex = -1;
                //if (column.DefaultMode == QueryColumns.DefaultModeType.Focused)
                //{
                (control as ComboBox).SelectedIndex = -1;//why...can not find reason
                //}
            }
            SetControlDefaultValue(column, control, GetPropertyName(column));
            //common property
            control.Name = "txt" + this.Columns.GetItemIndex(column);
            control.TabIndex = this.Columns.GetItemIndex(column) + 2;
            control.Size = new Size(column.Width, height);
            control.ForeColor = this.TextColor;
            control.Font = this.Font;
            control.Location = ctlocation;
            return control;
        }
 protected override void OnClick(DataGridViewCellEventArgs e)
 {
     base.OnClick(e);
     InfoDataGridViewRefButtonColumn refButtonColumn = this.OwningColumn as InfoDataGridViewRefButtonColumn;
     InfoRefButton refButton = new InfoRefButton();
     refButton.panel = this.Panel;
     refButton.infoTranslate = this.InfoTranslate;
     refButton.autoPanel = this.AutoPanel;
     refButton.multiSelect = this.MultiSelect;
     innerPanel = new InfoRefPanel(refButton);
     innerPanel.AfterOK += new EventHandler<AfterOKEventArgs>(innerPanel_AfterOK);
     innerPanel.ShowDialog();
 }