To Nages: Problem with Datepick control

To Nages: Problem with Datepick control

Postby Silvio.Falconi » Fri May 28, 2021 9:02 am

I make a small test taking the example of Nages dtprang1.prg

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
#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
//----------------------------------------------------------------------------------------------------------------//
 
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: To Nages: Problem with Datepick control

Postby Silvio.Falconi » Fri May 28, 2021 9:15 am

If I correct at init with

IF Empty(dDateini) .and. Empty(dDateFin)
dFirst := dMin
dLast := dMax
Endif

IF Empty(dDateini)
dFirst := dMin
else
dFirst := dDateini
Endif

IF Empty(dDateFin)
dLast := dMax
else
dLast := dDateFin
Endif


and then on activate dialog I add this

ON INIT ( oDtpFirst:SETDATE(dFirst), oDtpLast:SETDATE(dLast) )

Image


the new test

Code: Select all  Expand view
#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(dDateini)
        dFirst  := dMin
      else
        dFirst  := dDateini
       Endif

    IF Empty(dDateFin)
      dLast := dMax
    else
      dLast := dDateFin
       Endif

     ? dFirst, dLast,dDateini,dDateFin

   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 ;
   ON INIT ( oDtpFirst:SETDATE(dFirst),  oDtpLast:SETDATE(dLast) )
   RELEASE FONT oFont

   ? dFirst, dLast

return nil
//----------------------------------------------------------------------------------------------------------------//



Image


then the datepick control set allways 17.05 - 28.05 why ?
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: To Nages: Problem with Datepick control

Postby Silvio.Falconi » Fri May 28, 2021 9:29 am

the problem is allway :SetRange()

So if I rem all calls to * :SetRange( ) all run ok
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 52 guests