boa tarde fiz o que tu sugeriu, então, quando ele entra neste programa ele chama o Form_Valores, que por sua vez é para alimentar informações do cliente, até após a rotina eu coloquei um
Form_Valores.release
retu nil
e funcionou perfeitamente, só no programa ae ele chama outro form, para mostrar o valor total, deixar o usuario informar o valor pago, para mostrar um troco, ae que nao funciona mais, ele abre o form tudo normal, dae eu ao inves de imprimir o cupom, chamei um
Form_Valores.Release
Form_Encerra.Release
retu nil
e nao sei pra onde vai a rotina, mas nao retorna o programa anterior, vou postar o fonte aqui, se tiver uma alma caridosa rsrsrs
#Include "minigui.ch"
Function icupom(cser,ccup)
priv termina1:=termina2:=termina3:=termina4:=termina5:=termina6:=termina7:=termina8:="",vtotal:=0,;
TIMPOSTO:=0,cpfnfg:="",vserie:=SPACE(5),cnu:=SPACE(6),fser:=cser,fcup:=ccup
OPEN_DBF("MOVIMENT",1,1)
OPEN_DBF("ITENS",1,1)
OPEN_DBF("PRODUTOS",1,1)
OPEN_DBF("CLIENTES",1,1)
OPEN_DBF('VENDEDOR',1,1)
OPEN_DBF('EMPRESA',1,1)
OPEN_DBF('CADNCM',1,1)
Moviment->(DBSetOrder(1))
Moviment->(DBSeek(fser+Str(fcup,8),.T.))
if (Moviment->(Eof()) .or. Moviment->Numero <> fcup)
MsgStop("Cupom não encontrado")
retu .f.
endif
cpfnfg:=""
Nfg2()
vtotal:=Moviment->TTT_total
Fecha_Cupom()
Return nil
Function Fecha_Cupom()
cCliente := "999999"
cVendedor := "999999"
cDCliente := ""
cDVendedor := ""
cEndereco := SPACE(40)
cCidade := ""
cCep := ""
cCnpj := ""
cInscricao := ""
cCpf := ""
cDesconto := ""
cVenc := Date()
Vt := vtotal
citem:=''
DEFINE WINDOW Form_Encerra;
AT 0,0 ;
WIDTH 550 HEIGHT 360 ;
TITLE 'Encerramento do Cupom';
MODAL;
NOSYSMENU;
NOSIZE
@ 020,005 FRAME Fr_Dados OF Form_Encerra ;
CAPTION '';
WIDTH 525 HEIGHT 088 FONT 'ARIAL' SIZE 9
@ 100,005 FRAME Fr_Dados2;
CAPTION '';
WIDTH 525 HEIGHT 215 FONT 'ARIAL' SIZE 9
@ 044,010 LABEL Label_Cliente OF Form_Encerra ;
WIDTH 060 ;
HEIGHT 30 ;
VALUE "Cliente " ;
FONT 'Arial' SIZE 09;
FONTCOLOR BLUE BOLD
@ 074,010 LABEL Label_Vendedor OF Form_Encerra ;
VALUE 'Vendedor' ;
WIDTH 060 ;
HEIGHT 30 ;
FONT 'Arial' SIZE 09;
FONTCOLOR BLUE BOLD
@ 110,010 LABEL Label_Endereco OF Form_Encerra ;
VALUE 'Endereço' ;
WIDTH 060 ;
HEIGHT 30 ;
FONT 'Arial' SIZE 09;
FONTCOLOR BLUE BOLD
@ 110,320 LABEL Label_Cidade OF Form_Encerra ;
VALUE 'Cidade' ;
WIDTH 060 ;
HEIGHT 30 ;
FONT 'Arial' SIZE 09;
FONTCOLOR BLUE BOLD
@ 150,010 LABEL Label_Cep OF Form_Encerra ;
VALUE 'Cep' ;
WIDTH 060 ;
HEIGHT 30 ;
FONT 'Arial' SIZE 09;
FONTCOLOR BLUE BOLD
@ 150,140 LABEL Label_Cnpj OF Form_Encerra ;
VALUE 'Cnpj' ;
WIDTH 50 ;
HEIGHT 30 ;
FONT 'Arial' SIZE 09 ;
FONTCOLOR BLUE BOLD
@ 150,355 LABEL Label_Inscricao OF Form_Encerra ;
VALUE 'Inscrição' ;
WIDTH 60 ;
HEIGHT 30 ;
FONT 'Arial' SIZE 09 ;
FONTCOLOR BLUE BOLD
@ 190,010 LABEL Label_Cpf OF Form_Encerra ;
VALUE 'Cpf' ;
WIDTH 30 ;
HEIGHT 30 ;
FONT 'Arial' SIZE 09 ;
FONTCOLOR BLUE BOLD
@ 190,355 LABEL Label_vct OF Form_Encerra ;
VALUE 'Vencimento' ;
WIDTH 70 ;
HEIGHT 30 ;
FONT 'Arial' SIZE 09 ;
FONTCOLOR BLUE BOLD
@ 230,230 LABEL Label_Desconto OF Form_Encerra ;
VALUE 'Desconto' ;
WIDTH 100 ;
HEIGHT 27 ;
FONT 'Arial' SIZE 09 ;
FONTCOLOR BLUE BOLD
@ 040,070 TEXTBOX T_Cliente OF Form_Encerra ;
WIDTH 60 ;
VALUE cCliente ;
TOOLTIP 'Código do Cliente' ;
FONT "Arial" SIZE 09 ;
MAXLENGTH 06 ;
ON LOSTFOCUS B_Clientes_Cupon()
@ 040,130 TEXTBOX T_Dcliente OF Form_Encerra ;
WIDTH 290 ;
VALUE cDcliente ;
TOOLTIP 'Clientes/Fornecedores';
FONT "Arial" SIZE 09 ;
BACKCOLOR WHITE ;
FONTCOLOR BLUE BOLD
@ 070,070 TEXTBOX T_Vendedor OF Form_Encerra ;
WIDTH 60 ;
VALUE cVendedor ;
TOOLTIP 'Código do Vendedor' ;
FONT "Arial" SIZE 09 ;
MAXLENGTH 06 ;
ON LOSTFOCUS B_Vendedor_Cupon()
@ 125,010 TEXTBOX T_Endereco OF Form_Encerra ;
WIDTH 300 ;
VALUE cEndereco ;
TOOLTIP 'Endereço' ;
FONT "Arial" SIZE 09 ;
MAXLENGTH 40
@ 125,320 TEXTBOX T_Cidade OF Form_Encerra ;
WIDTH 205 ;
VALUE ccidade ;
TOOLTIP 'Endereço' ;
FONT "Arial" SIZE 09 ;
MAXLENGTH 30
@ 165,010 TEXTBOX T_Cep OF Form_Encerra ;
VALUE cCep ;
TOOLTIP 'Cep do Cliente' ;
INPUTMASK '99.999-999'
@ 165,140 TEXTBOX T_Cnpj OF Form_Encerra ;
WIDTH 200 ;
VALUE cCnpj ;
TOOLTIP 'Digite o Cnpj' ;
INPUTMASK '99.999.999/9999-99' ;
ON LOSTFOCUS desab_cnpjc()
@ 165,355 TEXTBOX T_Inscricao OF Form_Encerra ;
WIDTH 150 ;
VALUE cInscricao ;
TOOLTIP 'Inscrição do Cliente' ;
MAXLENGTH 20
@ 205,010 TEXTBOX T_Cpf OF Form_Encerra ;
WIDTH 150 ;
VALUE cCpf ;
TOOLTIP 'Digite o Cpf' ;
INPUTMASK '999.999.999-99'
@ 205,200 RADIOGROUP Radio OF Form_Encerra ;
OPTIONS { 'A Vista' , 'A Prazo'} ;
VALUE 1 ;
WIDTH 60 ;
SPACING 02 ;
FONT 'Arial' SIZE 09;
ON CHANGE FocaVencimentoc() ;
TOOLTIP 'RadioGroup horizontal rightjustify (default)' HORIZONTAL
@ 205,355 DATEPICKER TVenc OF Form_Encerra ;
WIDTH 100 FONT 'ARIAL' SIZE 9 ;
VALUE cVenc ;
TOOLTIP 'Vencimento'
@ 247,010 RADIOGROUP desconto OF Form_Encerra ;
OPTIONS { 'Desconto' , 'Acréscimo'} ;
VALUE 1 ;
WIDTH 90 ;
SPACING 02 ;
FONT 'Arial' SIZE 09;
ON CHANGE FocaDescontoc() ;
TOOLTIP 'RadioGroup horizontal rightjustify (default)' HORIZONTAL
@ 247,230 TEXTBOX T_Desconto OF Form_Encerra ;
WIDTH 080 ;
VALUE cdesconto ;
TOOLTIP 'Informe o Valor' ;
FONT 'Arial' SIZE 12 ;
FONTCOLOR BLUE BOLD ;
NUMERIC INPUTMASK '99,999.99' ;
ON LOSTFOCUS Calc_descc()
@ 280,030 BUTTON Bt_Finaliza OF Form_Encerra ;
CAPTION '&Finaliza' ;
FONT 'Arial' SIZE 09 ;
ACTION Finalizac()
@ 070,130 TEXTBOX T_DVendedor OF Form_Encerra ;
WIDTH 290 ;
VALUE cDVendedor ;
TOOLTIP 'Vendedor' ;
FONT "Arial" SIZE 09 ;
BACKCOLOR WHITE ;
FONTCOLOR BLUE BOLD
@ 038,428 BUTTON Btn_Clientes Of Form_Encerra;
CAPTION '&Clientes' ;
ACTION P_Cliente_Cupomc() ;
WIDTH 80 HEIGHT 27 ;
FONT "Arial" SIZE 09 ;
TOOLTIP "Pesquisa Clientes"
@ 075,428 BUTTON Btn_Vendedor Of Form_Encerra;
CAPTION '&Vendedores' ;
ACTION P_Vend_Cupomc() ;
WIDTH 80 HEIGHT 27 ;
FONT "Arial" SIZE 09 ;
TOOLTIP "Pesquisa Vendedores"
@ 280,250 LABEL La__Total OF Form_Encerra ;
VALUE "Valor Total" ;
WIDTH 120 ;
HEIGHT 30 ;
FONT 'Arial' SIZE 15;
FONTCOLOR BLUE BOLD
@ 280,420 TEXTBOX T_TOTAL OF Form_Encerra ;
WIDTH 080 ;
VALUE vtotal ;
FONT 'Arial' SIZE 12 ;
FONTCOLOR BLUE BOLD ;
NUMERIC INPUTMASK '99,999.99'
END WINDOW
Form_Encerra.Tvenc.Enabled:= .F.
Form_Encerra.T_Cliente.SetFocus
Form_Encerra.T_DVendedor.ReadOnly := .T.
Form_Encerra.T_Dcliente.ReadOnly := .T.
Form_Encerra.T_total.ReadOnly := .T.
CENTER WINDOW Form_Encerra
ACTIVATE WINDOW Form_Encerra
RETU NIL
Function desab_cnpjc()
retu .t.
if !empty(subs(Form_Encerra.T_Cnpj.Value,1,1))
Form_Encerra.T_Cpf.Readonly := .T.
else
Form_Encerra.T_Cpf.Readonly := .T.
endif
Function focavencimentoc()
If Form_Encerra.Radio.Value = 1
Form_Encerra.Tvenc.Enabled:= .F.
else
Form_Encerra.Tvenc.Enabled:= .T.
Endif
retu .t.
Function focaDescontoc()
If Form_Encerra.Desconto.Value = 1
Form_Encerra.Label_Desconto.Value := "Desconto"
Form_Encerra.T_Desconto.Setfocus
else
Form_Encerra.Label_Desconto.Value := "Acréscimo"
Form_Encerra.T_Desconto.Setfocus
Endif
Function Calc_descc()
Vtotal = Vt + if(Form_Encerra.Desconto.Value = 1, - Form_Encerra.T_Desconto.Value,Form_Encerra.T_Desconto.Value)
Form_Encerra.T_TOTAL.Value := Vtotal
retu nil
Function B_Clientes_Cupon()
monna_clientes(.F.)
If Form_Encerra.T_Cliente.Value = str(999999,6)
Form_Encerra.T_Dcliente.ReadOnly := .F.
Form_Encerra.T_Dcliente.Value:= "Venda a Vista"
Form_Encerra.T_Dcliente.SetFocus
Endif
If !Empty(Form_Encerra.T_Cliente.Value) .and. Form_Encerra.T_Cliente.Value <> str(999999,6)
Clientes->(DBSetOrder(1))
If ! Clientes->(DBSeek(VAL(Form_Encerra.T_Cliente.Value)))
Form_Encerra.T_Dcliente.Value := 'Não cadastrado'
Form_Encerra.T_Dcliente.ReadOnly := .T.
Form_Encerra.T_Vendedor.SetFocus
else
monna_clientes(.T.)
Form_Encerra.T_Dcliente.Value := Clientes->Cliente
Form_Encerra.T_Dcliente.ReadOnly := .T.
Form_Encerra.T_Vendedor.SetFocus
endif
Endif
return Nil
Function monna_clientes(mostra)
If mostra
Form_Encerra.T_DCliente.Value:=CLIENTES->CLIENTE
Form_Encerra.T_Endereco.Value:=CLIENTES->ENDERECO
Form_Encerra.T_Cidade.Value:=CLIENTES->CIDADE
Form_Encerra.T_Cep.Value:=CLIENTES->CEP
Form_Encerra.T_Cnpj.Value:=CLIENTES->CGC
Form_Encerra.T_Cpf.Value:=CLIENTES->CPF
Form_Encerra.T_Inscricao.Value:=CLIENTES->INSCRICAO
Form_Encerra.T_Dvendedor.Value:=""
else
Form_Encerra.T_DCliente.Value:="Venda a Vista"
Form_Encerra.T_Endereco.Value:=""
Form_Encerra.T_Endereco.Value:=""
Form_Encerra.T_Cep.Value:=""
Form_Encerra.T_Cnpj.Value:=""
Form_Encerra.T_Cpf.Value:=""
Form_Encerra.T_Inscricao.Value:=""
Form_Encerra.T_Dvendedor.Value:=""
Endif
retu nil
Function B_Vendedor_Cupon()
If !Empty(Form_Encerra.T_Vendedor.Value) .and. Form_Encerra.T_Vendedor.Value <> str(999999,6)
Vendedor->(DBSetOrder(1))
If ! Vendedor->(DBSeek(VAL(Form_Encerra.T_Vendedor.Value)))
Form_Encerra.T_DVendedor.Value := 'Não cadastrado'
else
Form_Encerra.T_DVendedor.Value := Vendedor->Vendedor
endif
Endif
return Nil
Function Finalizac()
Private CTROCO:="",cpago:= vtotal,ctotal := vtotal
DEFINE WINDOW Form_Valores;
AT 0,0 ;
WIDTH 270 HEIGHT 170 ;
TITLE 'Informe Valores';
MODAL;
NOSYSMENU;
NOSIZE
@ 010,010 LABEL Labe__Total Of Form_Valores;
VALUE "Valor Total" ;
WIDTH 120 ;
HEIGHT 30 ;
FONT 'Arial' SIZE 15;
FONTCOLOR BLUE BOLD
@ 050,010 LABEL Label_pago Of Form_Valores;
VALUE "Valor Pago" ;
WIDTH 120 ;
HEIGHT 30 ;
FONT 'Arial' SIZE 15;
FONTCOLOR BLUE BOLD
@ 090,010 LABEL Label_Troco Of Form_Valores;
VALUE "Troco" ;
WIDTH 120 ;
HEIGHT 30 ;
FONT 'Arial' SIZE 15;
FONTCOLOR BLUE BOLD
@ 050,170 TEXTBOX T_Pago Of Form_Valores;
WIDTH 080 ;
VALUE cpago ;
TOOLTIP 'Informe o Valor' ;
FONT 'Arial' SIZE 12 ;
FONTCOLOR BLUE BOLD ;
NUMERIC INPUTMASK '99,999.99' ;
ON LOSTFOCUS CALC_TROCOO()
@ 090,170 TEXTBOX T_troco Of Form_Valores;
WIDTH 080 ;
VALUE ctroco ;
FONT 'Arial' SIZE 12 ;
FONTCOLOR BLUE BOLD ;
NUMERIC INPUTMASK '99,999.99' ;
ON LOSTFOCUS Finaliza_valoresS()
@ 010,170 TEXTBOX T_TOTAL Of Form_Valores;
WIDTH 080 ;
VALUE ctotal ;
FONT 'Arial' SIZE 12 ;
FONTCOLOR BLUE BOLD ;
NUMERIC INPUTMASK '99,999.99'
END WINDOW
Form_Valores.T_troco.ReadOnly := .T.
Form_Valores.T_total.ReadOnly := .T.
Form_Valores.T_pago.Setfocus
CENTER WINDOW Form_Valores
ACTIVATE WINDOW Form_Valores
return nil
Function CALC_TROCOO()
Form_Valores.T_troco.Value := Form_Valores.T_PAGO.Value - vtotal
retu nil
Function P_Vend_Cupomc()
Private Vcodigo :=Form_Encerra.T_Vendedor.Value
Vendedores(Vcodigo,1)
Vendedor->(DBSetOrder(1))
If ! Vendedor->(DBSeek(Vcodigo))
MsgSTOP("Vendedor não encontrado","Produtos")
Form_Encerra.T_Vendedor.Setfocus
Return .f.
Endif
Form_Encerra.T_Vendedor.Value := Str(Vendedor->Codigo,6)
Form_Encerra.T_DVendedor.Value := Vendedor->Vendedor
return nil
Function P_Cliente_Cupomc()
Private Vcodigo :=Form_Encerra.T_Cliente.Value
Clientes(Vcodigo,1,"S")
Clientes->(DBSetOrder(1))
If ! Clientes->(DBSeek(Vcodigo))
MsgSTOP("Cliente não encontrado","Produtos")
Form_Encerra.T_Cliente.Setfocus
Return .f.
Endif
Form_Encerra.T_Cliente.Value := Str(Clientes->Codigo,6)
Form_Encerra.T_DCliente.Value := Clientes->CLIENTE
Form_Encerra.T_Cliente.Setfocus
return nil
Function Nfg2()
DEFINE WINDOW Form_Nfg;
AT 0,0 ;
WIDTH 450 HEIGHT 160 ;
TITLE 'Informações nota fiscal gaúcha';
MODAL;
NOSYSMENU;
NOSIZE
@ 020,005 FRAME Fr_Dadosx ;
CAPTION '';
WIDTH 425 HEIGHT 088 FONT 'ARIAL' SIZE 9
@ 050,010 LABEL Label_CpfNfg ;
VALUE 'Cpf' ;
WIDTH 30 ;
HEIGHT 30 ;
FONT 'Arial' SIZE 09 ;
FONTCOLOR BLUE BOLD
@ 050,050 TEXTBOX T_CpfNfg ;
WIDTH 150 ;
VALUE cpfnfg ;
TOOLTIP 'Digite o Cpf' ;
INPUTMASK '999.999.999-99'
@ 050,250 BUTTON Bt_Finalizanfg ;
CAPTION '&Confirma' ;
FONT 'Arial' SIZE 09 ;
ACTION Form_NfgOK2()
END WINDOW
Form_Nfg.T_CpfNfg.SetFocus
CENTER WINDOW Form_Nfg
ACTIVATE WINDOW Form_Nfg
Function Form_NfgOK2
cpfnfg:=Form_Nfg.T_CpfNfg.Value
cpfnfg=STRTRAN(cpfnfg,".","")
cpfnfg=STRTRAN(cpfnfg,"/","")
cpfnfg=STRTRAN(cpfnfg,"-","")
cpfnfg=STRTRAN(cpfnfg,",","")
cpfnfg=STRTRAN(cpfnfg," ","")
if vcic(cpfnfg)
Form_Nfg.Release
ELSE
Msgstop("Cpf Inválido")
Form_Nfg.T_CpfNfg.SetFocus
ENDIF
Function Finaliza_valoresS()
priv vDesconto:=alltrim(strtran(str(Form_Encerra.T_Desconto.Value,9,2),'.','')),;
termina1:=termina2:=termina3:=termina4:=termina5:=termina6:=termina7:=termina8:=""
If !Moviment->(eof()) .and. Bloarq("Moviment")
Moviment->Cliente = Val(Form_Encerra.T_Cliente.Value)
Moviment->Vendedor = Val(Form_Encerra.T_Vendedor.Value)
Moviment->(DBCommit())
Moviment->(DBUnlock())
Endif
msgstop("finaliza")
Form_Valores.Release
Form_Encerra.Release
retu