Example #1
0
        /// <summary>
        /// Search for a customer by their first and last name
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void lookupName_Click(object sender, EventArgs e)
        {
            try
            {
                Cursor = Cursors.WaitCursor;

                errormsg.Text = string.Empty;
                results       = null;
                resultsList.Items.Clear();

                firstName.Text = firstName.Text.Trim();                  // post 1.02 trim whitespace
                lastName.Text  = lastName.Text.Trim();

                results = CustomerLookup.GetCustomersByName(firstName.Text, lastName.Text, 10);

                if (results != null)
                {
                    foreach (CustomerWS.CustomerProviderCustomerRecord record in results)
                    {
                        fillList(record);
                    }
                }
                if (resultsList.Items.Count > 0)
                {
                    resultsList.Items[0].Selected = true;
                    resultsList.Focus();
                }
                else
                {
                    errormsg.Text = localize.LOOKUP_DLG_UNABLE_CUST_NAME;
                }
            }
            catch (System.ServiceModel.FaultException <System.ServiceModel.ExceptionDetail> ex)
            {
                errormsg.Text = ex.Message;
            }
            catch (System.Net.WebException wex)              // v1.02
            {
                Logging.Error(Application.ProductName, localize.DESKTOP_IIS_ERROR, wex);
            }
            catch (Exception exp)
            {
                // Post 1.02 - better error message
                Logging.Error(Application.ProductName, localize.LOOKUP_DLG_UNABLE_CUST_RECORD, exp);
            }
            finally
            {
                Cursor = Cursors.Default;
            }
        }