Warning: This file has been marked up for HTML
VERSION 5.00
Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.2#0"; "COMCTL32.OCX"
Begin VB.Form frmSkiClasses
Caption = "Uintah Ski Resort : Ski Class Registration"
ClientHeight = 4755
ClientLeft = 17430
ClientTop = 6690
ClientWidth = 13305
Icon = "SkiClass.frx":0000
LinkTopic = "Form1"
ScaleHeight = 4755
ScaleWidth = 13305
StartUpPosition = 1 'CenterOwner
Begin VB.CommandButton cmdRemove
Caption = "&Remove..."
Enabled = 0 'False
Height = 375
Left = 12000
TabIndex = 4
Top = 2940
Width = 1215
End
Begin VB.CommandButton cmdAdd
Caption = "&Add..."
Enabled = 0 'False
Height = 375
Left = 12000
TabIndex = 3
Top = 2460
Width = 1215
End
Begin VB.CommandButton cmdClose
Cancel = -1 'True
Caption = "&Close"
Default = -1 'True
Height = 375
Left = 12000
TabIndex = 2
Top = 120
Width = 1215
End
Begin ComctlLib.ListView lvClasses
Height = 2235
Left = 60
TabIndex = 0
Top = 120
Width = 11835
_ExtentX = 20876
_ExtentY = 3942
View = 3
LabelEdit = 1
LabelWrap = -1 'True
HideSelection = 0 'False
_Version = 327682
ForeColor = -2147483640
BackColor = -2147483643
Appearance = 1
NumItems = 10
BeginProperty ColumnHeader(1) {0713E8C7-850A-101B-AFC0-4210102A8DA7}
Key = "Class"
Object.Tag = ""
Text = "Class"
Object.Width = 2540
EndProperty
BeginProperty ColumnHeader(2) {0713E8C7-850A-101B-AFC0-4210102A8DA7}
Alignment = 1
SubItemIndex = 1
Key = "Size"
Object.Tag = ""
Text = "Size"
Object.Width = 2540
EndProperty
BeginProperty ColumnHeader(3) {0713E8C7-850A-101B-AFC0-4210102A8DA7}
Alignment = 1
SubItemIndex = 2
Key = "Enrolled"
Object.Tag = ""
Text = "Enrolled"
Object.Width = 2540
EndProperty
BeginProperty ColumnHeader(4) {0713E8C7-850A-101B-AFC0-4210102A8DA7}
SubItemIndex = 3
Key = "Instructor"
Object.Tag = ""
Text = "Instructor"
Object.Width = 2540
EndProperty
BeginProperty ColumnHeader(5) {0713E8C7-850A-101B-AFC0-4210102A8DA7}
Alignment = 1
SubItemIndex = 4
Key = "Start Date"
Object.Tag = ""
Text = "Start Date"
Object.Width = 2540
EndProperty
BeginProperty ColumnHeader(6) {0713E8C7-850A-101B-AFC0-4210102A8DA7}
Alignment = 1
SubItemIndex = 5
Key = "Time"
Object.Tag = ""
Text = "Time"
Object.Width = 2540
EndProperty
BeginProperty ColumnHeader(7) {0713E8C7-850A-101B-AFC0-4210102A8DA7}
Alignment = 1
SubItemIndex = 6
Key = "Duration"
Object.Tag = ""
Text = "Duration (Hours)"
Object.Width = 2540
EndProperty
BeginProperty ColumnHeader(8) {0713E8C7-850A-101B-AFC0-4210102A8DA7}
Alignment = 1
SubItemIndex = 7
Key = "End Date"
Object.Tag = ""
Text = "End Date"
Object.Width = 2540
EndProperty
BeginProperty ColumnHeader(9) {0713E8C7-850A-101B-AFC0-4210102A8DA7}
SubItemIndex = 8
Key = "Place"
Object.Tag = ""
Text = "Place"
Object.Width = 2540
EndProperty
BeginProperty ColumnHeader(10) {0713E8C7-850A-101B-AFC0-4210102A8DA7}
Alignment = 1
SubItemIndex = 9
Key = "Cost"
Object.Tag = ""
Text = "Cost"
Object.Width = 2540
EndProperty
End
Begin ComctlLib.ListView lvStudents
Height = 2235
Left = 60
TabIndex = 1
Top = 2460
Width = 11835
_ExtentX = 20876
_ExtentY = 3942
View = 3
LabelEdit = 1
MultiSelect = -1 'True
LabelWrap = -1 'True
HideSelection = 0 'False
_Version = 327682
ForeColor = -2147483640
BackColor = -2147483643
Appearance = 1
NumItems = 3
BeginProperty ColumnHeader(1) {0713E8C7-850A-101B-AFC0-4210102A8DA7}
Key = "StudentName"
Object.Tag = ""
Text = "Student Name"
Object.Width = 2540
EndProperty
BeginProperty ColumnHeader(2) {0713E8C7-850A-101B-AFC0-4210102A8DA7}
SubItemIndex = 1
Key = "Room"
Object.Tag = ""
Text = "Room"
Object.Width = 2540
EndProperty
BeginProperty ColumnHeader(3) {0713E8C7-850A-101B-AFC0-4210102A8DA7}
SubItemIndex = 2
Key = "EmailAddress"
Object.Tag = ""
Text = "E-Mail Address"
Object.Width = 2540
EndProperty
End
Begin VB.Image imgSplitter
Height = 135
Left = 60
MouseIcon = "SkiClass.frx":0442
MousePointer = 99 'Custom
Top = 2340
Width = 7035
End
End
Attribute VB_Name = "frmSkiClasses"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'/***************************************************************************
'$name: SkiClass.frm
'$version: 1.0
'$date_modified: 121298
'$description: Visual Basic form file
'$owner: GroupWise SDK Team Lead
'Copyright (c) 1998 Novell, Inc. All Rights Reserved.
'
'THIS WORK IS SUBJECT TO U.S. AND INTERNATIONAL COPYRIGHT LAWS AND TREATIES.
'USE AND REDISTRIBUTION OF THIS WORK IS SUBJECT TO THE LICENSE AGREEMENT
'ACCOMPANYING THE SOFTWARE DEVELOPMENT KIT (SDK) THAT CONTAINS THIS WORK.
'PURSUANT TO THE SDK LICENSE AGREEMENT, NOVELL HEREBY GRANTS TO DEVELOPER A
'ROYALTY-FREE, NON-EXCLUSIVE LICENSE TO INCLUDE NOVELL'S SAMPLE CODE IN ITS
'PRODUCT. NOVELL GRANTS DEVELOPER WORLDWIDE DISTRIBUTION RIGHTS TO MARKET,
'DISTRIBUTE, OR SELL NOVELL'S SAMPLE CODE AS A COMPONENT OF DEVELOPER'S
'PRODUCTS. NOVELL SHALL HAVE NO OBLIGATIONS TO DEVELOPER OR DEVELOPER'S
'CUSTOMERS WITH RESPECT TO THIS CODE.
'****************************************************************************/
Option Explicit
' Number of students in a class
Public nStudentsInClass As Integer
' Messages collection
Public objMessages As Messages
Public objFolder As Folder
Private Const UINTAH_SKI_CLASSES As String = "Uintah Ski Classes"
Private Const UINTAH_SKI_CONTEXT As String = "GW.MESSAGE.APPOINTMENT.SKICLASS"
Private Sub cmdAdd_Click()
frmAddStudents.Show vbModal
End Sub
Private Sub cmdClose_Click()
Unload Me
End Sub
Private Sub Form_Activate()
If lvStudents.ListItems.Count > 0 Then
cmdRemove.Enabled = True
End If
End Sub
Private Sub Form_Load()
Dim liClass As ListItem
Dim nClassNum As Integer
Dim nIndex As Integer
Dim objAllFolders As Folders
Dim objField As Field
Dim objFields As Fields
Dim objMessage As Message
Dim objSkiClassAppointment As Appointment
Dim sDate As String
Dim sString As String
Dim sTime As String
Show
Screen.MousePointer = vbHourglass
' Initialize the number of students in a class
nStudentsInClass = 0
' Show Login form
frmLogin.Show vbModal
Screen.MousePointer = vbDefault
' Get the AllFolders collection
Set objAllFolders = frmLogin.GWRootAccount.AllFolders
' Get the "Uintah Ski Classes" shared folder
Set objFolder = objAllFolders.ItemByName(UINTAH_SKI_CLASSES)
' Get the messages in the folder
Set objMessages = objFolder.Messages
' Initialize our class counter
nClassNum = 0
'Display the Ski Class Messages
For Each objMessage In objMessages
' Make sure this Appointment is a Ski Class Appointment!
If objMessage.ClassName = UINTAH_SKI_CONTEXT Then
' Make this a Ski Class Appointment
Set objSkiClassAppointment = objMessage
' Increment our class counter
nClassNum = nClassNum + 1
' Class
Set liClass = lvClasses.ListItems.Add(nClassNum, objSkiClassAppointment.MessageID, _
objSkiClassAppointment.Subject)
' Duration
liClass.SubItems(DURATION_INDEX) = CStr(objSkiClassAppointment.Duration * 24)
' Place
liClass.SubItems(PLACE_INDEX) = objSkiClassAppointment.Place
' Parse the Start Date into Date and Time pieces
Call Parse_Date_And_Time(objSkiClassAppointment.StartDate, sDate, sTime)
' Start Date
liClass.SubItems(STARTDATE_INDEX) = sDate
' Time
liClass.SubItems(TIME_INDEX) = sTime
' Get the User-defined fields
Set objFields = objSkiClassAppointment.Fields
For Each objField In objFields
sString = CStr(objField.Value)
Select Case objField.Name
Case COST_KEY
nIndex = COST_INDEX
Case ENDDATE_KEY
nIndex = ENDDATE_INDEX
' Parse the End Date into Date and Time pieces and use the
' date part
Call Parse_Date_And_Time(objField.Value, sString, sTime)
Case ENROLLED_KEY
nIndex = ENROLLED_INDEX
Case INSTRUCTOR_KEY
nIndex = INSTRUCTOR_INDEX
Case CLASS_SIZE_KEY
nIndex = CLASS_SIZE_INDEX
End Select
liClass.SubItems(nIndex) = sString
Next
End If
Next
' Size the columns of the class list
Call SizeLVColumns(lvClasses)
' If we have some classes in our list
If nClassNum > 0 Then
' Enable the "Add" button
cmdAdd.Enabled = True
' Highlight the first class
lvClasses.ListItems.Item(1).Selected = True
' Display the student(s) already signed up for this class
Call DisplayStudents(lvClasses.ListItems.Item(1))
End If
Screen.MousePointer = vbDefault
End Sub
Public Sub SizeLVColumns(lvControl As ListView)
Dim ClmX As ColumnHeader
Dim liObject As ListItem
Dim nTextWidth
' For each column in the ListView control
For Each ClmX In lvControl.ColumnHeaders
' Set the column width = width of column header text
ClmX.Width = TextWidth(ClmX.Text)
' For each ListItem in the ListView control
For Each liObject In lvControl.ListItems
' If it's the 1st column
If ClmX.Index = 1 Then
' Get the width of the ListItem text
nTextWidth = TextWidth(liObject)
Else
' Get the width of the SubItem text
nTextWidth = TextWidth(liObject.SubItems(ClmX.Index - 1))
End If
' If the text width is longer than our column width
If nTextWidth > ClmX.Width Then
' Set the column width = text width
ClmX.Width = nTextWidth
End If
Next
Next
End Sub
Private Sub DisplayStudents(objLIClass As ListItem)
Dim nPos As Integer
Dim objSkiClassAppointment As Appointment
Dim sBodyText As String
Dim sTemp As String
Screen.MousePointer = vbHourglass
' Get all the students in the Patrons' AddressBook
Call frmAddStudents.BuildPatronList
' Set the currently selected class
Set frmAddStudents.objLIClass = objLIClass
' Get the associated appointment
Set objSkiClassAppointment = objMessages.Item(objLIClass.Key)
sBodyText = objSkiClassAppointment.BodyText
' If we have already scheduled some students, display them in the student list
If Len(sBodyText) > 0 Then
'Find the end of the first student's name
nPos = InStr(sBodyText, " : ")
While nPos > 0
' Get the student's name
sTemp = Left(sBodyText, nPos - 1)
' Add the student to the class list
Call frmAddStudents.AddStudentToClassList(sTemp)
' Move our string pointer past the vbCrLf
nPos = InStr(sBodyText, vbCrLf)
sBodyText = Mid(sBodyText, nPos + 2)
'Find the end of the next student's name
nPos = InStr(sBodyText, " : ")
Wend
End If
' Size the columns of the student list
Call SizeLVColumns(lvStudents)
Screen.MousePointer = vbDefault
End Sub
Private Sub Parse_Date_And_Time(dDate As Date, sDateStr As String, _
sTimeStr As String)
Dim nPos As Integer
Dim sTemp As String
sTemp = CStr(dDate)
' Find the space in the date string
nPos = InStr(sTemp, " ")
' If no space was found we have just a date and no time
If nPos = 0 Then
sDateStr = sTemp
Else
sDateStr = Left(sTemp, nPos - 1)
sTimeStr = Mid(sTemp, InStr(sTemp, " ") + 1)
End If
End Sub
Private Sub Form_Resize()
Const RIGHT_SPACE1 = 1275
Const RIGHT_SPACE2 = 1455
Const BOTTOM_SPACE1 = 2505
Const MIN_HEIGHT = 3000
If ScaleHeight > MIN_HEIGHT Then
cmdClose.Left = ScaleWidth - RIGHT_SPACE1
cmdAdd.Left = ScaleWidth - RIGHT_SPACE1
cmdRemove.Left = ScaleWidth - RIGHT_SPACE1
With lvClasses
.Width = ScaleWidth - RIGHT_SPACE2
End With
With lvStudents
.Width = ScaleWidth - RIGHT_SPACE2
.Height = ScaleHeight - BOTTOM_SPACE1
End With
imgSplitter.Width = lvClasses.Width
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
Set objMessages = Nothing
Set objFolder = Nothing
Unload frmLogin
Unload frmAddStudents
End Sub
Private Sub lvClasses_GotFocus()
cmdClose.Default = True
End Sub
Private Sub lvClasses_ItemClick(ByVal Item As ComctlLib.ListItem)
Static sListItem As String
If sListItem <> Item Then
sListItem = Item
' Reset student count
nStudentsInClass = 0
' Clear the list of students
lvStudents.ListItems.Clear
' Display the students in the selected class
Call DisplayStudents(Item)
End If
End Sub
Private Sub lvStudents_GotFocus()
cmdAdd.Default = True
End Sub
Private Sub lvStudents_LostFocus()
cmdClose.Default = True
End Sub