Esempio 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;
            }
        }
Esempio n. 2
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;
            }
        }
Esempio n. 3
0
 private void textZip_Validating(object sender, System.ComponentModel.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=="" && (textCity.Text!="" || textState.Text!="")){
     //	if(MessageBox.Show(Lan.g(this,"Delete the City and State?"),"",MessageBoxButtons.OKCancel)
     //		==DialogResult.OK){
     //		textCity.Text="";
     //		textState.Text="";
     //	}
     //	return;
     //}
     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;
     }
     ZipCodes.GetALMatches(textZip.Text);
     if(ZipCodes.ALMatches.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(ZipCodes.ALMatches.Count==1){
         //only one match found.  Use it.
         textCity.Text=((ZipCode)ZipCodes.ALMatches[0]).City;
         textState.Text=((ZipCode)ZipCodes.ALMatches[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;
     }
 }
Esempio n. 4
0
 private void butEditZip_Click(object sender, System.EventArgs e)
 {
     if(textZip.Text.Length==0){
         MessageBox.Show(Lan.g(this,"Please enter a zipcode first."));
         return;
     }
     ZipCodes.GetALMatches(textZip.Text);
     if(ZipCodes.ALMatches.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;
         }
         //Not needed:
         //DataValid.SetInvalid(InvalidTypes.ZipCodes);
         textCity.Text=FormZS.ZipSelected.City;
         textState.Text=FormZS.ZipSelected.State;
         textZip.Text=FormZS.ZipSelected.ZipCodeDigits;
     }
 }