Is it possible to add this DATA ( ::bEdit ) to TXBrowse()?

Is it possible to add this DATA ( ::bEdit ) to TXBrowse()?

Postby dutch » Tue Feb 26, 2008 9:01 am

Is it possible to add this DATA to TXBrowse()?
Code: Select all  Expand view
oLbx:bEdit:= {|nCol, cBuffer, lFirstEdit| ..... }  // from TWbrowse() of Hernan

I used TWBrowse() of Hernan and it's used a lot in my program.

Regards,
Dutch
User avatar
dutch
 
Posts: 1542
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Re: Is it possible to add this DATA ( ::bEdit ) to TXBrowse(

Postby Patrick Mast » Tue Feb 26, 2008 9:25 am

dutch wrote:Is it possible to add this DATA to TXBrowse()?
Code: Select all  Expand view
oLbx:bEdit:= {|nCol, cBuffer, lFirstEdit| ..... }  // from TWbrowse() of Hernan

I used TWBrowse() of Hernan and it's used a lot in my program.

Regards,
Dutch

Good idea!

Patrick
User avatar
Patrick Mast
 
Posts: 246
Joined: Sat Mar 03, 2007 8:42 pm

Postby nageswaragunupudi » Tue Feb 26, 2008 1:25 pm

In the case of xBrowse, edit behavior is to be specified for the individual columns to be edited.

We specify the mode of edit of the column as oCol:nEdittype := EDIT_GET or EDIT_LISTBOX etc.

We also suplly a codeblock oCol:bOnPostEdit. After the user edits the column, this block is evaluated with oCol, EditedValue, LastKey as parameters.

Simple example of usage can be found in mallorca.prg in the samples folder
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10624
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Postby dutch » Wed Feb 27, 2008 2:28 am

Dear NageswaraRao,
nageswaragunupudi wrote:In the case of xBrowse, edit behavior is to be specified for the individual columns to be edited.

I like edit mode for the all column continuously. Because I use this as enter a transaction, it will be completed after enter data in all columns in the line. This is the example of TWBrowse() of Hernan.

Code: Select all  Expand view
#include "FiveWin.ch"

Function Main()
LOCAL aTotal:= {0,0,0, Nil, Nil, Nil}
LOCAL aDatos:= {} // Array MultiDimensional
                   // Cod.Art.  Descrip.  Cantidad  $Unitario  $Total  MarcaDeNuevo
LOCAL l3d:= .F.
LOCAL oDlg, oLbx, cPic:= "@ze 999,999.99", oFont
LOCAL hBmp:= ReadBitMap( 0, "finger.bmp" ) // Dedicado a mi amigo Mario Goanzalez

    If Alert("Quiere verlo en 3D ??", {"Aceptar","Cancelar"}) == 1
       l3D:= .T.
    EndIf

    DEFINE FONT oFont NAME "Times New Roman" SIZE 0,-15 BOLD

    DEFINE DIALOG oDlg FROM 0,0 TO 21,55 TITLE "::bEdit's TWBrowse Power !!!"

       TWBrowse():lHScroll:= .F.
       @2,2 LISTBOX oLbx FIELDS ""                                      ;
                         HEADER "Id","Articulo", "Descripcion", "Cantidad",  ;
                                "Unitario", "Total"                     ;
                         OF oDlg SIZE 207,100 PIXEL                     ;
                         SIZES 25,50, 130, 67,60,60

           oLbx:bLine:= {|nAt| nAt:= oLbx:nAt,                      ;
                               If( Len(aDatos)<1 .or. nAt>Len(aDatos),;
                                 Array(6),                            ;
                                 { If( oLbx!=Nil .and. oLbx:lSelect, hBmp, 0 ),;
                                   If( aDatos[nAt,1]==0,Space(4),StrZero( aDatos[nAt,1], 4 ) ),    ;
                                   aDatos[nAt,2],                       ;
                                   Transform( aDatos[nAt,3], cPic ),    ;
                                   Transform( aDatos[nAt,4], cPic ),    ;
                                   Transform( aDatos[nAt,5], cPic )  } ) }

           oLbx:aJustify:= { 2, 2, .f., .t., .t. , .t. }
           oLbx:SetArray( aDatos )

           oLbx:lAdjLastCol:= .f.

           oLbx:lAutoEdit  := .t.
           oLbx:lAutoSkip  := .t.

           oLbx:nLineStyle  := 2
           oLbx:nHeaderStyle:= 2

           oLbx:bBkColor:= {|nRow,nCol,nStyle| ;
                              if( nStyle==1,if( nCol%2==0, CLR_RED   , CLR_GREEN ),) }
           oLbx:bTextColor:= {|nRow,nCol,nStyle| ;
                              if( nStyle==1,if( nCol%2==0, CLR_YELLOW, CLR_WHITE ),) }
                                                                               
           If l3D
              oLbx:Set3DStyle()
           EndIf


           oLbx:bEdit:= {|nCol, cBuffer, lFirstEdit|;
                          EditaCelda( oLbx, nCol, cBuffer, aDatos, lFirstEdit, aTotal ) }


       @105, 110 SAY "Neto Gravado " OF oDlg PIXEL
       @115, 110 SAY "I.V.A. 21%   " OF oDlg PIXEL
       @125, 110 SAY "Total        " OF oDlg PIXEL
       @105, 150 SAY aTotal[4] PROMPT aTotal[1] PICTURE '@ZE 999,999.99' OF oDlg PIXEL RIGHT SIZE 50,10
       @115, 150 SAY aTotal[5] PROMPT aTotal[2] PICTURE '@ZE 999,999.99' OF oDlg PIXEL RIGHT SIZE 50,10
       @125, 150 SAY aTotal[6] PROMPT aTotal[3] PICTURE '@ZE 999,999.99' OF oDlg PIXEL RIGHT SIZE 50,10



       @137,10  BUTTON "Agrega" OF oDlg PIXEL ;
                ACTION ( NewReg( aDatos, oLbx ), oLbx:Edit() )  SIZE 50,Nil

       @137,80  BUTTON "Modifica" OF oDlg PIXEL ;
                ACTION If( Len(aDatos) > 0 .and.                      ;
                           oLbx:nAt <= Len(aDatos) .and. oLbx:nAt > 0,;
                           oLbx:Edit(), )       SIZE 50,Nil

       @137,150 BUTTON "Elimina" OF oDlg PIXEL ;
                ACTION If( Len(aDatos) > 0 .and.                      ;
                           oLbx:nAt <= Len(aDatos) .and. oLbx:nAt > 0 .and.  ;
                           Alert("Borra ?",{"ok","Cancela"}) == 1,      ;
                           DelReg( aDatos, oLbx, aTotal ),)  SIZE 50,Nil




    ACTIVATE DIALOG oDlg CENTERED



RELEASE FONT oFont
ReleaseDC( hBmp )

return Nil

//----------------------------------------------------------------------------//
Function GetSysFont() ; return "MS Sans Serif"


//----------------------------------------------------------------------------//
STATIC Function EditaCelda( oLbx, nCol, cBuffer, aDatos, lFirstEdit, aTotal )
LOCAL aResult, nAt:= oLbx:nAt, uBuffer, lContinue:= .t.
LOCAL bValid, nColReal:= nCol

    nCol--  // Para que sea como si no exisiera BitMap

    uBuffer:= aDatos[nAt,nCol]

    While .t.

       Do Case
          Case ( nCol == 2 .or. nCol == 5 ) .and. lFirstEdit
               Alert( "Columnas NO EDITABLES" )
               return .f.

          Case nCol == 1
               bValid:= {|| If( Empty( aResult:= SeekItem( uBuffer ) ), ;
                            (Alert( "Codigo Articulo Inexistente :-("),.F.) , .T. ) }

               If lContinue:= oLbx:lEditCol( nColReal, @uBuffer, "@ZE 9999", bValid,,CLR_YELLOW )
                  aDatos[nAt,1]:= uBuffer
                  aDatos[nAt,2]:= aResult[1]
                  aDatos[nAt,4]:= aResult[2]
               EndIf

          Case nCol == 3  // Cantidad
               If lContinue:= oLbx:lEditCol( nColReal,  @uBuffer, "@ZE 999,999.99",,,CLR_YELLOW )
                  If uBuffer <= 0
                     Alert("Debe Especificar una cantidad !!!")
                     Loop
                  EndIf
                  aDatos[nAt,3]:= uBuffer
               EndIf

          Case nCol == 4  // Unitario
               If lContinue:= oLbx:lEditCol( nColReal, @uBuffer, "@ZE 999,999.99",,,CLR_YELLOW )
                  aDatos[nAt,4]:= uBuffer
                  aDatos[nAt,6]:= .f.  // Ya no es un Nuevo Registro !!!
               EndIf

          Case nCol == 5 .and. ! lFirstEdit .and. Len( aDatos ) == nAt
               NewReg( aDatos, oLbx )

       EndCase

       If ! lContinue .and. aDatos[nAt,6] // Se habia agregado un nuevo Item !!!
          If Alert( "Cancela este Nuevo Registro", { "Ok","Cancelar" } ) == 1
             DelReg( aDatos, oLbx, aTotal )
             return .f.
          Else
             Loop
          EndIf
       EndIf

       Exit

    EndDo

    If Len( aDatos ) > 0
       aDatos[nAt,5]:= Round( aDatos[nAt,3] * aDatos[nAt,4], 2 )
       Suma( aDatos, aTotal )
    EndIf


    If lContinue
       Do Case
       Case oLbx:nLastKey == VK_UP
          return If( !GetKeyState(VK_SHIFT), -3, -2 )
       Case oLbx:nLastKey == VK_DOWN
          return If( !GetKeyState(VK_SHIFT),  3,  2 )
       Case oLbx:nLastKey == VK_TAB
          return If( GetKeyState(VK_SHIFT), -1, 1 )
       EndCase
    EndIf


return lContinue


//----------------------------------------------------------------------------//
STATIC Function SeekItem( nCod )  // Simulamos busqueda en Base de Datos :-)

    If nCod >= 1 .and. nCod <= 500
       return { "Producto " + StrZero( nCod, 4 ), nCod + 0.55 }
    EndIf

return ""
//----------------------------------------------------------------------------//
STATIC Function NewReg( aDatos, oLbx )
    Aadd( aDatos, {0,"",0,0,0,.t.} )
    oLbx:Refresh()
    oLbx:lHitBottom:= .f.
    oLbx:GoBottom()
    SysRefresh()
return Nil
//----------------------------------------------------------------------------//
STATIC Function DelReg( aDatos, oLbx, aTotal )
    ADel( aDatos, oLbx:nAt )
    ASize( aDatos, Len( aDatos ) - 1 )
    oLbx:GoUp()
    oLbx:Refresh()
    Suma( aDatos, aTotal )
return Nil
//----------------------------------------------------------------------------//
STATIC Function Suma( aDatos, aTotal )
    aTotal[1]:= 0
    AEval( aDatos, {|aItem| aTotal[1]+= aItem[5] } )
    aTotal[1]:= Round( aTotal[1], 2 )
    aTotal[2]:= Round( aTotal[1] * 0.21, 2 )
    aTotal[3]:= Round( aTotal[1] + aTotal[2],2 )
    AEval( aTotal, {|oSay| oSay:Refresh(.F.) }, 4 )

return Nil
//----------------------------------------------------------------------------//
User avatar
dutch
 
Posts: 1542
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 90 guests