private void textBoxCustomer_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { if (textBoxCustomer.Text != "") { String id = ""; String name = textBoxCustomer.Text; String aaa = name.Substring(name.IndexOf('(') + 1); if (aaa.IndexOf(')') != -1) { id = aaa.Substring(0, aaa.IndexOf(')')); this.inv.customer_id = id; } else { MessageDialog.ShowAlert("Invalid Customer", "Alert Message", "warning"); return; } CustomerModel cust = new CustomerModel(); dynamic customers = cust.where (cust, "id = " + id); if (customers.Count > 0) { if (this.inv != null) { textBoxCreditLimit.Text = "" + customers[0].credit_limit; textBoxBalance.Text = "" + customers[0].initial_balance; inv.update_attribute(inv, "customer_id", id, inv.id); } else { MessageDialog.ShowAlert("Invoice not initialized", "Alert Message", "warning"); } } else { MessageDialog.ShowAlert("Customer Not Found", "Alert Message", "warning"); return; } } textBoxDiscount.Focus(); } }