📄 frmqueryanaly.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using ControlSQLsrv2000.WSSQLsrv20004;
namespace ControlSQLsrv2000
{
/// <summary>
/// Summary description for frmQueryAnaly.
/// </summary>
public class frmQueryAnaly : System.Windows.Forms.Form
{
DataSet dsResults;
ConnectDB oConDb = new ConnectDB();
frmLogin.LoginInfo oLoginInfo;
private System.Windows.Forms.TextBox txtQuery;
private System.Windows.Forms.DataGrid dgResults;
private System.Windows.Forms.ToolBar tlbMenu;
private System.Windows.Forms.ImageList imgTollbar;
private Microsoft.WindowsCE.Forms.InputPanel inPanel;
private System.Windows.Forms.ToolBarButton tlBarButExecute;
public frmQueryAnaly()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(frmQueryAnaly));
this.txtQuery = new System.Windows.Forms.TextBox();
this.dgResults = new System.Windows.Forms.DataGrid();
this.tlbMenu = new System.Windows.Forms.ToolBar();
this.tlBarButExecute = new System.Windows.Forms.ToolBarButton();
this.imgTollbar = new System.Windows.Forms.ImageList();
this.inPanel = new Microsoft.WindowsCE.Forms.InputPanel();
//
// txtQuery
//
this.txtQuery.Location = new System.Drawing.Point(6, 6);
this.txtQuery.Multiline = true;
this.txtQuery.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
this.txtQuery.Size = new System.Drawing.Size(230, 74);
this.txtQuery.Text = "";
//
// dgResults
//
this.dgResults.Location = new System.Drawing.Point(7, 86);
this.dgResults.Size = new System.Drawing.Size(228, 176);
this.dgResults.Text = "Result";
//
// tlbMenu
//
this.tlbMenu.Buttons.Add(this.tlBarButExecute);
this.tlbMenu.ImageList = this.imgTollbar;
this.tlbMenu.ButtonClick += new System.Windows.Forms.ToolBarButtonClickEventHandler(this.tlbMenu_ButtonClick);
//
// tlBarButExecute
//
this.tlBarButExecute.ImageIndex = 0;
//
// imgTollbar
//
this.imgTollbar.Images.Add(((System.Drawing.Image)(resources.GetObject("resource"))));
this.imgTollbar.Images.Add(((System.Drawing.Image)(resources.GetObject("resource1"))));
this.imgTollbar.ImageSize = new System.Drawing.Size(16, 16);
//
// frmQueryAnaly
//
this.Controls.Add(this.dgResults);
this.Controls.Add(this.txtQuery);
this.Controls.Add(this.tlbMenu);
this.Text = "Query Analyser";
}
#endregion
public void init(frmLogin.LoginInfo oLogin)
{
oLoginInfo = oLogin;
this.Text = "Query Analyser - " + oLoginInfo.sDatabase;
oConDb.SetDBName (oLoginInfo.sDatabase);
this.Show();
}
private void tlbMenu_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
{
string sSql;
switch(tlbMenu.Buttons.IndexOf(e.Button))
{
case 0: //Execute button clicked
sSql = txtQuery.SelectedText;
if (sSql.Trim() == "")
{
MessageBox.Show("Select the query to execute!");
break;
}
dsResults = new DataSet();
dsResults = oConDb.ReturnResult(sSql);
dgResults.DataSource = dsResults.Tables[0];
break;
case 1:
//Cancel execution
break;
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -