コード例 #1
0
ファイル: ReportCreateor.cs プロジェクト: san90279/UK_OAS
 private static void CreateWinQueryField(Form FRootForm, TBlockFieldItem aFieldItem, string Range, InfoBindingSource ibs)
 {
     ClientQuery aClientQuery = FRootForm.Container.Components["clientQuery1"] as ClientQuery;
     if (aClientQuery != null)
     {
         if (ibs != null && aClientQuery != null)
             aClientQuery.BindingSource = ibs;
         if (aFieldItem.QueryMode != null && (aFieldItem.QueryMode.ToUpper() == "NORMAL" || aFieldItem.QueryMode.ToUpper() == "RANGE"))
         {
             QueryColumns qColumn = new QueryColumns();
             qColumn.Column = aFieldItem.DataField;
             qColumn.Caption = aFieldItem.Description;
             if (qColumn.Caption == "")
                 qColumn.Caption = aFieldItem.DataField;
             if (aFieldItem.QueryMode.ToUpper() == "NORMAL")
             {
                 if (aFieldItem.DataType == typeof(DateTime))
                     qColumn.Operator = "=";
                 if (aFieldItem.DataType == typeof(int) || aFieldItem.DataType == typeof(float) ||
                     aFieldItem.DataType == typeof(double) || aFieldItem.DataType == typeof(Int16))
                     qColumn.Operator = "=";
                 if (aFieldItem.DataType == typeof(String))
                     qColumn.Operator = "%";
             }
             if (aFieldItem.QueryMode.ToUpper() == "RANGE")
             {
                 qColumn.Condition = "And";
                 if (Range == "")
                 {
                     qColumn.Operator = "<=";
                     CreateWinQueryField(FRootForm, aFieldItem, ">=", null);
                 }
                 else
                 {
                     qColumn.Operator = Range;
                 }
             }
             switch (aFieldItem.ControlType.ToUpper())
             {
                 case "DATETIMEBOX":
                     qColumn.ColumnType = "ClientQueryCalendarColumn";
                     break;
                 case "CHECKBOX":
                     qColumn.ColumnType = "ClientQueryCheckBoxColumn";
                     break;
                 default:
                     qColumn.ColumnType = "ClientQueryTextBoxColumn";
                     break;
             }
             aClientQuery.Columns.Add(qColumn);
         }
     }
 }
