Skip to content

Commit

Permalink
adicionado nome fantasia para cliente
Browse files Browse the repository at this point in the history
  • Loading branch information
stdmedoth committed Jun 18, 2021
1 parent dc329c9 commit d2e0d72
Show file tree
Hide file tree
Showing 13 changed files with 61 additions and 26 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ BDFLAGS=-I /usr/include/mysql -l mysqlclient
XMLFLAGS=`pkg-config --libs --cflags libxml-2.0`
JSONFLAGS=`pkg-config --libs --cflags json-glib-1.0`
CURLFLAGS=`pkg-config --libs --cflags libcurl`
CCFLAGS1=-Wall -Wredundant-decls -Wuninitialized -Wreturn-type
CCFLAGS1=-Wall -Wredundant-decls -Wuninitialized -Wreturn-type -Wno-deprecated-declarations
CCFLAGS2=-Wpedantic -O0 -Woverflow -Wno-write-strings -Wfatal-errors -Wformat-overflow
CCFLAGS3=-Wunused-variable
DEBUG=-g
Expand Down
3 changes: 3 additions & 0 deletions src/Terceiros/altera.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ int altera_ter()
if(campo[RAZ_TER_COL]!=NULL)
gtk_entry_set_text(GTK_ENTRY(name_ter_field),campo[RAZ_TER_COL]);

if(campo[NOMFAN_TER_COL])
gtk_entry_set_text(GTK_ENTRY(ter_nome_fantasia_entry),campo[NOMFAN_TER_COL]);

if(campo[DOC_TER_COL]!=NULL)
gtk_entry_set_text(GTK_ENTRY(doc_ter_field),campo[DOC_TER_COL]);

Expand Down
25 changes: 21 additions & 4 deletions src/Terceiros/cadastro_terceiros.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ int cad_terc()
GtkWidget *addr_log_num_box,*addr_log_num_fixed, *logr_address;
GtkWidget *prazo_box;

GtkWidget *ter_nome_fantasia_box, *ter_nome_fantasia_frame;
GtkWidget *ter_nomes_box;

GtkWidget *ter_entrega_frame,*ter_endereco_frame;

GtkWidget *ter_img_box,
Expand Down Expand Up @@ -322,13 +325,26 @@ int cad_terc()
gtk_box_pack_start(GTK_BOX(inscr),inscr_ter_field,0,0,0);
gtk_entry_set_width_chars(GTK_ENTRY(inscr_ter_field),25);

name_ter_box = gtk_box_new(1,0);
name_ter_box = gtk_box_new(0,0);
name_ter_frame = gtk_frame_new("Nome");
gtk_widget_set_name(name_ter_box,"name_ter_box");
gtk_box_pack_start(GTK_BOX(name_ter_box),name_ter_field,0,0,0);
gtk_container_add(GTK_CONTAINER(name_ter_frame),name_ter_box);
gtk_entry_set_width_chars(GTK_ENTRY(name_ter_field),80);

ter_nome_fantasia_entry = gtk_entry_new();
ter_nome_fantasia_box = gtk_box_new(0,0);
ter_nome_fantasia_frame = gtk_frame_new("Nome Fantasia");
gtk_widget_set_name(ter_nome_fantasia_box,"ter_nome_fantasia_box");
gtk_box_pack_start(GTK_BOX(ter_nome_fantasia_box),ter_nome_fantasia_entry,0,0,0);
gtk_container_add(GTK_CONTAINER(ter_nome_fantasia_frame),ter_nome_fantasia_box);
gtk_entry_set_width_chars(GTK_ENTRY(ter_nome_fantasia_entry),80);

ter_nomes_box = gtk_box_new(1,0);
gtk_box_pack_start(GTK_BOX(ter_nomes_box),name_ter_frame,0,0,0);
gtk_box_pack_start(GTK_BOX(ter_nomes_box),ter_nome_fantasia_frame,0,0,0);


ter_endereco_frame = gtk_frame_new("Endereço Cliente");
ter_entrega_frame = gtk_frame_new("Endereço Entrega");

Expand Down Expand Up @@ -476,7 +492,7 @@ int cad_terc()
gtk_box_pack_start(GTK_BOX(horizontal_box_two),code_ter_nfe_box,0,0,5);
gtk_box_pack_start(GTK_BOX(horizontal_box_two),ter_cliente_desde_frame,0,0,5);

