1.11M Members

problem in listview

 
0
 
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

 
0
 

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

 
0
 

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

 
0
 

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?

 
0
 

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?

 
0
 

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?

 
0
 

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.

 
0
 

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 ", ""))

 
0
 

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...

 
0
 

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 ", "")) )

 
0
 

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.

 
0
 

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.

 
0
 

it says 'OUT' in all that codes.

anyone? please? help..

 
-1
 

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?

You
This article has been dead for over six months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article