コード例 #2
0
ファイル: fmExtClientWzdu.cs プロジェクト: san90279/UK_OAS
        private void CreateQueryField(TBlockFieldItem aFieldItem, String Range, InfoRefVal aRefVal, InfoBindingSource ibs)
        {
            if (aFieldItem.QueryMode == null)
                return;
            InfoNavigator navigator1 = FRootForm.Controls["infoNavigator1"] as InfoNavigator;
            if (navigator1 != null)
            {
                if (aFieldItem.QueryMode.ToUpper() == "NORMAL" || aFieldItem.QueryMode.ToUpper() == "RANGE")
                {
                    QueryField qField = new QueryField();
                    qField.FieldName = aFieldItem.DataField;
                    qField.Caption = aFieldItem.Description;
                    if (qField.Caption == "")
                        qField.Caption = aFieldItem.DataField;
                    if (aFieldItem.QueryMode.ToUpper() == "NORMAL")
                    {
                        if (aFieldItem.DataType == typeof(DateTime))
                            qField.Condition = "=";
                        if (aFieldItem.DataType == typeof(int) || aFieldItem.DataType == typeof(float) ||
                            aFieldItem.DataType == typeof(double) || aFieldItem.DataType == typeof(Int16))
                            qField.Condition = "=";
                        if (aFieldItem.DataType == typeof(String))
                            qField.Condition = "%";
                    }
                    if (aFieldItem.QueryMode.ToUpper() == "RANGE")
                    {
                        qField.Condition = "And";
                        if (Range == "")
                        {
                            qField.Condition = "<=";
                            CreateQueryField(aFieldItem, ">=", aRefVal, null);
                        }
                        else
                        {
                            qField.Condition = Range;
                        }
                    }
                    switch (aFieldItem.ControlType.ToUpper())
                    {
                        case "TEXTBOX":
                            qField.Mode = "TextBox";
                            break;
                        case "COMBOBOX":
                            qField.Mode = "ComboBox";
                            qField.RefVal = aRefVal;
                            break;
                        case "REFVALBOX":
                            qField.Mode = "RefVal";
                            qField.RefVal = aRefVal;
                            break;
                        case "DATETIMEBOX":
                            qField.Mode = "Calendar";
                            break;
                    }
                    navigator1.QueryFields.Add(qField);
                }
            }

            ClientQuery aClientQuery = FRootForm.Container.Components["clientQuery1"] as ClientQuery;
            if (aClientQuery != null)
            {
                if (ibs != null && aClientQuery != null)
                    aClientQuery.BindingSource = ibs;
                if (aFieldItem.QueryMode.ToUpper() == "NORMAL" || aFieldItem.QueryMode.ToUpper() == "RANGE")
                {
                    QueryColumns qColumn = new QueryColumns();
                    qColumn.Column = aFieldItem.DataField;
                    qColumn.Caption = aFieldItem.Description;
                    if (qColumn.Caption == "")
                        qColumn.Caption = aFieldItem.DataField;
                    if (aFieldItem.QueryMode.ToUpper() == "NORMAL")
                    {
                        if (aFieldItem.DataType == typeof(DateTime))
                            qColumn.Operator = "=";
                        if (aFieldItem.DataType == typeof(int) || aFieldItem.DataType == typeof(float) ||
                            aFieldItem.DataType == typeof(double) || aFieldItem.DataType == typeof(Int16))
                            qColumn.Operator = "=";
                        if (aFieldItem.DataType == typeof(String))
                            qColumn.Operator = "%";
                    }
                    if (aFieldItem.QueryMode.ToUpper() == "RANGE")
                    {
                        qColumn.Condition = "And";
                        if (Range == "")
                        {
                            qColumn.Operator = "<=";
                            CreateQueryField(aFieldItem, ">=", aRefVal, null);
                        }
                        else
                        {
                            qColumn.Operator = Range;
                            //qColumn.Condition = Range;
                        }
                    }
                    switch (aFieldItem.ControlType.ToUpper())
                    {
                        case "TEXTBOX":
                            qColumn.ColumnType = "ClientQueryTextBoxColumn";
                            break;
                        case "COMBOBOX":
                            qColumn.ColumnType = "ClientQueryComboBoxColumn";
                            qColumn.InfoRefVal = aRefVal;
                            break;
                        case "REFVALBOX":
                            qColumn.ColumnType = "ClientQueryRefValColumn";
                            qColumn.InfoRefVal = aRefVal;
                            break;
                        case "DATETIMEBOX":
                            qColumn.ColumnType = "ClientQueryCalendarColumn";
                            break;
                        case "CHECKBOX":
                            qColumn.ColumnType = "ClientQueryCheckBoxColumn";
                            break;
                    }
                    aClientQuery.Columns.Add(qColumn);
                }
            }
        }
コード例 #3
0
ファイル: ClientQuery.cs プロジェクト: san90279/UK_OAS
 private string GetPropertyName(QueryColumns column)
 {
     string propertyname = string.Empty;
     switch (column.ColumnType)
     {
         case "ClientQueryTextBoxColumn":
         case "ClientQueryRefButtonColumn":
             propertyname = "Text"; break;
         case "ClientQueryComboBoxColumn": propertyname = "SelectedValue"; break;
         case "ClientQueryRefValColumn": propertyname = "TextBoxSelectedValue"; break;
         case "ClientQueryCalendarColumn": propertyname = "Value"; break;
         case "ClientQueryCheckBoxColumn": propertyname = "Checked"; break;
         case "ClientQueryDateTimeBoxColumn": propertyname = "Value"; break;
         default: break;
     }
     return propertyname;
 }
