Example #1
0
 public void SetToTxt(InfoTextBox childTextBox)
 {
     infotxt = childTextBox;
 }
Example #2
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;
        }
        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);
        }