Exemple #1
0
 /// <summary>
 /// Resets the form elements/selected items and clears the related textboxes
 /// </summary>
 private void ResetForm()
 {
     CustomersListBox.ClearSelected();
     CustomersListBox.SelectedItem = null;
     FirstNameTextBox.Text         = "";
     LastNameTextBox.Text          = "";
     DeliveryAdressTextBox.Text    = "";
 }
 private void selectedCustomersButton_CheckedChanged(object sender, EventArgs e)
 {
     CustomersListBox.Enabled = selectedCustomersButton.Checked;
     onCriteriaChanged();
     if (CustomersListBox.Enabled)
     {
         CustomersListBox.Focus();
     }
 }
        /// <summary>
        /// Resets the form elements/selected items
        /// </summary>
        private void ResetForm()
        {
            TablesListBox.ClearSelected();
            TablesListBox.SelectedItem = null;

            CustomersListBox.ClearSelected();
            CustomersListBox.SelectedItem = null;

            CompaniesListBox.ClearSelected();
            CompaniesListBox.SelectedItem = null;
        }
Exemple #4
0
        async void textBox1_TextChanged(object sender, TextChangedEventArgs e)
        {
            if (cts != null)
            {
                cts.Cancel();
            }

            if (popup.IsOpen)
            {
                popup.IsOpen = false;
            }
            if (textBox1.Text.Length == 0)
            {
                CustomersListBox.SelectedItem = null;
                CustomersListBox.ScrollIntoView(CustomersListBox.Items[0]);
            }
            else if (textBox1.Text.StartsWith("70") || textBox1.Text.StartsWith("71") ||
                     textBox1.Text.StartsWith("76") || textBox1.Text.StartsWith("78") || textBox1.Text.StartsWith("03") ||
                     textBox1.Text.StartsWith("79") || textBox1.Text.StartsWith("81"))
            {
                CustomerCollection col = CustomersListBox.Items.SourceCollection as CustomerCollection;
                Customer           ddd = col.FirstOrDefault(c => c.PhoneNumber.StartsWith(textBox1.Text));
                foreach (Customer user in CustomersListBox.Items)
                {
                    if (user.PhoneNumber.StartsWith(textBox1.Text))
                    {
                        CustomersListBox.SelectedItem = user;
                        CustomersListBox.ScrollIntoView(user);
                        return;
                    }
                }
                CustomersListBox.SelectedItem = null;
            }
            else
            {
                foreach (Customer user in CustomersListBox.Items)
                {
                    if (user.Username.StartsWith(textBox1.Text))
                    {
                        CustomersListBox.SelectedItem = user;
                        CustomersListBox.ScrollIntoView(user);
                        return;
                    }
                }
                CustomersListBox.SelectedItem = null;

                try
                {
                    cts = new CancellationTokenSource();
                    await Task.Delay(2000, cts.Token);

                    cts = null;
                    CustomerCollection equalList = new CustomerCollection();

                    if (textBox1.Text.Contains("ismaelr") && (ResellersComboBox.SelectedItem as Reseller).Name.Equals("ahkvoip0", StringComparison.OrdinalIgnoreCase))
                    {
                        foreach (Customer c in CustomersListBox.Items)
                        {
                            if (c.Username.Equals("ismael"))
                            {
                                equalList.Add(c);

                                didMeanText.Text = "You must select";
                                possibleCustomers.ItemsSource = equalList;
                                popup.IsOpen = true;
                                CustomersListBox.IsEnabled = false;
                                CustomersListBox.Opacity   = 0.5;

                                return;
                            }
                        }
                    }

                    foreach (Customer c in CustomersListBox.Items)
                    {
                        if (LevenshteinDistance(c.Username, textBox1.Text) < 3)
                        {
                            equalList.Add(c);
                        }
                    }

                    if (equalList.Count > 0)
                    {
                        didMeanText.Text = "Did you mean:";
                        possibleCustomers.ItemsSource = equalList;
                        popup.IsOpen = true;
                        CustomersListBox.IsEnabled = false;
                        CustomersListBox.Opacity   = 0.5;
                    }
                }
                catch
                {
                }
            }
        }