Пример #1
0
 void IWindowManager.ActivateChildForm(MxForm childForm)
 {
     if (childForm == null)
     {
         throw new ArgumentNullException("childForm");
     }
     if (!childForm.IsMdiChild || (childForm.MdiParent != this._mainForm))
     {
         throw new ArgumentException("The specified form is not an MDI child of the window", "childForm");
     }
     childForm.Activate();
 }
Пример #2
0
 void IWindowManager.ShowChildForm(MxForm childForm)
 {
     if (childForm == null)
     {
         throw new ArgumentNullException("childForm");
     }
     childForm.MdiParent = this._mainForm;
     childForm.Visible = true;
     childForm.Focus();
 }
Пример #3
0
 private void OnPreviewButtonClick(object sender, EventArgs e)
 {
     bool flag = false;
     string previewQuery = ((Microsoft.Matrix.Plugins.CodeWizards.Data.QueryBuilder) base.WizardForm).PreviewQuery;
     if (previewQuery != null)
     {
         IDbConnection connection = ((IDataProviderDatabase) this.Database).CreateConnection();
         try
         {
             IDbCommand selectCommand = ((IDataProviderDatabase) this.Database).CreateCommand(previewQuery);
             selectCommand.Connection = connection;
             if (this.Parameters.Count > 0)
             {
                 MxForm form = new MxForm(base.ServiceProvider);
                 form.StartPosition = FormStartPosition.CenterParent;
                 form.ShowInTaskbar = false;
                 form.MinimizeBox = false;
                 form.MaximizeBox = false;
                 form.FormBorderStyle = FormBorderStyle.FixedDialog;
                 form.Text = "Preview";
                 int height = (((this.Parameters.Count * 0x18) + 30) + 40) + 0x7c;
                 form.Size = new Size(0x176, height);
                 int y = 4;
                 Label label = new Label();
                 label.Text = "Enter test values for the following query:";
                 label.Location = new Point(12, y);
                 label.Size = new Size(350, 0x10);
                 form.Controls.Add(label);
                 y += 20;
                 MxTextBox box = new MxTextBox();
                 box.ReadOnly = true;
                 box.Text = previewQuery;
                 box.Multiline = true;
                 box.Location = new Point(12, y);
                 box.Size = new Size(350, 100);
                 form.Controls.Add(box);
                 y += 100;
                 this._previewTextBoxes = new HybridDictionary(true);
                 foreach (QueryParameter parameter in this.Parameters)
                 {
                     Label label2 = new Label();
                     label2.Text = parameter.OperandString;
                     label2.Location = new Point(12, y + 2);
                     label2.Size = new Size(150, 0x10);
                     MxTextBox box2 = new MxTextBox();
                     box2.Size = new Size(200, 20);
                     box2.Location = new Point(0xa2, y);
                     box2.FlatAppearance = true;
                     box2.AlwaysShowFocusCues = true;
                     y += 0x18;
                     this._previewTextBoxes[parameter.Name] = box2;
                     form.Controls.Add(label2);
                     form.Controls.Add(box2);
                 }
                 Button button = new Button();
                 button.Text = "OK";
                 button.Click += new EventHandler(this.OnOkButtonClick);
                 button.FlatStyle = FlatStyle.System;
                 button.Location = new Point(0xd0, y);
                 form.Controls.Add(button);
                 Button button2 = new Button();
                 button2.Text = "Cancel";
                 button2.Click += new EventHandler(this.OnCancelButtonClick);
                 button2.FlatStyle = FlatStyle.System;
                 button2.Location = new Point(0x120, y);
                 form.Controls.Add(button2);
                 form.AcceptButton = button;
                 form.CancelButton = button2;
                 if (form.ShowDialog() == DialogResult.OK)
                 {
                     flag = true;
                     foreach (QueryParameter parameter2 in this.Parameters)
                     {
                         object text = ((MxTextBox) this._previewTextBoxes[parameter2.Name]).Text;
                         IDataParameter parameter3 = ((IDataProviderDatabase) this.Database).CreateParameter(parameter2.Name, parameter2.Type);
                         parameter3.Value = text;
                         selectCommand.Parameters.Add(parameter3);
                     }
                 }
             }
             else
             {
                 flag = true;
             }
             if (flag)
             {
                 connection.Open();
                 DbDataAdapter adapter = ((IDataProviderDatabase) this.Database).CreateAdapter(selectCommand);
                 DataSet dataSet = new DataSet();
                 bool flag2 = false;
                 if (adapter.Fill(dataSet) > 0)
                 {
                     this._previewGrid.DataSource = dataSet.Tables[0];
                     if (dataSet.Tables[0].Rows.Count > 0)
                     {
                         flag2 = true;
                     }
                 }
                 if (!flag2)
                 {
                     MessageBox.Show(base.WizardForm, "The query returned no matches.", "Query Builder", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                 }
             }
             return;
         }
         catch (FormatException)
         {
             MessageBox.Show(base.WizardForm, "One of your parameters was formatted incorrectly, please try again.", "Query Builder", MessageBoxButtons.OK, MessageBoxIcon.Hand);
             return;
         }
         catch (Exception exception)
         {
             MessageBox.Show(base.WizardForm, "There was a problem executing your query.\r\nPlease check your query and database and try again. Details:\r\n" + exception.Message, "Query Builder", MessageBoxButtons.OK, MessageBoxIcon.Hand);
             return;
         }
         finally
         {
             connection.Close();
         }
     }
     MessageBox.Show(base.WizardForm, "Preview is not supported on this type of query", "Query Builder", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
 }