} // RefreshOrders_Click private void LoyaltyAccountSearch_Button_Click(object sender, EventArgs e) { // Get the text entered into the text boxes. try { int ordercount = 0; // the number of orders to display List <string>[] Loyaltydata; // the orders that will be displayed ArrayList ListBoxInfo = new ArrayList(); // Array List where formatted text will be stored. // Buffer to store text string AccountID = SearchAccountNumber_Textbox.Text.ToString(); string AccountName = SearchAccountName_Textbox.Text.ToString(); string EmailAddress = SearchEmailAddress_Textbox.Text.ToString(); // connect to DB if it is not connected if (!nsadb.Connected()) { nsadb.OpenConnection(); } // Get the loyalty account data from the database ordercount = nsadb.ManagerGetLoyaltyAccount(out Loyaltydata, AccountID, AccountName, EmailAddress); // Clear any existing data in the list box AccountsFound_Listbox.DataSource = null; AccountsFound_Listbox.Items.Clear(); //loop over the records and format them in the Array List for (int index = 0; index < ordercount; index++) { int accountnumber = Convert.ToInt32(Loyaltydata[0][index]); ListBoxInfo.Add(new BoxFormat(accountnumber.ToString("D12") + " - " + Loyaltydata[1][index], accountnumber.ToString("D12"))); } // Insert Array List into the List Box AccountsFound_Listbox.DataSource = ListBoxInfo; // Define which information is actually displayed by the listbox and returned AccountsFound_Listbox.DisplayMember = "displayText"; AccountsFound_Listbox.ValueMember = "databaseID"; } catch (Exception ex) { MessageBox.Show(ex.Message, "Loyalty Account Search", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } // LoyaltyAccountSearch_Button_Click