Private Sub cmdOut_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdOut.Click
      If txtempno.Text = String.Empty Then
          MsgBox("Insert first your employee number.", vbExclamation)
          lblIN.Text = ""
          lblOUT.Text = ""
          Exit Sub
      End If

      Dim ssql As String

      ssql = "UPDATE tbl_timerec SET TimeOUT=@lblOUT WHERE EmpNo=@txtempno"
      Dim com As New SqlCeCommand
      Using con As SqlCeConnection = New SqlCeConnection("Data Source=" & My.Settings.PATS)
          Try
              lblOUT.Text = lbltime.Text
              With com
                  con.Open()
                  com.CommandType = CommandType.Text
                  com.CommandText = ssql
                  com.Connection = con
                  com.Parameters.AddWithValue("@lblOUT", lblOUT.Text)
                  com.Parameters.AddWithValue("@txtempno", txtempno.Text)
              End With
          Catch ex As Exception
              MsgBox(ex.Message, MsgBoxStyle.OkOnly, "Error!")
          Finally
              com.ExecuteNonQuery()
              Dim lv As ListViewItem = ListView1.Items.Add(lblIN.Text)
              lv.SubItems.Add(lblOUT.Text)
              MsgBox("Successfully Logged OUT!", vbInformation, "Success!")
              lblIN.Text = ""
              lblOUT.Text = ""
          End Try
      End Using
  End Sub

My problem is when i click log out. it goes to the next row of the listview at the column of Timeout.. here's some picture :-/

http://dl.dropbox.com/u/58701482/problem1.PNG

Recommended Answers

All 13 Replies

can you please explain your prob , so that i can help you

can you please explain your prob , so that i can help you

check the picture. the problem is when i click the button 'TIME OUT' it will go to the newline of the listview. I want is. just like this.. check the picture of the buttom.

EmpNo. TIME IN. TIME OUT.
123 8:00am 9:00pm


http://dl.dropbox.com/u/58701482/problem1.PNG

At the risk of sounding overly picky, in your first post you said "click log out", and in your next post you said "click the button 'TIME OUT'". Note that in neither picture do you have a button labeled as "log out" or "TIME OUT". It helps to be precise.

In any case, have you tried just resizing the column so that the text doesn't wrap? Because the text "OUT" already appears in the column header, why not just remove it from the output? You don't include "IN" with the time in data, why include "OUT" with the time out data?

At the risk of sounding overly picky, in your first post you said "click log out", and in your next post you said "click the button 'TIME OUT'". Note that in neither picture do you have a button labeled as "log out" or "TIME OUT". It helps to be precise.

In any case, have you tried just resizing the column so that the text doesn't wrap? Because the text "OUT" already appears in the column header, why not just remove it from the output? You don't include "IN" with the time in data, why include "OUT" with the time out data?

Sorry. the button is

CLOCK IN AND CLOCK OUT.. i just want to replace the 'OUT' string in that. Did you see the picture? and the red arrow?

No prob. It was easy to see what you meant but it may not on a more complicated example. Did you try removing the "OUT" text or resizing the column?

No prob. It was easy to see what you meant but it may not on a more complicated example. Did you try removing the "OUT" text or resizing the column?

i tried and test and tried.. but there is always a blank or 'OUT' word. my problem only is on my list view but in my database is okay.

I can't tell the value of lblOUT.Text by the picture. I presume by the time you took the picture, lblOUT.Text had been blanked, but somewhere you are setting it to "OUT" plus a date/time. Either change this assignment or remove "OUT" before adding it to the listview, perhaps like

lv.SubItems.Add(lblOUT.Text.Substring(4))

or

lv.SubItems.Add(lblOUT.Text.Replace("OUT ", ""))

I can't tell the value of lblOUT.Text by the picture. I presume by the time you took the picture, lblOUT.Text had been blanked, but somewhere you are setting it to "OUT" plus a date/time. Either change this assignment or remove "OUT" before adding it to the listview, perhaps like

lv.SubItems.Add(lblOUT.Text.Substring(4))

