Metode ini digunakan saat user menekan tombol add apabila barang yang dibeli/jual/pesan lebih dari satu item barang namun satu nota/faktur:
Private Sub LstTransaksi_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles LstTransaksi.DoubleClick
Try
Dim intIndex As Integer
Dim TotalHarga, Harga As Double
If LstTransaksi.SelectedItems.Count = 0 Then Exit Sub
With LstTransaksi
intIndex = .SelectedIndices(0)
txtKode_Brg.Text = .Items(intIndex).Text
TxtDeskripsi.Text = .Items(intIndex).SubItems(1).Text
TxtQty.Text = .Items(intIndex).SubItems(2).Text
txtHarga.Text = FormatCurrency(.Items(intIndex).SubItems(3).Text)
TxtDiskonPersen.Text = .Items(intIndex).SubItems(4).Text
TxtDiskonRp.Text = FormatCurrency(.Items(intIndex).SubItems(5).Text)
TxtHargaBarang.Text = .Items(intIndex).SubItems(6).Text
intIndex = 0
End With
For Each lvItem As ListViewItem In LstTransaksi.SelectedItems
lvItem.Remove()
Next
If txtTotalHarga.Text = "" Then Exit Sub
TxtDiskonPersen.Enabled = True
TxtDiskonRp.Enabled = True
TxtDiskonPersen.Focus()
TotalHarga = txtTotalHarga.Text
Harga = TxtHargaBarang.Text
TotalHarga = TotalHarga - Harga
txtTotalHarga.Text = FormatCurrency(TotalHarga)
Catch When Err.Number <> 0
MsgBox("Program error" _
& vbCrLf & Err.Description)
MyConnection.close()
End Try
End Sub
Ketika data yang dipilik di klik dua kali maka data akan berpindah ke textbox dan terhapus dari ListView(Bukan berarti terhapus dari database).