VERSION 1.0 CLASS
BEGIN
  MultiUse = 0  'False
END
Attribute VB_PredeclaredId = False
Attribute VB_Creatable = True
Attribute VB_Exposed = True
Attribute VB_GlobalNameSpace = True
Attribute VB_Name = "mpxProject"
' MPX-Project-X5.Cls
' ==================

' mpxProject Object class module
' Copyright (c) Mindjet LLC 2002, 2003  All Rights Reserved

Option Explicit
'#Uses "MPX-Tasks-X5.Cls" ' mpxTasks collection class module
'#Uses "MPX-Task-X5.Cls" ' mpxTask object class module
'#Uses "MPX-Resources-X5.Cls" ' mpxResources collection Class module
'#Uses "MPX-Resource-X5.Cls" ' mpxResource object Class module
'#Uses "MPX-Assignments-X5.Cls" ' mpxAssignments collection class module
'#Uses "MPX-Assignment-X5.Cls" ' mpxAssignment object Class module

' Project Data
Dim b_MPXMagic As Boolean ' MPX Magic record has been found (CR 10519)
Dim b_IsValid As Boolean ' Key project data is initialised
Dim i_ProjectStart As Date ' Estimated start date
'Dim i_ProjectDuration As Double ' Project Duration
Dim i_ProjectFinish As Date ' Project finish date
Dim s_ProjectFile As String ' Project file name
Dim s_ProjectName As String ' Project name
Dim s_ProjectNotes As String ' Project Notes
Dim b_ScheduleFromStart As Boolean ' schedule projects from start date (false = schedule from end date)
Dim i_HoursPerDay As Double ' working hours per day
Dim i_DaysPerWeek As Integer ' working days per week
Dim i_TimeUnits As Integer ' Time units for durations and work: 0=minutes, 1=hours, 2=days, 3=weeks

' Collections
Dim o_Resources As mpxResources ' Resources collection
Dim o_Tasks As mpxTasks ' Tasks collection
Dim o_Assignments As mpxAssignments  ' assignment records

Private Sub Class_Initialize()
' Initialise a new instance of a Project
' Set up default options, which may be overwritten by stored Preferences

	Set o_Resources = New mpxResources ' create & initialise a Resources collection
	Set o_Tasks = New mpxTasks ' create and initialise a Tasks collection
	Set o_Assignments = New mpxAssignments ' create and initialise an Assignment collection
	s_ProjectName = "" ' no name
	s_ProjectFile = "" ' no file
	i_ProjectStart = 0 ' no project start date
	i_ProjectFinish = 0 ' no project finish date
	b_ScheduleFromStart = True ' schedule from project start date
	i_HoursPerDay = 8 ' Default to 8 hours per day
	i_DaysPerWeek = 5 ' Default 5 days per week
	i_TimeUnits = 1 ' Default to time units of hours
	b_IsValid = False
	b_MPXMagic = False

End Sub

Private Sub Class_Terminate()
' Destroy this Project

	Set o_Resources = Nothing ' destroy Resources collection
	Set o_Tasks = Nothing ' destroy Tasks collection
	Set o_Assignments = Nothing ' destroy Assignments collection

End Sub

