Help with xBrowse and dbf\cdx

Help with xBrowse and dbf\cdx

Postby Rick Lipkin » Fri Sep 29, 2017 10:58 pm

To All

I have some VERY simple code that I can not get to work . For one .. the Headers are incorrect .. and I want to use FASTEDIT and SetCHeck on the first column and I just can't make it work ..

I would appreciate a second set of eyes for some advice .. as you can see from the pic below .. the Headers are not using the HEADERS defines ( lower case ) .

Image

Code: Select all  Expand view  RUN

// gasdupet.prg  delete routine for gas ticket dupe


#Include "FiveWin.Ch"
#Include "xBrowse.Ch"

//---------------------
FUNC _GasDupe()

LOCAL SAYING
LOCAL cSQL, oERR,oDlg,oSay,cSay,oRsGas
Local lOk
Local SiteDbf,SiteIdx
Local xGrad,oLbx,oCol
Local Dbf_Stru
Local cType,xAgency
Local cFile,aDir,nStart,dExe

REQUEST DBFCDX
rddsetdefault ( "DBFCDX" )


cFILE := GetModuleFileName( GetInstance() )
aDIR  := DIRECTORY( cFILE )

dEXE  := aDIR[1] [3]

// where .exe started from is default directory //

cFILE  := GetModuleFileName( GetInstance() )
nSTART := RAT( "\", cFILE )
cDEFA  := SUBSTR(cFILE,1,nSTART-1)

SET DEFA to ( cDEFA )

cType   := "
MANSFIELD"
xAgency := "
J12"


lOk  := .f.




Do Case
Case cType = "
MANSFIELD"

     If xAgency = "
J04" .or. xAgency = "J12" .or. xAgency = "1945"
     Else
        Saying := "
Sorry .. You are not authorized to use the Mansfield Option"
        Msginfo( saying )
        Return(.f.)
     Endif

Case cType = "
FUELMASTER"

   If xAgency = "
1750"
   Else
      Saying := "
Sorry .. You are not authorized to use the FUELMASTER Option"
       Msginfo( saying )
       Return(.f.)
   Endif

EndCase


//  cTYPE is either
//  MANSFIELD
//  FUELMASTER


IF EMPTY( cTYPE )
   cTYPE := "
MANSFIELD"
ENDIF

*oWndChild:END()
*SysReFresh()


DO WHILE .T.
   SITEDBF := "
TEMP"+(SUBSTR(TIME(),7,2)+SUBSTR(TIME(),4,2))+".DBF"
   IF .not. FILE( cDefa+"
\"+SITEDBF )
      EXIT
   ENDIF
ENDDO

*cLINE := "
Opening Temp Table "+xVOL+"\DBTMP\"+SITEDBF
*oLINE:ReFresh()
*SysReFresh()


DBF_STRU := { }
AADD( DBF_STRU, { "
ChkDel",       "L",   1,  0 } )
AADD( DBF_STRU, { "
Date",         "D",   8,  0 } )
AADD( DBF_STRU, { "
Vnumber",      "C",   6,  0 } )
AADD( DBF_STRU, { "
License",      "C",   8,  0 } )
AADD( DBF_STRU, { "
MotorPool",    "C",  10,  0 } )
AADD( DBF_STRU, { "
Deputy",       "C",  10,  0 } )
AADD( DBF_STRU, { "
Vendor",       "C",  30,  0 } )
AADD( DBF_STRU, { "
Fuel_Type",    "C",  15,  0 } )
AADD( DBF_STRU, { "
Gal_Pump",     "N",   7,  2 } )
AADD( DBF_STRU, { "
Trans_Amt",    "N",  10,  2 } )
AADD( DBF_STRU, { "
GasEid",       "C",  18,  0 } )

Try
   DBCREATE( cDefa+"
\"+SITEDBF, DBF_STRU )
Catch
   Saying := "
Sorry .. you do not have Sufficient Network Rights to "+chr(10)
   Saying += cDefa+"
\"+chr(10)
   Saying += "
Please seek your Network Administrator"+chr(10)
   MsgInfo( Saying )
   CLOSE DATABASES
   FERASE( cDefa+"
\"+SITEDBF)
   FERASE( cDefa+"
\"+SITEiDX)
   RETURN(NIL)
End Try

DO WHILE .T.
   SITEiDX := "
TEMP"+(SUBSTR(TIME(),7,2)+SUBSTR(TIME(),4,2))+".IDX"
   IF .not. FILE( cDefa+"
\"+SITEiDX )
      EXIT
   ENDIF
ENDDO

Select 4
Use( cDefa+"
\"+SITEDBF) VIA "DBFCDX" EXCL
Index on Dtos(Date)+Vnumber to ( cDefa+"
\"+SITEiDX )


Select 4
append blank

d->ChkDel    := .f.
d->Date      := Date()
d->Vnumber   := "
00655"
d->License   := "
SG71666"
d->Motorpool := "
2440"
d->Deputy    := "
DIV 1"
d->Fuel_Type := "
DIESEL"
d->Vendor    := "
MANSFIELD"
d->Gal_Pump  := 32.59
d->Trans_Amt := 67.39
d->GasEid    := "
123457778"

Select 4
Append Blank

d->ChkDel    := .f.
d->Date      := Date()
d->Vnumber   := "
00655"
d->License   := "
SG71666"
d->Motorpool := "
2440"
d->Deputy    := "
DIV 1"
d->Fuel_Type := "
DIESEL"
d->Vendor    := "
MANSFIELD"
d->Gal_Pump  := 32.59
d->Trans_Amt := 67.39
d->GasEid    := "
77888777666"

Select 4
GoTo Recno()

Select 4
Go Top

*xbrowse()


xGrad := { { .50, nRGB( 216, 216, 216 ), nRGB( 255, 255, 255 ) } }      // lightgreygrad
*SysReFresh()

DEFINE DIALOG oDlg RESOURCE "
GASDUPE"                ;
       TITLE cTYPE+"
Gas Duplication Routine"        ;

       REDEFINE xBROWSE oLBX     ;
           ALIAS @SiteDbf        ;
           COLUMNS "
CHKDEL",     ;
              "
DATE",            ;
              "
VNUMBER",         ;
              "
LICENSE",         ;
              "
MOTORPOOL",       ;
              "
DEPUTY",          ;
              "
VENDOR",          ;
              "
FUEL_TYPE",       ;
              "
GAL_PUMP",        ;
              "
TRANS_AMT",       ;
              "
GASEID"           ;
           COLSIZES 70,70,70,70,70,70,150,70,70,70,70;
           HEADERS "
ChkDel",        ;
               "
Date",           ;
               "
VehNumb",        ;
               "
License",        ;
               "
MotorPool",      ;
               "
Deputy",         ;
               "
Vendor",         ;
               "
FuelType",       ;
               "
GalPumped",      ;
               "
TransAmt",       ;
               "
GasEid"          ;
           ID 172 of oDlg        ;
           AUTOCOLS LINES AUTOSORT CELL
*AUTOCOLS LINES CELL
*AUTOCOLS LINES CELL FASTEDIT

     *  if ! empty(oCol := oLbx:oCol( "
CHKDEL" ))
     *     oCol:SetCheck( { "
ON", "OFF" }, EDIT_GET )
     *  endif


         *  AEval( oLbx:aCols, { |o| o:nEditType := EDIT_GET } )

         

      REDEFINE BTNBMP oBTN6 ID 122 of oDlg     ;
         RESOURCE "
CANCEL","DCANCEL","DCANCEL" ;
         PROMPT "
&Quit" LEFT 2007;
         ACTION ( lOK := .F., oDlg:End() )

      oDlg:bResized = { | nSizeType, nWidth, nHeight | _ResizeControls( nSizeType, nWidth, nHeight, oDlg )}

ACTIVATE DIALOG oDlg ;
         ON PAINT ( GradientFill( hDC, 0, 0, oDlg:nHeight, oDlg:nWidth, xGrad, .T. ));     // note GradientFill
                VALID(!GETKEYSTATE( 27 ))


Close Databases
FERASE( cDefa+"
\"+SITEDBF)
FERASE( cDefa+"
\"+SITEiDX)

RETURN( NIL )

//--------------------------------------------------------------------
Static Func _ResizeControls( nSizeType, nWidth, nHeight, oDlg )


*xbrowse(oDLg1:aControls)

if nSizeType = 0 //SIZE_MAXIMIZED         //60          //10
   oDlg:aControls[ 1  ]:SetSize( nWidth - 98, nHeight - 10 ) //txbrowse
endif

Return(nil)

// end



GasDupe.RC
Code: Select all  Expand view  RUN

// Generated by ResEdit 1.6.6
// Copyright (C) 2006-2015
// http://www.resedit.net

#include <windows.h>
#include <commctrl.h>

//
// Dialog resources
//
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
GASDUPE DIALOG 6, 13, 613, 355
STYLE DS_MODALFRAME | DS_SETFONT | WS_CAPTION | WS_POPUP | WS_THICKFRAME | WS_SYSMENU
FONT 8, "Arial"
{
    CONTROL         "Inventory Detail", 172, "TXBrowse", 0x50B10000, 4, 42, 605, 310, 0x00000000
    CONTROL         "Quit", 122, "TBtnBmp", 0x50010020, 567, 6, 41, 25, 0x00000000
}

 
User avatar
Rick Lipkin
 
Posts: 2666
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Help with xBrowse and dbf\cdx

Postby cnavarro » Sat Sep 30, 2017 3:22 pm

Rick, this run OK for me

Code: Select all  Expand view  RUN

.../...

Select 4
Use( cDefa+"\"+SITEDBF) VIA "DBFCDX" EXCL ALIAS "Temp"
Index on Dtos( Date ) + Vnumber to ( cDefa+"
\"+SITEiDX )

.../...

      REDEFINE xBROWSE oLBX     ;
         OF oDlg ID 172 ;
         DATASOURCE "
Temp"       ;
         COLUMNS "
CHKDEL",     ;
              "
DATE",            ;
              "
VNUMBER",         ;
              "
LICENSE",         ;
              "
MOTORPOOL",       ;
              "
DEPUTY",          ;
              "
VENDOR",          ;
              "
FUEL_TYPE",       ;
              "
GAL_PUMP",        ;
              "
TRANS_AMT",       ;
              "
GASEID"           ;
         COLSIZES 70,70,70,70,70,70,150,70,70,70,70;
         HEADERS "
ChkDel",        ;
               "
Date",           ;
               "
VehNumb",        ;
               "
License",        ;
               "
MotorPool",      ;
               "
Deputy",         ;
               "
Vendor",         ;
               "
FuelType",       ;
               "
GalPumped",      ;
               "
TransAmt",       ;
               "
GasEid"          ;
           LINES AUTOSORT CELL

     oLbX:aCols[ 1 ]:nEditType     := EDIT_GET
     oLbx:aCols[ 1 ]:SetCheck()

.../...



Also with

Code: Select all  Expand view  RUN

         COLUMNS 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 ;
 
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
cnavarro
 
Posts: 6549
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Help with xBrowse and dbf\cdx

Postby Rick Lipkin » Sat Sep 30, 2017 3:37 pm

Cristobol

YES .. thank you .. apparently ALIAS no longer works properly . ... DATASOURCE was the correct change ...

Many thanks ... I need to start using Rogaine again .. just about pulled all my hair out :lol:

Rick Lipkin
User avatar
Rick Lipkin
 
Posts: 2666
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Help with xBrowse and dbf\cdx

Postby Rick Lipkin » Sat Sep 30, 2017 3:45 pm

Cristobol

It appears the behavior of SetCHeck() EDIT_GET is to double click to either check or un-check .. is there a way to modify that behavior to aliow just a single click to make the change ?

Rick Lipkin
User avatar
Rick Lipkin
 
Posts: 2666
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Help with xBrowse and dbf\cdx

Postby cnavarro » Sat Sep 30, 2017 4:29 pm

Add

Code: Select all  Expand view  RUN

     oLBx:bLClicked := { | r,c,f,oB | if( oB:MouseColPos( c ) == 1, ;
                        ( oB:aCols[1]:CheckToggle(), oB:RefreshCurrent() ), nil ) }
 
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
cnavarro
 
Posts: 6549
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Help with xBrowse and dbf\cdx

Postby Rick Lipkin » Sat Sep 30, 2017 4:40 pm

Christobal

BRILLIANT !!!! Thank you Very Much !

Rick Lipkin
User avatar
Rick Lipkin
 
Posts: 2666
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Help with xBrowse and dbf\cdx

Postby nageswaragunupudi » Fri Oct 06, 2017 4:05 am

apparently ALIAS no longer works properly . ... DATASOURCE was the correct change

ALIAS or DATASOURCE mean the same thing and you can use either.
Regards

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


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 62 guests