protected void txtCEP_TextChanged(object sender, EventArgs e) { TextBox _txtCEP = (TextBox)sender; RepeaterItem item = ((RepeaterItem)_txtCEP.NamingContainer); try { if (!String.IsNullOrEmpty(_txtCEP.Text.Trim())) { item.FindControl("btnLimparEndereco").Visible = true; DataTable dt = END_EnderecoBO.GetSelect(Guid.Empty, Guid.Empty, Guid.Empty, Guid.Empty, _txtCEP.Text, "", "", "", "", "", "", 0, false, 0, 1); if (dt.Rows.Count == 1) { // Preenche os dados do endereço. PreencherDados(dt.Rows[0], item, false); HabilitaCamposEndereco(item, false); item.FindControl("txtNumero").Focus(); } else { LimpaDadosLinha(item, false); HabilitaCamposEndereco(item, true); item.FindControl("txtLogradouro").Focus(); } } else { item.FindControl("btnLimparEndereco").Visible = false; LimpaDadosLinha(item, false); HabilitaCamposEndereco(item, true); //item.FindControl("txtLogradouro").Focus(); } } catch (Exception ex) { ApplicationWEB._GravaErro(ex); ((Label)item.FindControl("lblMessage")).Text = UtilBO.GetErroMessage("Erro ao tentar carregar o endereço.", UtilBO.TipoMensagem.Erro); } }
/// <summary> /// Carrega o CEP /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void txtCEP_TextChanged(object sender, EventArgs e) { TextBox _txtCEP = (TextBox)sender; try { if (!String.IsNullOrEmpty(_txtCEP.Text.Trim())) { DataTable dt = END_EnderecoBO.GetSelect(Guid.Empty, Guid.Empty, Guid.Empty, Guid.Empty, _txtCEP.Text, "", "", "", "", "", "", 0, false, 0, 1); if (dt.Rows.Count == 1) { PreencherDados(dt.Rows[0], false); HabilitaCamposEndereco(false); txtNumero.Focus(); } else { HabilitaCamposEndereco(true); txtEnd_id.Value = string.Empty; txtLogradouro.Focus(); } } else { LimpaDadosLinha(false); HabilitaCamposEndereco(true); txtLogradouro.Focus(); } } catch (Exception ex) { ApplicationWEB._GravaErro(ex); lblMessage.Text = UtilBO.GetErroMessage("Erro ao tentar carregar o endereço.", UtilBO.TipoMensagem.Erro); } }