gtk_box_pack_start(GTK_BOX(horizontal_box_three),name_ter_frame,0,0,10);
gtk_box_pack_start(GTK_BOX(horizontal_box_three),ter_nomes_box,0,0,10);

gtk_box_pack_start(GTK_BOX(horizontal_box_four),ter_endereco_frame,0,0,10);

Expand Down Expand Up @@ -523,6 +539,7 @@ int cad_terc()
g_signal_connect(GTK_ENTRY(doc_ter_field),"activate",G_CALLBACK(escolha_doc),NULL);
g_signal_connect(GTK_ENTRY(inscr_ter_field),"activate",G_CALLBACK(inscr_terc),NULL);
g_signal_connect(GTK_ENTRY(name_ter_field),"activate",G_CALLBACK(name_terc),NULL);
g_signal_connect(GTK_ENTRY(ter_nome_fantasia_entry),"activate",G_CALLBACK(ter_nome_fantasia_fun),NULL);
g_signal_connect(GTK_ENTRY(ter_cliente_desde_entry),"activate",G_CALLBACK(ter_cliente_desde),NULL);

g_signal_connect(GTK_ENTRY(cep_ter_field),"activate",G_CALLBACK(cep_terc),NULL);
Expand Down Expand Up @@ -563,8 +580,8 @@ int cad_terc()
gtk_fixed_put(GTK_FIXED(fixed),horizontal_box_one,MARGEM_D,20); //codigo cnpj
gtk_fixed_put(GTK_FIXED(fixed),horizontal_box_two,MARGEM_D,80); //inscricao
gtk_fixed_put(GTK_FIXED(fixed),horizontal_box_three,MARGEM_D,140); //nome
gtk_fixed_put(GTK_FIXED(fixed),horizontal_box_four,MARGEM_D,200); //cep/endereco tipo ter
gtk_fixed_put(GTK_FIXED(fixed),horizontal_box_five,MARGEM_D,400); //observacoes
gtk_fixed_put(GTK_FIXED(fixed),horizontal_box_four,MARGEM_D,240); //cep/endereco tipo ter
gtk_fixed_put(GTK_FIXED(fixed),horizontal_box_five,MARGEM_D,440); //observacoes
gtk_fixed_put(GTK_FIXED(fixed2),horizontal_box_six,MARGEM_D,20); //contatos

