Get valid

Re: Get valid

Postby Otto » Sat Mar 13, 2010 10:54 pm

Hello James,

>available rooms are added to an array

I also need the exact dates when the room is available.
Sometimes guests have to make a room transfer. Saturday to Wednesday in room 100 the rest of the week in 1010, etc. .
Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6263
Joined: Fri Oct 07, 2005 7:07 pm

Re: Get valid

Postby James Bott » Sat Mar 13, 2010 11:42 pm

Otto,

Ah, yes, I also did a routine for that. First it looks for available rooms for the entire date range, if not found, then in looks for the next optimal ranges in two rooms (e.g. 4 days in one room and 1 day in another, then 3 days in one, 2 in another). If two rooms can't be found then it looks for 3 rooms. Then all the choices can be put into an array for browsing by the user. The user could then select any senario and all the needed reservations would be posted automatically. Quite complicated.

Back to your original example dialog, in many cases a single room number field would not be sufficent.

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Get valid

Postby demont frank » Sun Mar 14, 2010 3:13 pm

Otto wrote:Hello James,
thank you for your answer.
The valid is on the Zimmer-Nr: - field (engl. Room number).
If the room is occupied the valid returns false and you can’t navigate back to change the
“Anreise” or “Abreise” (arrival/departure) .
Best regards,
Otto
Image

Otto,

I have a solution (see code) .

Code: Select all  Expand view

#include "FiveWin.ch"
# include "common.ch"

function Main()
   LOCAL oDlg, oGet[3]
   LOCAL cCad := "Testing    "
   LOCAL nNum := 0
   LOCAL dDat := Date(), lOk
     Local LastGet
   Set century On
   Set Date Ansi
   Set Date format "mm/dd/yyyy"

   SET _3DLOOK ON

   DEFINE DIALOG oDlg TITLE "TGet from " + FWDESCRIPTION

   @ 1,    2 SAY "Text..:" OF oDlg
   @ 1,    6 GET oGet[1] VAR cCad OF oDlg SIZE 60, 10 COLOR "W/G" PICTURE "@K"
   @ 1.8,  2 SAY "Number:" OF oDlg
   @ 2,    6 GET oGet[2] VAR nNum OF oDlg SIZE 60, 10 PICTURE "9999999.99"
   @ 2.6,  2 SAY "Date:" OF oDlg
   @ 3,    6 GET oGet[3] VAR dDat PICTURE "@E" OF oDlg SIZE 60, 10 VALID (lOk .OR. ! EMPTY(dDat))
   @ 3,    7 BUTTON "&Ok" OF oDlg SIZE 30, 12 ACTION oDlg:End()
   @ 3,   16 BUTTON "&Cancel" SIZE 30, 12 OF oDlg ACTION oDlg:End() CANCEL
     oGet[1]:bGotFocus := {||lOk := Test(oDlg,oGet[1],Lastget),Lastget:=oGet[1]}
     oGet[2]:bGotFocus := {||lOk := Test(oDlg,oGet[2],Lastget),Lastget:=oGet[2]}
     oGet[3]:bGotFocus := {||Test(oDlg,oGet[3],Lastget),Lastget:=oGet[3]}
   ACTIVATE DIALOG oDlg CENTERED ON INIT LastGet:= oGet[1]

return nil

FUNC Test(oDlg,oGet,Lastget)
LOCAL Obj , i , j , k

FOR EACH Obj IN oDlg:aControls
    i := Hb_EnumIndex()
    IF Obj==oGet
        j := i
    END
    IF Obj==Lastget
        k := i
    END
NEXT
IF k == 6  .AND. j < k       // or  ASCAN({2,4},j) > 0
    RETURN .T.
END
RETURN  .F. //(k<=j)

 
demont frank
 
Posts: 167
Joined: Thu Mar 22, 2007 11:24 am

Re: Get valid

Postby Otto » Sun Mar 14, 2010 4:57 pm

Thank you Frank.
Your sample code is working well.
After inserting some logfile calls and studying of your code I understand your code. Very sophisticated. I will try to implement your logic into my own code.
Thanks again for your valuable help.
Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6263
Joined: Fri Oct 07, 2005 7:07 pm

Re: Get valid

Postby demont frank » Sun Mar 14, 2010 5:49 pm

Otto,

I unterstood : When the user has selected a non available room , the user must have the possibilty to change the period. But when the user navigates to the periode dates , we have to check the availbilty from the room again. If not , which action ? . I think that a better aproach is to disable the OK button till the room is free in the choosen period.

Frank
demont frank
 
Posts: 167
Joined: Thu Mar 22, 2007 11:24 am

Re: Get valid

Postby Otto » Sun Mar 14, 2010 6:10 pm

Hello Frank,
Implementing your code will do the job. My input screen has much more controls as I posted for demonstrating my problem.
I have a OK = SAVE and a CANCEL button.
Code: Select all  Expand view
REDEFINE BUTTON oBtnEnd ID 2 OF oDlg ACTION (oDlg:end()) CANCEL

If the popup screen does not show any vacancies the only way to go is to cancel the booking.
Thank you again for your help.
Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6263
Joined: Fri Oct 07, 2005 7:07 pm

Previous

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 58 guests