#include "hwgui.ch"
STATIC Thisform

FUNCTION pfnf01.scr.backup( p1, p2, p3, p4 )
 RETURN _pfnf01.scr.backup( p1, p2 ,p3 ,p4)

FUNCTION _pfnf01.scr.backup

 PRIVATE m_pffor := "", M_cp_fantasi := "", m_pfvalprod := "", m_pfval := "", m_PFTAXAICMS := "", m_PFBASEICMS := "" ;
        , vEdit2 := "", vEdit3 := "", m_PFTOTICMS := "", vEdit1 := "", m_PFVALRET := "", m_PFTOTIPI := "", m_PFOUTROS := "" ;
        , m_PFVALDES := "", m_PFVALREP := "", m_PFDATAPED := date(), m_PFDATAEMI := date(), m_PFDATACHE := date(), m_PFCODOP := "", m_PFSERIESUB := "" ;
        , m_PFNUM := ""
 PRIVATE oDlgStatusBar, oLabel1, oLabel2, D_oB, oLabel7, oLabel10, oLabel11 ;
        , oLabel12, oLabel20, oLabel21, oLabel13, oLabel19, oLabel14, oLabel15, oLabel16 ;
        , oLabel17, oLabel22, oLabel18, oLabel3, oLabel4, oLabel5, oLabel6, oLabel8 ;
        , oLabel9, osoSayPFCODOP, opffor, ocp_fantasi, opfvalprod, opfval, oPFTAXAICMS, oPFBASEICMS ;
        , oEdit2, oEdit3, oPFTOTICMS, oEdit1, oPFVALRET, oPFTOTIPI, oPFOUTROS, oPFVALDES ;
        , oPFVALREP, oPFDATAPED, oPFDATAEMI, oPFDATACHE, oPFCODOP, oPFSERIESUB, oPFNUM

  INIT DIALOG pf_nf01 TITLE "Entrada de Produtos" ;
        COLOR 14215660 BACKGROUND BITMAP HBitmap():AddFile('icon\nota.jpg')  ;
    AT 6,83 SIZE 1024,677 ;
        FONT HFont():Add( 'Verdana',0,-13,400,,,) CLIPPER  ;
     STYLE WS_CAPTION+WS_SIZEBOX+DS_CENTER  ;
     ON INIT {|oDlg| onDlgInit( oDlg ) } ;
     ON PAINT {|oCtrl,hDC| onPaint( oCtrl,hDC ) }
    Thisform := pf_nf01

   ADD STATUS oDlgStatusBar TO pf_nf01  ; 
        PARTS 640, 160, 0
   @ 33,30 SAY oLabel1 CAPTION "Código"  TRANSPARENT SIZE 49,20    ;
        FONT HFont():Add( 'Courier New',0,-12,700,,,)
   @ 89,30 SAY oLabel2 CAPTION "Fantasia do Forn.:"  TRANSPARENT SIZE 133,20    ;
        FONT HFont():Add( 'Courier New',0,-12,700,,,)
   @ 20,247 BROWSE D_oB DATABASE SIZE 989,234 ;
        STYLE WS_TABSTOP        ;
        ON GETFOCUS {|| nBrwAtivo:=1 } ; 
        ON INIT {|| D_oB_onInit(  ) }
    // CREATE D_oB   //  SCRIPT GENARATE BY DESIGNER

   @ 32,248 SAY oLabel18 CAPTION "REPASSE DE ICMS...:" OF D_oB  SIZE 0,16    ;
        FONT HFont():Add( 'Courier New',0,-12,700,,,)
   @ 737,128 SAY oLabel7 CAPTION "Valor dos Produtos"  TRANSPARENT SIZE 140,20    ;
        FONT HFont():Add( 'Courier New',0,-12,700,,,)
   @ 737,175 SAY oLabel10 CAPTION "Valor Contabil NF"  TRANSPARENT SIZE 140,20    ;
        FONT HFont():Add( 'Courier New',0,-12,700,,,)
   @ 655,30 SAY oLabel11 CAPTION "Aliquota"  TRANSPARENT SIZE 64,20    ;
        FONT HFont():Add( 'Courier New',0,-12,700,,,)
   @ 33,128 SAY oLabel12 CAPTION "BASE DO ICMS"  TRANSPARENT SIZE 104,20    ;
        FONT HFont():Add( 'Courier New',0,-12,700,,,)
   @ 33,175 SAY oLabel20 CAPTION "VALOR DO FRETE"  TRANSPARENT SIZE 104,21    ;
        FONT HFont():Add( 'Courier New',0,-12,700,,,)
   @ 156,175 SAY oLabel21 CAPTION "VALOR DO SEGURO"  TRANSPARENT SIZE 109,20    ;
        FONT HFont():Add( 'Courier New',0,-12,700,,,)
   @ 156,128 SAY oLabel13 CAPTION "VALOR DO ICMS"  TRANSPARENT SIZE 109,20    ;
        FONT HFont():Add( 'Courier New',0,-12,700,,,)
   @ 285,128 SAY oLabel19 CAPTION "BASE DE CALCULO DO ICMS SUBSTITUICAO"  TRANSPARENT SIZE 262,20    ;
        FONT HFont():Add( 'Courier New',0,-12,700,,,)
   @ 572,128 SAY oLabel14 CAPTION "ICMS SUBSTITUICAO"  TRANSPARENT SIZE 140,20    ;
        FONT HFont():Add( 'Courier New',0,-12,700,,,)
   @ 572,175 SAY oLabel15 CAPTION "VALOR DO IPI"  TRANSPARENT SIZE 140,20    ;
        FONT HFont():Add( 'Courier New',0,-12,700,,,)
   @ 420,175 SAY oLabel16 CAPTION "OUTROS ENCARGOS"  TRANSPARENT SIZE 126,20    ;
        FONT HFont():Add( 'Courier New',0,-12,700,,,)
   @ 285,175 SAY oLabel17 CAPTION "DESCONTO"  TRANSPARENT SIZE 127,20    ;
        FONT HFont():Add( 'Courier New',0,-12,700,,,)
   @ 18,497 SAY oLabel22 CAPTION "REPASSE DE ICMS"  TRANSPARENT SIZE 114,21    ;
        FONT HFont():Add( 'Courier New',0,-12,700,,,)
   @ 767,29 SAY oLabel3 CAPTION "DT. PEDIDO"  TRANSPARENT SIZE 84,20    ;
        FONT HFont():Add( 'Courier New',0,-12,700,,,)
   @ 767,58 SAY oLabel4 CAPTION "DT. EMISSAO"  TRANSPARENT SIZE 84,20    ;
        FONT HFont():Add( 'Courier New',0,-12,700,,,)
   @ 767,87 SAY oLabel5 CAPTION "DT. CHEGADA"  TRANSPARENT SIZE 84,20    ;
        FONT HFont():Add( 'Courier New',0,-12,700,,,)
   @ 368,30 SAY oLabel6 CAPTION "Cod Oper Fiscal"  TRANSPARENT SIZE 140,20    ;
        FONT HFont():Add( 'Courier New',0,-12,700,,,)
   @ 544,30 SAY oLabel8 CAPTION "Serie"  TRANSPARENT SIZE 42,20    ;
        FONT HFont():Add( 'Courier New',0,-12,700,,,)
   @ 593,30 SAY oLabel9 CAPTION "Nº Nota"  TRANSPARENT SIZE 53,20    ;
        FONT HFont():Add( 'Courier New',0,-12,700,,,)
   @ 418,56 SAY osoSayPFCODOP CAPTION "..."  TRANSPARENT SIZE 119,20 ;
        STYLE WS_BORDER   ;
        FONT HFont():Add( 'Courier New',0,-12,700,,,)
   @ 33,56 GET opffor VAR m_pffor CONTROLSOURCE  SIZE 49,20 ;
        STYLE WS_DLGFRAME   MAXLENGTH 4  ; 
        TOOLTIP ""
   @ 89,56 GET ocp_fantasi VAR M_cp_fantasi CONTROLSOURCE  SIZE 272,20 ;
        STYLE WS_DLGFRAME   MAXLENGTH 20  ; 
        TOOLTIP "" ;
        WHEN  {|| .f. }
   @ 737,151 GET opfvalprod VAR m_pfvalprod CONTROLSOURCE  SIZE 140,20 ;
        STYLE WS_DLGFRAME   MAXLENGTH 12  ; 
        TOOLTIP "" ;
        WHEN  {|| .f. }
   @ 737,199 GET opfval VAR m_pfval CONTROLSOURCE  SIZE 140,20 ;
        STYLE WS_DLGFRAME   MAXLENGTH 12  ; 
        TOOLTIP ""
   @ 655,57 GET oPFTAXAICMS VAR m_PFTAXAICMS CONTROLSOURCE  SIZE 64,20 ;
        STYLE WS_DLGFRAME   MAXLENGTH 5  ; 
        TOOLTIP ""
   @ 33,151 GET oPFBASEICMS VAR m_PFBASEICMS CONTROLSOURCE  SIZE 104,20 ;
        STYLE WS_DLGFRAME   MAXLENGTH 12  ; 
        TOOLTIP "" ;
        WHEN  {|| if(M_PFBASEICMS=0.or.M_PFBASEICMS>M_PFval,(M_PFBASEICMS:=M_PFval,.t.),.t.) }
   @ 33,199 GET oEdit2 VAR vEdit2 CONTROLSOURCE  SIZE 104,20 ;
        STYLE WS_DLGFRAME   MAXLENGTH 12  ; 
        TOOLTIP "" ;
        WHEN  {|| if(M_PFBASEICMS=0.or.M_PFBASEICMS>M_PFval,(M_PFBASEICMS:=M_PFval,.t.),.t.) }
   @ 156,199 GET oEdit3 VAR vEdit3 CONTROLSOURCE  SIZE 109,20 ;
        STYLE WS_DLGFRAME   MAXLENGTH 12  ; 
        TOOLTIP "" ;
        WHEN  {|| if(M_PFBASEICMS=0.or.M_PFBASEICMS>M_PFval,(M_PFBASEICMS:=M_PFval,.t.),.t.) }
   @ 156,151 GET oPFTOTICMS VAR m_PFTOTICMS CONTROLSOURCE  SIZE 109,20 ;
        STYLE WS_DLGFRAME   MAXLENGTH 12  ; 
        TOOLTIP "" ;
        WHEN  {|| (M_PFTOTICMS:=M_PFBASEICMS*M_PFTAXAICMS/100,.t.) }
   @ 285,151 GET oEdit1 VAR vEdit1 CONTROLSOURCE  SIZE 262,20 ;
        STYLE WS_DLGFRAME   MAXLENGTH 12  ; 
        TOOLTIP "" ;
        WHEN  {|| (M_PFTOTICMS:=M_PFBASEICMS*M_PFTAXAICMS/100,.t.) }
   @ 572,151 GET oPFVALRET VAR m_PFVALRET CONTROLSOURCE  SIZE 140,20 ;
        STYLE WS_DLGFRAME   MAXLENGTH 12  ; 
        TOOLTIP ""
   @ 572,199 GET oPFTOTIPI VAR m_PFTOTIPI CONTROLSOURCE  SIZE 140,20 ;
        STYLE WS_DLGFRAME   MAXLENGTH 12  ; 
        TOOLTIP ""
   @ 420,199 GET oPFOUTROS VAR m_PFOUTROS CONTROLSOURCE  SIZE 126,20 ;
        STYLE WS_DLGFRAME   MAXLENGTH 12  ; 
        TOOLTIP ""
   @ 285,199 GET oPFVALDES VAR m_PFVALDES CONTROLSOURCE  SIZE 127,20 ;
        STYLE WS_DLGFRAME   MAXLENGTH 12  ; 
        TOOLTIP ""
   @ 136,497 GET oPFVALREP VAR m_PFVALREP CONTROLSOURCE  SIZE 91,21 ;
        STYLE WS_DLGFRAME   MAXLENGTH 12  ; 
        TOOLTIP ""
   @ 850,29 GET DATEPICKER oPFDATAPED VAR m_PFDATAPED CONTROLSOURCE  SIZE 84,20 ;
        STYLE 0    
   @ 850,58 GET DATEPICKER oPFDATAEMI VAR m_PFDATAEMI CONTROLSOURCE  SIZE 84,20 ;
        STYLE 0     ;
        VALID  {|| M_PFDATAEMI>=M_PFDATAPED }
   @ 850,87 GET DATEPICKER oPFDATACHE VAR m_PFDATACHE CONTROLSOURCE  SIZE 84,20 ;
        STYLE 0     ;
        VALID  {|| M_PFDATACHE>=M_PFDATAEMI }
   @ 368,56 GET oPFCODOP VAR m_PFCODOP CONTROLSOURCE  SIZE 42,20 ;
        STYLE WS_DLGFRAME   MAXLENGTH 5  ; 
        TOOLTIP "" ;
        VALID  {|| PSQ_BROW('SF_CODOP','PSFCODOP','M_PFCODOP','N','S',9,2,'DESCOP','9.999','',,oPFCODOP,osoSayPFCODOP) }
   @ 544,57 GET oPFSERIESUB VAR m_PFSERIESUB CONTROLSOURCE  SIZE 42,20 ;
        STYLE WS_DLGFRAME   MAXLENGTH 3  ; 
        TOOLTIP ""
   @ 593,57 GET oPFNUM VAR m_PFNUM CONTROLSOURCE  SIZE 53,20 ;
        STYLE WS_DLGFRAME   MAXLENGTH 6  ; 
        TOOLTIP "" ;
        VALID  {|| M_PFNUM<>0 }

   ACTIVATE DIALOG pf_nf01 NOMODAL

    SETFOCUS(pf_nf01:Handle) 

