Imports System.Xml
Imports DTools.SystemIntegrator.Reporting
Imports System.Collections.Generic
Imports ActiveReports3.DataDynamics.ActiveReports
Private showModel As Boolean
Private showPrice As Boolean
Private showLaborItems As Boolean
Sub ActiveReport_ReportStart
' Apply Items Filter
ReportUtilities.ApplyProposalItemLevel2DataSourceFilter(rpt)
'****************************************New Script Code Starts Here *****************************************************
Dim ds As DataDynamics.ActiveReports.Datasources.XMLDatasource = ctype(rpt.Datasource, DataDynamics.ActiveReports.Datasources.XMLDatasource)
If ds.EOF Then return
If ds.Count > 0 Then
Dim doc As XmlDocument = ds.Document
'Get the root element
Dim xmlRoot As XmlElement = doc.DocumentElement
'Get the name space for this xml document
xmns = ReportingNamespaceUtility.ReturnXMLNamespaceManager(doc.NameTable)
Dim mainList As XmlNodeList = xmlRoot.SelectNodes("//dtr:Level2Items",xmns)
'Get the Phases of the items
Dim ns As XmlNodeList = xmlRoot.SelectNodes("//dtr:Level2Items/dtr:ProposalItemLevel2/dtr:PhaseOrder",xmns)
Dim revisedNodeList As New List(Of XmlNode)
'Get the uniquelist of Phase
Dim uniqueList As List(Of String) = ReturnUniqueList(ns)
'Sort the unique list values.
Dim phaseOrdervalues(uniqueList.Count - 1) As String
uniqueList.CopyTo(phaseOrdervalues,0)
Array.Sort(phaseOrdervalues)
For Each phase As String in phaseOrdervalues
'get the Items for this phase order.
Dim itemList As XmlNodeList = xmlRoot.SelectNodes(String.Format("//dtr:Level2Items/dtr:ProposalItemLevel2[dtr:PhaseOrder = {0}]", phase),xmns)
For Each node3 As XmlNode in itemList
'Add the Revised Items
revisedNodeList.Add(node3)
Next
Next
'remove all items from the main list
mainList(0).RemoveAll()
For Each node2 As XmlNode In revisedNodeList
're-add the revised (re-ordered) node list
mainList(0).AppendChild(node2)
Next
'reload the datasource
ds.LoadXML(ds.Document.OuterXml)
End If
'*************************************New Script Code Ends here *****************************************************************
' set the default value
showModel = false
' get the parameter value
Dim showModelParam As object = ReportUtilities.ReturnParameterValue("ShowModel")
' if the parameter value is not null, then parse it
If Not showModelParam Is Nothing Then
If Not Boolean.TryParse(showModelParam.ToString, showModel) Then
showModel = false
End If
End If
' get the parameter value
Dim showPriceParam As object = ReportUtilities.ReturnParameterValue("ShowPrice")
' if the parameter value is not null, then parse it
If Not showPriceParam Is Nothing Then
If Not Boolean.TryParse(showPriceParam.ToString, showPrice) Then
showPrice = false
End If
End If
End Sub
Sub ActiveReport_NoData
rpt.Cancel
End Sub
Function ActiveReport_FetchData(ByVal EOF As Boolean) As Boolean
If Not EOF Then
' This will set the CurrentProposalItemLevel2 Property to for consumption by the report and/or sub reports
ReportUtilities.SetCurrentProposalItemLevel2(rpt)
Return False
Else
Return True
End If
End Function
Sub grpItemHeader_Format
' If we are showing the Model #, then set it, otherwise the control will use the default binding
If showModel Then
ReportUtilities.SetManufacturerModelTextBox(rpt,"grpItemHeader","txtManufacturer")
End If
ReportUtilities.SetControlTopPosition(rpt, "grpItemHeader", "txtDescription", "txtManufacturer", .02)
Dim itm As DTools.SystemIntegrator.Reporting.Item = ReportUtilities.ReturnItem(rpt)
Dim accessorizedPrice As Boolean = false
' if the item is not null and we are showing price, check the value, otherwise false
If itm IsNot Nothing And showPrice Then
accessorizedPrice = itm.AccessorizedPrice
End If
' set the visibility of the label
ReportUtilities.SetControlVisibility(rpt, "lblAccessorized", accessorizedPrice)
' set the visibility of the price textbox
ReportUtilities.SetControlVisibility(rpt, "txtInstallPrice",showPrice)
End Sub
Sub grpItemFooter_Format
Dim itm As DTools.SystemIntegrator.Reporting.Item = ReportUtilities.ReturnItem(rpt)
Dim accessorizedPrice As Boolean = false
Dim itemHash As Integer = 0
try
itemHash = Ctype(ReportUtilities.ReturnTextBoxValue(rpt,"grpItemFooter","txtItemHash"), Integer)
catch
End try
ReportUtilities.SetCurrentProposalItemLevel2(itemHash)
If itm IsNot Nothing Then
accessorizedPrice = itm.AccessorizedPrice
Select Case ReportUtilities.SummarizeEquipment
Case 0 ' ShowAllDetail
ReportUtilities.BindSubReport(rpt, "grpItemFooter", "subProposalLevel3Items")
Case 1 ' ItemSetting
If itm.Summarize Then
ReportUtilities.UnBindSubReport(rpt, "grpItemFooter", "subProposalLevel3Items")
Else
ReportUtilities.BindSubReport(rpt, "grpItemFooter", "subProposalLevel3Items")
End If
Case 2 ' ShowNoDetail
ReportUtilities.UnBindSubReport(rpt, "grpItemFooter", "subProposalLevel3Items")
End Select
End If
End Sub
'***************************************** New Function to get Unique list from the Node List **************************************
'Returns the unique list of values from the nodelist
Private Function ReturnUniqueList(ByVal xmlNodeList As XmlNodeList) As List(Of String)
Dim uniqueList As List(Of String) = New List(Of String)
For Each node As XmlNode In xmlNodeList
If Not (uniqueList.Contains(node.InnerText)) Then
uniqueList.Add(node.InnerText)
End If
Next
Return uniqueList
End Function
'******************************************************************************************************************************************* |