/* asi next button click that search the company info from the user input asi number */ protected void asiNextButton_Click(object sender, EventArgs e) { // reset textbox color asiTextbox.BackColor = Color.White; if (asiTextbox.Text != "") { // get company information from the asi number that user entered BPvalues asiValue = asi.GetCompanyInfo(asiTextbox.Text); // the case if the asi number does not exist -> return if (asiValue == null) { asiTextbox.BackColor = Color.Red; asiPopup.Show(); return; } // search result by company name value = bp.GetCustomerWithInfo(null, asiValue.Company, 2); #region Error Check // the case if there is no result or there are too many result if (value == null) { // inform user there is not existing cusomter on the database from the company const string script = "<script>alert(\"There is no customer exist from this company. Please enter information manually\");</script>"; Page.ClientScript.RegisterStartupScript(GetType(), "Scripts", script); // show company info on the form phoneTextbox.Text = asiValue.Phone; emailTextbox.Text = asiValue.Email; companyTextbox.Text = asiValue.Company; address1Textbox.Text = asiValue.Address1; address2Textbox.Text = asiValue.Address2; cityTextbox.Text = asiValue.City; provinceTextbox.Text = asiValue.Province; postalCodeTextbox.Text = asiValue.PostalCode; countryTextbox.Text = asiValue.Country; firstNameTextbox.Text = string.Empty; lastNameTextbox.Text = string.Empty; return; } if (value[0].FirstName == "-1") { tooManyResultLabel.Visible = true; searchPopup.Show(); return; } #endregion // sort array by first name value = value.OrderBy(s => s.FirstName).ToArray(); // show all the result listbox.Items.Clear(); foreach (BPvalues result in value) { ListItem item = new ListItem(result.FirstName + ' ' + result.LastName); listbox.Items.Add(item); } ShowResult(value[0]); // show result panel asiPopup.Hide(); resultPopup.Show(); // save viewstate ViewState["Value"] = value; } else { // the case if user did not put anything on the textbox -> signal them asiTextbox.BackColor = Color.Red; asiPopup.Show(); } }