コード例 #4
0
ファイル: ClientQuery.cs プロジェクト: san90279/UK_OAS
 private void SetControlDefaultValue(QueryColumns column, Control control, string propertyname)
 {
     PropertyInfo pi = control.GetType().GetProperty(propertyname);
     if (pi != null)
     {
         if (column.DefaultMode == QueryColumns.DefaultModeType.Initial)
         {
             object value = CliUtils.GetValue(column.DefaultValue, this.OwnerComp as InfoForm);
             if (value != null && value.ToString().Length > 0)
             {
                 if (control is DateTimePicker)
                 {
                     (control as DateTimePicker).Checked = true;
                 }
                 else if (control is InfoDateTimeBox)
                 {
                     (control as InfoDateTimeBox).IsEmpty = false;
                 }
                 try
                 {
                     pi.SetValue(control, Convert.ChangeType(value, pi.PropertyType), null);
                 }
                 catch { }
             }
         }
         else
         {
             control.Enter += delegate(object sender, EventArgs e)
             {
                 object value = CliUtils.GetValue(column.DefaultValue, this.OwnerComp as InfoForm);
                 if (value != null && value.ToString().Length > 0)
                 {
                     object controlvalue = pi.GetValue(control, null);
                     if (control is DateTimePicker && !(control as DateTimePicker).Checked)
                     {
                         (control as DateTimePicker).Checked = true;
                         controlvalue = string.Empty;
                     }
                     else if (control is InfoDateTimeBox)
                     {
                         (control as InfoDateTimeBox).IsEmpty = false;
                     }
                     if (controlvalue == null || controlvalue.ToString().Length == 0)
                     {
                         try
                         {
                             pi.SetValue(control, Convert.ChangeType(value, pi.PropertyType), null);
                         }
                         catch { }
                     }
                 }
             };
         }
     }
 }
コード例 #5
0
ファイル: ClientQuery.cs プロジェクト: san90279/UK_OAS
 private Label CreateLabel(QueryColumns column, Point location)
 {
     Label label = new Label();
     ActivePanel.Controls.Add(label);
     label.AutoSize = true;
     label.TextAlign = ContentAlignment.MiddleRight;
     label.Name = "caplbl" + column.Column;
     label.Text = column.Caption;
     label.BackColor = Color.Transparent;
     label.ForeColor = this.ForeColor;
     label.Font = this.Font;
     label.Location = new Point(location.X - label.PreferredWidth, location.Y + 4);
     return label;
 }
コード例 #6
0
ファイル: ClientQuery.cs プロジェクト: san90279/UK_OAS
        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;
        }
コード例 #7
0
ファイル: InfoNavigator.cs プロジェクト: san90279/UK_OAS
        private ClientQuery CopyQueryFileds(int columncount)
        {
            ClientQuery cq = new ClientQuery();
            cq.OwnerComp = (IDataModule)this.FindForm();
            if (this.QueryFields.Count > 0)
            {
                InfoBindingSource ibs = null;
                if (this.ViewBindingSource != null)
                {
                    ibs = this.ViewBindingSource;
                }
                else if (this.BindingSource != null)
                {
                    ibs = this.BindingSource;
                }
                if (ibs == null)
                {
                    throw new Exception("Can't find InfoBindingSource");
                }
                cq.BindingSource = ibs;
                cq.GapVertical = 8;
                cq.KeepCondition = this.QueryKeepCondition;
                cq.Margin = this.QueryMargin;
                cq.Font = this.QueryFont;
                int columnindex = 0;
                //int index = 0;
                foreach (QueryField qf in this.QueryFields)
                {
                    QueryColumns qc = new QueryColumns(qf.Name, true, qf.FieldName, qf.Caption, 120);
                    //if (PreQueryValue.Count > 0)
                    //{
                    //    qc.Text = PreQueryValue[index];
                    //    index++;
                    //}

                    if (columnindex == columncount)
                    {
                        qc.NewLine = true;
                        columnindex = 1;
                    }
                    else
                    {
                        qc.NewLine = false;
                        columnindex++;
                    }
                    qc.DefaultValue = qf.DefaultValue;
                    if (qf.Mode == "")
                    {
                        qc.ColumnType = "ClientQueryTextBoxColumn";
                    }
                    else
                    {
                        qc.ColumnType = "ClientQuery" + qf.Mode + "Column";
                    }
                    if (qf.Condition == "")
                    {
                        Type tp = (ibs.GetDataSource() as InfoDataSet).RealDataSet.Tables[ibs.DataMember].Columns[qf.FieldName].DataType;
                        if (tp == typeof(string))
                        {
                            qc.Operator = "%";
                        }

                        else
                        {
                            qc.Operator = "=";
                        }
                    }
                    else
                    {
                        qc.Operator = qf.Condition;
                    }
                    qc.Width = qf.Width;
                    qc.InfoRefVal = qf.RefVal;
                    qc.InfoRefButtonAutoPanel = qf.RefButtonAutoPanel;
                    qc.InfoRefButtonPanel = qf.RefButtonPanel;
                    qc.IsNvarChar = qf.IsNvarChar;
                    cq.Columns.Add(qc);
                }
            }
            else
            {
                throw new Exception("No QueryFields in InfoNavigator");
            }
            return cq;
        }
