home *** CD-ROM | disk | FTP | other *** search
Null Bytes Alternating | 1997-01-09 | 13.5 KB | 148 lines |
- '++LotusScript Development Environment:2:5:(Options):0:66
-
- '++LotusScript Development Environment:2:5:(Forward):0:1
- Declare Sub Click(Source As Button, X As Long, Y As Long, Flags As Long)
-
- '++LotusScript Development Environment:2:5:(Declarations):0:2
-
- '++LotusScript Development Environment:2:2:BindEvents:1:129
- Private Sub BindEvents(Byval Objectname_ As String)
- Static Source As BUTTON
- Set Source = Bind(Objectname_)
- On Event Click From Source Call Click
- End Sub
-
- '++LotusScript Development Environment:2:2:Click:1:12
- Sub Click(Source As Button, X As Long, Y As Long, Flags As Long)
- ' Click event for the btnDone button object on the Reservation view
- ' This script checks to see if there is a complete reservation in the
- ' boxes in the view, checks the label of the btnDone on the view to
- ' see what to do with the reservation (Reserve or Remove), and then
- ' add the reservation to the schedule database or removes the
- ' reservation. Prompts are given to the user if there are errors at
- ' various stages in the process.
-
- Dim dateReserved As String ' Reservation date as entered in the view
- Dim ReservedBy As String ' Reservation owner as entered in the view
- Dim StartTime As String ' Start time for the reservation
- Dim FinishTime As String ' End time for the reservation
- Dim roomName As String ' Room being reserved
- Dim note As String ' Comments as entered in the view
-
- Dim start As Double ' Holds unformatted start time
- Dim finish As Double ' Holds unformatted end time
- Dim OK As Integer ' Flag to indicate if the reservation is completed
- Dim msg As String ' Store error message text
-
- ' Initialize the flag as 'Reservation is not complete'
- OK = False
-
- ' Store the values entered in the view
- dateReserved = source.fbxDate.text
- ReservedBy = source.fbxReservedBy.text
- StartTime = source.ddbStart.text
- FinishTime = source.ddbEnd.text
- roomName = source.ddbRoom.text
- note = source.fbxNotes.text
-
- ' Check to see if the required parts of the reservation exist in the view
- ' and set the OK flag appropriately
- If (ReservedBy <>"") And (dateReserved <> "") And (roomName <> "") And (StartTime <> "") And (FinishTime <> "")Then
- OK = True
- Else ' If the reservation is missing required data, then
- OK = False
- Messagebox "Invalid request. Be sure the entire reservation form is complete."
- End If ' If the reservation is complete
-
- ' With a complete reservation, determine what operation to perform and perform it.
- ' This view can create a reservation (Reserve) or delete a reservation (Remove)
- If OK Then ' If the reservation is complete, then
-
- ' Remove the formatting from the start and end time strings
- start = Timevalue(Trim(source.ddbStart.text)) * 24
- finish = Timevalue(Trim(source.ddbEnd.text)) * 24
-
- ' Check to see that the start and end times are in the correct order
- If start < finish Then ' If the start time comes before the end time, then
-
- ' Refer to the text from btnDone to determine the action to perform.
- ' This text is set by the subs that switch to the Reservation view
- Select Case source.text ' Text from btnDone
-
- ' If the button label reads "Reserve", compare the reservation information
- ' to the schedule database and update the schedule if there are no conflicts.
- ' Then switch back to the Schedule Display view, clear the existing reservation
- ' information, and display the new information for the date on the new reservation.
- Case "Reserve"
- ' If the new reservation has no conflicts and is recorded successfully, then
- If modifySchedule(dateReserved, roomName, ReservedBy, start, finish, note, 1) Then
-
- ' Switch from the current view to Schedule Display. Because
- ' the current view was displayed as a dialog box, it can be treated
- ' as the current window, using the global variable CurrentWindow
- currentwindow.close
- 'Doevents returns control back to operating system so that pending
- 'actions can be performed
- Doevents
-
- ' Remove existing reservation information from the view
- Call clearDisplay()
-
- ' Display reservation information for the date that the new reservation was
- ' made for
- Call readBlock (dateReserved)
-
- ' Display the date of the reservation information in the field box on the
- ' top left of the view
- currentview.body.fbxDateDisplay.text = dateReserved
-
- Else ' If there is a conflicting schedule in the schedule database, then
-
- ' Tell the user that the reservation failed to be added because of a conflict
- msg = "Room " + roomName + " is not available from " +source.ddbStart.text+" to " + source.ddbEnd.text + " on " + dateReserved + "."
- Messagebox msg, MB_OK,"Schedule Conflict"
- End If ' Does the new reservation conflict with an existing one?
-
- ' If the button label reads "Remove", compare the reservation information
- ' to the schedule database and remove any matching reservation.
- ' Then switch back to the Schedule Display view, clear the existing reservation
- ' information, and display the new information for the date of the removed reservation.
- Case "Remove"
- ' If the reservation to be removed exists in the database and is removed successfully, then
- If modifySchedule(dateReserved, roomName, "", start, finish, "", -1) Then
-
- ' Switch from the current view to Schedule Display. Because
- ' the current view was displayed as a dialog box, it can be treated
- ' as the current window, using the global variable CurrentWindow
- currentwindow.close
- 'Doevents returns control back to operating system so that pending
- 'actions can be performed
- Doevents
- ' Remove existing reservation information from the view
- Call clearDisplay()
-
- ' Display reservation information for the date that the reservation was removed from
- Call readBlock (dateReserved)
-
- ' Display the date of the reservation information in the field box on the
- ' top left of the view
- currentview.body.fbxDateDisplay.text = dateReserved
- Else ' If the reservation did not match an existing reservation, then
-
- ' Tell the user that the reservation failed to be added because of a conflict
- msg = "Room " + roomName + " is not scheduled from " + source.ddbStart.text+" to " + source.ddbEnd.text + " on " + dateReserved + "."
- Messagebox msg, MB_OK, "Room Not Scheduled"
- End If ' If the reservation exists and was removed successfully
-
- End Select ' Choose from Reserve and Remove
-
- Else ' If start is after finish, then
-
- ' Prompt the user to correct the times
- msg = "End time must be greater than Start time."
- Messagebox msg , MB_OK, "Invalid Times Entered"
- End If ' If start is before finish
-
- End If ' If the reservation is complete in the view
-
- End Sub ' Click event for the btnDone on the Reservation view