📄 dbview.cs
字号:
{
string dbname = this.logo.dbname;
TreeNode node3 = new TreeNode(dbname);
node3.ImageIndex = 2;
node3.SelectedImageIndex = 2;
node3.Tag = "db";
node.Nodes.Add(node3);
this.mainfrm.toolComboBox_DB.Items.Clear();
this.mainfrm.toolComboBox_DB.Items.Add(dbname);
DataTable tabViews = this.dbobj.GetTabViews(dbname);
if (tabViews != null)
{
this.mainfrm.toolComboBox_Table.Items.Clear();
foreach (DataRow row in tabViews.Rows)
{
row["name"].ToString();
this.mainfrm.toolComboBox_Table.Items.Add(dbname);
}
}
}
}
catch (Exception exception)
{
LogInfo.WriteLog(exception);
throw new Exception("获取数据库失败:" + exception.Message);
}
}
if (dbtype == "Oracle")
{
string text = ServerIp;
TreeNode node4 = new TreeNode(text);
node4.ImageIndex = 2;
node4.SelectedImageIndex = 2;
node4.Tag = "db";
node.Nodes.Add(node4);
this.mainfrm.toolComboBox_DB.Items.Add(text);
DataTable table2 = this.dbobj.GetTabViews(text);
if (table2 != null)
{
this.mainfrm.toolComboBox_Table.Items.Clear();
foreach (DataRow row2 in table2.Rows)
{
row2["name"].ToString();
this.mainfrm.toolComboBox_Table.Items.Add(text);
}
if (this.mainfrm.toolComboBox_Table.Items.Count > 0)
{
this.mainfrm.toolComboBox_Table.SelectedIndex = 0;
}
}
}
if (dbtype == "MySQL")
{
try
{
if ((this.loginMysql.dbname == "mysql") || (this.loginMysql.dbname == ""))
{
List<string> list2 = this.dbobj.GetDBList();
if ((list2 != null) && (list2.Count > 0))
{
this.mainfrm.toolComboBox_DB.Items.Clear();
foreach (string str4 in list2)
{
TreeNode node5 = new TreeNode(str4);
node5.ImageIndex = 2;
node5.SelectedImageIndex = 2;
node5.Tag = "db";
node.Nodes.Add(node5);
this.mainfrm.toolComboBox_DB.Items.Add(str4);
}
if (this.mainfrm.toolComboBox_DB.Items.Count > 0)
{
this.mainfrm.toolComboBox_DB.SelectedIndex = 0;
}
}
}
else
{
string str5 = this.loginMysql.dbname;
TreeNode node6 = new TreeNode(str5);
node6.ImageIndex = 2;
node6.SelectedImageIndex = 2;
node6.Tag = "db";
node.Nodes.Add(node6);
this.mainfrm.toolComboBox_DB.Items.Clear();
this.mainfrm.toolComboBox_DB.Items.Add(str5);
DataTable table3 = this.dbobj.GetTabViews(str5);
if (table3 != null)
{
this.mainfrm.toolComboBox_Table.Items.Clear();
foreach (DataRow row3 in table3.Rows)
{
row3["name"].ToString();
this.mainfrm.toolComboBox_Table.Items.Add(str5);
}
if (this.mainfrm.toolComboBox_Table.Items.Count > 0)
{
this.mainfrm.toolComboBox_Table.SelectedIndex = 0;
}
}
}
}
catch (Exception exception2)
{
LogInfo.WriteLog(exception2);
throw new Exception("获取数据库失败:" + exception2.Message);
}
}
if (dbtype == "OleDb")
{
string str6 = ServerIp.Substring(ServerIp.LastIndexOf(@"\") + 1);
TreeNode node7 = new TreeNode(str6);
node7.ImageIndex = 2;
node7.SelectedImageIndex = 2;
node7.Tag = "db";
node.Nodes.Add(node7);
this.mainfrm.toolComboBox_DB.Items.Add(str6);
DataTable table4 = this.dbobj.GetTabViews(str6);
if (table4 != null)
{
this.mainfrm.toolComboBox_Table.Items.Clear();
foreach (DataRow row4 in table4.Rows)
{
row4["name"].ToString();
this.mainfrm.toolComboBox_Table.Items.Add(str6);
}
if (this.mainfrm.toolComboBox_Table.Items.Count > 0)
{
this.mainfrm.toolComboBox_Table.SelectedIndex = 0;
}
}
}
node.ExpandAll();
foreach (TreeNode node8 in node.Nodes)
{
string dbName = node8.Text;
this.mainfrm.StatusLabel1.Text = "加载数据库 " + dbName + "...";
SplashScreen.SetStatus("加载数据库 " + dbName + "...");
TreeNode node9 = new TreeNode("表");
node9.ImageIndex = 3;
node9.SelectedImageIndex = 4;
node9.Tag = "tableroot";
node8.Nodes.Add(node9);
TreeNode node10 = new TreeNode("视图");
node10.ImageIndex = 3;
node10.SelectedImageIndex = 4;
node10.Tag = "viewroot";
node8.Nodes.Add(node10);
TreeNode node11 = new TreeNode("存储过程");
node11.ImageIndex = 3;
node11.SelectedImageIndex = 4;
node11.Tag = "procroot";
node8.Nodes.Add(node11);
try
{
List<string> tables = this.dbobj.GetTables(dbName);
if (tables.Count > 0)
{
foreach (string str8 in tables)
{
SplashScreen.SetStatus("加载数据库信息 " + str8);
TreeNode node12 = new TreeNode(str8);
node12.ImageIndex = 5;
node12.SelectedImageIndex = 5;
node12.Tag = "table";
node9.Nodes.Add(node12);
if (!this.logo.chk_Simple.Checked)
{
List<LTP.CodeHelper.ColumnInfo> columnList = this.dbobj.GetColumnList(dbName, str8);
if ((columnList != null) && (columnList.Count > 0))
{
foreach (LTP.CodeHelper.ColumnInfo info in columnList)
{
string columnName = info.ColumnName;
string typeName = info.TypeName;
TreeNode node13 = new TreeNode(columnName + "[" + typeName + "]");
node13.ImageIndex = 7;
node13.SelectedImageIndex = 7;
node13.Tag = "column";
node12.Nodes.Add(node13);
}
continue;
}
}
}
}
}
catch (Exception exception3)
{
LogInfo.WriteLog(exception3);
MessageBox.Show(this, "获取数据库" + dbName + "的表信息失败:" + exception3.Message, "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Hand);
}
try
{
DataTable vIEWs = this.dbobj.GetVIEWs(dbName);
if (vIEWs != null)
{
foreach (DataRow row5 in vIEWs.Select("", "name ASC"))
{
string str11 = row5["name"].ToString();
SplashScreen.SetStatus("加载数据库信息 " + str11);
TreeNode node14 = new TreeNode(str11);
node14.ImageIndex = 6;
node14.SelectedImageIndex = 6;
node14.Tag = "view";
node10.Nodes.Add(node14);
if (!this.logo.chk_Simple.Checked)
{
List<LTP.CodeHelper.ColumnInfo> list5 = this.dbobj.GetColumnList(dbName, str11);
if ((list5 != null) && (list5.Count > 0))
{
foreach (LTP.CodeHelper.ColumnInfo info2 in list5)
{
string str12 = info2.ColumnName;
string str13 = info2.TypeName;
TreeNode node15 = new TreeNode(str12 + "[" + str13 + "]");
node15.ImageIndex = 7;
node15.SelectedImageIndex = 7;
node15.Tag = "column";
node14.Nodes.Add(node15);
}
}
}
}
}
}
catch (Exception exception4)
{
LogInfo.WriteLog(exception4);
MessageBox.Show(this, "获取数据库" + dbName + "的视图信息失败:" + exception4.Message, "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Hand);
}
try
{
DataTable procs = this.dbobj.GetProcs(dbName);
if (procs != null)
{
foreach (DataRow row6 in procs.Select("", "name ASC"))
{
string str14 = row6["name"].ToString();
SplashScreen.SetStatus("加载数据库信息 " + str14);
TreeNode node16 = new TreeNode(str14);
node16.ImageIndex = 8;
node16.SelectedImageIndex = 8;
node16.Tag = "proc";
node11.Nodes.Add(node16);
if (!this.logo.chk_Simple.Checked)
{
List<LTP.CodeHelper.ColumnInfo> list6 = this.dbobj.GetColumnList(dbName, str14);
if ((list6 != null) && (list6.Count > 0))
{
foreach (LTP.CodeHelper.ColumnInfo info3 in list6)
{
string str15 = info3.ColumnName;
string str16 = info3.TypeName;
TreeNode node17 = new TreeNode(str15 + "[" + str16 + "]");
node17.ImageIndex = 9;
node17.SelectedImageIndex = 9;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -