private void btnCreateCustomsInvoice_Click(object sender, EventArgs e) { if (txtInvoiceNumber.Text.Trim() == "") { MessageBox.Show("Please enter an Invoice number"); return; } if (txtNumberOfCases.Text.Trim() == "") { MessageBox.Show("Please enter Number of Cases"); return; } if (txtTotalWeight.Text.Trim() == "") { MessageBox.Show("Please enter Weight"); return; } try { int salesOrder = Convert.ToInt32(txtInvoiceNumber.Text.Trim()); } catch (InvalidCastException) { MessageBox.Show("Please enter numbers only in the Invoice number textbox"); return; } try { InvoiceHelper invoiceHelper = new InvoiceHelper(SessionManager.NewQBSession()); Invoice invoice = invoiceHelper.Populate(txtInvoiceNumber.Text); ExcelExportCanadaCustomsInvoice exporter = new ExcelExportCanadaCustomsInvoice(invoice, Convert.ToDouble(txtTotalWeight.Text), Convert.ToInt64(txtNumberOfCases.Text)); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error in Program", MessageBoxButtons.OK, MessageBoxIcon.Information); } }