Ejemplo n.º 1
0
        private void FillGrid()
        {
            ZipCodes.RefreshCache();
            _listZipCodes = ZipCodes.GetDeepCopy();
            gridZipCode.BeginUpdate();
            gridZipCode.ListGridColumns.Clear();
            GridColumn col;

            col = new GridColumn(Lan.g(this, "ZipCode"), 75);
            gridZipCode.ListGridColumns.Add(col);
            col = new GridColumn(Lan.g(this, "City"), 270);
            gridZipCode.ListGridColumns.Add(col);
            col = new GridColumn(Lan.g(this, "State"), 50);
            gridZipCode.ListGridColumns.Add(col);
            col = new GridColumn(Lan.g(this, "Frequent"), 80);
            gridZipCode.ListGridColumns.Add(col);
            gridZipCode.ListGridRows.Clear();
            GridRow row;

            foreach (ZipCode zip in _listZipCodes)
            {
                row = new GridRow();
                row.Cells.Add(zip.ZipCodeDigits);
                row.Cells.Add(zip.City);
                row.Cells.Add(zip.State);
                row.Cells.Add((zip.IsFrequent ? "X" : ""));
                row.Tag = zip;
                gridZipCode.ListGridRows.Add(row);
            }
            gridZipCode.EndUpdate();
        }
Ejemplo n.º 2
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;
            }
        }
Ejemplo n.º 3
0
 private void FillComboZip()
 {
     comboZip.Items.Clear();
     _listZipCodes = ZipCodes.GetDeepCopy(true);
     for (int i = 0; i < _listZipCodes.Count; i++)
     {
         comboZip.Items.Add((_listZipCodes[i]).ZipCodeDigits
                            + " (" + (_listZipCodes[i]).City + ")");
     }
 }
Ejemplo n.º 4
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 = _listZipCodes[listMatches.SelectedIndex];

            ZipCodes.Delete(ZipCodeCur);
            changed = true;
            ZipCodes.RefreshCache();
            FillList();
        }
Ejemplo n.º 5
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();
        }
Ejemplo n.º 6
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();
        }
Ejemplo n.º 7
0
        private void butDelete_Click(object sender, System.EventArgs e)
        {
            if (tbZips.SelectedRow == -1)
            {
                MessageBox.Show(Lan.g(this, "Please select an item first."));
                return;
            }
            ZipCode ZipCur = ZipCodes.List[tbZips.SelectedRow];

            if (MessageBox.Show(Lan.g(this, "Delete Zipcode?"), "", MessageBoxButtons.OKCancel) != DialogResult.OK)
            {
                return;
            }
            changed = true;
            ZipCodes.Delete(ZipCur);
            FillTable();
        }
Ejemplo n.º 8
0
        private void butDelete_Click(object sender, System.EventArgs e)
        {
            if (gridZipCode.SelectedIndices.Length == 0)
            {
                MessageBox.Show(Lan.g(this, "Please select an item first."));
                return;
            }
            ZipCode ZipCur = gridZipCode.SelectedTag <ZipCode>();

            if (MessageBox.Show(Lan.g(this, "Delete Zipcode?"), "", MessageBoxButtons.OKCancel) != DialogResult.OK)
            {
                return;
            }
            changed = true;
            ZipCodes.Delete(ZipCur);
            FillGrid();
        }
Ejemplo n.º 9
0
        private void FillList()
        {
            //refreshing is done within each routine
            listMatches.Items.Clear();
            string itemText = "";

            _listZipCodes = ZipCodes.GetDeepCopy();
            for (int i = 0; i < _listZipCodes.Count; i++)
            {
                itemText = (_listZipCodes[i]).City + " "
                           + (_listZipCodes[i]).State;
                if ((_listZipCodes[i]).IsFrequent)
                {
                    itemText += Lan.g(this, " (freq)");
                }
                listMatches.Items.Add(itemText);
            }
            listMatches.SelectedIndex = -1;
        }
Ejemplo n.º 10
0
 private void FillTable()
 {
     ZipCodes.Refresh();
     tbZips.ResetRows(ZipCodes.List.Length);
     tbZips.SetGridColor(Color.Gray);
     tbZips.SetBackGColor(Color.White);
     for (int i = 0; i < ZipCodes.List.Length; i++)
     {
         tbZips.Cell[0, i] = ZipCodes.List[i].ZipCodeDigits;
         tbZips.Cell[1, i] = ZipCodes.List[i].City;
         tbZips.Cell[2, i] = ZipCodes.List[i].State;
         if (ZipCodes.List[i].IsFrequent)
         {
             tbZips.Cell[3, i] = "X";
         }
     }
     tbZips.SelectedRow = -1;
     tbZips.LayoutTables();
 }
Ejemplo n.º 11
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();
        }
Ejemplo n.º 12
0
 private void butOK_Click(object sender, System.EventArgs e)
 {
     if (textZip.Text == "" || textCity.Text == "" || textState.Text == "")
     {
         MessageBox.Show(Lan.g(this, "City,State, or Zip Cannot be left blank"));
         return;
     }
     ZipCodeCur.City          = textCity.Text;
     ZipCodeCur.State         = textState.Text;
     ZipCodeCur.ZipCodeDigits = textZip.Text;
     ZipCodeCur.IsFrequent    = checkIsFrequent.Checked;
     if (IsNew)
     {
         ZipCodes.Insert(ZipCodeCur);
     }
     else
     {
         ZipCodes.Update(ZipCodeCur);
     }
     DialogResult = DialogResult.OK;
 }
Ejemplo n.º 13
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;
            }
        }
Ejemplo n.º 14
0
        private void FillList()
        {
            //refreshing is done within each routine
            listMatches.Items.Clear();
            string itemText = "";

            _listZipCodes = ZipCodes.GetDeepCopy();
            if (!string.IsNullOrWhiteSpace(_zipCodeDigits))
            {
                _listZipCodes.RemoveAll(x => x.ZipCodeDigits != _zipCodeDigits);
            }
            for (int i = 0; i < _listZipCodes.Count; i++)
            {
                itemText = (_listZipCodes[i]).City + " "
                           + (_listZipCodes[i]).State;
                if ((_listZipCodes[i]).IsFrequent)
                {
                    itemText += Lan.g(this, " (freq)");
                }
                listMatches.Items.Add(itemText);
            }
            listMatches.SelectedIndex = -1;
        }