ok i try to be more specific, I explain you
I'm using the tdatabase class with two file reserva.dbf and resItems.dbf
I have a window where I have a series of btnbmp controls
the buttons can be free green or busy red the procedure check the file reserva.dbf if found the reservatiion, if yes load the reservation and change the button as red ( occupated)
when the user presses a btnbmp must open a menupopup where the user can change if it is red or can insert a reservation if it is green.
if it is a new entry, create the record object type
oPrenotazione:=oreservations:record(.t.)or if a modify
oPrenotazione:=oreservations:record()If is a modify I load the aItems array from resitems archive with
aItems := ( oPartres:cAlias )->( FW_DbfToArray( cItemFlds, { || AllTrim( FIELD->INVNUM ) = alltrim(nInvoice) }) )When the reservation dialog opens, the number, type and dates of check_in and check-out, the user can select the customer holding the invoice
as you can see here
as I explained before I use an "aItems" array to create the body of the invoice
the procedure as the first line must include the information and the price of the item rented in this case the umbrella number 2 from 5 to 9 August ie for 4 days
therefore the first line must contain the reference to the umbrella with the aforementioned dates and the price that the procedure must assign according to a specific table
the user can insert the products you see listed in the figure, the procedure inserts them in the xbrowse (body of Invoice)
now I have to proceed with the save operation on reserva.dbf and resitems.dbf
for reserva.dbf there are no problemsthere may be some edit fields but in general use to save
oPrenotazione :save ()for the body ( resitems.dbf) I didn't understand how to proceed
if it is a new entry I go to the content of the "aItems" array in the resitems archive
if instead it is a change how do I save the detail?
in the exclusive version I decided to delete all records with the same invoice number and re-enter everything from the "aItems" array and then make the archive pack
but with the database class I open all the archives in share mode and I don't have to do the same operation that is I can't delete the records and then pack them
then I delete the records with the same invoice number and then replace the records with the arraytodbf function also making a recall of the deleted files
this procedure can run ok but there is an error as you can see here
the records you see in red are deleted, then the function
- Code: Select all Expand view RUN
oPartRes:ArrayToDBF( aItems, cItemFlds,nil , .t., .t. )
is not recalling deleted records and still saves the "aItems" array
I show you more specifically the rescue procedure
//check line number
AEval( aItems, { |a,i| a[ 2 ] := i } )
// delete all those with the same invoice number
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()
// except by calling the deleted and filtering by num invoice
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( "" )
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