private void btnApply_Click(object sender, EventArgs e) { if (btnApply.Text == "Apply") { SQLTestResult frm = new SQLTestResult(); if (frm.ShowDataResult(parentForm.ConnectionStr, txtStatement.Text)) { frm.ShowDialog(this); } } else if (btnApply.Text == "Advance") { FormInputParameterSP frm = new FormInputParameterSP(channel); frm.ShowDialog(this); } }
private void ApplyFileQuery() { string sqlStr = txtStatement.Text; if (sqlStr.IndexOf("{FileName}") >= 0) { OpenFileDialog dlg = new OpenFileDialog(); dlg.InitialDirectory = ConfigHelper.GetFullPath(parentForm.DBconfig.ConnectionParameter.FileFolder); dlg.Multiselect = false; dlg.ShowReadOnly = false; dlg.Title = "Select a data file for testing."; dlg.RestoreDirectory = true; if (dlg.ShowDialog(this) != DialogResult.OK) { return; } string fileLocation = dlg.FileName; string fileDirectory = Path.GetDirectoryName(fileLocation); if (fileDirectory.ToLowerInvariant() != dlg.InitialDirectory.ToLowerInvariant()) { MessageBox.Show(this, string.Format("Please select a data file in {0} folder.", dlg.InitialDirectory), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); ApplyFileQuery(); return; } string fileName = dlg.SafeFileName; sqlStr = sqlStr.Replace("{FileName}", string.Format("[{0}]", fileName)); } SQLTestResult frm = new SQLTestResult(); if (frm.ShowDataResult(parentForm.DBconfig.ConnectionParameter.FileConnectionString, sqlStr)) { frm.ShowDialog(this); } }