home *** CD-ROM | disk | FTP | other *** search
- *******************************************************************************
- * PROGRAM: Getflts.wfm
- *
- * WRITTEN BY: Borland Samples Group
- *
- * DATE: 5/93
- *
- * UPDATED: 5/95
- *
- * REVISION: $Revision: 1.30 $
- *
- * VERSION: Visual dBASE
- *
- * DESCRIPTION: This is a form called from Equipmnt.wfm that brings up a
- * dialog which allows selecting AirBorland flights based on
- * their origin, destination, and departure date. This form
- * has two listboxes -- originList and destList, and one
- * spinbox -- dateSpin. It also has Ok and Cancel buttons
- * that respectively allow the selections to be saved or
- * ignored.
- *
- *
- * PARAMETERS: None
- *
- * CALLS: Buttons.cc (Custom controls file)
- * Equipmnt.qbe (View of tables)
- *
- * USAGE: SET PROCEDURE TO GETFLTS.WFM
- * LOCAL F
- * F = NEW GETFLTS()
- * F.READMODAL()
- *
- *******************************************************************************
- #include <Messdlg.h>
- #include <Utils.h>
- #include "Equipmnt.h"
-
-
- create session
- set talk off
- set ldCheck off
-
- set ldCheck off
-
- ** END HEADER -- do not remove this line*
- * Generated on 07/06/95
- *
- parameter bModal
- local f
- f = new GETFLTSFORM()
- if (bModal)
- f.mdi = .F. && ensure not MDI
- f.ReadModal()
- else
- f.Open()
- endif
- CLASS GETFLTSFORM OF FORM
- Set Procedure To &_dbwinhome.samples\BUTTONS.CC additive
- this.OnOpen = CLASS::ONOPEN
- this.Height = 14.5293
- this.OnClose = CLASS::ONCLOSE
- this.MousePointer = 1
- this.ColorNormal = "N/GB+"
- this.Text = "Flight Selection"
- this.Width = 54.166
- this.Top = 0.1172
- this.OnSelection = CLASS::ONSELECTION
- this.Left = 16.666
-
- DEFINE IMAGE LOGOIMAGE OF THIS;
- PROPERTY;
- Height 7.5293,;
- Width 53,;
- DataSource "FILENAME AIRBRLND.BMP",;
- Alignment 2,;
- Left 0.5
-
- DEFINE TEXT ORIGTEXT OF THIS;
- PROPERTY;
- Height 1,;
- ColorNormal "N/GB+",;
- Text "Origin",;
- Width 17,;
- Top 7.6465,;
- FontSize 10,;
- Left 1
-
- DEFINE LISTBOX ORIGINLIST OF THIS;
- PROPERTY;
- Height 5.8701,;
- ColorNormal "N/W",;
- FontBold .F.,;
- ColorHighLight "W+/B",;
- Width 17,;
- ID 800,;
- Top 8.5996,;
- FontSize 9,;
- Left 1
-
- DEFINE TEXT DESTTEXT OF THIS;
- PROPERTY;
- Height 1,;
- ColorNormal "N/GB+",;
- Text "Destination",;
- Width 17,;
- Top 7.6465,;
- FontSize 10,;
- Left 20
-
- DEFINE LISTBOX DESTLIST OF THIS;
- PROPERTY;
- Height 5.8701,;
- ColorNormal "N/W",;
- FontBold .F.,;
- ColorHighLight "W+/B",;
- Width 17,;
- ID 800,;
- Top 8.5996,;
- FontSize 9,;
- Left 20
-
- DEFINE TEXT DATETEXT OF THIS;
- PROPERTY;
- Height 1,;
- ColorNormal "N/GB+",;
- Text "Date",;
- Width 14.5,;
- Top 7.6465,;
- FontSize 10,;
- Left 39
-
- DEFINE SPINBOX DATESPIN OF THIS;
- PROPERTY;
- Height 1.2822,;
- Function "J",;
- FontBold .F.,;
- ColorNormal "N/W",;
- Value {01/01/92},;
- ColorHighLight "W+/B",;
- Rangemin {01/01/90},;
- Width 14.166,;
- Rangemax {01/01/94},;
- Top 8.5996,;
- FontSize 10,;
- Left 39
-
- DEFINE OKBUTTON GETFLTSOKBUTTON OF THIS;
- PROPERTY;
- Height 1.5469,;
- Width 14.166,;
- Top 11.0996,;
- Group .T.,;
- Left 39
-
- DEFINE CANCELBUTTON GETFLTSCANCELBUTTON OF THIS;
- PROPERTY;
- Height 1.5527,;
- Width 14.166,;
- ID 0,;
- Top 12.7998,;
- Group .F.,;
- Left 39
-
- procedure OnOpen
- *******************************************************************************
- set procedure to program(1) additive && for functions located after class
- set procedure to &_dbwinhome.samples\Sampproc.prg additive
- && for FormatStr function
-
- if type("originAr") = "U"
-
- public originAr, destAr && if called stand alone, create vars
- local curRecCnt
- private tagName
-
- this.standAlone = .T.
- this.view = "Equipmnt.qbe"
- *** make arrays of unique origins and destinations
- select flights
- tagName = field(2) + "UN"
- set order to &tagName && origin unique
- count to curRecCnt && count of unique origins -- for declaring array
-
- declare originAr[curRecCnt,1]
- declare destAr[curRecCnt,1]
-
- copy to array originAr field origin
- tagName = field(3) + "UN"
- set order to &tagName && destination unique
- count to curRecCnt && count of unique destinations -- for declaring array
- copy to array destAr field dest
- tagName = field(1)
- set order to &tagName && don't need the index for a while
- go top
- else
- this.standAlone = .F.
- endif
- this.originList.dataSource = "Array originAr"
- this.destList.dataSource = "Array destAr"
- this.dateSpin.value = flights->date
-
- *******************************************************************************
-
- procedure OnClose
- *******************************************************************************
-
- if form.standAlone && if not called from equipmnt.wfm
- release originAr, destAr
- endif
-
- close procedure &_dbwinhome.samples\Buttons.cc,;
- &_dbwinhome.samples\Sampproc.prg,;
- program(1)
-
-
- *******************************************************************************
-
- procedure OnSelection (controlId)
-
- * Filter out records that match specified conditions.
- *******************************************************************************
- private originT, destT, dateT, filter, planeT, curTable, tryAgain, tagName
-
- tryAgain = .F.
- *** if Cancel wasn't selected and if not running standalone
- if controlId <> 0
- * get the selected origin, destination
- originT = ALLTRIM(form.originList.value)
- destT = ALLTRIM(form.destList.value)
- dateT = form.dateSpin.value
- filter = ""
- *** longer, but looks cleaner with IF instead of IIF()
- if .not. empty(originT)
- filter = FormatStr("origin = %1", AddQuotes(originT))
- endif
- if .not. empty(destT)
- if .not. empty(filter)
- filter = FormatStr("%1 .and. dest = %2", filter, AddQuotes(destT))
- else
- filter = FormatStr("dest = %1", AddQuotes(destT))
- endif
- endif
- if .not. empty(dateT)
- if .not. empty(filter)
- filter = FormatStr("%1 .and. date >= ctod(%2)", filter, AddQuotes(dtoc(dateT)))
- else
- filter = FormatStr("date >= ctod(%1)", AddQuotes(dtoc(dateT)))
- endif
- endif
- * Check filter in another area, so form doesn't get updated unnecessarily
- use dbf() in select() alias temp
- select temp
- set filter to &filter
- go top
- if eof() && no flights match the selections made
- if ConfirmationMessage(;
- FormatStr("There are no flights from %1 to %2 on or after %3."+;
- chr(13) +;
- "Would you like to select another set of flights?",;
- originT, destT, dtoc(dateT)),;
- "Confirmation") = YES
- tryAgain = .T. && flag to specify that form stays open
- endif
- select flights
- else
- select flights
- set filter to &filter
- go top
- do case
- case .not. empty(originT) && if an origin was specified, index on
- && origin, and look for selected origin
- tagName = field(2)
- set order to &tagName && tag origin
- seek originT
- case .not. empty(destT) && otherwise, if a destination was
- tagName = field(3) && specified, index on that, and seek.
- set order to &tagName && tag dest
- seek destT
-
- otherwise && index on origin if no selection was
- tagName = field(2)
- set order to &tagName && made, and go to the top of the database
- go top
- endcase
- endif
- use in temp
- endif
- if .not. tryAgain
- form.Close()
- endif
-
- ENDCLASS
-
- *******************************************************************************
- function AddQuotes(string)
-
- * Add quotes to the parameter string. This function is used when combining
- * several strings and macrosubstituting (&) the resulting string
- *******************************************************************************
-
- return "'" + string + "'"
-
-
-
-
-
-
-
-
-