Get valid

Get valid

Postby Otto » Fri Mar 12, 2010 4:49 pm

I don’t know how to handle this problem:
I have a get-field with a valid.
In case of backward navigation the valid should not be executed.
Thanks in advance
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6329
Joined: Fri Oct 07, 2005 7:07 pm

Re: Get valid

Postby James Bott » Fri Mar 12, 2010 5:13 pm

You could check for Shift-Tab, but a user could click on any other control. You would have to know which controls are before the Get with the valid.

Perhaps if you could explain what you are trying to do, someone can come up with another solution. Maybe the valid is dependent on another control's data? Why would the valid not need to be checked when moving backward?

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

Re: Get valid

Postby Otto » Fri Mar 12, 2010 6:01 pm

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
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6329
Joined: Fri Oct 07, 2005 7:07 pm

Re: Get valid

Postby James Bott » Fri Mar 12, 2010 8:20 pm

Otto,

OK. Does this mean that the record is for a previously reserved room and thus the entire record should only be read-only? Or, is this a new record?

Is the room number automatically filled in by the system after the dates are entered?

Tell me more how this all works.

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

Re: Get valid

Postby Otto » Fri Mar 12, 2010 8:51 pm

Hello James,
this could be a new one or a previously reserved one where someone wants to change his arrival or the departure date. The room number is entered manually. 95% of the users navigate with the mouse. At the moment I have the valid check on the room number get field. If the room is not free you “hang” in the get field.
I thought there is maybe a build in method or you could check if you navigate up or down .

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: 6329
Joined: Fri Oct 07, 2005 7:07 pm

Re: Get valid

Postby James Bott » Sat Mar 13, 2010 12:27 am

Otto,

OK, this will probably answer your question but I am not sure it is a very good interface design.

You could disable the arrival and departure date fields when the room no field is not empty. I suggest disabling them since they will then be grayed out and it will be obvious to the user that they cannot be changed. However, it will not be obvious WHY they cannot be changed.

What does the user do when they want to change one of the dates? Do they have to clear the room number field?

How does the user know what room numbers are available for the dates?

What you originally asked for seems that it would still allow the user to enter any room no. Having it hang in the field when the room is unavailable is not good. It is much better if you can prevent the user from having the option to enter "invalid" data. As a designer we want to avoid (at all cost) telling the usesr that they did something wrong. It would be worse to leave them wondering why they can't leave the field with no explaination.

Perhaps an better solution would be to use a listbox for the rooom no and fill it out automatically when the user enters the dates. Then they get a list of all available room no's for the date range AND they cannot enter an unavailable room no. For a small number of rooms this should be fast enough.

Actually, maybe a disabled GET with a Lookup button next to it would be better than a listbox. There would be a lag with a listbox, however when using a Lookup button the user expects a delay.

I did some work on a reservation system awhile back and I do remember it being quite complicated. I expect I still have the code that looks for available rooms for a date range, however, another idea just came to me that might make it much simpler. I would have to think on it some more.

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

Re: Get valid

Postby Otto » Sat Mar 13, 2010 6:25 am

Hello James,

thank you for your help. As I didn’t found a solution how to disable valid navigating upwards I thought of forcing the system to navigate upwards with Setfocus().
iif(oSelf:verfuegbarkeiten(oDlg), ( oGetAnreise:refresh(), oGetAbreise:refresh(), oGetZiNr:refresh(),.t. ), (oGetAbreise:setfocus(),.t.) ) )
It seems that this could be a solution for me.
I have a listbox in a popup if a wrong date or room no is entered. But if you leave the listbox with cancel it should be possible to leave the get field too. Now with setfocus() I can.
You are right the search for free rooms is a little time consuming. I will remember having seen some code you posted on this issue on the forum. I have to search the forum.
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: 6329
Joined: Fri Oct 07, 2005 7:07 pm

Re: Get valid

Postby Otto » Sat Mar 13, 2010 7:26 am

James,

Code: Select all  Expand view
freieZimmer  := TBelegung():new()
freieZimmer:setorder(4)                      //freieZimmer:zimmernr + dtos(freieZimmer:abreise)
   freieZimmer:seek(::cZiNr)

   if freieZimmer:found() = .T.
   
      freivom := ARR_ANREISE
      do while freieZimmer:zimmernr = adr->zimmernr
     
      ...
     
      freieZimmer:skip(+1)
      enddo
    endif


I always use a seek to search and then a do while with a condition.

Overthinking my code maybe to use scope would be better than do/while with a condition. Do you think a set scope would be quicker?
Code: Select all  Expand view
freieZimmer->(ordScope(0, dtos(zimmernr) ))    // set top scope
freieZimmer->(ordScope(1, dtos(zimmernr) ) )   // set bottom scope
freieZimmer->(dbgotop())
I will try.
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: 6329
Joined: Fri Oct 07, 2005 7:07 pm

Re: Get valid

Postby Otto » Sat Mar 13, 2010 9:04 am

Hello James,

The speed test with OrdScope is very promising.
Seek/do/while with condition
13.03.2010 09:54:04: Start
13.03.2010 09:54:24: Ende

OrdScope
13.03.2010 09:56:51: Start
13.03.2010 09:56:52: Ende

Code: Select all  Expand view
freieZimmer  := TBelegung():new()
freieZimmer:setorder(4)                      //freieZimmer:zimmernr + dtos(freieZimmer:abreise)
   
   
(freieZimmer:cAlias)->( OrdScope(0, adr->zimmernr +  dtos( ARR_ABREISE ) ) )    //99920100401
(freieZimmer:cAlias)->( OrdScope(1, adr->zimmernr + "A" ) )                     //999A  
freieZimmer:gotop()

   
   if freieZimmer:eof()  = .f.
   
      freivom := ARR_ANREISE
      do while freieZimmer:zimmernr = adr->zimmernr
     
      ...
     
      freieZimmer:skip(+1)
      enddo
    endif
 

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: 6329
Joined: Fri Oct 07, 2005 7:07 pm

Re: Get valid

Postby nageswaragunupudi » Sat Mar 13, 2010 10:51 am

When we SET OPTIMIZE ON on DBFCDX, both OrdScope and DbSetFilter() work with acceptable speeds, if we create indexes in the right way, even on quite large tables.

It is a good idea to popup of a list of unoccupied rooms and let the user select one of them.
Regards

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

Re: Get valid

Postby James Bott » Sat Mar 13, 2010 8:02 pm

Otto,

It looks like you are using scopes to search only for a certain room. Perhaps this is useful for when the customer wants a particular room, but to search for any available room is another matter.

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

Re: Get valid

Postby Otto » Sat Mar 13, 2010 9:21 pm

Hello James,
Yes. But I browse the whole room database and with the routine I posted I search after the vacancies in this certain room and write it into an array which I browse in a popup window.
So fare I didn’t found a quicker method.
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: 6329
Joined: Fri Oct 07, 2005 7:07 pm

Re: Get valid

Postby James Bott » Sat Mar 13, 2010 10:07 pm

But I browse the whole room database and with the routine I posted I search after the vacancies in this certain room and write it into an array which I browse in a popup window.


OK, this works for finding available dates for a certain room, but don't you need a routine to return all available rooms for a certain date range? I would think most people have a fixed date range in mind, not a certain room number.

Perhaps you need both.

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

Re: Get valid

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

Hello James,

Maybe I explained myself wrong:
Room database in my case is the database with the rooms of the hotel for example 1-100 and
then there is a database with the reservations.
I browse the room database and lookup for every room into the reservation database for vacancies.
(the negative of the reservation)

Code: Select all  Expand view
ASIZE(::afrei,0)
Select room
 do while .not. EOF()
        ::cZiNr:= field->zimmernr
        ::Lookup_ vacancies ()   //Buchung
          select room
           skip
           ENDDO


Now writing this “the negative of the reservation” I think a very quick solution came into my mind.
Room 100
Reservations:
10-3. 14.3. / 20.3. – 27.3. / 1.4.- 8.4.
If I cut the first arraival and add a enddate the vacancies are ready.
14.3. -/ 20.3./ 27.3. - 1.4./ 8.4. - 31.12.
I have to proof this.
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: 6329
Joined: Fri Oct 07, 2005 7:07 pm

Re: Get valid

Postby James Bott » Sat Mar 13, 2010 10:43 pm

Otto,

So is this returning an array of available date ranges? What to you do with that?

One of my routines is:

isFree( nRoom, dArrival, dDeparture)

It returns a logical.

Like your routine, there is a loop through all available rooms and the available rooms are added to an array. This array can be used in a listbox or browse.

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

Next

Return to FiveWin for Harbour/xHarbour

Who is online

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