Peter Dzuya

Peter Dzuya

  • NA
  • 313
  • 39.4k

Recursing a method

Sep 16 2015 10:03 AM

Hi Experts. I Thank this forum so much for the previous assistance.

 I have this  task of posting a new Invoice. Its working very well. What I wish to do is to ask the user if he/she wants to proceed with feeding another invoice item. If the answer is Yes, then the form should be able accept another transaction. Can someone show me how to do this from the code provided below. Thanks

private void simpleButtonAccept_Click(object sender, EventArgs e){

try {

if (

MessageBox.Show("Do you really want to Accept this invoice transaction", "GMIS Question",

MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) {

var TotalInvoiceSum = totalAmountTextEdit.Value + textEditInvoiceAmount.Value;

totalAmountTextEdit.Text = Convert.ToString(TotalInvoiceSum);

_invoiceTransaction.InvoiceAmount = Convert.ToInt32(textEditInvoiceAmount.Text);

_invoiceTransaction.InvoiceDetails = jobCardDetailsSearchLookUpEdit.Text;

gridInvoiceTransactions.Focus();

InvoiceTransactionbindingSource.EndEdit();

                    _InvoiceService.Insert(_Invoice);

if (

MessageBox.Show(

"Invoice transaction accepted. Do you want to post another invoice transaction",

"GMIS - Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) {

                        

jobCardDetailsSearchLookUpEdit.Text = string.Empty;

InvoiceTransactionsView.AddNewRow();

_invoiceTransaction = new InvoiceTransaction() {

Datecreated = DateTime.Now,

LastEditedDate = DateTime.Now,

DeletedStatus = false,

};

}

else {

}

}

} catch (UwapiValidationException ex) {

string errorMessage = "Please fix the issue below before Proceeding:";

int i = 0;

foreach (var error in ex.Errors) errorMessage += string.Format("\n{0}) {1}", ++i, error.Message);

MessageBox.Show(errorMessage, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

}

}

 


 


Answers (4)