RETURN pf_nf01:lresult

STATIC FUNCTION onDlgInit
parameters oDlg
//skel VARIAVEL w_colsep = chr(179)
//skel VARIAVEL w_headsep = chr(196)
//skel 
//skel COMANDO ANTES abra_arq("sccpfab")
//skel COMANDO ANTES DbSelectArea("SP_MOVF")
//skel COMANDO DEPOIS sccpfab->(DbCloseArea())
//skel VARIAVEL z_blkdsp = 'zpcod:=pcod,zseek:=zpcod<>se_prod->pcod,znil:=prd_dados("DAGO"),znil:=if(zseek,se_prod->(DbSeek(zpcod)),NIL),zlab:=se_prod->pprincforn,sccpfab->(DbGoto(zlab)),'
//skel VARIAVEL z_blkdsp = z_blkdsp + 'znil:=if(zseek.and.se_prod->pitens>1,alert_tef("Produto fracionado!",1),NIL),zcor:=SetColor("R/W"),DevPos(6,41),DevOut("Fabr:"+sccpfab->CP_FANTASI),SetColor(ZCOR)'
//skel VARIAVEL z_blkdsp = _CreateBlock( z_blkdsp )
//skel comando durante znil = eval(z_blkdsp)
oContextMenu:=Hwg_ContextMenu()
hwg_Btn(oToolbar,24,544,54,54)
hwg_TbMt(oToolbar,'22;ins_prd(D_oB,"R",.T.,.t.);Ins-Inclui ;Inclui Novo produto no Cadastro;xml\icon\add.jpg;28;28;;;')
hwg_TbMt(oToolbar,'7;tb_del(D_oB);Del-Apaga ;Deleta/Exclui o Cadastro de um Produto;xml\icon\deleta.jpg;28;28;;;')
hwg_TbMt(oToolbar,'79;tb_index(D_OB);O-Ordena ;O - Ordena;xml\icon\ordena.jpg;28;28;;;')
hwg_TbMt(oToolbar,'73;Lst_alias(D_OB);I-Imprime ;I - Imprime;xml\icon\impressora.jpg;28;28;;;')
hwg_TbMt(oToolbar,'82;pfrecquant(D_oB);R-Confirma_Todos ;R - Confirma_Todos;xml\icon\r.jpg;28;28;;;')
hwg_TbMt(oToolbar,'13;pf_DoGet(D_oB,"R");Enter-Altera ;Enter-Altera;xml\icon\enter.jpg;28;28;;;')
d_ob:lEditable = .t.
hwg_TbMt(oToolbar,'86;pfvalor(D_oB);V-Valor_Pedido ;V - Valor_Pedido;xml\icon\v.jpg;28;28;;;')
hwg_TbMt(oToolbar,'32;OrdSetFocus(0);Barra-Ordem_Digitacao ;Barra - Ordem_Digitacao;xml\icon\barrae.jpg;28;28;;;')
hwg_TbMt(oToolbar,'93;disp_sdse(D_OB);]-Demanda;] - Demanda;;')
hwg_TbMt(oToolbar,'47;chk_sp_movf(,,D_oB,"AJUSTA_TODOS");/-Ajusta_Valores ;/ - Ajusta_Valores;xml\icon\barra.jpg;28;28;;;')
hwg_TbMt(oToolbar,'66;pf_ean(nrow,d_ob);B-Cod_Barras ;B - Cod_Barras;xml\icon\b.jpg;28;28;;;')
hwg_TbMt(oToolbar,'63;chk_sp_movf(,,,"CALCULA_VALOR");?-Valor_NF ;? - Valor_NF;;')
hwg_TbMt(oToolbar,'0;;;espaco;espaco;')
hwg_TbMt(oToolbar,'27;hwg_oDlgKey(oDlg, 27, nBrwAtivo);Saida;Saida;xml\icon\saida.ico;28;28;;;')
SetDlgKey(oDlg,8,26,{|| (aBrowses[nBrwAtivo,2])->(moveRec(aBrowses[nBrwAtivo,1],"UP"))})
SetDlgKey(oDlg,8,28,{|| (aBrowses[nBrwAtivo,2])->(moveRec(aBrowses[nBrwAtivo,1],"DOWN"))})
Hwg_EndMenu()

