Delete not updating ?

Delete not updating ?

Postby TimStone » Wed Oct 31, 2007 5:16 pm

Here is a section of code that uses FWH 7.10, xHarbour, tSBrowse, and tData ( data object extension ). If I click on the delete button, the browse removes the record, moves to the next record, but the edit control is not updating. I have a feeling I'm missing something ... just not getting through to my brain right now. This code is cut from the full function which has some more edit and label controls.

Tim

FUNCTION list01

// Declare LOCAL variables
LOCAL oDbl, oEdit, lFirst := .F.

// Open the labor rate reference database and index
oDbl := tdata():new(, "erflab" )
oDbl:use()
oDbl:setorder( "erflab" )
oDbl:gotop()

DEFINE DIALOG oDlg RESOURCE "LISTS" OF oWnd TITLE "Labor Rates" FONT oWnd:oFont

// Build the button controls
REDEFINE BUTTON ID 107 of oDlg ACTION( IIF( MsgYesNo( "Do you wish to delete this item ?"), ( oDBl:delete( ),;
oDlg:update()),)) MESSAGE "Delete the current item"

.....

// Build the edit controls
REDEFINE GET oEdit VAR oDbl:charge ID 102 OF oDlg PICTURE "$99999.99" MESSAGE "The charge for this service" UPDATE
REDEFINE GET oDbl:servic ID 103 OF oDlg MESSAGE "A description of the service type" UPDATE

.....

// Create the BROWSE control
REDEFINE BROWSE oLbx1 ID 101 OF oDlg ON CHANGE oDlg:update() UPDATE
oLbx1:setoDBF( oDbl )
add column to oLbx1 header "Charge" data oDbl:charge ALIGN 2,1 size 120
add column to oLbx1 size 25
add column to oLbx1 Header "Service" data oDbl:servic ALIGN 0,1 size 400

.....

// Activate the dialog screen
ACTIVATE DIALOG oDlg

// Close the file
oDbl:close()

RETURN NIL
:roll:
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2944
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Postby Armando » Wed Oct 31, 2007 6:47 pm

Timm:

I don't know TDATA, but.....

Perhaps you need read the new record to fill the bufer.

oDbl:Read()

just a tip

Regards
SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
User avatar
Armando
 
Posts: 3228
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México

Buffer

Postby TimStone » Wed Oct 31, 2007 7:19 pm

tData has a load() method ... it makes no difference ...
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2944
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Postby Gale FORd » Wed Oct 31, 2007 8:43 pm

I have a varying degrees of success with this subject.
I think one of the issues is that when you delete the record it is still visible and the msgyesno() function displays a dialog and the when it goes away the browse gets refreshed.

I ended up using a method/function that does the following.


Code: Select all  Expand view  RUN
METHOD DataDelete
   local nRecNo, nNewRecNo, lAnswer
   // store current record before window has a chance to move record pointer
   nRecno := ::oDbf:Recno()
   // to stop refresh
   ::oWnd:disable()
   lAnswer := MsgYesNo ( "Delete record: Are you sure ?", "DELETE" )
   if lAnswer
      // Get next good record if possible
      ::oDbf:goto( nRecNo )
      ::oDbf:skip()
      if ::oDbf:eof()
         ::oDbf:goto( nRecNo )
         ::oDbf:skip( -1 )
      endif
      nNewRecNo := ::oDbf:recno()
      // Now go back and delete record
      ::oDbf:goto( nRecNo )
      ::oDbf:delete()
      ::oDbf:unlock()
      // go to new record
      ::oDbf:goto( nNewRecNo )
   endif
   // enable window
   ::oWnd:enable()
   sysrefresh()
   if lAnswer
      // There is a question whether to use upstable() with database object
      // or use refresh(). I am using refresh() with database object
      //::oBrw:Upstable()
      ::oBrw:Refresh()
      ::oBrw:setfocus()
   endif
return( nil )
Gale FORd
 
Posts: 663
Joined: Mon Dec 05, 2005 11:22 pm
Location: Houston

Postby James Bott » Thu Nov 01, 2007 7:16 am

Tim,

Try adding oDbl:skip() right after oDbl:delete(). This will force the record pointer to the next record and reload the buffer.

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Skip

Postby TimStone » Thu Nov 01, 2007 8:14 pm

I just did that ( prior to your post, but after thinking about Gale's post) and it does indeed force the two records ( browse and data object ) to match up. I'm thinking perhaps this is a problem in TSBrowse as it currently stands.

The oDbf:skip() does work and I can add it throughout the code.

Thanks :D
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2944
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: antolin, Google [Bot] and 64 guests