TSBrowse.PRG Version 8.0 Feb/01/2008
Is attached the source.
- Code: Select all Expand view
*--------------------------------------------------------------------------
FUNCTION Estoque_Cadastro()
*--------------------------------------------------------------------------
LOCAL aSets, aFiles
LOCAL nI
LOCAL hTicket
LOCAL oDlg, oTbr, oVar
aSets := Set_Save()
aFiles := { "Estoque", "GrupoProduto", "EstDeposito", "Obsoleto", "Ticket", "Aliquota", "TabArray", "SisArray" }
IF !EA_GetOpenFileName( aFiles, True )
Set_Restore( aSets )
Return( Nil )
ENDIF
EstDeposito->( OrdSetFocus( "Produto" ) )
oVar := TPublic():New( False )
oVar:Add( "cBoxTitle" , "Estoque de Produtos e Serviços" )
oVar:Add( "Icms_SubsTrib", False )
oVar:Add( "Nota_Emite" , False )
oVar:Add( "Nota_Separado", False )
oVar:Add( "Info_Sefaz" , False )
oVar:Add( "lAppend" , False )
oVar:Add( "lInfoCodigo" , Substr( Empresa->Emp_Cfg, 5, 1 ) )
oVar:Add( "lArmazem" , EA_CtoL( Substr( Empresa->Emp_Cfg, 7, 1 ) ) )
oVar:Add( "lProduto" , False )
oVar:Add( "nArea" , "" )
oVar:Add( "aAreaEstoque" , "" )
oVar:lInfoCodigo := IIF( oVar:lInfoCodigo = "1", True, False )
oVar:aAreaEstoque := { "Deposito", "Área 1", "Área 2", "Área 3", "Área 4", "Área 5", "Área 6", "Área 7", "Área 8", "Área 9" }
oVar:nArea := oVar:aAreaEstoque[1]
SetResources( hHyper )
DbSelectArea( "Estoque" )
OrdSetFocus( "Nome" )
DbGoTop()
DEFINE BITMAP hTicket RESOURCE "16_Ticket_Green"
DEFINE CURSOR oHand HAND
DEFINE DIALOG oDlg RESOURCE IIF( lVideo_1024, "TS_Browse_1024_01", "TS_Browse_0860_01" ) TITLE oVar:cBoxTitle FONT oWnd:oFont
//********************************************************************************
REDEFINE BROWSE oTbr ALIAS "Estoque" ID 500 OF oDlg
ADD COLUMN TO oTbr HEADER "Código" SIZE 120 ALIGN DT_LEFT ORDER "CODIGO" DATA TransField( Estoque->Est_Cod, oPub:wEstPic )
ADD COLUMN TO oTbr HEADER "Descrição" SIZE 344 ALIGN DT_LEFT ORDER "NOME" DATA Estoque->Est_Nom
ADD COLUMN TO oTbr HEADER "Grupo" SIZE 70 ALIGN DT_CENTER ORDER "GRUPO" DATA Estoque->Est_FamCod + "-" + TransField( Estoque->Est_GruCod, "@R 99.999" )
ADD COLUMN TO oTbr HEADER "Código de Barra" SIZE 150 ALIGN DT_LEFT DATA Estoque->Est_CodBar
ADD COLUMN TO oTbr HEADER "Estoque" SIZE 100 ALIGN DT_RIGHT DATA TransAmount( IIF( Estoque->Est_FamCod = "0", 0, Estoque->Est_QtdSdo ), Estoque->Est_Fra, True )
ADD COLUMN TO oTbr HEADER "Deposito" SIZE 100 ALIGN DT_RIGHT DATA Estoque_TrazQuantidade( oVar, oTbr )
ADD COLUMN TO oTbr HEADER "Venda" SIZE 100 ALIGN DT_RIGHT DATA TransField( Estoque->Est_ValVda, TransUnitario( Estoque->Est_NumDec ) )
ADD COLUMN TO oTbr HEADER "Aquisição" SIZE 100 ALIGN DT_RIGHT DATA TransField( Estoque->Est_ValDco, _PicUnit4 )
ADD COLUMN TO oTbr HEADER "Custo Médio" SIZE 100 ALIGN DT_RIGHT DATA TransField( Estoque->Est_CstMed, _PicMoeCusto )
ADD COLUMN TO oTbr HEADER "1" SIZE 40 ALIGN nMakeLong( , DT_CENTER )
ADD COLUMN TO oTbr HEADER "2" SIZE 40 ALIGN nMakeLong( , DT_CENTER )
ADD COLUMN TO oTbr HEADER "3" SIZE 40 ALIGN nMakeLong( , DT_CENTER )
ADD COLUMN TO oTbr HEADER "4" SIZE 40 ALIGN nMakeLong( , DT_CENTER )
ADD COLUMN TO oTbr HEADER "5" SIZE 40 ALIGN nMakeLong( , DT_CENTER )
ADD COLUMN TO oTbr HEADER "6" SIZE 40 ALIGN nMakeLong( , DT_CENTER )
ADD COLUMN TO oTbr HEADER "7" SIZE 40 ALIGN nMakeLong( , DT_CENTER )
ADD COLUMN TO oTbr HEADER "8" SIZE 40 ALIGN nMakeLong( , DT_CENTER )
ADD COLUMN TO oTbr HEADER "9" SIZE 40 ALIGN nMakeLong( , DT_CENTER )
ADD COLUMN TO oTbr HEADER "Grupo Principal" SIZE 150 ALIGN DT_LEFT ORDER "GRUPO" DATA Fetch( Left( Estoque->Est_GruCod, 2 ) + Space(3), "GrupoProduto", "Est_GruNom", "Codigo" )
ADD COLUMN TO oTbr HEADER "Familia" SIZE 100 ALIGN DT_LEFT ORDER "FAMILIA" DATA ASeek( Estoque->Est_FamCod, oPub:aCodFamilia, oPub:aTabFamilia )
ADD COLUMN TO oTbr HEADER "Fabricante" SIZE 150 ALIGN DT_LEFT ORDER "MARCA" DATA Fetch( "201" + Estoque->Est_FabCod, "TabArray", "Tab_Nom", "Codigo" )
ADD SUPER HEADER TO oTbr FROM COLUMN 1 TO COLUMN 4 COLORS CLR_BLACK, oPub:nClrBrush 3DLOOK FONT oPub:hFntBarra TITLE "Produto"
ADD SUPER HEADER TO oTbr FROM COLUMN 5 TO COLUMN 6 COLORS CLR_BLACK, oPub:nClrBrush 3DLOOK FONT oPub:hFntBarra TITLE "Saldo"
ADD SUPER HEADER TO oTbr FROM COLUMN 7 TO COLUMN 9 COLORS CLR_BLACK, oPub:nClrBrush 3DLOOK FONT oPub:hFntBarra TITLE "Valor de"
ADD SUPER HEADER TO oTbr FROM COLUMN 10 TO COLUMN 18 COLORS CLR_BLACK, oPub:nClrBrush 3DLOOK FONT oPub:hFntBarra TITLE "Áreas"
ADD SUPER HEADER TO oTbr FROM COLUMN 19 TO COLUMN 21 COLORS CLR_BLACK, oPub:nClrBrush 3DLOOK FONT oPub:hFntBarra TITLE "Informações"
oTbr:cAlias := "Estoque"
oTbr:l2007 := True
oTbr:lVScroll := True
oTbr:nHeightSuper := 25
oTbr:nHeightHead := 30
oTbr:nHeightCell := 25
oTbr:bKeyDown := {|nKey| Estoque_TeclaFuncao( nKey, oDlg, oTbr, oVar ) }
oTbr:aColumns[10]:uBmpCell := {|| IIF( EA_CtoL( Substr( Estoque->Est_Are, 1, 1 ) ), hTicket, 0 ) }
oTbr:aColumns[11]:uBmpCell := {|| IIF( EA_CtoL( Substr( Estoque->Est_Are, 2, 1 ) ), hTicket, 0 ) }
oTbr:aColumns[12]:uBmpCell := {|| IIF( EA_CtoL( Substr( Estoque->Est_Are, 3, 1 ) ), hTicket, 0 ) }
oTbr:aColumns[13]:uBmpCell := {|| IIF( EA_CtoL( Substr( Estoque->Est_Are, 4, 1 ) ), hTicket, 0 ) }
oTbr:aColumns[14]:uBmpCell := {|| IIF( EA_CtoL( Substr( Estoque->Est_Are, 5, 1 ) ), hTicket, 0 ) }
oTbr:aColumns[15]:uBmpCell := {|| IIF( EA_CtoL( Substr( Estoque->Est_Are, 6, 1 ) ), hTicket, 0 ) }
oTbr:aColumns[16]:uBmpCell := {|| IIF( EA_CtoL( Substr( Estoque->Est_Are, 7, 1 ) ), hTicket, 0 ) }
oTbr:aColumns[17]:uBmpCell := {|| IIF( EA_CtoL( Substr( Estoque->Est_Are, 8, 1 ) ), hTicket, 0 ) }
oTbr:aColumns[18]:uBmpCell := {|| IIF( EA_CtoL( Substr( Estoque->Est_Are, 9, 1 ) ), hTicket, 0 ) }
oTbr:bLDblClick := {|| Estoque_Consulta( oTbr, oVar ) }
oTbr:SetOrder( 2 )
oTbr:GoTop()
oTbr:ChangeFont( oPub:hFntBarra, , 2 )
oTbr:SetIndexCols( 2, 3, 4, 5 )
oTbr:SetColor( { 2, 4, 5, 6, 11, 12, 14, 15 } ,;
{ {|| IF( oTbr:nLogicPos % 2 = 0, oPub:nClrBrowse_021, oPub:nClrBrowse_022 ) },;
oPub:nClrBrowse_04 ,;
oPub:nClrBrowse_05 ,;
oPub:nClrBrowse_06 ,;
oPub:nClrBrowse_11 ,;
oPub:nClrBrowse_12 ,;
oPub:nClrBrowse_14 ,;
oPub:nClrBrowse_15 } )
ACTIVATE DIALOG oDlg ON INIT ( oDlg:Move( 0, 0 ), Estoque_BuildMenu( oDlg, oTbr, oVar ) )
oVar:Release()
EA_GetOpenFileName( aFiles, False )
DeleteObject( oDlg )
DeleteObject( oTbr )
DeleteObject( oHand )
DeleteObject( oVar )
Set_Restore( aSets )
Return( Nil )
//******************************************************************************************
*--------------------------------------------------------------------------
STATIC FUNCTION Estoque_BuildMenu( oDlg, oTbr, oVar )
*--------------------------------------------------------------------------
LOCAL oDlgMenu, oHand, oDlgBar, oAre
MENU oDlgMenu
MENUITEM "&Arquivo"
MENU
MENUITEM "Produtos" + Chr(9) + "Insert" ACTION Estoque_Get_Registro( oTbr, oVar, True, True )
MENUITEM "Serviços" + Chr(9) + "Ctrl+S" ACTION Estoque_Get_Registro( oTbr, oVar, True, False )
SEPARATOR
MENUITEM "Modificar" + Chr(9) + "Ctrl+M" ACTION Estoque_Get_Registro( oTbr, oVar, False )
MENUITEM "Eliminar" + Chr(9) + "Delete" ACTION Estoque_Del_Registro( oTbr, oVar )
SEPARATOR
MENUITEM "Fechar" + Chr(9) + "Alt+F4" ACTION oDlg:End() RESOURCE "16_Close"
ENDMENU
MENUITEM "&Editar"
MENU
MENUITEM "Deposito" + Chr(9) + "Ctlr+D" ACTION Estoque_DepositoArea( oTbr, oVar )
MENUITEM "Composição de Kits" WHEN False
SEPARATOR
MENUITEM "Preço de Compras" + Chr(9) + "Ctlr+C" ACTION Estoque_Preco_Compra( oTbr )
MENUITEM "Acordo Especial de Preço" + Chr(9) + "Ctlr+V" ACTION Estoque_Preco_Venda( oTbr, oVar )
ENDMENU
MENUITEM "E&xibir"
MENU
MENUITEM "Ficha do Produto" + Chr(9) + "Enter" ACTION Estoque_Consulta( oTbr, oVar )
MENUITEM "Ficha de Movimentação" WHEN False
SEPARATOR
MENUITEM "Localizar" + Chr(9) + "Ctlr+L" ACTION SeekIt( MakeEmpty( Estoque->( OrdKeyVal() ) ), oTbr, "Estoque" ) RESOURCE "16_Search"
ENDMENU
MENUITEM "&Dados"
MENU
MENUITEM "Auto Filtro" ACTION Estoque_Filtro( oTbr, oVar, True )
MENUITEM "Mostrar Tudo" ACTION Estoque_Filtro( oTbr, oVar, False )
SEPARATOR
MENUITEM "Classificar" ACTION DB_IndexOrder( "Estoque", oTbr ) RESOURCE "16_Indice"
ENDMENU
MENUITEM "&Impressão"
MENU
MENUITEM "Relatório" RESOURCE "16_Printer"
MENUITEM "Etiqueta" RESOURCE "16_Label"
ENDMENU
ENDMENU
oDlg:SetMenu( oDlgMenu )
DEFINE CURSOR oHand HAND
DEFINE BUTTONBAR oDlgBar SIZE oPub:nBarLargura,30 OF oDlg CURSOR oHand
DEFINE BUTTON OF oDlgBar RESOURCE "16_New" TOOLTIP "Incluir Produto" NOBORDER ACTION Estoque_Get_Registro( oTbr, oVar, True, True )
DEFINE BUTTON OF oDlgBar RESOURCE "16_Write" TOOLTIP "Incluir Serviço" NOBORDER ACTION Estoque_Get_Registro( oTbr, oVar, True, False )
DEFINE BUTTON OF oDlgBar RESOURCE "16_Edit" TOOLTIP cBar_Modifica NOBORDER ACTION Estoque_Get_Registro( oTbr, oVar, False )
DEFINE BUTTON OF oDlgBar RESOURCE "16_Delete" TOOLTIP cBar_Deleta NOBORDER ACTION Estoque_Del_Registro( oTbr, oVar )
DEFINE BUTTON OF oDlgBar RESOURCE "16_Open" TOOLTIP cBar_Registro GROUP NOBORDER ACTION Estoque_Consulta( oTbr, oVar )
DEFINE BUTTON OF oDlgBar RESOURCE "16_Search" TOOLTIP cBar_Localiza NOBORDER ACTION SeekIt( MakeEmpty( Estoque->( OrdKeyVal() ) ), oTbr, "Estoque" )
DEFINE BUTTON OF oDlgBar RESOURCE "16_Filter" TOOLTIP cBar_Filtro GROUP NOBORDER ACTION Estoque_Filtro( oTbr, oVar, True )
DEFINE BUTTON OF oDlgBar RESOURCE "16_Cancel" TOOLTIP cBar_Tudo NOBORDER ACTION Estoque_Filtro( oTbr, oVar, False )
DEFINE BUTTON OF oDlgBar RESOURCE "16_Indice" TOOLTIP cBar_Classifica NOBORDER ACTION DB_IndexOrder( "Estoque", oTbr )
DEFINE BUTTON OF oDlgBar RESOURCE "16_Printer" TOOLTIP cBar_Relatorio GROUP NOBORDER
DEFINE BUTTON OF oDlgBar RESOURCE "16_Label" TOOLTIP cBar_Etiqueta NOBORDER
DEFINE BUTTON OF oDlgBar RESOURCE "16_Close" TOOLTIP cBar_Encerra GROUP NOBORDER ACTION oDlg:End()
oDlgBar:bRClicked := {|| Nil }
@ 0.30,107 COMBOBOX oAre VAR oVar:nArea ITEMS oVar:aAreaEstoque OF oDlgBar SIZE 150, 200 FONT oPub:hFntBold ON CHANGE Estoque_Filtro_Area( oTbr, oVar, oAre )
DeleteObject( oDlgMenu )
DeleteObject( oHand )
DeleteObject( oDlgBar )
Return( Nil )
//******************************************************************************************
*--------------------------------------------------------------------------
STATIC FUNCTION Estoque_TeclaFuncao( nKey, oDlg, oTbr, oVar )
*--------------------------------------------------------------------------
IF nKey == VK_RETURN ; Estoque_Consulta( oTbr, oVar )
ELSEIF nKey == VK_DELETE ; Estoque_Del_Registro( oTbr, oVar )
ELSEIF nKey == VK_INSERT ; Estoque_Get_Registro( oTbr, oVar, True, True )
ELSEIF nKey == Asc( "D" ) .AND. GetKeyState( VK_CONTROL ); Estoque_DepositoArea( oTbr, oVar )
ELSEIF nKey == Asc( "L" ) .AND. GetKeyState( VK_CONTROL ); SeekIt( MakeEmpty( Estoque->( OrdKeyVal() ) ), oTbr, "Estoque" )
ELSEIF nKey == Asc( "M" ) .AND. GetKeyState( VK_CONTROL ); Estoque_Get_Registro( oTbr, oVar, False )
ELSEIF nKey == Asc( "P" ) .AND. GetKeyState( VK_CONTROL ); Estoque_Get_Registro( oTbr, oVar, True, True )
ELSEIF nKey == Asc( "S" ) .AND. GetKeyState( VK_CONTROL ); Estoque_Get_Registro( oTbr, oVar, True, False )
ELSEIF nKey == Asc( "C" ) .AND. GetKeyState( VK_CONTROL ); Estoque_Preco_Compra( oTbr )
ELSEIF nKey == Asc( "V" ) .AND. GetKeyState( VK_CONTROL ); Estoque_Preco_Venda( oTbr, oVar )
ENDIF
Return( Nil )
//******************************************************************************************
*--------------------------------------------------------------------------
STATIC FUNCTION Estoque_TrazQuantidade( oVar, oTbr )
*--------------------------------------------------------------------------
LOCAL nPos, nSaldo
nPos := AScan( oVar:aAreaEstoque, oVar:nArea )
IF Estoque->Est_FamCod = "0"
nSaldo := 0
ELSE
EstDeposito->( DbSeek( Estoque->Est_Cod + NTrim( nPos - 1 ) ) )
nSaldo := EstDeposito->Est_QtdSdo
ENDIF
Return( TransAmount( nSaldo, Estoque->Est_Fra, True ) )
Elias Abrão Júnior
Indaiatuba - SP - Brasil