📄 dbquery.cs
字号:
string text = this._dragObject.Parent.Parent.Parent.Text;
string dbname = this._dragObject.Parent.Parent.Text;
string tablename = this._dragObject.Text;
string sQLSelect = ObjHelper.CreatDsb(text).GetSQLSelect(dbname, tablename);
this.txtContent.ActiveTextAreaControl.TextArea.InsertString(sQLSelect);
}
private void menuItemWhere_Click(object sender, EventArgs e)
{
}
private void miAddToSnippet_Click(object sender, EventArgs e)
{
new FrmAddToSnippet(this.txtContent.Text).ShowDialog(this);
}
private void miAllSel_Click(object sender, EventArgs e)
{
this.txtContent.Select(0, this.txtContent.Text.Length);
}
private void miCopy_Click(object sender, EventArgs e)
{
this.Copy();
}
private void miCut_Click(object sender, EventArgs e)
{
this.txtContent.Cut();
}
private void miGoToAnyRererence_Click(object sender, EventArgs e)
{
this.GoToReferenceAny();
}
private void miGoToDefinision_Click(object sender, EventArgs e)
{
this.GoToDefenition();
}
private void miGoToRererence_Click(object sender, EventArgs e)
{
this.GoToReferenceObject();
}
private void miMakeCurrentQueryCS_Click(object sender, EventArgs e)
{
try
{
this.toolStripStatusLabel1.Text = "正在生成......";
string text = this.txtContent.Text;
if (this.txtContent.SelectedText.Length > 1)
{
text = this.txtContent.SelectedText;
}
else
{
text = this.txtContent.Text;
}
if (text.Trim() == "")
{
this.toolStripStatusLabel1.Text = "查询语句为空!";
}
else
{
StringPlus plus = new StringPlus();
plus.AppendLine("StringBuilder strSql=new StringBuilder();");
if (text.IndexOf("\r\n") > 0)
{
foreach (string str2 in text.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries))
{
if (str2.Trim() != "")
{
plus.AppendLine("strSql.Append(\"" + str2 + " \");");
}
}
}
else
{
plus.AppendLine("strSql.Append(\"" + text + " \");");
}
this.mainfrm.AddTabPage("Class1.cs", new CodeEditor(plus.Value, "cs", ""));
this.toolStripStatusLabel1.Text = "成功完成。";
}
}
catch (Exception exception)
{
LogInfo.WriteLog(exception);
this.toolStripStatusLabel1.Text = "执行失败!";
}
}
private void miMakeCurrentQuerySQL_Click(object sender, EventArgs e)
{
try
{
MainForm mdiParentForm = (MainForm) this.MdiParentForm;
string longServername = ((DbView) Application.OpenForms["DbView"]).GetLongServername();
if (longServername.Length < 1)
{
this.toolStripStatusLabel1.Text = "没有选择任何服务器!";
}
else
{
string text = mdiParentForm.toolComboBox_DB.Text;
if (text.Length < 1)
{
this.toolStripStatusLabel1.Text = "没有选择可执行的数据库!";
}
else
{
this.toolStripStatusLabel1.Text = "正在生成......";
string selectedText = this.txtContent.Text;
if (this.txtContent.SelectedText.Length > 1)
{
selectedText = this.txtContent.SelectedText;
}
else
{
selectedText = this.txtContent.Text;
}
if (selectedText.Trim() == "")
{
this.toolStripStatusLabel1.Text = "查询语句为空!";
}
else
{
string strCode = ObjHelper.CreatDsb(longServername).CreateTabScriptBySQL(text, selectedText.Trim());
this.mainfrm.AddTabPage("SQL1.sql", new CodeEditor(strCode, "sql", ""));
this.toolStripStatusLabel1.Text = "成功完成。";
}
}
}
}
catch (Exception exception)
{
LogInfo.WriteLog(exception);
this.toolStripStatusLabel1.Text = "执行失败!";
}
}
private void miOptions_Click(object sender, EventArgs e)
{
}
private void miPaste_Click(object sender, EventArgs e)
{
this.Paste();
}
private void miRunCurrentQuery_Click(object sender, EventArgs e)
{
this.RunCurrentQuery();
}
private void miSnippet_Click(object sender, EventArgs e)
{
string text = ((SnippetMenuItem) sender).statement.Replace(@"\n", "\n").Replace(@"\t", "\t");
int selectionStart = this.txtContent.SelectionStart;
this.txtContent.Document.Replace(selectionStart, 0, text);
if (text.IndexOf("{}") > -1)
{
selectionStart = (selectionStart + text.IndexOf("{}")) + 1;
}
this.txtContent.SetPosition(selectionStart);
this.txtContent.Refresh();
}
public void miValidateCurrentQuery_Click(object sender, EventArgs e)
{
this.txtContent.ResumeLayout();
string content = this.Content;
if (this.txtContent.SelectedText.Length > 0)
{
string newValue = "SET NOEXEC ON;" + this.txtContent.SelectedText + ";SET NOEXEC OFF;";
int length = newValue.Length;
int index = this.Content.IndexOf(this.txtContent.SelectedText);
if (((this.Content.IndexOf("SET NOEXEC ON", 0) < 0) && (index >= 0)) && (length > 0))
{
this.Content = this.Content.Replace(this.txtContent.SelectedText, newValue);
this.txtContent.Select(index, length);
}
}
else
{
this.Content = "SET NOEXEC ON;" + this.Content + ";SET NOEXEC OFF;\n\n";
}
this.RunQuery();
this.Content = content;
this.txtContent.ResumeLayout();
}
public void Paste()
{
this.txtContent.Paste();
}
public void PrintOutPut(bool preview)
{
}
public void PrintPageSetUp()
{
}
public void PrintStatement(bool preview)
{
}
private void qcTextEditor_KeyPressEvent(object sender, KeyEventArgs e)
{
e.ToString();
this.txtContent.ActiveTextAreaControl.Caret.Line.ToString();
this.txtContent.ActiveTextAreaControl.Caret.Column.ToString();
if (e.Alt && (e.KeyValue == 0x58))
{
e.Handled = false;
this.RunQuery();
}
else
{
Keys keyCode = e.KeyCode;
if (e.KeyCode == Keys.F5)
{
this.RunQuery();
}
if (((((Control.ModifierKeys & Keys.Control) == Keys.Control) && (e.KeyValue == 0x20)) || (e.KeyValue == 190)) && (e.KeyValue != 190))
{
e.Handled = true;
}
if (((Control.ModifierKeys & Keys.Control) != Keys.Control) || (e.KeyValue != 0x43))
{
int keyValue = e.KeyValue;
}
}
}
private void qcTextEditor_MouseUp(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
this.txtContent.GetCurrentWord();
IDataObject dataObject = Clipboard.GetDataObject();
MenuItem item = null;
MenuItem item2 = null;
MenuItem item3 = null;
MenuItem item4 = null;
MenuItem item5 = new MenuItem("复制 (&C)");
MenuItem item6 = new MenuItem("剪切 (&T)");
MenuItem item7 = new MenuItem("粘贴 (&P)");
MenuItem item8 = new MenuItem("全选 (&A)");
new MenuItem("-");
MenuItem item9 = new MenuItem("转到定义 (&G)");
MenuItem item10 = new MenuItem("转到对象引用 (&R)");
MenuItem item11 = new MenuItem("转到所有对象引用");
MenuItem item12 = new MenuItem("-");
if (this.txtContent.SelectedText.Length > 0)
{
item = new MenuItem("运行当前选择");
item2 = new MenuItem("验证当前选择");
item3 = new MenuItem("生成当前选择SQL语句的拼接代码");
item4 = new MenuItem("生成当前选择查询结果的数据脚本");
}
else
{
item = new MenuItem("运行当前查询");
item2 = new MenuItem("验证当前查询");
item3 = new MenuItem("生成当前查询SQL语句的拼接代码");
item4 = new MenuItem("生成当前查询结果的数据脚本");
}
MenuItem item13 = new MenuItem("-");
MenuItem item14 = new MenuItem("选项 (&O)");
MenuItem item15 = new MenuItem("-");
MenuItem item16 = new MenuItem("脚本片断");
MenuItem item17 = new MenuItem("增加到脚本片断");
item5.Click += new EventHandler(this.miCopy_Click);
item6.Click += new EventHandler(this.miCut_Click);
item7.Click += new EventHandler(this.miPaste_Click);
item8.Click += new EventHandler(this.miAllSel_Click);
item9.Click += new EventHandler(this.miGoToDefinision_Click);
item10.Click += new EventHandler(this.miGoToRererence_Click);
item11.Click += new EventHandler(this.miGoToAnyRererence_Click);
item.Click += new EventHandler(this.miRunCurrentQuery_Click);
item2.Click += new EventHandler(this.miValidateCurrentQuery_Click);
item3.Click += new EventHandler(this.miMakeCurrentQueryCS_Click);
item4.Click += new EventHandler(this.miMakeCurrentQuerySQL_Click);
item14.Click += new EventHandler(this.miOptions_Click);
item17.Click += new EventHandler(this.miAddToSnippet_Click);
if (!dataObject.GetDataPresent(DataFormats.Text))
{
item7.Enabled = false;
}
this.cmShortcutMeny.MenuItems.Clear();
this.cmShortcutMeny.MenuItems.Add(item5);
this.cmShortcutMeny.MenuItems.Add(item6);
this.cmShortcutMeny.MenuItems.Add(item7);
this.cmShortcutMeny.MenuItems.Add(item8);
this.cmShortcutMeny.MenuItems.Add(item12);
this.cmShortcutMeny.MenuItems.Add(item);
this.cmShortcutMeny.MenuItems.Add(item13);
this.cmShortcutMeny.MenuItems.Add(item3);
this.cmShortcutMeny.MenuItems.Add(item4);
this.cmShortcutMeny.MenuItems.Add(item15);
this.cmShortcutMeny.MenuItems.Add(item16);
XmlDocument document = new XmlDocument();
document.Load(Application.StartupPath + @"\Snippets.xml");
XmlNodeList elementsByTagName = document.GetElementsByTagName("snippets");
if (this.txtContent.SelectedText.Length > 1)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -