private void btnOpenFile_Click(object sender, EventArgs e) { try { if (ofdCSfile.ShowDialog() == DialogResult.OK) { if (ofdCSfile.FileName == string.Empty) { MessageBox.Show("No file selected"); } else { tbFile.Text = ofdCSfile.SafeFileName; reporter = new frmFilter(ofdCSfile.FileName); this.Hide(); reporter.Owner = this; reporter.Show(); } } } catch (Exception ex) { ExceptionHandler.handleException(ex, "Error occurred getting file name from dialog"); Application.Exit(); } }
private void btnGenerate_Click(object sender, EventArgs e) { if (cbbMAs.SelectedIndex == -1) { MessageBox.Show("You must select an MA from the list."); return; } RadioButton selectedRB; try { selectedRB = gbDataSelection.Controls.OfType <RadioButton>().First(r => r.Checked); } catch (InvalidOperationException) { MessageBox.Show("You must select the data you wish to report on"); return; } if (sfdReport.ShowDialog() == DialogResult.OK) { Process proc = new Process(); proc.StartInfo.UseShellExecute = false; proc.StartInfo.FileName = csExportFilePath; generatedFile = sfdReport.FileName; string subElements = ""; if (!cbSystem.Checked) { subElements = " /o:bhd"; } if (File.Exists(generatedFile)) { File.Delete(generatedFile); } switch (selectedRB.Name) { case "rbAll": proc.StartInfo.Arguments = "\"" + cbbMAs.SelectedItem.ToString() + "\" \"" + generatedFile + "\"" + subElements; break; case "rbExport": proc.StartInfo.Arguments = "\"" + cbbMAs.SelectedItem.ToString() + "\" \"" + generatedFile + "\" /f:x" + subElements; break; case "rbImport": proc.StartInfo.Arguments = "\"" + cbbMAs.SelectedItem.ToString() + "\" \"" + generatedFile + "\" /f:m" + subElements; break; case "rbImportError": proc.StartInfo.Arguments = "\"" + cbbMAs.SelectedItem.ToString() + "\" \"" + generatedFile + "\" /f:i" + subElements + "e"; break; case "rbExportError": proc.StartInfo.Arguments = "\"" + cbbMAs.SelectedItem.ToString() + "\" \"" + generatedFile + "\" /f:e" + subElements + "e"; break; } proc.Start(); proc.WaitForExit(); reporter = new frmFilter(generatedFile); this.Hide(); reporter.Owner = this; reporter.Show(); } }