Exemplo n.º 1
0
        private void textZip_Validating(object sender, CancelEventArgs e)
        {
            //fired as soon as control loses focus.
            //it's here to validate if zip is typed in to text box instead of picked from list.
            if (textZip.Text.Length < 5)
            {
                return;
            }
            if (comboZip.SelectedIndex != -1)
            {
                return;
            }
            //the autofill only works if both city and state are left blank
            if (textCity.Text != "" || textState.Text != "")
            {
                return;
            }
            List <ZipCode> listZipCodes = ZipCodes.GetALMatches(textZip.Text);

            if (listZipCodes.Count == 0)
            {
                //No match found. Must enter info for new zipcode
                ZipCode ZipCodeCur = new ZipCode();
                ZipCodeCur.ZipCodeDigits = textZip.Text;
                FormZipCodeEdit FormZE = new FormZipCodeEdit();
                FormZE.ZipCodeCur = ZipCodeCur;
                FormZE.IsNew      = true;
                FormZE.ShowDialog();
                if (FormZE.DialogResult != DialogResult.OK)
                {
                    return;
                }
                DataValid.SetInvalid(InvalidType.ZipCodes);                //FormZipCodeEdit does not contain internal refresh
                FillComboZip();
                textCity.Text  = ZipCodeCur.City;
                textState.Text = ZipCodeCur.State;
                textZip.Text   = ZipCodeCur.ZipCodeDigits;
            }
            else if (listZipCodes.Count == 1)
            {
                //only one match found.  Use it.
                textCity.Text  = ((ZipCode)listZipCodes[0]).City;
                textState.Text = ((ZipCode)listZipCodes[0]).State;
            }
            else
            {
                //multiple matches found.  Pick one
                FormZipSelect FormZS = new FormZipSelect();
                FormZS.ShowDialog();
                FillComboZip();
                if (FormZS.DialogResult != DialogResult.OK)
                {
                    return;
                }
                DataValid.SetInvalid(InvalidType.ZipCodes);
                textCity.Text  = FormZS.ZipSelected.City;
                textState.Text = FormZS.ZipSelected.State;
                textZip.Text   = FormZS.ZipSelected.ZipCodeDigits;
            }
        }
Exemplo n.º 2
0
        private void butDelete_Click(object sender, System.EventArgs e)
        {
            if (listMatches.SelectedIndex == -1)
            {
                MessageBox.Show(Lan.g(this, "Please select an item first."));
                return;
            }
            ZipCode ZipCodeCur = (ZipCode)ZipCodes.ALMatches[listMatches.SelectedIndex];

            ZipCodes.Delete(ZipCodeCur);
            changed = true;
            ZipCodes.Refresh();
            //next line might not be right.
            ZipCodes.GetALMatches(ZipCodeCur.ZipCodeDigits);
            FillList();
        }
Exemplo n.º 3
0
        private void butAdd_Click(object sender, System.EventArgs e)
        {
            FormZipCodeEdit FormZCE = new FormZipCodeEdit();

            FormZCE.ZipCodeCur = new ZipCode();
            FormZCE.ZipCodeCur.ZipCodeDigits = (_listZipCodes[0]).ZipCodeDigits;
            FormZCE.IsNew = true;
            FormZCE.ShowDialog();
            if (FormZCE.DialogResult != DialogResult.OK)
            {
                return;
            }
            changed = true;
            ZipCodes.RefreshCache();
            ZipCodes.GetALMatches(FormZCE.ZipCodeCur.ZipCodeDigits);
            FillList();
        }
Exemplo n.º 4
0
        private void butEdit_Click(object sender, System.EventArgs e)
        {
            if (listMatches.SelectedIndex == -1)
            {
                MessageBox.Show(Lan.g(this, "Please select an item first."));
                return;
            }
            FormZipCodeEdit FormZCE = new FormZipCodeEdit();

            FormZCE.ZipCodeCur = _listZipCodes[listMatches.SelectedIndex];
            FormZCE.ShowDialog();
            if (FormZCE.DialogResult != DialogResult.OK)
            {
                return;
            }
            changed = true;
            ZipCodes.RefreshCache();
            ZipCodes.GetALMatches(FormZCE.ZipCodeCur.ZipCodeDigits);
            FillList();
        }
Exemplo n.º 5
0
        private void butEditZip_Click(object sender, EventArgs e)
        {
            if (textZip.Text.Length == 0)
            {
                MessageBox.Show(Lan.g(this, "Please enter a zipcode first."));
                return;
            }
            List <ZipCode> listZipCodes = ZipCodes.GetALMatches(textZip.Text);

            if (listZipCodes.Count == 0)
            {
                FormZipCodeEdit FormZE = new FormZipCodeEdit();
                FormZE.ZipCodeCur = new ZipCode();
                FormZE.ZipCodeCur.ZipCodeDigits = textZip.Text;
                FormZE.IsNew = true;
                FormZE.ShowDialog();
                FillComboZip();
                if (FormZE.DialogResult != DialogResult.OK)
                {
                    return;
                }
                DataValid.SetInvalid(InvalidType.ZipCodes);
                textCity.Text  = FormZE.ZipCodeCur.City;
                textState.Text = FormZE.ZipCodeCur.State;
                textZip.Text   = FormZE.ZipCodeCur.ZipCodeDigits;
            }
            else
            {
                FormZipSelect FormZS = new FormZipSelect();
                FormZS.ShowDialog();
                FillComboZip();
                if (FormZS.DialogResult != DialogResult.OK)
                {
                    return;
                }
                textCity.Text  = FormZS.ZipSelected.City;
                textState.Text = FormZS.ZipSelected.State;
                textZip.Text   = FormZS.ZipSelected.ZipCodeDigits;
            }
        }