FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Delete not updating ?
Posts: 3022
Joined: Fri Oct 07, 2005 01:45 PM
Delete not updating ?
Posted: Wed Oct 31, 2007 05: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
Posts: 3358
Joined: Fri Oct 07, 2005 08:20 PM
Delete not updating ?
Posted: Wed Oct 31, 2007 06: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
Posts: 3022
Joined: Fri Oct 07, 2005 01:45 PM
Buffer
Posted: Wed Oct 31, 2007 07: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
Posts: 663
Joined: Mon Dec 05, 2005 11:22 PM
Delete not updating ?
Posted: Wed Oct 31, 2007 08: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.


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 )
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Delete not updating ?
Posted: Thu Nov 01, 2007 07: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

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 3022
Joined: Fri Oct 07, 2005 01:45 PM
Skip
Posted: Thu Nov 01, 2007 08: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

Continue the discussion