Let Xbrowse update selected colums in other dbf

Post Reply
User avatar
Marc Venken
Posts: 727
Joined: Tue Jun 14, 2016 7:51 am

Let Xbrowse update selected colums in other dbf

Post by Marc Venken »

I have a master xbrowse (dbf) with many colums
With Xbrowse i select the colums that I want to update in a second database (fieldnames are identical)

For the selecting of colums i use Mr. Rao's function : XbrColselector(oBrw)

Now it would be nice If I could klik a button or so that only the selected colums are updated . (many times the selection can be different)

Always the field 'Code' will be used as seek parameter in the second database.


Code: Select all

function XbrColselector(oBrowse)

   local oDlg, oBrw
   local aSave    := aCopy( oBrowse:aCols )

   DEFINE DIALOG oDlg SIZE 300,400 PIXEL TRUEPIXEL

   @ 60,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
      DATASOURCE oBrowse:aCols ;
      COLUMNS "lHide", "cHeader" ;
      HEADERS "", "Header" ;
      COLSIZES 40, 100 ;
      CELL LINES NOBORDER

   WITH OBJECT oBrw
      :nStretchCol   := 2
      WITH OBJECT :aCols[ 1 ]
         :bEditValue    := { |x| If( x == nil, !oBrw:aRow:lHide, oBrw:aRow:lHide := !x ) }
         :SetCheck( nil, .t. )
         :nHeadBmpNo    := 2
      END
      :CreateFromCode()
   END

   @ 20,180 BTNBMP PROMPT "Close" SIZE 100,30 FLAT PIXEL OF oDlg ACTION oDlg:End()
   @ 20,80 BTNBMP PROMPT "ALL" SIZE 100,30 FLAT PIXEL OF oDlg ACTION (AEval( oBrowse:aCols, { |o| o:lHide := .f. } ),oDlg:End() )

   ACTIVATE DIALOG oDlg CENTERED

   oBrowse:Refresh()

return nil


[code]
function +

   local oDlg, oBrw
   local aSave    := aCopy( oBrowse:aCols )

   DEFINE DIALOG oDlg SIZE 300,400 PIXEL TRUEPIXEL

   @ 60,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
      DATASOURCE oBrowse:aCols ;
      COLUMNS "lHide", "cHeader" ;
      HEADERS "", "Header" ;
      COLSIZES 40, 100 ;
      CELL LINES NOBORDER

   WITH OBJECT oBrw
      :nStretchCol   := 2
      WITH OBJECT :aCols[ 1 ]
         :bEditValue    := { |x| If( x == nil, !oBrw:aRow:lHide, oBrw:aRow:lHide := !x ) }
         :SetCheck( nil, .t. )
         :nHeadBmpNo    := 2
      END
      :CreateFromCode()
   END

   @ 20,180 BTNBMP PROMPT "Close" SIZE 100,30 FLAT PIXEL OF oDlg ACTION oDlg:End()
   @ 20,80 BTNBMP PROMPT "ALL" SIZE 100,30 FLAT PIXEL OF oDlg ACTION (AEval( oBrowse:aCols, { |o| o:lHide := .f. } ),oDlg:End() )

   ACTIVATE DIALOG oDlg CENTERED

   oBrowse:Refresh()

return nil


 [/code]
Marc Venken
Using: FWH 20.08 with Harbour
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: Let Xbrowse update selected colums in other dbf

Post by nageswaragunupudi »

I might have given the function xbrColSelector as a variation, but just right-click on any column header also does the same job, without this function.

Coming to your main requirement, do you want to update only the second dbf or both main dbf and second dbf?
Regards

G. N. Rao.
Hyderabad, India
User avatar
Marc Venken
Posts: 727
Joined: Tue Jun 14, 2016 7:51 am

Re: Let Xbrowse update selected colums in other dbf

Post by Marc Venken »

nageswaragunupudi wrote:I might have given the function xbrColSelector as a variation, but just right-click on any column header also does the same job, without this function.

Coming to your main requirement, do you want to update only the second dbf or both main dbf and second dbf?
This function let me tag more than one item. The build in function just one each time.

Only the second dbf should be changed.

Thanks
Marc Venken
Using: FWH 20.08 with Harbour
User avatar
Marc Venken
Posts: 727
Joined: Tue Jun 14, 2016 7:51 am

Re: Let Xbrowse update selected colums in other dbf

Post by Marc Venken »

Do I look into xbrowse for this to work of should I go outside xbrowse and make a loop with the database fields ?
Marc Venken
Using: FWH 20.08 with Harbour
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: Let Xbrowse update selected colums in other dbf

Post by nageswaragunupudi »

Sorry, I missed this post.
I will post a sample.
Regards

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

Re: Let Xbrowse update selected colums in other dbf

Post by nageswaragunupudi »

Assuming the other alias is opened in EXCLUSIVE mode.

First SET RELATION to the other alias on the field Code.

You know the field names of the selected columns.
For each selected column, please change the oCol:bEditValue like this:

Code: Select all

nPos := ( cOtherAlias )->( FieldPos( <cfieldname> ) )
oCol:bEditValue := { |x| If( x == nil, ( cOtherAlias )->( FieldGet( nPos ) ), ( cOtherAlias )->( FieldPut( nPos, x )  ) ) }
 
Regards

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

Re: Let Xbrowse update selected colums in other dbf

Post by nageswaragunupudi »

Your requirement made me to think.
We may provide a much simpler way in the next version FWH2009.
That will be as simple as setting

Code: Select all

oCol:cAlias := <cOtherAlias>
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
Marc Venken
Posts: 727
Joined: Tue Jun 14, 2016 7:51 am

Re: Let Xbrowse update selected colums in other dbf

Post by Marc Venken »

nageswaragunupudi wrote:Assuming the other alias is opened in EXCLUSIVE mode.

First SET RELATION to the other alias on the field Code.

You know the field names of the selected columns.
For each selected column, please change the oCol:bEditValue like this:

Code: Select all

nPos := ( cOtherAlias )->( FieldPos( <cfieldname> ) )
oCol:bEditValue := { |x| If( x == nil, ( cOtherAlias )->( FieldGet( nPos ) ), ( cOtherAlias )->( FieldPut( nPos, x )  ) ) }
 
This will work for real time edit and update the 2de dbf... ok

But for my purpose I explane...

The program is made for updating a online webshop database.
The first time all fields are needed to fill the online database from the offline source (the fill is done with the import function of the shop system, not FWH) i make a CSV file for it from Xbrowse

The idea now is that the source dbf has 22 fields and the prices are changed into it. Now my question for Xbrowse to unselect All 20 others (function i have) and see only the 2 fields

Code and Price. Now I need een button ? that when hit, ALL rows of the source dbf (the 2 field for ex.) are looked up in the target dbf (always field CODE) and the field price = updated.
The field-count can be more than 2 if online changes are needed (price and discount for example) than the program will look up the code and change the 2 fields. (all fields that a still selected in the xbrowse)

Maybe this is more clear
Marc Venken
Using: FWH 20.08 with Harbour
Post Reply