/// <summary> /// 得到当前数据库浏览器选中的服务器名称 /// </summary> public static string GetDbViewSelServer() { if (Application.OpenForms["DbView"] == null) { return(""); } DbView dbviewfrm1 = (DbView)Application.OpenForms["DbView"]; TreeNode SelNode = dbviewfrm1.treeView1.SelectedNode; if (SelNode == null) { return(""); } string longservername = ""; switch (SelNode.Tag.ToString()) { case "serverlist": return(""); case "server": { longservername = SelNode.Text; } break; case "db": { longservername = SelNode.Parent.Text; } break; case "tableroot": case "viewroot": { longservername = SelNode.Parent.Parent.Text; } break; case "table": case "view": { longservername = SelNode.Parent.Parent.Parent.Text; } break; case "column": longservername = SelNode.Parent.Parent.Parent.Parent.Text; break; } return(longservername); }
private void lblAddServer_Click(object sender, EventArgs e) { var dbview = new DbView(mainfrm); dbview.bgwRegServer.RunWorkerAsync(); }
public void SetListView(DbView dbviewfrm) { #region 得到类型对象 var treeNodeSelected = dbviewfrm.treeView1.SelectedNode; if (treeNodeSelected == null) { return; } var servername = ""; switch (treeNodeSelected.Tag.ToString()) { case "serverlist": return; case "server": { servername = treeNodeSelected.Text; CreatDbObj(servername); #region listView1 this.lblViewInfo.Text = " 服务器:" + servername; this.lblNum.Text = treeNodeSelected.Nodes.Count.ToString() + "项"; this.listView1.Columns.Clear(); this.listView1.Items.Clear(); this.listView1.LargeImageList = this.imglistDB; //this.listView1.SmallImageList = imglistView; this.listView1.View = View.LargeIcon; foreach (TreeNode node in treeNodeSelected.Nodes) { var dbName = node.Text; var item1 = new ListViewItem(dbName, 0); item1.SubItems.Add(dbName); item1.ImageIndex = 0; listView1.Items.AddRange(new ListViewItem[] { item1 }); } SetListViewMenu("db"); #endregion } break; case "db": { servername = treeNodeSelected.Parent.Text; CreatDbObj(servername); #region this.lblViewInfo.Text = " 数据库:" + treeNodeSelected.Text; this.lblNum.Text = treeNodeSelected.Nodes.Count.ToString() + "项"; SetListViewMenu("table"); BindlistViewTab(treeNodeSelected.Text, treeNodeSelected.Tag.ToString()); #endregion } break; case "tableroot": case "viewroot": case "procroot": { servername = treeNodeSelected.Parent.Parent.Text; var dbName = treeNodeSelected.Parent.Text; CreatDbObj(servername); #region this.lblViewInfo.Text = " 数据库:" + dbName; this.lblNum.Text = treeNodeSelected.Nodes.Count.ToString() + "项"; SetListViewMenu("table"); BindlistViewTab(dbName, treeNodeSelected.Tag.ToString()); #endregion } break; case "table": case "view": { servername = treeNodeSelected.Parent.Parent.Parent.Text; var dbName = treeNodeSelected.Parent.Parent.Text; var tabname = treeNodeSelected.Text; CreatDbObj(servername); #region this.lblViewInfo.Text = " 表:" + tabname; this.lblNum.Text = treeNodeSelected.Nodes.Count.ToString() + "项"; SetListViewMenu("column"); BindlistViewCol(dbName, tabname); #endregion } break; case "proc": { servername = treeNodeSelected.Parent.Parent.Parent.Text; var dbName = treeNodeSelected.Parent.Parent.Text; var tabname = treeNodeSelected.Text; CreatDbObj(servername); #region this.lblViewInfo.Text = " 存储过程:" + tabname; this.lblNum.Text = treeNodeSelected.Nodes.Count.ToString() + "项"; //SetListViewMenu("column"); //BindlistViewCol(dbName, tabname); //this.listView1.Columns.Clear(); this.listView1.Items.Clear(); #endregion } break; case "column": servername = treeNodeSelected.Parent.Parent.Parent.Parent.Text; break; } #endregion }