Пример #1
0
        /// <summary>
        /// This method searches for a customer by name when the button is clicked.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void NameSearchButton_Click(object sender, EventArgs e)
        {
            CustomerIDSearchTextBox.Text  = "";
            PhoneNumberSearchTextBox.Text = "";

            if (FirstNameSearchTextBox.Text.Trim().Length < 1 || LastNameSearchTextBox.Text.Trim().Length < 1)
            {
                MessageBox.Show("Both First Name and Last Name has to be typed!!!!",
                                "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            string firstName = FirstNameSearchTextBox.Text;
            string lastName  = LastNameSearchTextBox.Text;

            StoreMember storeMember = null;

            try
            {
                List <StoreMember> storeMembers = this.storeMemberController.GetStoreMemberByName(firstName, lastName);
                if (storeMembers.Count > 1)
                {
                    StoreMemberPicker storeMemberPicker = new StoreMemberPicker(storeMembers, this);
                    storeMemberPicker.ShowDialog();
                    return;
                }
                else if (storeMembers.Count == 1)
                {
                    storeMember = storeMembers[0];
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error while searching for Store Member!!!! - " + ex.Message,
                                "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (storeMember != null)
            {
                this.DisplayResults(storeMember);
            }
            else
            {
                MessageBox.Show("No Customer found!!!! - ",
                                "Information!", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Пример #2
0
        /// <summary>
        /// This method searches for a customer by phone number when the button is clicked.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void PhoneNumberSearchButton_Click(object sender, EventArgs e)
        {
            CustomerIDSearchTextBox.Text = "";
            FirstNameSearchTextBox.Text  = "";
            LastNameSearchTextBox.Text   = "";

            if (!Regex.IsMatch(PhoneNumberSearchTextBox.Text.Trim(), @"\d\d\d-\d\d\d-\d\d\d\d"))
            {
                MessageBox.Show("Phone Number should be XXX-XXX-XXXX format!!!!",
                                "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            string      phoneNumber = PhoneNumberSearchTextBox.Text;
            StoreMember storeMember = null;

            try
            {
                List <StoreMember> storeMembers = this.storeMemberController.GetStoreMemberByPhoneNumber(phoneNumber);
                if (storeMembers.Count > 1)
                {
                    StoreMemberPicker storeMemberPicker = new StoreMemberPicker(storeMembers, this);
                    storeMemberPicker.ShowDialog();
                    return;
                }
                else if (storeMembers.Count == 1)
                {
                    storeMember = storeMembers[0];
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error while searching for Store Member!!!! - " + ex.Message,
                                "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (storeMember != null)
            {
                this.DisplayResults(storeMember);
            }
            else
            {
                MessageBox.Show("No Customer found!!!! - ",
                                "Information!", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }