'This method populates any previous visit's selected pharmacy if none is
'selected yet.
Private Sub PopulatePrevPharm(ByVal pPrevPharm As Pharmacy)
Dim PharmCmboCtr As Integer
Dim PharmMatchFd As Boolean
Dim Ctr As Integer
Dim ErrLine As Integer = 1 'error code
Dim CurPharm As Pharmacy 'error code
Dim Ex2 As Exception 'error code
Try
'------------------------------------------------------------------------------
'if a pharmacy was set in the previous visit, but one doesn't exist for this one,
'populate with the prev pharmacy and show as green.
PharmCmboCtr = 0
PharmMatchFd = False
ErrLine = 2
If Not pPrevPharm Is Nothing Then
Try 'nested try/catch to locate bug
'cycle through the list and see if the one we are bring in is in the list
For Each Pharm As Pharmacy In cmboDefaultPharmacy.Items
ErrLine = 3
'---------------------------------------
CurPharm = Pharm
ErrLine = 31
If Pharm.PharDBId = pPrevPharm.PharDBId Then
ErrLine = 32
cmboDefaultPharmacy.SelectedIndex = PharmCmboCtr
ErrLine = 33
cmboDefaultPharmacy.BackColor = Color.LightGreen
ErrLine = 34
PharmMatchFd = True
Exit For
ErrLine = 35
End If
PharmCmboCtr += 1
Next
Catch ex As Exception
'log our elusive pharmacy null pointer exception.
If ex.Message.IndexOf("Too many items in the combo box") <> -1 Then
Ex2 = New Exception("1Nested Catch Pharm null ptr error. ErrLine: " + Convert.ToString(ErrLine) _
+ ", Pharm Name: " + CurPharm.Name + ", Pharm List Name: " _
+ CurPharm.ListName + ", Pharm Db Id: " + Convert.ToString(CurPharm.PharDBId) _
+ ", Orig Ex: " + ex.message)
Else
Ex2 = New Exception("Nested Catch Pharm non-null ptr error. Orig Message: " + ex.message)
End If
LocalErrorLink.Error_Handler(Ex2)
End Try
ErrLine = 4
'if not in combo box, add
Ctr = 0
If Not PharmMatchFd Then
cmboDefaultPharmacy.Items.Add(pPrevPharm)
ErrLine = 5
Try 'nested try/catch to locate bug
For Each pharm As Pharmacy In cmboDefaultPharmacy.Items
ErrLine = 6
CurPharm = Pharm
If pharm.equals(pPrevPharm) Then
cmboDefaultPharmacy.SelectedIndex = Ctr
cmboDefaultPharmacy.BackColor = Color.LightGreen
End If
Ctr += 1
Next
Catch ex As Exception
'log our elusive pharmacy null pointer exception.
If ex.Message.IndexOf("Too many items in the combo box") <> -1 Then
Ex2 = New Exception("2Nested Catch Pharm null ptr error. ErrLine: " + Convert.ToString(ErrLine) _
+ ", Pharm Name: " + CurPharm.Name + ", Pharm List Name: " _
+ CurPharm.ListName + ", Pharm Db Id: " + Convert.ToString(CurPharm.PharDBId) _
+ ", Orig Ex: " + ex.message)
Else
Ex2 = New Exception("Nested Catch Pharm non-null ptr error. Orig Message: " + ex.message)
End If
LocalErrorLink.Error_Handler(Ex2)
End Try
ErrLine = 7
End If
End If
ErrLine = 8
cmboDefaultPharmacy.Sorted = True
Catch ex As Exception
'log our elusive pharmacy null pointer exception.
If ex.Message.IndexOf("Too many items in the combo box") <> -1 Then
Ex2 = New Exception("3Nested Catch Pharm null ptr error. ErrLine: " + Convert.ToString(ErrLine) _
+ ", Pharm Name: " + CurPharm.Name + ", Pharm List Name: " _
+ CurPharm.ListName + ", Pharm Db Id: " + Convert.ToString(CurPharm.PharDBId) _
+ ", Orig Ex: " + ex.message)
LocalErrorLink.Error_Handler(Ex2)
'log as normal error
Else
LocalErrorLink.Error_Handler(ex)
End If
End Try
End Sub