コード例 #8
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            int columncount = dgvClientQuery.Rows.Count;

            QueryColumns[] qc = new QueryColumns[columncount];
            InfoRefVal[] refval = new InfoRefVal[columncount];

            for (int i = 0; i < columncount - 1; i++)
            {
                for (int j = 0; j < 9; j++)
                {
                    if (dgvClientQuery.Rows[i].Cells[j].Value == null)
                    {
                        if (dgvClientQuery.Columns[j].Name != "DefaultValue")
                        {
                            MessageBox.Show(string.Format("Record {0}: Can't be null in {1}", i + 1, dgvClientQuery.Columns[j].HeaderText));
                            return;
                        }
                    }
                }

                if (dgvClientQuery.Rows[i].Cells["InfoRefVal"].Value != null && dgvClientQuery.Rows[i].Cells["InfoRefVal"].Value.ToString() != "(None)")
                {
                    if ((dgvClientQuery.Rows[i].Cells["ColumnType"].Value.ToString() != "ClientQueryComboBoxColumn")
                        && (dgvClientQuery.Rows[i].Cells["ColumnType"].Value.ToString() != "ClientQueryRefValColumn"))
                    {
                        MessageBox.Show(string.Format("Record {0} :\nInfoRefval can be set only when\ncolumntype is combobox & refval.",i + 1));
                        return;
                    }
                    else
                    {
                        try
                        {
                            refval[i] = (InfoRefVal)ict.Components[dgvClientQuery.Rows[i].Cells["InfoRefVal"].Value.ToString()];
                        }
                        catch
                        {
                            MessageBox.Show(string.Format("InfoRefVal {0} doesn't exist", dgvClientQuery.Rows[i].Cells["InfoRefVal"].Value.ToString()));
                            return;
                        }
                    }

                }
            }

            try
            {
                cqeditor.BindingSource = (InfoBindingSource)ict.Components[cmbbindingsource.Text];
                cqeditor.Columns.Clear();
            }
            catch
            {

            }
            for (int i = 0; i < columncount - 1; i++)
            {
                qc[i] = new QueryColumns();
                qc[i].setcolumn(dgvClientQuery.Rows[i].Cells["Column"].Value.ToString());
                qc[i].Caption = dgvClientQuery.Rows[i].Cells["Caption"].Value.ToString();
                qc[i].ColumnType = dgvClientQuery.Rows[i].Cells["ColumnType"].Value.ToString();
                qc[i].Condition = dgvClientQuery.Rows[i].Cells["Condition"].Value.ToString();
                if (dgvClientQuery.Rows[i].Cells["DefaultValue"].Value != null)
                {
                    qc[i].DefaultValue = dgvClientQuery.Rows[i].Cells["DefaultValue"].Value.ToString();
                }
                else
                {
                    qc[i].DefaultValue = "";
                }
                qc[i].Operator = dgvClientQuery.Rows[i].Cells["Operator"].Value.ToString();
                qc[i].NewLine = Boolean.Parse(dgvClientQuery.Rows[i].Cells["NewLine"].Value.ToString());
                qc[i].TextAlign = dgvClientQuery.Rows[i].Cells["TextAlign"].Value.ToString();
                try
                {
                    qc[i].Width = int.Parse(dgvClientQuery.Rows[i].Cells["TextWidth"].Value.ToString());
                    if(qc[i].Width <= 0)
                    {
                        MessageBox.Show(string.Format("Record {0}: Width should be an positive integer", i + 1));
                        return;
                    }
                }
                catch
                {
                    MessageBox.Show(string.Format("Record {0}: Width should be an positive integer", i + 1));
                    return;
                }
                if (dgvClientQuery.Rows[i].Cells["InfoRefVal"].Value != null && dgvClientQuery.Rows[i].Cells["InfoRefVal"].Value.ToString() != "(None)")
                {
                    qc[i].InfoRefVal = refval[i];
                }
                if (dgvClientQuery.Rows[i].Cells["ExternalRefval"].Value != null)
                {
                    qc[i].ExternalRefVal = dgvClientQuery.Rows[i].Cells["ExternalRefval"].Value.ToString();
                }
                if (dgvClientQuery.Rows[i].Cells["ColumnVisible"].Value != null)
                {
                    qc[i].Visible = (bool)dgvClientQuery.Rows[i].Cells["ColumnVisible"].Value;
                }
                cqeditor.Columns.Add(qc[i]);
            }

            //MessageBox.Show(string.Format("cqeditor has {0} columns", cqeditor.Columns.Count));

            //new add
            IComponentChangeService ComponentChangeService =
                this.DesignerHost.GetService(typeof(IComponentChangeService)) as IComponentChangeService;

            object oldValue = null;
            object newValue = null;

            //BindingSource

            PropertyDescriptor descBindingSource = TypeDescriptor.GetProperties(this.cqold)["BindingSource"];
            ComponentChangeService.OnComponentChanging(this.cqold, descBindingSource);
            oldValue = cqold.BindingSource;
            cqold.BindingSource = cqeditor.BindingSource;
            newValue = cqold.BindingSource;
            ComponentChangeService.OnComponentChanged(this.cqold, descBindingSource, oldValue, newValue);

            // Columns
            PropertyDescriptor descColumns = TypeDescriptor.GetProperties(this.cqold)["Columns"];
            ComponentChangeService.OnComponentChanging(this.cqold, descColumns);
            oldValue = cqold.Columns;
            cqold.Columns = cqeditor.Columns;
            newValue = cqold.Columns;
            ComponentChangeService.OnComponentChanged(this.cqold, descColumns, oldValue, newValue);

            this.Close();
        }
