home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1997 February / PCWK0297.iso / lotus / english / lotus036.dsk / SCHEDULE.MPR / SCRIPT / A007ApprGlobObj897.s (.txt) < prev    next >
Encoding:
Null Bytes Alternating  |  1995-11-10  |  22.4 KB  |  408 lines

  1. '++LotusScript Development Environment:2:5:(Options):0:66
  2. Option Public
  3.  
  4. '++LotusScript Development Environment:2:5:(Forward):0:1
  5. Declare Sub displayBlock(txt As String, start As Double, finish As Double, roomName As String)
  6. Declare Sub readBlock(d As String)
  7. Declare Sub clearDisplay
  8. Declare Sub displayRooms
  9. Declare Function modifySchedule(d As String, roomName As String, txt As String, start As Double, finish As Double, note As String, modType As Integer) As Integer
  10. Declare Sub modifyRoomsArray(modifyType As Integer)
  11. Declare Sub fillRoomsArray
  12. Declare Function modifyRooms
  13. Declare Sub deleteScheduledRemovedRooms
  14. Declare Sub string_sort(array() As String)
  15. Declare Function isScheduled(d As String, roomName As String, t As Double) As Integer
  16.  
  17. '++LotusScript Development Environment:2:5:(Declarations):0:10
  18. Dim rooms() As String
  19. Dim deletedRooms() As String
  20. Dim GlobDateDisplay As String
  21. Dim GlobStartTime As String
  22. Dim GlobEndTime As String
  23. Dim GlobRoom As String
  24. Dim GlobReservedBy As String
  25. Dim GlobNote As String
  26.  
  27.  
  28. '++LotusScript Development Environment:2:2:displayBlock:1:8
  29. Sub displayBlock(txt As String, start As Double, finish As Double, roomName As String)
  30.     Dim tt As textbox
  31.     
  32.     Dim h As Integer
  33.     Dim i As Integer
  34.     
  35.     For i = 0 To Ubound(rooms)
  36.         If rooms(i) = roomName Then
  37.             t = i
  38.             i = Ubound(rooms)
  39.         End If
  40.     Next
  41.     t = 1635 + (330 * t)
  42.     Set tt = New textbox(currentview.body)
  43.     tt.text = " " + txt + " "
  44.     tt.font.size = 8
  45.     tt.border.style = $ltsBorderStyleNone    
  46.     tt.border.left = True
  47.     tt.border.right = True
  48.     tt.border.top = False
  49.     tt.border.bottom = False
  50.     tt.border.width = $apr1point
  51.     tt.border.color.setrgb color_ultramarine
  52.     tt.background.color.setrgb color_50_gray
  53.     tt.height = 325
  54.     tt.top = t
  55.     tt.left = (((start - 8) * 750) + 960)
  56.     tt.width =  (750 * (finish - start))
  57.     tt.name = "tt" + Str$(tt.top) + Str$(tt.left)    
  58. End Sub
  59. '++LotusScript Development Environment:2:2:readBlock:1:8
  60. Sub readBlock(d As String)
  61.     
  62.     Dim C As New Connection
  63.     Dim Q As New Query
  64.     Dim RS As New ResultSet
  65.     
  66.     Dim s As Double
  67.     Dim f As Double
  68.     Dim row As String
  69.     Dim n As String
  70.     Dim tname As String
  71.     
  72.     tname = currentdocument.tables(0).tablename
  73.     displayRooms
  74.     If C.ConnectTo("dBASE IV") Then
  75.         Set Q.Connection = C
  76.         Q.Tablename =  currentdocument.tables(0).path + tname
  77.         Q.SQL = "SELECT * FROM """+Q.Tablename+""""+ tname+" WHERE (("+ tname+".""Date Reserved"" = '"+d+"'))"        
  78.         Set RS.Query = Q
  79.         Print rs.execute
  80.         Print rs.numrows
  81.         
  82.         If (RS.Execute) Then
  83.             If (RS.numrows) Then
  84.                 RS.firstrow
  85.                 Do
  86.                     s = RS.getvalue("Start Time")
  87.                     f = RS.getvalue("End Time")
  88.                     row = RS.getvalue("Room Name/Number")
  89.                     n = RS.getvalue("Reserved By")
  90.                     displayBlock n, s, f, row
  91.                 Loop    While RS.nextrow                
  92.             End If
  93.         End If
  94.     End If
  95.     c.disconnect
  96. '    currentwindow.redraw = True
  97. '    currentapplication.applicationwindow.domenucommand IDM_REFRESH
  98. End Sub
  99. '++LotusScript Development Environment:2:2:clearDisplay:1:8
  100. Sub clearDisplay
  101.     Dim f As form
  102.     Dim cl As collection
  103.     
  104.     Set f = currentdocument.Schedule~ Display
  105.     Set cl = f.objectlist
  106.     
  107.     Forall i In cl
  108.         If Left$(i.name, 2) = "tt" Then
  109.             Delete i
  110.         End If
  111.     End Forall
  112.     
  113. End Sub
  114. '++LotusScript Development Environment:2:2:displayRooms:1:8
  115. Sub displayRooms
  116.     Dim roomText As textbox
  117.     
  118.     Dim i As Integer
  119.     
  120.     fillRoomsArray    
  121.     For i = 0 To Ubound(rooms)
  122.         Set roomText = New textbox(currentdocument.Schedule~ Display.body)
  123.         roomText.name = "tt"+Str$(i)
  124.         roomText.Top = 1650 + (330 * i)
  125.         roomText.text = rooms(i)                
  126.         roomText.width = 750
  127.         roomText.height = 300
  128.         roomText.left = 160
  129.         roomText.font.size = 8
  130.         roomText.border.style = $ltsBorderStyleNone    
  131.         roomText.border.color.setrgb(color_ivory)
  132.         roomText.background.color.setrgb(color_ivory)
  133.     Next    
  134. End Sub
  135. '++LotusScript Development Environment:2:1:modifySchedule:1:8
  136. Function modifySchedule(d As String, roomName As String, txt As String, start As Double, finish As Double, note As String, modType As Integer) As Integer
  137.     Dim C As New Connection
  138.     Dim Q As New Query
  139.     Dim RS As New ResultSet
  140.     
  141.     Dim tname As String
  142.     
  143.     tname = currentdocument.tables(0).tablename
  144.     modifySchedule = False
  145.     
  146.     If C.ConnectTo("dBASE IV") Then
  147.         Set Q.Connection = C
  148.         Q.Tablename = currentdocument.tables(0).path + tname
  149.         If modType > 0 Then
  150.             Q.SQL = "SELECT * FROM """+Q.Tablename+""" "+ tname + " WHERE (("+ tname + ".""Date Reserved"" = '"+d+"') AND ("+ tname + ".""Room Name/Number"" = '"+roomName+"'))"        
  151.         Elseif modType < 0 Then
  152.             Q.SQL = "SELECT * FROM """+Q.Tablename+""" "+ tname + " WHERE (("+ tname + ".""Date Reserved"" = '"+d+"') AND ("+ tname + ".""Room Name/Number"" = '"+roomName+"') AND ("+ tname + ".""Start Time"" = '"+Trim$(Str$(start))+"') AND ("+ tname + ".""End Time"" = '"+Trim$(Str$(finish))+"'))"
  153.         End If
  154.         Set RS.Query = Q
  155.         
  156.         If (RS.Execute)Then
  157.             If (RS.numrows) Then
  158.                 RS.firstrow
  159.             End If
  160.             modifySchedule = True
  161.             If modType < 0 Then
  162.                 If RS.numrows Then
  163.                     RS.deleterow
  164.                     RS.updaterow
  165.                 Else
  166.                     modifySchedule = False
  167.                 End If
  168.             Else
  169.                 If (RS.numrows) Then
  170.                     Do
  171.                         If start <= RS.getvalue("Start Time") And finish >  RS.getvalue("Start Time") Then
  172.                             Print rs.getvalue("Start Time")
  173.                             modifySchedule = False
  174.                         Elseif finish <= RS.getvalue("End Time") And finish >  RS.getvalue("Start Time") Then
  175.                             modifySchedule = False
  176.                         Elseif start < RS.getvalue("End Time") And start >=  RS.getvalue("Start Time") Then
  177.                             modifySchedule = False
  178.                         End If
  179.                     Loop    While (RS.nextrow And modifySchedule = True)
  180.                 End If
  181.                 If modifySchedule = True Then
  182.                     RS.addrow
  183.                     RS.setvalue "Start Time", start
  184.                     RS.setvalue "End Time", finish
  185.                     RS.setvalue "Reserved By", txt
  186.                     RS.setvalue "Date Reserved", d
  187.                     RS.setvalue "Room Name/Number", roomName
  188.                     RS.setvalue "Note", note
  189.                     RS.updaterow
  190.                 End If
  191.             End If    
  192.         End If
  193.     End If
  194.     c.disconnect
  195.     
  196. End Function
  197. '++LotusScript Development Environment:2:2:modifyRoomsArray:1:8
  198. Sub modifyRoomsArray(modifyType As Integer)
  199.     Dim fbx As fieldbox
  200.     Dim lbx As listbox
  201.     Dim btn As button
  202.     
  203.     Dim i As Integer
  204.     Dim ret As Integer
  205.     Dim roomExists As Integer    
  206.     Dim newRoomName As String
  207.     Dim tempRooms() As String
  208.     Dim numRooms As Integer
  209.     Dim badname As Integer
  210.     
  211.     If ((Ubound(rooms) + 1) = 20) And (modifyType > 0)Then
  212.         Messagebox "Cannot add anymore rooms.  Maximum number of rooms is 20."
  213.     Else    
  214.         Set fbx = currentview.body.fbxRoomName
  215.         Set lbx = currentview.body.lbxRooms
  216.         Set btn = currentview.body.btnDone
  217.         If modifyType > 0 Then
  218.             roomExists = False
  219.             newRoomName = fbx.text
  220.             If fbx.text = "" Then
  221.                 badname = True
  222.             End If
  223.             For i = 0 To Ubound(rooms)
  224.                 If Ucase$(rooms(i)) = Ucase$(newRoomName) Then
  225.                     roomExists = True        
  226.                     i = Ubound(rooms) + 1
  227.                 End If
  228.             Next
  229.             If (roomExists = False And badname = False) Then
  230.                 If Ubound(rooms) = 0  And rooms(0) = "" Then
  231.                     rooms(0) = newRoomName
  232.                 Else
  233.                     Redim Preserve rooms(Ubound(rooms) + 1)
  234.                     rooms(Ubound(rooms)) = newRoomName
  235.                 End If
  236.                 lbx.setlist rooms
  237.                 fbx.text = ""
  238.                 btn.enabled = True
  239.             Elseif badname = False Then
  240.                 Messagebox "A room named """ + Ucase$(newRoomName) + """ already exists"
  241.             End If
  242.         Else
  243.             ret = Messagebox( "Are you sure you want to delete this room?  Deleting this room will also delete any scheduled conferences for this room.", 4, "Delete Room")
  244.             If ret = 6 Then
  245.                 deleteRoomName = lbx.text
  246.                 Redim Preserve deletedRooms(Ubound(deletedRooms) + 1)
  247.                 deletedRooms(Ubound(deletedRooms)) = deleteRoomName
  248.                 For i = 0 To Ubound(rooms)
  249.                     If Ucase$(rooms(i)) = Ucase$(deleteRoomName) Then
  250.                         numRooms = numRooms - 1
  251.                         For j = i To (Ubound(rooms) - 1)
  252.                             rooms(j) = rooms(j + 1)
  253.                         Next
  254.                         i = Ubound(rooms) + 1    
  255.                     End If
  256.                 Next
  257.                 If Ubound(rooms) Then
  258.                     Redim Preserve rooms(Ubound(rooms) - 1)                
  259.                 Else
  260.                     rooms(0) = ""
  261.                     currentview.body.btnRemove.enabled = False
  262.                 End If
  263.             End If
  264.         End If
  265.         lbx.setlist rooms
  266.         btn.enabled = True
  267.         string_sort rooms
  268.     End If
  269.     
  270. End Sub
  271. '++LotusScript Development Environment:2:2:fillRoomsArray:1:8
  272. Sub fillRoomsArray
  273.     Dim C As New Connection
  274.     Dim Q As New Query
  275.     Dim RS As New ResultSet
  276.     Dim roomText As textbox
  277.     
  278.     Dim numRooms As Integer
  279.     Dim i As Integer
  280.     
  281.     i = 0
  282.     If C.ConnectTo("dBASE IV") Then
  283.         Set Q.Connection = C
  284.         Q.Tablename = currentdocument.tables(0).path + "rooms.dbf"
  285.         Set RS.Query = Q 'need to sort by ROOMID
  286.         If (RS.Execute) Then
  287.             numRooms = RS.numrows()
  288.             If numrooms Then
  289.                 Redim rooms(numRooms - 1)
  290.                 RS.firstrow
  291.                 Do
  292.                     rooms(i) = RS.getvalue("room")
  293.                     i = i + 1
  294.                 Loop    While RS.nextrow
  295.             Else
  296.                 Redim rooms(numRooms)
  297.             End If
  298.         End If
  299.     End If
  300.     c.disconnect
  301.     string_sort rooms
  302. End Sub
  303. '++LotusScript Development Environment:2:1:modifyRooms:1:8
  304. Function modifyRooms
  305.     Dim C As New Connection
  306.     Dim Q As New Query
  307.     Dim RS As New ResultSet
  308.     
  309.     modifyRooms = False
  310.     
  311.     If C.ConnectTo("dBASE IV") Then
  312.         Set Q.Connection = C
  313.         Q.Tablename = currentdocument.tables(0).path + "rooms"
  314.         Set RS.Query = Q
  315.         If (RS.Execute)Then
  316.             If (RS.numrows) Then
  317.                 RS.firstrow
  318.                 Do
  319.                     RS.deleteRow
  320.                 Loop    While (RS.numrows)
  321.             End If
  322.             modifyRooms = True
  323.             For i = 0 To Ubound(rooms)
  324.                 RS.addrow
  325.                 RS.setvalue "room", rooms(i)
  326.                 RS.updaterow
  327.             Next
  328.         End If    
  329.     End If
  330.     c.disconnect
  331.     
  332. End Function
  333. '++LotusScript Development Environment:2:2:deleteScheduledRemovedRooms:1:8
  334. Sub deleteScheduledRemovedRooms
  335.     Dim C As New Connection
  336.     Dim Q As New Query
  337.     Dim RS As New ResultSet
  338.     
  339.     Dim tname As String
  340.     fillRoomsArray
  341.     tname = currentdocument.tables(0).tablename
  342.     
  343.     If C.ConnectTo("dBASE IV") Then
  344.         Set Q.Connection = C
  345.         Q.Tablename = currentdocument.tables(0).path + tname
  346.         For i = 1 To Ubound(deletedRooms)
  347.             Q.SQL = "SELECT * FROM """+Q.Tablename+""""+ tname + " WHERE ("+ tname + ".""Room Name/Number"" = '"+deletedRooms(i)+"')"
  348.             Set RS.Query = Q
  349.             If (RS.Execute)Then
  350.                 If (RS.numrows) Then
  351.                     RS.firstrow                
  352.                     Do
  353.                         RS.deleteRow
  354.                     Loop    While (RS.numrows)
  355.                 End If
  356.             End If    
  357.         Next        
  358.         c.disconnect
  359.     End If    
  360. End Sub
  361. '++LotusScript Development Environment:2:2:string_sort:1:8
  362. Sub string_sort(array() As String)
  363.     Dim temp As String
  364.     Dim i As Integer
  365.     Dim j As Integer
  366.     
  367.     For i = Lbound(array) To Ubound(array)
  368.         temp = array(i)
  369.         For j = i + 1 To Ubound(array)
  370.             If array(j) < array(i) Then
  371.                 array(i) = array(j)
  372.                 array(j) = temp
  373.                 temp = array(i)
  374.             End If
  375.         Next
  376.     Next
  377. End Sub
  378. '++LotusScript Development Environment:2:1:isScheduled:1:8
  379. Function isScheduled(d As String, roomName As String, t As Double) As Integer
  380.     Dim C As New Connection
  381.     Dim Q As New Query
  382.     Dim RS As New ResultSet
  383.     
  384.     Dim tname As String
  385.     
  386.     isScheduled = False
  387.     tname = currentdocument.tables(0).tablename
  388.     If C.ConnectTo("dBASE IV") Then
  389.         Set Q.Connection = C
  390.         Q.Tablename = currentdocument.tables(0).path + tname
  391.         Q.SQL = "SELECT * FROM """+Q.Tablename+""" "+ tname + " WHERE (("+ tname + ".""Date Reserved"" = '"+d+"') AND ("+ tname + ".""Room Name/Number"" = '"+roomName+"') AND ("+ tname + ".""Start Time"" <= "+Trim$(Str$(t))+")  AND ("+ tname + ".""End Time"" > "+Trim$(Str$(t))+"))"
  392.         Set RS.Query = Q
  393.         
  394.         If (RS.Execute)Then
  395.             If (RS.numrows) Then
  396.                 isScheduled = True
  397.                 GlobDateDisplay = RS.getvalue("Date Reserved")
  398.                 GlobStartTime = RS.getvalue("Start Time")
  399.                 GlobEndTime = RS.getvalue("End Time")
  400.                 GlobRoom = RS.getvalue("Room Name/Number")
  401.                 GlobReservedBy = RS.getvalue("Reserved By")
  402.                 GlobNote = RS.getvalue("Note")
  403.             End If
  404.         End If
  405.         c.disconnect
  406.     End If
  407.     
  408. End Function