Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27196

VS 2010 Adding the same data from listview1 to listview2 on VB.NET?

$
0
0
This is the form of the 2 listview:
https://www.dropbox.com/s/ebp93mfzlqj43i2/Capture.JPG

Name:  Capture.JPG
Views: 109
Size:  98.7 KB

What i want to do is i need to add the same data by just adding the quantity and not the whole info of the product,

example:
I want to add another "screwdriver" to listview 2. so the listview 2 should just update the quantity where the productname screwdriver is included.

here is my code anyway:

Private Sub AddToLvPOS()
Try
Dim dt As New DataTable
For Each lvi As ListViewItem In LISTVIEW1.SelectedItems
lblItem.Text = lvi.SubItems(1).Text
subtotal = Val(txtQuantity.Text) * Val(lvi.SubItems(3).Text)

Next

dt = ExecuteQuery("SELECT * FROM Products WHERE Product_Name = '" & lblItem.Text & "'")
If dt.Rows.Count > 0 Then
For ctr = 0 To dt.Rows.Count - 1
Dim item As New ListViewItem

item.Text = dt.Rows(ctr)("ProductCode")
item.SubItems.Add(dt.Rows(ctr)("Product_…
item.SubItems.Add(txtQuantity.Text)
item.SubItems.Add(dt.Rows(ctr)("Price"))
item.SubItems.Add(subtotal)
LISTVIEW2.Items.Add(item)



Me.Close()
Next
End If
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Attached Images
 

Viewing all articles
Browse latest Browse all 27196

Trending Articles