or

lv.SubItems.Add(lblOUT.Text.Replace("OUT ", ""))

sorry both them didn't work...

What is the output of the following (place before you add lblOUT to the listview)

MsgBox(lblOUT.Text)
MsgBox((lblOUT.Text.Substring(4)))
MsgBox((lblOUT.Text.Replace("OUT ", "")) )

What is the output of the following (place before you add lblOUT to the listview)

MsgBox(lblOUT.Text)
MsgBox((lblOUT.Text.Substring(4)))
MsgBox((lblOUT.Text.Replace("OUT ", "")) )

it says 'OUT' in all that codes.

What is the output of the following (place before you add lblOUT to the listview)

MsgBox(lblOUT.Text)
MsgBox((lblOUT.Text.Substring(4)))
MsgBox((lblOUT.Text.Replace("OUT ", "")) )

Imports System.Data.SqlServerCe
Public Class DTR
    Private Sub tmrclock_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrclock.Tick
        lbltime.Text = TimeOfDay()
        lbldate.Text = Date.Now().ToString("D")
    End Sub
    Private Sub cmdIN_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdIN.Click
        If txtempno.Text = "" Then
            MsgBox("Insert first your employee number.", vbExclamation)
            Exit Sub
        End If
        If lblIN.Text = "" Then
            MsgBox("ASD")
            Exit Sub
        End If

        Using con As SqlCeConnection = New SqlCeConnection("Data Source=" & My.Settings.PATS)
            Dim com As New SqlCeCommand("INSERT INTO tbl_timerec (EmpNo,TimeIN) values(@txtempno,@lblIN)", con)
            Try
                lblIN.Text = lbltime.Text
                With con
                    con.Open()
                    com.Parameters.AddWithValue("@lblIN", lblIN.Text)
                    com.Parameters.AddWithValue("@txtempno", txtempno.Text)
                    com.ExecuteNonQuery()
                End With
            Catch ex As Exception
                MsgBox(ex.Message, MsgBoxStyle.OkOnly, "Error!")
            Finally
                con.Close()
                Dim lv As ListViewItem = ListView1.Items.Add(lblIN.Text)
                MsgBox("Successfully Logged In!", vbInformation, "Success!")
                lblIN.Text = ""
                lblOUT.Text = ""
            End Try
        End Using
    End Sub

    Private Sub cmdOut_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdOut.Click
        If txtempno.Text = String.Empty Then
            MsgBox("Insert first your employee number.", vbExclamation)
            lblIN.Text = ""
            lblOUT.Text = ""
            Exit Sub
        End If

        Dim ssql As String

        ssql = "UPDATE tbl_timerec SET TimeOUT=@lblOUT WHERE EmpNo=@txtempno"
        Dim com As New SqlCeCommand
        Using con As SqlCeConnection = New SqlCeConnection("Data Source=" & My.Settings.PATS)
            Try
                lblOUT.Text = lbltime.Text
                With com
                    con.Open()
                    com.CommandType = CommandType.Text
                    com.CommandText = ssql
                    com.Connection = con
                    com.Parameters.AddWithValue("@lblOUT", lblOUT.Text)
                    com.Parameters.AddWithValue("@txtempno", txtempno.Text)
                End With
            Catch ex As Exception
                MsgBox(ex.Message, MsgBoxStyle.OkOnly, "Error!")
            Finally
                com.ExecuteNonQuery()
                Dim lv As ListViewItem = ListView1.Items.Add(lblIN.Text)
                lv.SubItems.Add(lblOUT.Text.Replace("ASD", ""))
                MsgBox("Successfully Logged OUT!", vbInformation, "Success!")
                lblIN.Text = ""
                lblOUT.Text = ""
            End Try
        End Using
    End Sub
End Class

this is all my code.

it says 'OUT' in all that codes.

anyone? please? help..

anyone? Please? Help..

delete this thread please?

delete this thread please?

delete this thread please?

delete this thread please?

delete this thread please?

delete this thread please?

delete this thread please?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.