RETURN Nil

STATIC FUNCTION onPaint
Parameters oCtrl,hDC
oCtrl:bpaint:=NIL
//D_oB:setFocus()
opffor:setFocus()
RETURN Nil

STATIC FUNCTION D_oB_onInit
D_oB:bColorSel:= RGB(3,23,133)
D_oB:tColorSel:= RGB(255,255,255)
D_oB:bKeyDown := {|self, wParam| (aBrowses[nBrwAtivo,2])->(hwg_oDlgKey(self, wparam,1)) , .T. }
hwg_TbFi(D_oB, 'Cod;PCOD;N;9999999; 7;N;')
hwg_TbFi(D_oB, 'Desc;PDESC;C;@S24; 22;N;')
hwg_TbFi(D_oB, 'Receb;mqatend;N;9999;  4;S;')
hwg_TbFi(D_oB, 'PrTab;pvlutab;N;9999.99;7;S;')
hwg_TbFi(D_oB, '%Negoc;PdscCompr;N;999.99;6;S;')
hwg_TbFi(D_oB, 'PrUnNf;pvluven3;N;9999.99;7;S;')
hwg_TbFi(D_oB, '%Prd;Pdesconto;N;999.99;6;N;')
hwg_TbFi(D_oB, 'CstTotl;mvalor3;N;9999.99;7;S;')
hwg_TbFi(D_oB, '%Rod;PdscRodape;N;999.99;6;S;')
hwg_TbFi(D_oB, '*;pnegpos;C;x;1;S;')
hwg_TbFi(D_oB, 'Cf;pcategoria;C;xxx;3;S;')
hwg_TbFi(D_oB, '%Repas;prepasse;N;999.99;6;S;')
hwg_TbFi(D_oB, '%IPI;pipient;N;999.99;6;S;')
hwg_TbFi(D_oB, 'Pr Vend;pvluvenda;N;9999.99;7;S;')
hwg_TbFi(D_oB, '%DscTt;if(mvalor3>0,100*(mqatend*pvlutab-mvalor3)/(mqatend*pvlutab),0);N;999.99;6;N;')
hwg_TbFi(D_oB, 'Pend;unid_fech-mqatend;N;9999; 4;N;')
hwg_TbFi(D_oB, 'UndVnd;mquant;N;999999;  6;N;')
hwg_TbFi(D_oB, 'Frc;pitens;N;9999;  4;N;')
hwg_TbFi(D_oB, 'Dicionario;pdic;N;99999999;  8;S;')
D_oB:ALIAS := alias()
D_oB:bOther:={|o,m,wp,lp| MessagesBrowse(o,m,wp,lp)}
D_oB:cargo:={.T.,.T.,"SP_MOVF",.F.,.T.,{||.T.} }
d_ob:bEdit := &('{|D_oB| nKey:=13,pf_DoGet(D_oB,"R")}')
AADD(aBrowses,{D_oB,D_oB:Alias,{||.f.},{|| .T.},})
 
RETURN Nil

