Private Sub treeloadall()
objDS.Clear()
Dim servicetype
servicetype = "SERVICE"
' If Program = "ContactLog" Then
daSections = New SqlDataAdapter("SELECT DISTINCT TOP 100 PERCENT convert(varchar(10),dbo.tblMHCIntake.dtmIntake,101) as intakedate,dtmintake, DATENAME(dw, dbo.tblMHCIntake.dtmIntake) AS dayname FROM dbo.tblMHCIntake where dtmintake > '01/01/2005'ORDER BY dbo.tblMHCIntake.dtmIntake DESC", Connection1)
daContent = New SqlDataAdapter("SELECT DISTINCT TOP 100 PERCENT tblPatient.strLName + ', ' + tblPatient.strFName AS name, CONVERT(varchar(10), tblMHCIntake.dtmIntake, 101) AS intakedate, DATENAME(dw, dbo.tblMHCIntake.dtmIntake) AS dayname, tblMHCIntake.dtmIntake, tblMHCIntake.strStaff, CONVERT(varchar(10), tblPatient.dtmDOB, 101) AS dtmdob, tblPatient.strPatientId, tblMHCIntakeDetail.lngIntakeId FROM tblMHCIntake INNER JOIN tblMHCIntakeDetail ON tblMHCIntake.lngIntakeId = tblMHCIntakeDetail.lngIntakeId INNER JOIN tblLUMHCData ON tblMHCIntakeDetail.lngDataId = tblLUMHCData.lngDataID RIGHT OUTER JOIN tblPatient ON tblMHCIntake.lngPatientId = tblPatient.lngPatientId WHERE (tblMHCIntake.dtmIntake > '1/1/2005')ORDER BY tblMHCIntake.dtmIntake DESC", Connection1)
datype = New SqlDataAdapter("SELECT DISTINCT TOP 100 PERCENT tblMHCIntakeDetail.lngIntakeId , tblMHCIntakeDetail.lngDataId, tblLUMHCData.strData FROM tblMHCIntake INNER JOIN tblMHCIntakeDetail ON tblMHCIntake.lngIntakeId = tblMHCIntakeDetail.lngIntakeId INNER JOIN tblLUMHCData ON tblMHCIntakeDetail.lngDataId = tblLUMHCData.lngDataID RIGHT OUTER JOIN tblPatient ON tblMHCIntake.lngPatientId = tblPatient.lngPatientId WHERE (tblMHCIntake.dtmIntake > '1/1/2005') and tblLUMHCData.strtype = '" & servicetype & "'", Connection1)
Try
daSections.Fill(objDS, "dtSections")
Catch ex As Exception
MsgBox(ex.Message)
End Try
Try
daContent.Fill(objDS, "dtContent")
Catch ex As Exception
MsgBox(ex.Message)
End Try
Try
counttype = datype.Fill(objDS, "dtType")
Catch ex As Exception
MsgBox(ex.Message)
End Try
' If Program = "contactLog" Then
' System.Threading.Thread.Sleep(100000)
' End If
objDS.Relations.Add("SectionToContent", _
objDS.Tables("dtSections").Columns("dtmIntake"), _
objDS.Tables("dtContent").Columns("dtmIntake"))
objDS.Relations.Add("SectionToType", _
objDS.Tables("dtContent").Columns("lngIntakeId"), _
objDS.Tables("dtType").Columns("lngIntakeId"))
nodenew = New TreeNode
nodenew.Text = "Create new Client Contact..."
nodenew.Tag = "new"
TreeView1.Nodes.Add(nodenew)
For Each rowSupp In objDS.Tables("dtSections").Rows
nodeSupp = New TreeNode
nodeSupp.Text = rowSupp("dtmIntake") & " - " & rowSupp("dayname")
nodeSupp.Tag = "Intake Date"
Dim dotw
nodeSupp.Expand()
TreeView1.Nodes.Add(nodeSupp)
ProgressBar1.Maximum = objDS.Tables("dtContent").Rows.Count 'this will set the max value to avoid the error you got before
For Each rowProd In rowSupp.GetChildRows("SectionToContent")
nodeProd = New TreeNode
nodeProd.Text = rowProd("intakedate") & " - " & rowProd("strStaff") & " - " & rowProd("name") & " - " & rowProd("dtmdob") & " - " & rowProd("strPatientid")
nodeProd.Tag = rowProd("lngIntakeID")
nodeSupp.Nodes.Add(nodeProd)
For Each rowType In rowProd.GetChildRows("SectionToType")
nodetype = New TreeNode
nodetype.Text = rowType("strData")
nodeProd.Nodes.Add(nodetype)
Next
Application.DoEvents()
ProgressBar1.Value += 1 'this will increase the value after every object completed
Next
Next
' Timer1.Stop()
'TreeView1.ExpandAll()
' TreeView1.SelectedNode = TreeView1.Nodes.Item(2)
TreeView1.Focus()
pageload = True
End Sub
|