コード例 #9
0
        private void btnPreview_Click(object sender, EventArgs e)
        {
            int columncount = dgvClientQuery.Rows.Count;

            QueryColumns[] qc = new QueryColumns[columncount];
            InfoRefVal[] refval = new InfoRefVal[columncount];

            for (int i = 0; i < columncount - 1; i++)
            {
                for (int j = 0; j < 8; j++)
                {
                    if (dgvClientQuery.Rows[i].Cells[j].Value == null)
                    {
                        if (dgvClientQuery.Columns[j].Name != "DefaultValue")
                        {
                            MessageBox.Show(string.Format("Record {0}: Can't be null in {1}", i + 1, dgvClientQuery.Columns[j].HeaderText));
                            return;
                        }
                    }
                }

                if (dgvClientQuery.Rows[i].Cells["InfoRefVal"].Value != null && dgvClientQuery.Rows[i].Cells["InfoRefVal"].Value.ToString() != "(None)")
                {
                    if ((dgvClientQuery.Rows[i].Cells["ColumnType"].Value.ToString() != "ClientQueryComboBoxColumn")
                        && (dgvClientQuery.Rows[i].Cells["ColumnType"].Value.ToString() != "ClientQueryRefValColumn"))
                    {
                        MessageBox.Show(string.Format("Record {0} :\nInfoRefval can be set only when\ncolumntype is combobox & refval.", i + 1));
                        return;
                    }
                    else
                    {
                        try
                        {
                            refval[i] = (InfoRefVal)ict.Components[dgvClientQuery.Rows[i].Cells["InfoRefVal"].Value.ToString()];
                        }
                        catch
                        {
                            MessageBox.Show(string.Format("InfoRefVal {0} doesn't exist", dgvClientQuery.Rows[i].Cells["InfoRefVal"].Value.ToString()));
                            return;
                        }
                    }

                }
            }

            try
            {
                cqpreivewer.BindingSource = (InfoBindingSource)ict.Components[cmbbindingsource.Text];
                cqpreivewer.Columns.Clear();
            }
            catch
            {

            }
            for (int i = 0; i < columncount - 1; i++)
            {
                qc[i] = new QueryColumns();
                qc[i].setcolumn(dgvClientQuery.Rows[i].Cells["Column"].Value.ToString());
                qc[i].Caption = dgvClientQuery.Rows[i].Cells["Caption"].Value.ToString();
                if (dgvClientQuery.Rows[i].Cells["DefaultValue"].Value != null)
                {
                    qc[i].DefaultValue = dgvClientQuery.Rows[i].Cells["DefaultValue"].Value.ToString();
                }
                else
                {
                    qc[i].DefaultValue = "";
                }
                qc[i].ColumnType = dgvClientQuery.Rows[i].Cells["ColumnType"].Value.ToString();
                qc[i].Condition = dgvClientQuery.Rows[i].Cells["Condition"].Value.ToString();
                qc[i].Operator = dgvClientQuery.Rows[i].Cells["Operator"].Value.ToString();
                qc[i].NewLine = Boolean.Parse(dgvClientQuery.Rows[i].Cells["NewLine"].Value.ToString());
                qc[i].TextAlign = dgvClientQuery.Rows[i].Cells["TextAlign"].Value.ToString();
                try
                {
                    qc[i].Width = int.Parse(dgvClientQuery.Rows[i].Cells["TextWidth"].Value.ToString());
                    if (qc[i].Width <= 0)
                    {
                        MessageBox.Show(string.Format("Record {0}: Width should be an positive integer", i + 1));
                        return;
                    }
                }
                catch
                {
                    MessageBox.Show(string.Format("Record {0}: Width should be an positive integer", i + 1));
                    return;
                }
                if (dgvClientQuery.Rows[i].Cells["InfoRefVal"].Value != null && dgvClientQuery.Rows[i].Cells["InfoRefVal"].Value.ToString() != "(None)")
                {
                    qc[i].InfoRefVal = refval[i];
                }
                cqpreivewer.Columns.Add(qc[i]);
            }
            cqpreivewer.Caption = cqold.Caption;
            cqpreivewer.Margin = cqold.Margin;
            cqpreivewer.Font = cqold.Font;
            cqpreivewer.ForeColor = cqold.ForeColor;
            cqpreivewer.TextColor = cqold.TextColor;

            fcq = new frmClientQuery(cqpreivewer,true);
            fcq.btnOk.Enabled = false;
            fcq.btnCancel.Enabled = false;
            fcq.ShowDialog();
        }