I try to pass certain dates because I need it to search for all bookings in a range of dates
So, I pass to function Reserva() two paramters dDateini and dDateFin
sample :
Reserva() // all bookings
If I not insert these parameters the procedure must set the dfirst:= dmin and dLast := dMax
Reserva( date(),) //today
the procedure must set the dfirst:= date() and dLast := dMax
Reserva( date()+1,) //tomorrow
the procedure must set the dfirst:= date()+1 and dLast := dMax
the problem is dLast is allway the date()
the problem is the dfirst and dlast not changed
I have allway from 17.05 to 28.05 why ?
this is the test
- Code: Select all Expand view RUN
- #include "fivewin.ch"
#include "dtpicker.ch"
Function Main()
Local oMain,oBtn[7]
SET DATE ITALIAN
SET CENTURY ON
Define Dialog oMain SIZE 400,400 Title "Test with datepicker control"
@ 20,10 BUTTON oBtn[1] PROMPT "All" Action Reserva(,) SIZE 100,10 PIXEL of oMain
@ 40,10 BUTTON oBtn[2] PROMPT "Arrive Today" Action Reserva(date(),) SIZE 100,10 PIXEL of oMain
@ 60,10 BUTTON oBtn[3] PROMPT "Arrive Tomorrow" Action Reserva(date()+1,) SIZE 100,10 PIXEL of oMain
@ 80,10 BUTTON oBtn[4] PROMPT "Arrive After tomorrow" Action Reserva(date()+2,) SIZE 100,10 PIXEL of oMain
@ 120,10 BUTTON oBtn[5] PROMPT "Departure Today" Action Reserva(,date()) SIZE 100,10 PIXEL of oMain
@ 140,10 BUTTON oBtn[6] PROMPT "Departure Tomorrow" Action Reserva(,date()+1) SIZE 100,10 PIXEL of oMain
@ 160,10 BUTTON oBtn[7] PROMPT "Departure After tomorrow" Action Reserva(,date()+2) SIZE 100,10 PIXEL of oMain
Activate Dialog oMain
Return nil
//----------------------------------------------------------------------------//
function Reserva(dDateini,dDateFin)
local oDlg, oFont, oDtpFirst, oDtpLast
local dMin := {^ 2021/05/17 } //may
local dMax := {^ 2021/09/20 } //september
local dFirst //:= {^ 2021/04/08 }
local dLast //:= {^ 2021/04/08 }
IF Empty(dDateini) .and. Empty(dDateFin)
dFirst := dMin
dLast := dMax
Endif
IF Empty(dLast)
dLast := dMax
else
dLast := dDateFin
Endif
IF Empty(dFirst)
dFirst := dMin
else
dFirst := dDateini
Endif
DEFINE FONT oFont NAME "Segoe UI" SIZE 0,-16
DEFINE DIALOG oDlg SIZE 500,240 PIXEL TRUEPIXEL FONT oFont ;
TITLE FWVERSION + " : RANGE OF DATES WITH TWO DATEPICKERS"
@ 30, 30 DTPICKER oDtpFirst VAR dFirst SIZE 200,28 PIXEL OF oDlg ;
PICTURE "ddd dd mmm yyyy" ;
ON CHANGE ( oDtpLast:SetRange( dFirst ), oDlg:Update() ) UPDATE
WITH OBJECT oDtpFirst
:lNoToday := .t.
:lNoTodayCircle := .t.
:SetRange( dMin, dMax )
END
@ 65, 30 BTNBMP PROMPT "-" SIZE 30,30 PIXEL OF oDlg FLAT ;
ACTION ( dFirst--, oDtpFirst:SetFocus() )
@ 65,200 BTNBMP PROMPT "+" SIZE 30,30 PIXEL OF oDlg FLAT ;
ACTION ( dFirst++, oDtpFirst:SetFocus() )
@ 30,250 DTPICKER oDtpLast VAR dLast SIZE 200,28 PIXEL OF oDlg ;
PICTURE "ddd dd mmm yyyy" ON CHANGE oDlg:Update() UPDATE
WITH OBJECT oDtpLast
:lNoToday := .t.
:lNoTodayCircle := .t.
:SetRange( dFirst, dMax )
END
@ 65,250 BTNBMP PROMPT "-" SIZE 30,30 PIXEL OF oDlg FLAT ;
ACTION ( dLast--, oDtpLast:SetFocus() )
@ 65,420 BTNBMP PROMPT "+" SIZE 30,30 PIXEL OF oDlg FLAT ;
ACTION ( dLast++, oDtpLast:SetFocus() )
@ 120, 30 SAY { || FW_TRANSFORM( dFirst, "ddd dd mmm yyyy" ) } SIZE 200,24 PIXEL OF oDlg UPDATE
@ 120,250 SAY { || FW_TRANSFORM( dLast, "ddd dd mmm yyyy" ) } SIZE 200,24 PIXEL OF oDlg UPDATE
@ 180,370 BUTTON "OK" SIZE 100,30 PIXEL OF oDlg ACTION oDlg:End()
ACTIVATE DIALOG oDlg CENTERED
RELEASE FONT oFont
? dFirst, dLast
return nil
//----------------------------------------------------------------------------------------------------------------//