strange problem with tdatabase

strange problem with tdatabase

Postby Silvio.Falconi » Sat Aug 10, 2019 10:37 am

I must erase all record of an invoice number ( the filed is 13cr)
Local nInvoice := "1234567890128"
the oPartres dbf is index on INDEX ON RESITEMS->INVNUM + STR( SERIAL, 3, 0 ) TAG invnum TO resitems

oPartres:=TDatabase():Open( , cDir+"ResItems", "DBFCDX", .T. )
oPartres:setorder(1)
oPartres:gotop()

oPartRes:Gotop()
Do While .not. oPartRes:eof()
IF alltrim(oPartRes:InvNum) == alltrim(nInvoice)
// Msginfo( oPartRes:InvNum ,nInvoice)
oPartRes:delete()
Endif
oPartRes:skip()
EndDo
oPartRes:Gotop()

SET DELETED ON
oPartRes:SetOrder( 0 )
oPartRes:GoTo( 1 )
oPartRes:ArrayToDBF( aItems, cItemFlds, nil, .t., .t. )

it save goog but erased all records
I wish save on dbf with the condition alltrim(oPartRes:InvNum) == alltrim(nInvoice

Any solution please ...
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7053
Joined: Thu Oct 18, 2012 7:17 pm

Re: strange problem with tdatabase

Postby Silvio.Falconi » Sat Aug 10, 2019 11:12 am

Perhaps I resolve but I not Know it it is correct

Code: Select all  Expand view

    SET DELETED  ON
    oPartRes:setorder(0)
    oPartRes:Exec( < ||
    SET FILTER TO AllTrim( FIELD->INVNUM ) = alltrim(nInvoice)
   return nil
   > )
    oPartRes:gotop()
    oPartRes:ArrayToDBF( aItems, cItemFlds,nil , .t., .t. )
    oPartRes:SetFilter( "" )
 

any suggestion ?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7053
Joined: Thu Oct 18, 2012 7:17 pm

Re: strange problem with tdatabase

Postby nageswaragunupudi » Sat Aug 10, 2019 11:35 pm

I must erase all record of an invoice number

If you want to delete all records where the field INVNUM == nInvoice, i.e., "1234567890128", then:
[code]
Local nInvoice := "1234567890128"

oPartres:Exec( <||
DELETE ALL FOR ALLTRIM(FIIELD->INVNUM) == nInvoice
> )
[code]
Regards

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

Re: strange problem with tdatabase

Postby nageswaragunupudi » Sun Aug 11, 2019 1:59 am

You want to read all records relating to one invoice, add/edit/delete in memory and save all changes at once to the database.

FWH1907 simplifies the entire process.

Code: Select all  Expand view

oBatch := oPartRes:ReadBatch( { "INVNUM", nInvoice } )
// oBatch is like a mini Tdatabase
// Browse, Edit, Append, Delete records in oBatch
// All changes are made in memory only and not written to database
// When you want to write all changes, call
oBatch:SaveBatch()

//If you change the invoice number in the main table
oBatch:Load( { "INVNUM", nInvoce } ) // loads records of new invoice number
 

Please wait for a sample
Regards

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

Re: strange problem with tdatabase

Postby Silvio.Falconi » Sun Aug 11, 2019 9:58 am

Nages
I must use an array for the invoice body (xbrowse) where the first line (which cannot be deleted by the user only it can be modified) is like a repetition of the element described in the header ( saved on Reserva.dbf) for example:

HEADER
Image

BODY
Image

then the other lines of body are the services associated to this element

Image



when the user change something of the first line of Xbrowse ( for a sample the dates) the procedure must change also the header

I need this solution because I have to enter the price of the item (ie the first line of the xbrowse) and then the prices of the other lines (services)
Reserva.dbf must have only the element number the arrival and departure dates the total cost and the customer, while in detail (resItems.dbf) there must be all the prices of both the element and the services associated with the element

doing so I do not know if I should save all the lines of the body or delete the first line and insert it again to the modification

I have big problems with the rescue now I'm trying this solution

1) delete all records on resItems.dbf having the same invoice number
2) re-enter the invoice item on resItems.dbfs from the aItems array

but I did not understand if it is correct to do this, or there is another method

then I have the problem of the lock record in reserva that is

1) I have to take the record on reserva.dbf
2) upload the invoice details to aItems
3) work on xbrowse
4) save on Resitems.dbf
5) save the record on reserva.dbf
6) unlock the record on reserva.dbf

but I still haven't figured out how I can do it
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7053
Joined: Thu Oct 18, 2012 7:17 pm

Re: strange problem with tdatabase

Postby Silvio.Falconi » Sun Aug 11, 2019 6:37 pm

nageswaragunupudi wrote:
I must erase all record of an invoice number

If you want to delete all records where the field INVNUM == nInvoice, i.e., "1234567890128", then:
Code: Select all  Expand view

Local nInvoice := "1234567890128"

oPartres:Exec( <||
   DELETE ALL FOR ALLTRIM(FIIELD->INVNUM) == nInvoice
   > )
[code][/quote]

Error
[code]Application
===========
   Path and name: C:\Work\Errori\aarray_dlg_invoice\test.Exe (32 bits)
   Size: 4,024,320 bytes
   Compiler version: Harbour 3.2.0dev (r1904111533)
   FiveWin  version: FWH 19.05
   C compiler version: Borland/Embarcadero C++ 7.0 (32-bit)
   Windows version: 6.2, Build 9200

   Time from start: 0 hours 0 mins 3 secs
   Error occurred at: 11-08-2019, 20:36:04
   Error description: Error DBFCDX/1022  Richiede un Lock

Stack Calls
===========
   Called from:  => DBDELETE( 0 )
   Called from:  => (b)EVAL( 387 )
   Called from:  => DBEVAL( 0 )
   Called from: test.prg => (b)TEST_INVOICE( 387 )
   Called from: .\source\classes\DATABASE.PRG => (b)TDATABASE( 140 )
   Called from: .\source\classes\DATABASE.PRG => TDATABASE:EXEC( 0 )
   Called from: test.prg => TEST_INVOICE( 388 )
   Called from: test.prg => MAIN( 46 )
 
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7053
Joined: Thu Oct 18, 2012 7:17 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 85 guests