(DISTFILES): Comment out a few missing files.
[mono-project.git] / mcs / class / ByteFX.Data / Common / SqlCommandEditorDlg.cs
blob7f1abeee674a86bf4062d1ac06ab3ea12a982ec7
1 // ByteFX.Data data access components for .Net
2 // Copyright (C) 2002-2003 ByteFX, Inc.
3 //
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License, or (at your option) any later version.
8 //
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
13 //
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 using System;
19 using System.Windows.Forms;
20 using System.Data;
21 using ByteFX.Data.MySqlClient;
23 namespace ByteFX.Data.Common
25 /// <summary>
26 /// Summary description for SqlCommandEditorDlg.
27 /// </summary>
28 internal class SqlCommandEditorDlg : System.Windows.Forms.Form
30 private System.Windows.Forms.TextBox sqlText;
31 private System.Windows.Forms.Button CancelBtn;
32 private System.Windows.Forms.Button OKBtn;
33 private System.Windows.Forms.Panel panel1;
34 private System.Windows.Forms.Splitter splitter1;
35 private System.Windows.Forms.DataGrid dataGrid;
36 private System.Windows.Forms.ContextMenu sqlMenu;
37 private System.Windows.Forms.MenuItem runMenuItem;
38 private IDbCommand command;
39 private System.Windows.Forms.DataGridTableStyle dataGridTableStyle1;
41 /// <summary>
42 /// Required designer variable.
43 /// </summary>
44 private System.ComponentModel.Container components = null;
46 public SqlCommandEditorDlg(object o)
48 command = (IDbCommand)o;
50 InitializeComponent();
53 /// <summary>
54 /// Clean up any resources being used.
55 /// </summary>
56 protected override void Dispose( bool disposing )
58 if( disposing )
60 if(components != null)
62 components.Dispose();
65 base.Dispose( disposing );
68 public string SQL
70 get { return sqlText.Text; }
71 set { sqlText.Text = value; }
74 #region Windows Form Designer generated code
75 /// <summary>
76 /// Required method for Designer support - do not modify
77 /// the contents of this method with the code editor.
78 /// </summary>
79 private void InitializeComponent()
81 this.sqlText = new System.Windows.Forms.TextBox();
82 this.sqlMenu = new System.Windows.Forms.ContextMenu();
83 this.runMenuItem = new System.Windows.Forms.MenuItem();
84 this.CancelBtn = new System.Windows.Forms.Button();
85 this.OKBtn = new System.Windows.Forms.Button();
86 this.panel1 = new System.Windows.Forms.Panel();
87 this.splitter1 = new System.Windows.Forms.Splitter();
88 this.dataGrid = new System.Windows.Forms.DataGrid();
89 this.dataGridTableStyle1 = new System.Windows.Forms.DataGridTableStyle();
90 this.panel1.SuspendLayout();
91 ((System.ComponentModel.ISupportInitialize)(this.dataGrid)).BeginInit();
92 this.SuspendLayout();
93 //
94 // sqlText
95 //
96 this.sqlText.ContextMenu = this.sqlMenu;
97 this.sqlText.Dock = System.Windows.Forms.DockStyle.Top;
98 this.sqlText.Location = new System.Drawing.Point(10, 10);
99 this.sqlText.Multiline = true;
100 this.sqlText.Name = "sqlText";
101 this.sqlText.Size = new System.Drawing.Size(462, 144);
102 this.sqlText.TabIndex = 0;
103 this.sqlText.Text = "";
105 // sqlMenu
107 this.sqlMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
108 this.runMenuItem});
110 // runMenuItem
112 this.runMenuItem.Index = 0;
113 this.runMenuItem.Text = "Run";
114 this.runMenuItem.Click += new System.EventHandler(this.runMenuItem_Click);
116 // CancelBtn
118 this.CancelBtn.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right);
119 this.CancelBtn.DialogResult = System.Windows.Forms.DialogResult.Cancel;
120 this.CancelBtn.Location = new System.Drawing.Point(400, 350);
121 this.CancelBtn.Name = "CancelBtn";
122 this.CancelBtn.TabIndex = 3;
123 this.CancelBtn.Text = "Cancel";
124 this.CancelBtn.Click += new System.EventHandler(this.CancelBtn_Click);
126 // OKBtn
128 this.OKBtn.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right);
129 this.OKBtn.DialogResult = System.Windows.Forms.DialogResult.OK;
130 this.OKBtn.Location = new System.Drawing.Point(316, 350);
131 this.OKBtn.Name = "OKBtn";
132 this.OKBtn.TabIndex = 4;
133 this.OKBtn.Text = "OK";
134 this.OKBtn.Click += new System.EventHandler(this.OKBtn_Click);
136 // panel1
138 this.panel1.Anchor = (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
139 | System.Windows.Forms.AnchorStyles.Left)
140 | System.Windows.Forms.AnchorStyles.Right);
141 this.panel1.Controls.AddRange(new System.Windows.Forms.Control[] {
142 this.splitter1,
143 this.dataGrid,
144 this.sqlText});
145 this.panel1.DockPadding.Bottom = 10;
146 this.panel1.DockPadding.Left = 10;
147 this.panel1.DockPadding.Right = 14;
148 this.panel1.DockPadding.Top = 10;
149 this.panel1.Location = new System.Drawing.Point(2, 2);
150 this.panel1.Name = "panel1";
151 this.panel1.Size = new System.Drawing.Size(486, 344);
152 this.panel1.TabIndex = 5;
154 // splitter1
156 this.splitter1.Dock = System.Windows.Forms.DockStyle.Top;
157 this.splitter1.Location = new System.Drawing.Point(10, 154);
158 this.splitter1.Name = "splitter1";
159 this.splitter1.Size = new System.Drawing.Size(462, 3);
160 this.splitter1.TabIndex = 3;
161 this.splitter1.TabStop = false;
163 // dataGrid
165 this.dataGrid.CaptionVisible = false;
166 this.dataGrid.DataMember = "";
167 this.dataGrid.Dock = System.Windows.Forms.DockStyle.Fill;
168 this.dataGrid.HeaderForeColor = System.Drawing.SystemColors.ControlText;
169 this.dataGrid.Location = new System.Drawing.Point(10, 154);
170 this.dataGrid.Name = "dataGrid";
171 this.dataGrid.Size = new System.Drawing.Size(462, 180);
172 this.dataGrid.TabIndex = 2;
173 this.dataGrid.TableStyles.AddRange(new System.Windows.Forms.DataGridTableStyle[] {
174 this.dataGridTableStyle1});
176 // dataGridTableStyle1
178 this.dataGridTableStyle1.AllowSorting = false;
179 this.dataGridTableStyle1.DataGrid = this.dataGrid;
180 this.dataGridTableStyle1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
181 this.dataGridTableStyle1.MappingName = "";
183 // SqlCommandEditorDlg
185 this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
186 this.ClientSize = new System.Drawing.Size(486, 384);
187 this.ControlBox = false;
188 this.Controls.AddRange(new System.Windows.Forms.Control[] {
189 this.panel1,
190 this.OKBtn,
191 this.CancelBtn});
192 this.DockPadding.Bottom = 10;
193 this.DockPadding.Left = 10;
194 this.DockPadding.Right = 12;
195 this.DockPadding.Top = 10;
196 this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
197 this.Name = "SqlCommandEditorDlg";
198 this.Text = "Query Builder";
199 this.panel1.ResumeLayout(false);
200 ((System.ComponentModel.ISupportInitialize)(this.dataGrid)).EndInit();
201 this.ResumeLayout(false);
204 #endregion
206 private void CancelBtn_Click(object sender, System.EventArgs e)
208 this.Close();
211 private void OKBtn_Click(object sender, System.EventArgs e)
213 this.Close();
216 private void runMenuItem_Click(object sender, System.EventArgs e)
218 if (command is MySqlCommand)
220 RunMySql();
224 private void RunMySql()
226 try
228 MySqlDataAdapter da = new MySqlDataAdapter((MySqlCommand)command);
229 command.CommandText = sqlText.Text;
230 command.Connection.Open();
231 DataTable dt = new DataTable();
232 da.Fill(dt);
233 dataGrid.DataSource = dt;
234 command.Connection.Close();
235 dataGrid.Expand(-1);
237 catch (Exception ex)
239 MessageBox.Show(ex.Message);