Public Function Dump() As String
' Debug routine: dump the Project object
Dim s_1 As String
Dim i_1 As Integer

	s_1 = ""
	s_1 = s_1 & "Project File: " & s_ProjectFile & vbCrLf
	s_1 = s_1 & "Project Name: " & s_ProjectName & vbCrLf
	s_1 = s_1 & "Hours per day: " & i_HoursPerDay & vbCrLf
	s_1 = s_1 & "Days per week: " & i_DaysPerWeek & vbCrLf
	s_1 = s_1 & "Start Date: " & Format(i_ProjectStart) & vbCrLf
	s_1 = s_1 & "Finish Date: " & Format(i_ProjectFinish) & vbCrLf
	s_1 = s_1 & vbCrLf

	s_1 = s_1 & o_Tasks.Count & " Tasks" & vbCrLf
	For i_1 = 1 To o_Tasks.Count
		s_1 = s_1 & "  Task ID: " & o_Tasks.Item(i_1).ID & "  Name: <" & o_Tasks.Item(i_1).Name & ">" & vbCrLf
	Next i_1
	s_1 = s_1 & vbCrLf

	s_1 = s_1 & o_Resources.Count & " Resources" & vbCrLf
	For i_1 = 1 To o_Resources.Count
		s_1 = s_1 & "  Resource ID: " & o_Resources.Item(i_1).ID & "  Name: <" & o_Resources.Item(i_1).Name & ">" & vbCrLf
	Next i_1
	s_1 = s_1 & vbCrLf

	s_1 = s_1 & o_Assignments.Count & " Resource Assignments" & vbCrLf
	For i_1 = 1 To o_Assignments.Count
		s_1 = s_1 & "  A" & i_1 & ". Resource ID " & o_Assignments.Item(i_1).ResourceID
		s_1 = s_1 &	" assigned to Task ID " & o_Assignments.Item(i_1).TaskID
		s_1 = s_1 & vbCrLf
	Next i_1
	Dump = s_1 ' return result

End Function

Property Get Resources() As mpxResources
' Get the Resources collection
	Set Resources = o_Resources
End Property

Property Get Tasks() As mpxTasks
' Get the Tasks collection
	Set Tasks = o_Tasks
End Property

Property Get Assignments() As mpxAssignments
' Get the Assignments collection
	Set Assignments = o_Assignments
End Property

Property Let StartDate(ByVal i_Date As Date)
	i_ProjectStart = i_Date
End Property

Property Get StartDate() As Date
' Read the project start date
	StartDate = i_ProjectStart
End Property

Property Let FinishDate(ByVal i_Date As Date)
	i_ProjectFinish = i_Date
End Property

Property Get FinishDate() As Date
' Read the project start date
	FinishDate = i_ProjectFinish
End Property

Property Let ScheduleFromStart(ByVal b_value As Boolean)
	b_ScheduleFromStart = b_value
End Property

Property Get ScheduleFromStart() As Boolean
	ScheduleFromStart = b_ScheduleFromStart
End Property

Property Let HoursPerDay(ByVal i_value As Double)
	i_HoursPerDay = i_value
End Property

Property Get HoursPerDay As Double
	HoursPerDay = i_HoursPerDay
End Property

Property Let DaysPerWeek(ByVal i_value As Integer)
' Set working days per week
	i_DaysPerWeek = i_value
End Property

Property Get DaysPerWeek() As Integer
	DaysPerWeek = i_DaysPerWeek
End Property

Property Get TimeUnits() As Integer
	TimeUnits = i_TimeUnits
End Property

Property Let TimeUnits(ByVal i_value As Integer)
	If i_value < 0 Then i_value = 0 ' apply limits
	If i_Value > 3 Then i_Value = 3
	i_TimeUnits = i_Value
End Property

Property Let Name(ByVal s_Value As String)
	s_ProjectName = s_Value
End Property

Property Get Name() As String
	Name = s_ProjectName
End Property

Property Let FileName(ByVal s_Value As String)
	s_ProjectFile = s_Value
End Property

Property Get FileName() As String
	FileName = s_ProjectFile
End Property

Property Let Notes(ByVal s_Value As String)
	s_ProjectNotes = s_Value
End Property

Property Get Notes() As String
	Notes = s_ProjectNotes
End Property

Property Let IsValid(ByVal b_Value As Boolean)
	b_IsValid = b_Value
End Property

Property Get IsValid() As Boolean
	IsValid = b_IsValid
End Property

Property Let MPXMagic(ByVal b_Value As Boolean)
	b_MPXMagic = b_Value
End Property

Property Get MPXMagic() As Boolean
	MPXMagic = b_MPXMagic
End Property