gtk_fixed_put(GTK_FIXED(fixed4),horizontal_box_seven,MARGEM_D,20); //outros
Expand Down
1 change: 1 addition & 0 deletions src/Terceiros/cadastro_terceiros.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ struct _terc_infos{
int index;
int code;
char *razao;
char *nomes_fantasia;
char *ie;
char *doc;
int tipo_terc;
Expand Down
1 change: 1 addition & 0 deletions src/Terceiros/campos.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "campos/cpf.c"
#include "campos/escolher_doc.c"
#include "campos/nome.c"
#include "campos/nome_fantasia.c"
#include "campos/cliente_desde.c"
#include "campos/cep.c"
#include "campos/bairro.c"
Expand Down
11 changes: 6 additions & 5 deletions src/Terceiros/campos.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ int notebook_preco_ter();
int altera_ter();

#include "campos/vars/campos_ter.h"
#include "campos/nome_fantasia.h"
#include "campos/cliente_desde.h"
#include "campos/cep.h"
#include "campos/contatos.h"
Expand All @@ -19,9 +20,9 @@ int altera_ter();


#define CAD_QUERY_TER "insert into terceiros\
(razao, code_nfe, doc, ie, tipo_doc, tipoc, tipo, relacionamento_desde , cep, endereco, complmt, bairro, cidade, uf, numrua, tiporua, transp_code, transp_num, transp_logradouro, transp_bairro, transp_cidade, transp_estado, transp_cep, transp_obs, obs, frete_pago, vlr_frete_pago, prazo ) values\
('%s', '%s', '%s', '%s', %i, '%s', %i, %s, '%s', '%s', '%s', '%s', '%s', '%s', %s, %i, '%i', %i, '%s', '%s', '%s', '%s', '%s', '%s', '%s', %i, %s, %s);"
#define CAD_QUERY_TER_VAR nomes_ter, codigos_ter_nfe, doc_ter, inscr_ter, tipo_doc, tipo_ter, terci_tipo, ter_cliente_desde_gchar, cep_ter, endereco_ter, complmt_ter, bairro_ter, cidade_ter, uf_ter, address_num, tipo_log, atoi(transp_codigo), atoi(transp_num), transp_logradouro, transp_bairro, transp_cidade, transp_estado, transp_cep, transp_obs,observacoes_ter, frete_frag_int, vlr_frete_pago_gchar, prazo_ter
(razao, nome_fantasia, code_nfe, doc, ie, tipo_doc, tipoc, tipo, relacionamento_desde , cep, endereco, complmt, bairro, cidade, uf, numrua, tiporua, transp_code, transp_num, transp_logradouro, transp_bairro, transp_cidade, transp_estado, transp_cep, transp_obs, obs, frete_pago, vlr_frete_pago, prazo ) values\
('%s', '%s', '%s', '%s', '%s', %i, '%s', %i, %s, '%s', '%s', '%s', '%s', '%s', '%s', %s, %i, '%i', %i, '%s', '%s', '%s', '%s', '%s', '%s', '%s', %i, %s, %s);"
#define CAD_QUERY_TER_VAR nomes_ter, ter_nome_fantasia_gchar, codigos_ter_nfe, doc_ter, inscr_ter, tipo_doc, tipo_ter, terci_tipo, ter_cliente_desde_gchar, cep_ter, endereco_ter, complmt_ter, bairro_ter, cidade_ter, uf_ter, address_num, tipo_log, atoi(transp_codigo), atoi(transp_num), transp_logradouro, transp_bairro, transp_cidade, transp_estado, transp_cep, transp_obs,observacoes_ter, frete_frag_int, vlr_frete_pago_gchar, prazo_ter

#define UPDATE_QUERY_TER "update terceiros set razao = '%s', code_nfe = '%s', doc = '%s', tipo_doc = %i, ie = '%s' ,tipoc = '%s', tipo = %i, relacionamento_desde = %s, cep = '%s', endereco = '%s', complmt = '%s', bairro = '%s', cidade = '%s', uf = '%s', numrua = %i, tiporua = %i, transp_code = '%i', transp_num = %i ,transp_logradouro = '%s',transp_cidade = '%s', transp_bairro = '%s' ,transp_estado = '%s' , transp_cep = '%s' , transp_obs = '%s', obs = '%s', frete_pago = %i, vlr_frete_pago = %s , prazo = %s where code = %s;"
#define UPDATE_QUERY_TER_VAR nomes_ter, codigos_ter_nfe, doc_ter, tipo_doc, inscr_ter, tipo_ter, terci_tipo, ter_cliente_desde_gchar, cep_ter,endereco_ter, complmt_ter, bairro_ter, cidade_ter, uf_ter, atoi(address_num), tipo_log, atoi(transp_codigo), atoi(transp_num), transp_logradouro , transp_cidade, transp_bairro, transp_estado, transp_cep, transp_obs, observacoes_ter, frete_frag_int, vlr_frete_pago_gchar, prazo_ter, codigos_ter
#define UPDATE_QUERY_TER "update terceiros set razao = '%s', nome_fantasia = '%s', code_nfe = '%s', doc = '%s', tipo_doc = %i, ie = '%s' ,tipoc = '%s', tipo = %i, relacionamento_desde = %s, cep = '%s', endereco = '%s', complmt = '%s', bairro = '%s', cidade = '%s', uf = '%s', numrua = %i, tiporua = %i, transp_code = '%i', transp_num = %i ,transp_logradouro = '%s',transp_cidade = '%s', transp_bairro = '%s' ,transp_estado = '%s' , transp_cep = '%s' , transp_obs = '%s', obs = '%s', frete_pago = %i, vlr_frete_pago = %s , prazo = %s where code = %s;"
#define UPDATE_QUERY_TER_VAR nomes_ter, ter_nome_fantasia_gchar, codigos_ter_nfe, doc_ter, tipo_doc, inscr_ter, tipo_ter, terci_tipo, ter_cliente_desde_gchar, cep_ter,endereco_ter, complmt_ter, bairro_ter, cidade_ter, uf_ter, atoi(address_num), tipo_log, atoi(transp_codigo), atoi(transp_num), transp_logradouro , transp_cidade, transp_bairro, transp_estado, transp_cep, transp_obs, observacoes_ter, frete_frag_int, vlr_frete_pago_gchar, prazo_ter, codigos_ter
6 changes: 3 additions & 3 deletions src/Terceiros/campos/escolher_doc.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ int mover_para_doc()
switch(opcao)
{
case 1:
gtk_frame_set_label(GTK_FRAME(code_frame),"Razão");
gtk_frame_set_label(GTK_FRAME(code_frame),(gchar*)"Razão");
break;
case 2:
gtk_frame_set_label(GTK_FRAME(code_frame),"Nome");
gtk_frame_set_label(GTK_FRAME(code_frame),(gchar*)"Nome");
break;
case 3:
gtk_frame_set_label(GTK_LABEL(code_frame),"Nome");
gtk_frame_set_label(GTK_FRAME(code_frame),(gchar*)"Nome");
break;
}
gtk_widget_grab_focus(doc_ter_field);
Expand Down
14 changes: 2 additions & 12 deletions src/Terceiros/campos/nome.c
Original file line number Diff line number Diff line change
@@ -1,23 +1,13 @@
int name_terc()
{

nomes_ter = (gchar *) gtk_entry_get_text(GTK_ENTRY(name_ter_field));
if(strlen(nomes_ter)>MAX_RAZ_LEN)
{
popup(NULL,"Nome muito grande\nPor favor diminua");
gtk_widget_grab_focus(GTK_WIDGET(name_ter_field));
return 1;
}
if(strlen(nomes_ter)<=0)
{
popup(NULL,"Por favor insira um nome para o terceiro");
gtk_widget_grab_focus(GTK_WIDGET(name_ter_field));
return 1;
}
else
{
gtk_widget_grab_focus(cep_ter_field);
}
g_print("nome: %s\n",nomes_ter);

gtk_widget_grab_focus(ter_nome_fantasia_entry);
return 0;
}
11 changes: 11 additions & 0 deletions src/Terceiros/campos/nome_fantasia.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
int ter_nome_fantasia_fun(){
ter_nome_fantasia_gchar = (gchar *) gtk_entry_get_text(GTK_ENTRY(ter_nome_fantasia_entry));
if(strlen(ter_nome_fantasia_gchar)<=0){
ter_nome_fantasia_gchar = strdup("");
return 0;
}

gtk_widget_grab_focus(cep_ter_field);
return 0;

}
3 changes: 3 additions & 0 deletions src/Terceiros/campos/nome_fantasia.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
int ter_nome_fantasia_fun();
GtkWidget *ter_nome_fantasia_entry;
gchar *ter_nome_fantasia_gchar;
1 change: 1 addition & 0 deletions src/Terceiros/cancela.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ void cancelar_ter(){
//terceiros
gtk_entry_set_text(GTK_ENTRY(code_ter_field),code);
gtk_entry_set_text(GTK_ENTRY(name_ter_field),"");
gtk_entry_set_text(GTK_ENTRY(ter_nome_fantasia_entry),"");
gtk_entry_set_text(GTK_ENTRY(ter_cliente_desde_entry),"");
gtk_entry_set_text(GTK_ENTRY(inscr_ter_field),"");
gtk_entry_set_text(GTK_ENTRY(code_ter_nfe_field),"");
Expand Down
8 changes: 7 additions & 1 deletion src/Terceiros/conclui.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ int conclui_ter(GtkWidget* nome, gpointer *botao)
return 1;
}

if(ter_nome_fantasia_fun()){
gtk_notebook_set_current_page(GTK_NOTEBOOK(ter_notebook),0);
gtk_widget_grab_focus(ter_nome_fantasia_entry);
return 1;
}

if(escolha_doc()){
gtk_notebook_set_current_page(GTK_NOTEBOOK(ter_notebook),0);
gtk_widget_grab_focus(doc_combo);
Expand All @@ -38,7 +44,7 @@ int conclui_ter(GtkWidget* nome, gpointer *botao)
gtk_widget_grab_focus(type_ter_field);
return 1;
}

if(ter_cliente_desde()){
gtk_notebook_set_current_page(GTK_NOTEBOOK(ter_notebook),0);
gtk_widget_grab_focus(ter_cliente_desde_entry);
Expand Down
1 change: 1 addition & 0 deletions src/Terceiros/get.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ struct _terc_infos *terceiros_get_simp_terceiro(int code){
if((row = mysql_fetch_row(res))){
terceiros->code = atoi(row[COD_TER_COL]);
terceiros->razao = strdup(row[RAZ_TER_COL]);
terceiros->nomes_fantasia = strdup(row[RAZ_TER_COL]);
terceiros->ie = strdup(row[IE_TER_COL]);
terceiros->doc = strdup(row[IE_TER_COL]);
terceiros->tipo_terc = atoi(row[TIPI_TER_COL]);
Expand Down

0 comments on commit d2e0d72

Please sign in to comment.