//>>>>>>> master public void MyRefresh() { dbDic = new Dictionary <string, List <string> >(); tvc = new TreeviewController(this.treeView1); ZBindNode(); this.Refresh(); }
public MainForm() { dbDic = new Dictionary <string, List <string> >(); InitializeComponent(); materialSkinManager = MaterialSkinManager.Instance; materialSkinManager.AddFormToManage(this); materialSkinManager.Theme = MaterialSkinManager.Themes.LIGHT; materialSkinManager.ColorScheme = new ColorScheme(Primary.BlueGrey800, Primary.BlueGrey900, Primary.BlueGrey500, Accent.LightBlue200, TextShade.WHITE); tvc = new TreeviewController(this.treeView1); //con.Open(); ZBindNode(); Control.mainform = this; }
private void treeView1_AfterSelect(object sender, TreeViewEventArgs e) { TreeviewController tvc = new TreeviewController(this.treeView1); if (this.treeView1.SelectedNode.Name == "db") { Control.connection.SqlConn.Close(); Control.connection.SqlConn = tvc.EsConOnDataBase(this.treeView1.SelectedNode); } if (this.treeView1.SelectedNode.Name == "sc") { Control.connection.SqlConn.Close(); Control.connection.SqlConn = tvc.EsConOnSchemas(this.treeView1.SelectedNode); String sel_table = "select * from information_schema.tables;"; // Control.background.tableName = this.treeView1.SelectedNode.Text; NpgsqlCommand command = new NpgsqlCommand(sel_table, Control.connection.SqlConn); // Control.connection.SqlConn.Open(); try { command.ExecuteNonQuery(); NpgsqlDataAdapter npgsql = new NpgsqlDataAdapter(sel_table, Control.connection.SqlConn); Control.connection.ds = new DataSet(); npgsql.Fill(Control.connection.ds); //Control.connection.SqlConn.Close(); Control.background2.GetDataGridView1().DataSource = null; Control.background2.GetDataGridView1().EditMode = DataGridViewEditMode.EditOnEnter; Control.background2.GetDataGridView1().DataSource = Control.connection.ds; Control.background2.GetDataGridView1().DataMember = Control.connection.ds.Tables[0].TableName; Control.background2.GetDataGridView1().EnableHeadersVisualStyles = false; Control.background2.GetDataGridView1().ColumnHeadersDefaultCellStyle.Font = new Font("隶书", 9, FontStyle.Italic); Control.background2.GetDataGridView1().ColumnHeadersDefaultCellStyle.ForeColor = Color.Purple; //Control.background2.SetFormerNum(Control.background2.GetDataGridView1().ColumnCount); } catch (Exception ee) { MessageBox.Show("请检查您的指令!\ntips:" + ee.Message); } String sel_table2 = "select * from information_schema.columns;"; // Control.background.tableName = this.treeView1.SelectedNode.Text; NpgsqlCommand command2 = new NpgsqlCommand(sel_table2, Control.connection.SqlConn); // Control.connection.SqlConn.Open(); try { command2.ExecuteNonQuery(); NpgsqlDataAdapter npgsql = new NpgsqlDataAdapter(sel_table2, Control.connection.SqlConn); Control.connection.ds = new DataSet(); npgsql.Fill(Control.connection.ds); //Control.connection.SqlConn.Close(); Control.background2.GetDataGridView2().DataSource = null; Control.background2.GetDataGridView2().EditMode = DataGridViewEditMode.EditOnEnter; Control.background2.GetDataGridView2().DataSource = Control.connection.ds; Control.background2.GetDataGridView2().DataMember = Control.connection.ds.Tables[0].TableName; Control.background2.GetDataGridView2().EnableHeadersVisualStyles = false;//这样就可以使用当前的主题的样式了,这句话十分关键! Control.background2.GetDataGridView2().ColumnHeadersDefaultCellStyle.Font = new Font("隶书", 9, FontStyle.Italic); Control.background2.GetDataGridView2().ColumnHeadersDefaultCellStyle.ForeColor = Color.Purple; //Control.background2.SetFormerNum(Control.background2.GetDataGridView1().ColumnCount); } catch (Exception ee) { MessageBox.Show("请检查您的指令!\ntips:" + ee.Message); } } if (this.treeView1.SelectedNode.Text == "Table") { Control.connection.SqlConn.Close(); Control.connection.SqlConn = tvc.EsConOnTable1(this.treeView1.SelectedNode); // // } if (this.treeView1.SelectedNode.Name == "tb") { Control.connection.SqlConn.Close(); Control.connection.SqlConn = tvc.EsConOnTable2(this.treeView1.SelectedNode); String sel_table = "select * from " + this.treeView1.SelectedNode.Text; Control.background.tableName = this.treeView1.SelectedNode.Text; NpgsqlCommand command = new NpgsqlCommand(sel_table, Control.connection.SqlConn); // Control.connection.SqlConn.Open(); try { command.ExecuteNonQuery(); NpgsqlDataAdapter npgsql = new NpgsqlDataAdapter(sel_table, Control.connection.SqlConn); Control.connection.ds = new DataSet(); npgsql.Fill(Control.connection.ds); //Control.connection.SqlConn.Close(); Control.background.FullFilDataGrid(); //Control.background.GetDataGridView().DataMember = Control.connection.ds.Tables[0].TableName; Control.background.GetDataGridView().EnableHeadersVisualStyles = false;//这样就可以使用当前的主题的样式了,这句话十分关键! Control.background.GetDataGridView().ColumnHeadersDefaultCellStyle.Font = new Font("隶书", 9, FontStyle.Italic); Control.background.GetDataGridView().ColumnHeadersDefaultCellStyle.ForeColor = Color.Purple; Control.background.SetFormerNum(Control.background.GetDataGridView().ColumnCount); } catch (Exception ee) { MessageBox.Show("请检查您的指令!\ntips:" + ee.Message); } } if (this.treeView1.SelectedNode.Name == "con") { Control.connection.SqlConn.Close(); Control.connection.SqlConn = tvc.EsConOnColumn(this.treeView1.SelectedNode); } }