Advertisement
Advertisement
| 06.09.2008 at 06:55AM PDT, ID: 23469017 |
|
[x]
Attachment Details
|
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: |
Private Sub CheckForNewMessages()
Try
'If the database connection is not open
If DBConn.State <> ConnectionState.Open Then
'Connect to the database
DBConn.Open()
End If
'Change the system tray icon to show that the client is checking for messages
niSysTrayIcon.Icon = My.Resources.Receiving
Dim i As Integer
Dim DisplayFlag As Boolean = True
For i = 0 To SQLQueries.Count - 1
'Run an SQL command
DBCmd = New OleDbCommand(SQLQueries.Item(i), DBConn)
DBReader = DBCmd.ExecuteReader
While DBReader.Read()
Dim j As Integer
DisplayFlag = True
For j = 0 To myStructs.ReceivedMessages.Count - 1
If DBReader("tblMessages.ID") = myStructs.ReceivedMessages.Item(j).ID Then
Dim tempDate1 As DateTime = DBReader("TimeSent")
Dim tempDate2 As DateTime = myStructs.ReceivedMessages.Item(j).DateTime
If tempDate1.Date = tempDate2.Date Then
If tempDate1.TimeOfDay = tempDate2.TimeOfDay Then
DisplayFlag = False
End If
End If
End If
Next
'If the message hasnt been received yet, display it, otherwise dont
If DisplayFlag = True Then
DisplayMessage(DBReader("FilterType"), DBReader("Filter"), DBReader("Forename") & " " & DBReader("Surname") & " (" & DBReader("Description") & ")", DBReader("TimeSent"), DBReader("Message"), DBReader("MsgBoxType"))
myStructs.AddNewMessage(DBReader("tblMessages.ID"), DBReader("TimeSent"))
End If
End While
Next
If DBConn.State <> ConnectionState.Closed Then
DBConn.Close()
End If
'Change the system tray icon to show that the client is has finished checking for messages
niSysTrayIcon.Icon = My.Resources.Online
'Start the next check timer
tmrNextCheck.Start()
Catch ex As Exception
'MsgBox(ex.Message, MsgBoxStyle.Critical + MsgBoxStyle.ApplicationModal)
modErrorLogging.LogError(ex.Message, Me.Name, "CheckForNewMessages")
If DBConn.State <> ConnectionState.Closed Then
DBConn.Close()
End If
'Start the next check timer
tmrNextCheck.Start()
End Try
End Sub
|