private void btnExport_Click(object sender, EventArgs e) { try { SimpleInt integer = new SimpleInt(); DtoInputBox <SimpleInt> inputBox = new DtoInputBox <SimpleInt>(integer, DtoInputBox <SimpleInt> .InputType.Insert); inputBox.ShowDialog(this); if (!inputBox.Submited) { return; } var auction = serviceOperations.ExportAuctionData(integer.Value); string path = System.IO.Path.Combine(Environment.CurrentDirectory, "ExportTest.xml"); Export.Exporter.Export(auction, path); MessageBox.Show("Exportação terminada", "Mensagem"); } catch (ConnectException ex) { MessageBox.Show(ex.Message, "Erro"); } catch (DisconnectException ex) { MessageBox.Show(ex.Message, "Erro"); } catch (Exception ex) { MessageBox.Show(ex.Message, "Erro"); } }
private void inputboxWithExceptionHandle(T value, DtoInputBox <T> .InputType type, Action submitAction) { bool done = false; while (!done) { try { DtoInputBox <T> inBox = new DtoInputBox <T>(value, type); inBox.ShowDialog(this); if (inBox.Submited) { submitAction(); } done = true; } catch (Exception ex) { handleException(ex, value); } } }