Click here to Skip to main content
15,893,668 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I'm creating an issue logging tool using vb.net.

When any issue is assigned to a user from another user then he gets a notification (I have used notify icon here).

Please check the code
Private Sub tmrPrfrmDBLd_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles tmrPrfrmDBLd.Tick
    Try
        Dim sqlGetIssueRouteInfo As String = "select IssueID  from routTo where visible = 'True'and currownr = " & empID.ToString
        Dim IssueID As String = ""
        Dim IssueAssignedInfo As String = ""
        IssueID = DataStore.ExecuteScalar(sqlGetIssueRouteInfo, sqlConnStr)
        If IssueID.Length <> 0 Then
            IssueAssignedInfo = IssueID.ToString + "  has been assigned to you"
            nicoIssuUpdt.ShowBalloonTip(2000, "Issue Update", IssueAssignedInfo.ToString, ToolTipIcon.Info)
        Else
            Exit Sub
        End If
    Catch ex As Exception
        MsgBox(ex.ToString)
    End Try
End Sub
Private Sub nicoIssuUpdt_BalloonTipClosed(ByVal sender As Object, ByVal e As System.EventArgs) Handles nicoIssuUpdt.BalloonTipClosed
    Dim sqlGetIssueRouteInfo As String = "select IssueID  from routTo where visible = 'True'and currownr = " & empID.ToString
    Dim getIssueRouteInfo As String = DataStore.ExecuteScalar(sqlGetIssueRouteInfo, sqlConnStr)
    Dim UpdtRouteto As String = "update routTo set visible = 'False' where IssueID = '" & getIssueRouteInfo.ToString & "'"
    DataStore.ExecuteNonQuery(UpdtRouteto, sqlConnStr)
End Sub


This code is working fine, I'm ticking the timer at an interval of 7 sec and it shows all the issues perfectly one by one.
The problem is the first issue comes twice and I'm unble to find out why it is behaving in such a way - please help with a code.
Posted
Updated 31-Aug-10 22:30pm
v2
Comments
Dalek Dave 1-Sep-10 4:30am    
Edited for Grammar and Syntax.

The this approach is prone to failure simply because you are using a timer to show the balloon tip and in the balloon tip closed event you are writing the Visible flag to the database, this is a very bad way to solve your problem, you need to use the timer to update a list or a datatable in memory with all the "issues", you can use the same query and insted of a ExecuteScalar you can use a DataReader or a data adapter , linq is good too :cool: , so your timer only puts the result in memory

The timer should do the following :
1 - Query the Table to find Issues
2 - If issues are found then Put all of them in a (List, DataTable or anything you like )
3 - Call a method that shows a the first issue in the list, this method shouldn't take any parameters
4 - set
VB
tmrPrfrmDBLd.Enabled = False



now on the screen a balloon tip is shown
in the event of closing this balloon tip either by a user action or by time out , you need to do the following :
1 - Delete the issue from the List in memory
2 - Update the table to set visible = false
3 - if there are any more items in list then Call the same method that shows the first Issue in the list
4 - if there are NO items in list then
VB
tmrPrfrmDBLd.enabled = true


This should save you many many problems in your code you may haven't even discovered yet

Some Notes:
In Balloon-tip closing event you need to ask yourself , what if the user isn't in front of is computer, all the issue notification will be shown and they will disappear after reaching time out, without the user even seeing any of them, your application need to show a different tray icon to indicate that there are issues waiting for the user to be seen, or something of the sort to let the user know when he/she comes back that the application needs their attention.
 
Share this answer
 
This code doesn't look different to what you posted yesterday. Have you considered setting a breakpoint and learning to use your debugger ? I bet if you do, you'll find out why it behaves this way.

My guess is that your code doesn't mark it as false in time, but it's hard to say without having the code and a debugger to check it.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900