📄 form1.cs
字号:
bool hasNextResult = false;
try
{
do
{
i = 0;
try
{
xw.WriteStartElement("s");
#region headers
try
{
xw.WriteStartElement("h");
string header = null;
string type = null;
string len = null;
for (int c = 0; c < rd.FieldCount; c++)
{
try
{
type = "n/a";
object o = rd.GetName(c);
if (o == null)
header = "<n/a>";
else if (o.ToString() == "")
header = "<n/a>";
else
{
header = o.ToString();
type = rd.GetDataTypeName(c);
len = rd.GetSchemaTable().Rows[c][2].ToString();
}
}
catch
{
header = "<n/a>";
}
xw.WriteStartElement("c");
xw.WriteAttributeString("t", type);
xw.WriteAttributeString("l", len);
xw.WriteString(header);
xw.WriteEndElement();
}
}
catch
{ }
finally
{
xw.WriteEndElement();
}
#endregion
string h = "d";
while (rd.Read())
{
i++;
total++;
totalResult++;
try
{
if (Properties.Settings.Default.MaxRecords && totalResult > Properties.Settings.Default.MaxRecordCount)
{
total--;
totalResult--;
xw.WriteStartElement("truncate");
break;
}
xw.WriteStartElement("r");
for (int c = 0; c < rd.FieldCount; c++)
{
//string h = headers[c];
try
{
object o = rd.GetValue(c);
xw.WriteStartElement(h);
if (o is DBNull)
xw.WriteAttributeString("isNull", "1");
xw.WriteString(o.ToString());
xw.WriteEndElement();
//xw.WriteElementString(h, o.ToString());
}
catch
{
xw.WriteElementString(h, "<n/a>");
}
}
}
catch
{ }
finally
{
xw.WriteEndElement();
}
}
totalResult = 0;
hasNextResult = rd.NextResult();
}
catch (DbException ex)
{
if (ex.ErrorCode == -2146232009)
hasNextResult = rd.NextResult();
else
throw ex;
}
finally
{
xw.WriteEndElement();
}
}
while (hasNextResult);
}
finally
{
if (Properties.Settings.Default.MaxRecords && total >= Properties.Settings.Default.MaxRecordCount)
RecordsToolStripStatusLabel.Text = total.ToString() + Properties.Resources.StatusRecordsTruncated;
else
RecordsToolStripStatusLabel.Text = total.ToString();
}
}
}
catch (Exception ex)
{
xw.WriteStartElement("error");
xw.WriteElementString("msg", ex.ToString());
xw.WriteEndElement();
throw ex;
}
finally
{
xw.WriteEndDocument();
xw.Flush();
m.Position = 0;
XmlReader xr = new XmlTextReader(m);
xsl.Transform(xr, null, mout);
mout.Position = 0;
htmlControl1.webBrowser1.DocumentStream = mout;
}
}
private void Form1_KeyUp(object sender, KeyEventArgs e)
{
if (e.Modifiers == 0)
{
switch (e.KeyCode)
{
case Keys.F5:
e.Handled = true;
RunButton.PerformClick();
break;
}
}
}
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
if (e.Modifiers == Keys.Control)
{
switch (e.KeyCode)
{
case Keys.A:
object o = this.ActiveControl;
while (o is ContainerControl)
o = ((ContainerControl)o).ActiveControl;
TextBox c = o as TextBox;
if (c != null)
{
if (c.SelectionLength != c.Text.Length)
c.SelectAll();
e.SuppressKeyPress = true;
}
break;
}
}
}
private void CommitToolStripStatusLabel_Click(object sender, EventArgs e)
{
Properties.Settings.Default.Commit = !Properties.Settings.Default.Commit;
UpdateStatusStrip();
}
private void MaxRecordsToolStripStatusLabel_Click(object sender, EventArgs e)
{
Properties.Settings.Default.MaxRecords = !Properties.Settings.Default.MaxRecords;
MaxRecordsToolStripStatusLabel.Text = Properties.Settings.Default.MaxRecords ? Properties.Resources.StatusMax : Properties.Resources.StatusAll;
}
private void cSVToolStripMenuItem_Click(object sender, EventArgs e)
{
toolStripDropDownButton1.Tag = cSVToolStripMenuItem.Tag;
toolStripDropDownButton1.Text = cSVToolStripMenuItem.Text;
}
private void htmlToolStripMenuItem_Click(object sender, EventArgs e)
{
toolStripDropDownButton1.Tag = htmlToolStripMenuItem.Tag;
toolStripDropDownButton1.Text = htmlToolStripMenuItem.Text;
}
private void UpdateStatusStrip()
{
CommitToolStripStatusLabel.Text = Properties.Settings.Default.Commit ? Properties.Resources.StatusCommit : Properties.Resources.StatusRollback;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -