private string codMunic(string ufVaraX, string value) { if (ufVara(ufVaraX) == null) { string msg = "Município"; List <string> ufSigla = new List <string> { "AC", "AL", "AP", "AM", "BA", "CE", "DF", "ES", "GO", "MA", "MT", "MS", "MG", "PA", "PB", "PR", "PE", "PI", "RJ", "RN", "RS", "RO", "RR", "SC", "SP", "SE", "TO", "EX", }; List <int> ufCod = new List <int> { 12, 27, 16, 13, 29, 23, 53, 32, 52, 21, 51, 50, 31, 15, 25, 41, 26, 22, 33, 24, 43, 11, 14, 42, 35, 28, 17, 99 }; int cod = 0; for (int i = 0; i < ufSigla.Count; i++) { if (ufSigla[i].Equals(ufVaraX)) { cod = ufCod[i]; break; } } MunicipioFacede facede = new MunicipioFacede(); MunicipioModel model = facede.RetornaDadosMunicipioFacede(value); if (model == null) { return(msg); } if (model.uf != cod) { return(msg); } } return(null); }
private void UFmudou(object sender, EventArgs e) { codMunic_comboBox.Items.Clear(); ComboBox combo = (ComboBox)sender; UfModel uf = (UfModel)combo.SelectedItem; MunicipioFacede facede = new MunicipioFacede(); List <MunicipioModel> municipios = facede.RetornaDadosMunicipiosFacede(uf.codigo); codMunic_comboBox.DisplayMember = "nome"; codMunic_comboBox.ValueMember = "codigo"; object[] x = municipios.ToArray(); codMunic_comboBox.Items.AddRange(x); }