Skip to content

Commit

Permalink
correcao cep em terceiro
Browse files Browse the repository at this point in the history
  • Loading branch information
stdmedoth committed Jun 28, 2021
1 parent 705820b commit 6cd9ede
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/Terceiros/altera.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ int altera_ter()
gtk_entry_set_text(GTK_ENTRY(transp_cidade_entry),campo[TER_TRSP_CID_COL]);

if(campo[TER_TRSP_BAIR_COL])
gtk_entry_set_text(GTK_ENTRY(transp_estado_entry),campo[TER_TRSP_BAIR_COL]);
gtk_entry_set_text(GTK_ENTRY(transp_bairro_entry),campo[TER_TRSP_BAIR_COL]);

if(campo[TER_TRSP_UF_COL])
gtk_entry_set_text(GTK_ENTRY(transp_estado_entry),campo[TER_TRSP_UF_COL]);
Expand Down
33 changes: 16 additions & 17 deletions src/Terceiros/campos/entrega/transp_cep.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,7 @@ int transp_cepc()
MYSQL_RES *vetor;
MYSQL_ROW campos;
transp_cep = (gchar *) gtk_entry_get_text(GTK_ENTRY(transp_cep_entry));
if(strlen(transp_cep)>=MAX_CEP_LEN)
{
popup(NULL,"CEP muito grande\nPor favor verifique");
gtk_widget_grab_focus(GTK_WIDGET(transp_cep_entry));
return 1;
}

if(strlen(transp_cep)<=0)
{
if(terceiros.criticar.entrega==0)
Expand All @@ -24,41 +19,45 @@ int transp_cepc()
gtk_widget_grab_focus(GTK_WIDGET(transp_cep_entry));
return 1;
}

if(strlen(transp_cep)!=CEP_LEN)
{
popup(NULL,"Insira o CEP com formato indicado");
gtk_widget_grab_focus(GTK_WIDGET(transp_cep_entry));
return 1;
}
g_print("CEP: %s\n",transp_cep);
autologger("CEP:");
autologger(transp_cep);
sprintf(query,"select l.descricao, c.descricao, l.UF, l.descricao_bairro from logradouro as l inner join cidade as c on l.code = c.id_cidade where CEP = '%s'",transp_cep);
vetor = consultar(query);
if(vetor==NULL)
sprintf(query,"select l.descricao, c.descricao, l.UF, l.descricao_bairro from logradouro as l inner join cidade as c on l.id_cidade = c.code where CEP = '%s'",transp_cep);
if(!(vetor = consultar(query)))
{
popup(NULL,"Erro na query para CEP\n\tConsulte suporte");
gtk_widget_grab_focus(GTK_WIDGET(transp_cep_entry));
return 1;
}
if((campos = mysql_fetch_row(vetor))==NULL)
if(!(campos = mysql_fetch_row(vetor)))
{
if(transp_msg_cep==0&&alterando_ter==0)
if(transp_msg_cep==0 && alterando_ter==0){
popup(NULL,"CEP não encontrado,\npor favor insira o endereço manualmente");
transp_msg_cep = 1;
}

autologger("CEP não encontrado,\n\tpor favor insira o endereço manualmente");
autologger(transp_cep);
transp_msg_cep = 1;
gtk_widget_grab_focus(transp_logradouro_entry);
return 0;
}
g_print("cep_len: %li\n",strlen(transp_cep));
if(campos[0])
if( campos[0] && !strlen(gtk_entry_get_text(GTK_ENTRY(transp_logradouro_entry) ) ) )
gtk_entry_set_text(GTK_ENTRY(transp_logradouro_entry),campos[0]);
if(campos[1])

if(campos[1] && !strlen(gtk_entry_get_text(GTK_ENTRY(transp_cidade_entry) ) ))
gtk_entry_set_text(GTK_ENTRY(transp_cidade_entry),campos[1]);
if(campos[2])

if(campos[2] && !strlen(gtk_entry_get_text(GTK_ENTRY(transp_estado_entry) ) ))
gtk_entry_set_text(GTK_ENTRY(transp_estado_entry),campos[2]);
if(campos[3])

if(campos[3] && !strlen(gtk_entry_get_text(GTK_ENTRY(transp_bairro_entry) ) ))
gtk_entry_set_text(GTK_ENTRY(transp_bairro_entry),campos[3]);

gtk_widget_grab_focus(transp_logradouro_entry);
Expand Down

0 comments on commit 6cd9ede

Please sign in to comment.