Example #1
0
        /// <summary>   Event handler. Called by HohTextBox for text changed events.
        ///             See if there is an Hoh with the given values and autofill
        ///             the rest of the user information including, addresses, prov, postal
        ///             code, city and phone number </summary>
        ///
        /// <remarks> 2019-04-20. </remarks>
        ///
        /// <param name="sender">   Source of the event. </param>
        /// <param name="e">        Text changed event information. </param>

        private void HohTextBox_TextChanged(object sender, TextChangedEventArgs e)
        {
            SubmitError.Visibility = Visibility.Hidden; //Hide the error initally
            //Set everything to empty and enable the boxes of the Hoh fields.
            addressTextBox.Text      = "";
            addressTextBox.IsEnabled = true;

            addressTwoTextbox.Text      = "";
            addressTwoTextbox.IsEnabled = true;

            cityTextBox.Text      = "";
            cityTextBox.IsEnabled = true;

            pNumberTextBox.Text      = "";
            pNumberTextBox.IsEnabled = true;

            pCodeTextBox.Text      = "";
            pCodeTextBox.IsEnabled = true;

            provComboBox.SelectedIndex = 0;
            provComboBox.IsEnabled     = true;


            bool isValid = true; //Validate the Healthcard number of the HoH entry

            isValid = PatientValidation.ValidateHoH(hohTextBox.Text);

            //If not vlaid and string is not null
            if (!isValid && !String.IsNullOrEmpty(hohTextBox.Text))
            {
                headOfHousehold     = ""; //Set the hoh value to blank, show an error
                hohError.Visibility = Visibility.Visible;
            }
            //If it is null.. Dont shoe the error, still set value to blank
            else if (String.IsNullOrEmpty(hohTextBox.Text))
            {
                headOfHousehold     = "";
                hohError.Visibility = Visibility.Hidden;
            }
            //Else, valid health card.. Input HoH details into the required boxes.
            else
            {
                //Hide the error.
                hohError.Visibility = Visibility.Hidden;
                fillPatient         = Database.HoH_GetAutoFill(hohTextBox.Text); //Get the HoH information

                //Use the list returned from the Hohautofill to fill in the contents,
                // Set all of the boxes to be disabled until the user modifies the hoh
                // textbox again.
                addressTextBox.Text      = fillPatient[0];
                addressTextBox.IsEnabled = false;

                addressTwoTextbox.Text      = fillPatient[1];
                addressTwoTextbox.IsEnabled = false;

                cityTextBox.Text      = fillPatient[2];
                cityTextBox.IsEnabled = false;

                //Loop through the provinces to find the correct one, or select 0.
                for (i = 0; i < provComboBox.Items.Count; i++)
                {
                    if (string.Compare(fillPatient[4], provComboBox.Items[i].ToString()) == 0)
                    {
                        provComboBox.SelectedIndex = i;
                    }
                }
                if (fillPatient[4] == "  ")
                {
                    provComboBox.SelectedIndex = 0;
                }

                provComboBox.IsEnabled = false;

                pCodeTextBox.Text      = fillPatient[3];
                pCodeTextBox.IsEnabled = false;

                pNumberTextBox.Text      = fillPatient[5];
                pNumberTextBox.IsEnabled = false;

                headOfHousehold = hohTextBox.Text;
            }
        }
        ///
        /// <summary>   Event handler. Called by HohTextBox for text changed events. </summary>
        ///
        /// <remarks>   2019-04-20. </remarks>
        ///
        /// <param name="sender">   Source of the event. </param>
        /// <param name="e">        Text changed event information. </param>
        ///

        private void HohTextBox_TextChanged(object sender, TextChangedEventArgs e)
        {
            //Sets all textboxes to be enabled
            addressTextBox.IsEnabled    = true;
            addressTwoTextbox.IsEnabled = true;
            cityTextBox.IsEnabled       = true;
            pNumberTextBox.IsEnabled    = true;
            pCodeTextBox.IsEnabled      = true;
            provComboBox.IsEnabled      = true;


            bool isValid = true;

            //Check healthcard validation
            isValid = PatientValidation.ValidateHoH(hohTextBox.Text);

            if (!isValid && !String.IsNullOrEmpty(hohTextBox.Text)) //Not valid, non-empty string
            {
                hohEnteredBool      = false;
                hohError.Visibility = Visibility.Visible;
            }
            else if (String.IsNullOrEmpty(hohTextBox.Text)) //Empty string
            {
                hohEnteredBool      = false;
                hohError.Visibility = Visibility.Hidden;
            }
            else //valid
            {
                hohEnteredBool      = true;
                hohError.Visibility = Visibility.Hidden;
                //Get autofill information
                fillPatient = Database.HoH_GetAutoFill(hohTextBox.Text);

                //Fill textboxes with returned list information accordingly
                addressTextBox.Text      = fillPatient[0];
                addressTextBox.IsEnabled = false;

                addressTwoTextbox.Text      = fillPatient[2];
                addressTwoTextbox.IsEnabled = false;

                cityTextBox.Text      = fillPatient[1];
                cityTextBox.IsEnabled = false;

                //Province
                for (i = 0; i < provComboBox.Items.Count; i++)
                {
                    if (string.Compare(fillPatient[4], provComboBox.Items[i].ToString()) == 0)
                    {
                        provComboBox.SelectedIndex = i;
                    }
                }
                if (fillPatient[4] == "  ")
                {
                    provComboBox.SelectedIndex = 0;
                }
                provComboBox.IsEnabled = false;

                pCodeTextBox.Text      = fillPatient[3];
                pCodeTextBox.IsEnabled = false;

                pNumberTextBox.Text      = fillPatient[5];
                pNumberTextBox.IsEnabled = false;
            }
        }