private void bt_UseDataSource_Click(object sender, EventArgs e) { if (txt_DataSourceExistsFilePath.Tag == null) { MessageBox.Show("请选择数据文件."); return; } instance.SetDataSourcePath(txt_DataSourceExistsFilePath.Text); instance.Init(); InitUI(false); InitDataSource(); }
private void bt_See_Click(object sender, EventArgs e) { var openFileDialog = new OpenFileDialog(); if (openFileDialog.ShowDialog() != DialogResult.OK) { return; } instance.SetDataSourcePath(openFileDialog.FileName); txt_UseDataSource.Text = openFileDialog.FileName; instance.Init(); var sql = "select * from FileInfo "; var table = instance.GetTable(sql, default(SQLiteParameter[])); if (table == null) { return; } list = new List <Model>(); foreach (DataRow row in table.Rows) { list.Add(new Model(row)); } tree_See.Nodes.Clear(); var rootTreeNodeModel = list.FirstOrDefault(predicate => string.IsNullOrEmpty(predicate.parentID)); var treeNode = new TreeNode(); treeNode.Text = rootTreeNodeModel.fileName; treeNode.Tag = rootTreeNodeModel; tree_See.Nodes.Add(treeNode); AddNextTreeNode(treeNode, rootTreeNodeModel.fileID); var contextMenu = new ContextMenu(); var menuItem = new MenuItem(); menuItem.Text = "下载."; menuItem.Click += menuItem_Click; contextMenu.MenuItems.Add(menuItem); list_DownLoad.ContextMenu = contextMenu; }