private bool LoadFile() { fbd = fbd ?? new FolderBrowserDialog() { Description = "选择脚本所在文件夹", }; if (fbd.ShowDialog(this) == DialogResult.OK) { this.context.Path = fbd.SelectedPath; isChooseScriptDir = true; lblInfo2 = $"脚本目录:\r\n{this.context.Path}"; welcome.SetLabel(lblInfo, lblInfo2); this.context.Files = SqlAdoExecutor.GetFiles(context.Path); if (this.context.Files != null && this.context.Files.Any()) { return(true); } else { MessageBox.Show(this, "您选择的文件夹不包含脚本,或者未按规定方式组织脚本,\r\n请重新选择目录。", "提示", MessageBoxButtons.OK); return(false); } } welcome.SetLabel(lblInfo, lblInfo2); return(false); }
private void BtnOpen_Click(object sender, EventArgs e) { this.context.Path = @"E:\Tests\TestScripts"; this.context.Files = SqlAdoExecutor.GetFiles(context.Path); this.context.ConnectionString = "data source=.;initial catalog=test;user id=sa;password=111111;MultipleActiveResultSets=True"; GoToNext(); return; if (this.LoadFile() && isConfigDb) { GoToNext(); } }