'Agency Type Literals
Dim agencyTypesLiteral() As String = {"POLICE", "FIRE", "MEDICAL", "EMERGENCY"}
'Agency Types (Police, Fire, Medical, Emergency)
Dim agencyType() As String = {"P", "F", "M", "9"}
'
vsql = "SELECT AGENCY_ID, AGENCY_NAME, AGENCY_CODE, AGENCY_TYPE FROM CLEAR_ENTITY_AGENCIES WHERE AGENCY_TYPE in " & _
"('P', 'F', 'M', '9') AND ENTITY_ID = " & pEntity_Id & " order by AGENCY_TYPE, AGENCY_NAME"
Dim notRows As New List(Of Notifications)
Using dcNot As New OleDbCommand(vsql, vConn2)
If vConn2.State <> ConnectionState.Open Then vConn2.Open()
Using drNot As OleDbDataReader = dcNot.ExecuteReader
While drNot.Read
If Not IsDBNull(drNot.Item("AGENCY_ID")) Then
'Build list of all rows of this type to be added
Dim notRow = New Notifications() With
{ _
.NotificationId = CInt(Get_Seq("CAD_EVENT_NOTIFICATION_ID", "QuickCall.LoadNotifications")), _
.MasterId = _masterid, _
.EntityId = pEntity_Id, _
.AgencyCode = drNot.Item("AGENCY_CODE").ToString(), _
.AgencyType = agencyTypesLiteral(Array.IndexOf(agencyType, drNot.Item("AGENCY_TYPE").ToString())), _
.AgencyId = drNot.Item("AGENCY_ID").ToString() _
}
'Add Row to List
notRows.Add(notRow)
End If
End While
End Using
End Using
Dim policeRows = notRows.Where(Function(r) r.AgencyType = "POLICE").ToList()
If policeRows.Count = 0 Then
PageVisible(tabPolice, False)
Else
CreateRows(gridpolice, POLICENOTIFICATIONSBindingSource, policeRows)
SetGridFocused(gridpolice, gridviewpolice, 0)
End If
Dim fireRows = notRows.Where(Function(r) r.AgencyType = "FIRE").ToList()
If fireRows.Count = 0 Then
PageVisible(tabFire, False)
Else
CreateRows(gridfire, FIRENOTIFICATIONSBindingSource, fireRows)
SetGridFocused(gridfire, gridviewfire, 0)
End If
Dim medicalRows = notRows.Where(Function(r) r.AgencyType = "MEDICAL").ToList()
If medicalRows.Count = 0 Then
PageVisible(tabMedical, False)
Else
CreateRows(gridMedical, MEDICALNOTIFICATIONSBindingSource, medicalRows)
SetGridFocused(gridMedical, gridviewmedical, 0)
End If
Dim emergencyRows = notRows.Where(Function(r) r.AgencyType = "EMERGENCY").ToList()
If emergencyRows.Count = 0 Then
PageVisible(tabEmergency, False)
Else
CreateRows(gridEmergency, EMERGENCYNOTIFICATIONSBindingSource, emergencyRows)
SetGridFocused(gridEmergency, gridview911, 0)
End If
notRows.Clear()