3 Replies - 278 Views - Last Post: 27 November 2017 - 02:45 AM Rate Topic: -----

#1 micro1111  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 27-November 17

how can I use timer to "refresh" form

Posted 27 November 2017 - 01:08 AM

Hi! I have a queuing system that is in development, I have a server and five workstations those WS are controlling the queuing window that displays the number next in line. Now I'm having a problem with the queuing system, whenever a controller clicks the "next" button the server does not respond to any of the workstations. My question is how can I somehow "refresh" the form that'll make the latest customer in line and what counter he should go appear on the queuing window. I'm out of ideas on how to do it. Thanks!

I'm currently using VS2012 and SQLServer2014.

the code below is the what I have tried:
Dim bBtnClicked As Boolean = False
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        'next
        Dim strHostName As String
        strHostName = System.Net.Dns.GetHostName()

        If (wcon.Text = 0) Then
            MessageBox.Show("There are no queues as of now!")

        ElseIf (Queue.Label1.Text < FrmNumApp.NumCon.Text) Then
            If bBtnClicked = True Then
                Queue.Timer7.Start()
                Queue.Timer7.Enabled = True

                Dim sqlconn6 As New SqlConnection
                Dim sqlquery6 As New SqlCommand
                Dim connString6 As String
                wcon.Text = CStr(CDbl(wcon.Text) - 1)
                Try
                    connString6 = "Server=MISKRISTIAN-PC\HMO_OPD;Database=HMO_OPD_QUEUE;User Id=sa;Password=sa;"
                    sqlconn6.ConnectionString = connString6
                    sqlquery6.Connection = sqlconn6
                    sqlconn6.Open()
                    sqlquery6.CommandText = "INSERT INTO ConCon([Number], [Counter])VALUES(@Number, @Counter)"
                    sqlquery6.Parameters.AddWithValue("@Number", Queue.Label1.Text)
                    sqlquery6.Parameters.AddWithValue("@Counter", Queue.Label18.Text)
                    sqlquery6.ExecuteNonQuery()
                    sqlconn6.Close()
                Catch ex As Exception
                    MessageBox.Show(ex.Message)
                End Try

                Queue.Label1.Text = CStr(CDbl(Queue.Label1.Text) + 1)
                Queue.Label4.Text = "0"
                My.Computer.Audio.Play(My.Resources.DoorBell, AudioPlayMode.Background)
                Dim speaker As New SpeechSynthesizer()
                Dim speak As New Prosody()
                'tts
                speak.Duration = 3
                speaker.Rate = -5
                speaker.Volume = 100
                speaker.Speak("Now serving number " + Queue.Label1.Text)
                speaker.SelectVoiceByHints(VoiceGender.Male)
                Queue.Label18.Text = strHostName
            End If
            Queue.Timer7.Stop()
        End If

This post has been edited by andrewsw: 27 November 2017 - 02:00 AM
Reason for edit:: added missing [code][/code] tags


Is This A Good Question/Topic? 0
  • +

Replies To: how can I use timer to "refresh" form

#2 andrewsw  Icon User is offline

  • blow up my boots
  • member icon

Reputation: 6541
  • View blog
  • Posts: 26,484
  • Joined: 12-December 12

Re: how can I use timer to "refresh" form

Posted 27 November 2017 - 02:01 AM

Please wrap your code in code tags, it shows how to do this directly in the box where you type your post. I have added them for you this time.
Was This Post Helpful? 0
  • +
  • -

#3 andrewsw  Icon User is offline

  • blow up my boots
  • member icon

Reputation: 6541
  • View blog
  • Posts: 26,484
  • Joined: 12-December 12

Re: how can I use timer to "refresh" form

Posted 27 November 2017 - 02:18 AM

"whenever a controller clicks the "next" button the server does not respond to any of the workstations."
Please describe exactly what happens when "next is clicked. Have you set a breakpoint and stepped through your code? (There is a debugging tutorial linked in my signature below if you aren't aware of debugging features.)

By the "next" button I guess you mean "Button1"? It would help us, and yourself, if you improved your naming of variables and controls.

Also, is Queue a new instance of a form? (I would name the form itself frmQueue.)
Was This Post Helpful? 0
  • +
  • -

#4 micro1111  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 27-November 17

Re: how can I use timer to "refresh" form

Posted 27 November 2017 - 02:45 AM

Hi! Thanks for replying. When the system is running on the server the program works perfectly fine, but when the workstations attempts to call for the next in line the server does not simply respond. Yes, the next button is Button1(sorry for that). Queue is the form where the system displays the queuing window that has the numbers being served and what counter they will go.

This post has been edited by andrewsw: 27 November 2017 - 03:04 AM
Reason for edit:: removed previous quote, just press REPLY

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1