I not understood why it save bad
I open oServizi
oServizi:= TServizi():new()
oServizi:gotop()
at init I have this dbf
and I have this dialog
the services on first xbrowse are single, the services on second xbrowse are Multi
Services 1,2,3,4 are single and have the field multiple = .f. and have the field struttura empty
services 5,6,7 are Multi and have the field multiple = .t. and have the field struttura with words
then open the order function and I see it
Now I try to move servizi7 to top
Now save and return to my dialog
ERROR
as you can see there is something of wrong
there are two record "servizi7" one on first xbrowse the other on second xbrowse
the record "Servizi1" now is on second xbrowse while it must be on first xbrowse because it is single service
then If you see the dbf you can see the error
the service have ID 0001 "Servizi1" now have the filed "struttura" full ( instead empty) and the field multiple now is .t. ( instead .f.)
WHY ?
this is the code
- Code: Select all Expand view
Function Order(oBrw1,oBrw2,cFilter1,cfilter2,oServizi)
local aArray,oLbx,oFont
local cFieldList:="id,name,breve,price,image,struttura,unit,a4,pos,multiple,islock,ordine"
local oDlgOrder
Local cCursor:= TCursor():New(,'HAND')
oServizi:GOTOP()
aArray := oServizi:FW_DbfToArray( cFieldList )
DEFINE FONT oFont NAME "VERDANA" SIZE 0,-14
DEFINE DIALOG oDlgOrd SIZE 600, 480 ;
TITLE " Cambia la posizione"
@ 5, 2 XBROWSE oLbx OF oDlgOrd ;
DATASOURCE aArray ;
COLUMNS 5,2 ;
HEADERS "Servizio","Desc" ;
SIZE 200,210 PIXEL FONT oFont
WITH OBJECT oLbx
WITH OBJECT oLbx:aCols[1]
:cDataType := 'F'
:nWidth := 80
:nDataBmpAlign := AL_CENTER
:lBmpTransparent := .T.
END
:lheader:=.f.
:nMarqueeStyle := MARQSTYLE_HIGHLWIN7
:lHscroll := .F.
:l2007 := .F.
:l2015 := .T.
:nStretchCol := STRETCHCOL_WIDEST
:lAllowRowSizing := .F.
:lAllowColSwapping := .F.
:lAllowColHiding := .F.
:lRecordSelector := .F.
:CreateFromCode()
END
@ 22,208 BTNBMP oBtnUp PROMPT "&UP" ;
RESOURCE "BTN_PNG_SCROLLUP" FLAT;
SIZE 80,25 LEFT PIXEL OF oDlgOrd ;
ACTION oLbx:SwapUp()
@ 72,208 BTNBMP oBtnDown PROMPT "&Down" ;
RESOURCE "BTN_PNG_SCROLLDOWN" FLAT;
SIZE 80,25 LEFT PIXEL OF oDlgOrd;
ACTION oLbx:SwapDn()
@ 122,208 BTNBMP oBtnOrdine PROMPT "&Save" ;
RESOURCE "BTN_PNG_SAVE" FLAT;
SIZE 80,25 LEFT PIXEL OF oDlgOrd ;
ACTION oDlgOrd:end( IDOK )
@ 162,208 BTNBMP oBtnUscita PROMPT "&Exit" ;
RESOURCE "BTN_PNG_USCITA" FLAT;
SIZE 80,25 LEFT PIXEL OF oDlgOrd ;
ACTION oDlgOrd:end( IDCANCEL )
oBtnUp:oCursor:= cCursor
oBtnDown:oCursor:= cCursor
oBtnOrdine:oCursor:= cCursor
oBtnUscita:oCursor:= cCursor
ACTIVATE DIALOG oDlgOrd CENTER
if oDlgOrd:nresult == IDOK
//save the poistion on records of array
AEval( aArray, { |a,i| a[ 12 ] := i } )
// save the oServizi
oServizi:GOTOP()
aArray := oServizi:FW_ArrayToDbf( aArray, cFieldList, nil, .T. )
oServizi:GOTOP()
Endif
//refresh the xbrowses
if oBrw1 != nil
IF !empty(cFilter1)
(oBrw1:cAlias)->(DbSetFilter( {|| &cFilter1 }, ))
(oBrw1:cAlias)->(DBGOTOP())
ENDIF
oBrw1:Refresh(.t.)
oBrw1:SetFocus( .t. )
endif
if oBrw2 != nil
IF !empty(cFilter2)
(oBrw2:cAlias)->(DbSetFilter( {|| &cFilter2 }, ))
(oBrw2:cAlias)->(DBGOTOP())
ENDIF
oBrw2:Refresh(.t.)
oBrw2:SetFocus( .t. )
endif
RETURN NIL