I must delete the User and all permission of this user
The user is deleted as you can see here
USERS
The permissions are not deleted ( sometimes two or three records are deleted)
I not understood why
the function to delete is this
- Code: Select all Expand view RUN
Static Function UtBorra(oUtenti,oPermessi,oGrid2,oGrid3,oBtnCambia)
local cClave:= alltrim(oUtenti:Clave)
IF lABC .AND. !oUtenti:EoF()
IF MsgYesNo("Cancellare i permessi dell'utente "+Alltrim(oUtenti:Nombre)+"?","Confermare!")
oPermessi:Seek(cClave)
DO WHILE !oPermessi:EoF()
IF alltrim(oPermessi:Usuario)==cClave
oPermessi:Delete()
ENDIF
oPermessi:Skip()
ENDDO
oUtenti:Delete()
oGrid2:GoUp()
oGrid2:Refresh()
oGrid2:SetFocus()
Rinfresca(nMod,oUtenti,oPermessi,oGrid2,oGrid3,oBtnCambia)
ENDIF
ELSE
ENDIF
oGrid2:SetFocus()
RETURN (NIL)
the key and the name of the user is always 8 characters but I put an alltrim () because it can be even less than 8 characters like for example "TEST"
on the oPermessi there is a SetScope
static cKey
cKey:=oUtenti:Clave
oPermessi:setscope(cKey)
I did not understand why sometimes some records are cacenalled and other times none and other times only one,
Another test made this morning
yet putting an xbrowser after the seek makes me see all the modules of that user but then does not delete them all
Any solution ?
a test sample to try the problem
- Code: Select all Expand view RUN
#include "FiveWin.ch"
static cKey,lABC
request dbfcdx
request dbffpt
Function test()
local ctest:="Test"
RddSetDefault( "DBFCDX" )
oUtenti:= TUtenti():New()
oModuli:= TModuli():New()
oPermessi:=TPermessi():New()
lABC :=.t.
xbrowser oUtenti
xbrowser oPermessi
oPermessi:SetOrder(2)
cKey:=oUtenti:Clave
oPermessi:setscope(cKey)
xbrowser oPermessi
UtBorra(oUtenti,oPermessi)
xbrowser oPermessi
return nil
Static Function UtBorra(oUtenti,oPermessi)
local cClave:= alltrim(oUtenti:Clave) // può essere meno di 8 caratteri data errore
IF lABC .AND. !oUtenti:EoF()
IF MsgYesNo("Cancellare i permessi dell'utente "+Alltrim(oUtenti:Nombre)+"?","Confermare!")
oPermessi:Seek(cClave)
xbrowser oPermessi
DO WHILE !oPermessi:EoF()
IF alltrim(oPermessi:Usuario)==cClave
oPermessi:Delete()
ENDIF
oPermessi:Skip()
ENDDO
oUtenti:Delete()
*oGrid2:GoUp()
*oGrid2:Refresh()
*oGrid2:SetFocus()
*Rinfresca(nMod,oUtenti,oPermessi,oGrid2,oGrid3,oBtnCambia)
ENDIF
ELSE
ENDIF
* oGrid2:SetFocus()
RETURN (NIL)
CLASS TXData from TDataBase
DATA cExePath init cFilePath(GetModuleFileName( GetInstance() ))
ENDCLASS
CLASS TUtenti from TXData
METHOD New()
ENDCLASS
METHOD New( lShared ) CLASS TUtenti
Default lShared := .t.
::super:Open(,::cExePath + "Utenti" ,, lShared)
if ::use()
::setOrder(1)
::gotop()
endif
RETURN Self
//----------------------------------------------------------------------moduli
CLASS TModuli from TXData
METHOD New()
ENDCLASS
METHOD New( lShared ) CLASS TModuli
Default lShared := .t.
::super:Open(,::cExePath + "Moduli" ,, lShared)
if ::use()
::setOrder(1)
::gotop()
endif
RETURN Self
//----------------------------------------------------------------------Permessi
CLASS TPermessi from TXData
METHOD New()
ENDCLASS
METHOD New( lShared ) CLASS TPermessi
Default lShared := .t.
::super:Open(,::cExePath + "Permessi" ,, lShared)
if ::use()
::setOrder(1)
::gotop()
endif
RETURN Self
write to me at silvio[dot]falconi[at]gmail[dot]com if you need the dbfs to test it